From e8640989b5cb0503f33143e0597bdb0bffc93f97 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Mon, 16 Jan 2023 16:32:55 +0100 Subject: [PATCH] [orx-fx] Fix content-scale-awareness for FrameBlur --- orx-fx/src/commonMain/kotlin/blur/FrameBlur.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/orx-fx/src/commonMain/kotlin/blur/FrameBlur.kt b/orx-fx/src/commonMain/kotlin/blur/FrameBlur.kt index d6c85b34..056afecc 100644 --- a/orx-fx/src/commonMain/kotlin/blur/FrameBlur.kt +++ b/orx-fx/src/commonMain/kotlin/blur/FrameBlur.kt @@ -8,7 +8,8 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Frame blur") -class FrameBlur : Filter1to1(mppFilterShader(fx_frame_blur, "frame-blur")) { +class FrameBlur(val colorType: ColorType = ColorType.FLOAT16) : + Filter1to1(mppFilterShader(fx_frame_blur, "frame-blur")) { @DoubleParameter("blend", 0.0, 1.0) var blend: Double by parameters @@ -20,16 +21,16 @@ class FrameBlur : Filter1to1(mppFilterShader(fx_frame_blur, "frame-blur")) { } override fun apply(source: Array, target: Array) { - if (target.isNotEmpty()) { + if (source.isNotEmpty() && target.isNotEmpty()) { intermediate?.let { - if (it.width != target[0].width || it.height != target[0].height) { + if (it.isEquivalentTo(target[0], ignoreFormat = true, ignoreLevels = true)) { it.destroy() intermediate = null } } if (intermediate == null) { - intermediate = colorBuffer(target[0].width, target[0].height, type = ColorType.FLOAT16) + intermediate = target[0].createEquivalent(type = colorType) intermediate?.fill(ColorRGBa.TRANSPARENT) }