From 7b8c476b326e92bfecdc47759ef445969fdf0ebf Mon Sep 17 00:00:00 2001 From: Baz Utsahajit Date: Thu, 8 Feb 2024 12:50:54 +0000 Subject: [PATCH] Chore: Use Program.from for Caching --- src/adjustment/AdjustmentFilter.ts | 4 ++-- src/advanced-bloom/ExtractBrightnessFilter.ts | 4 ++-- src/bevel/BevelFilter.ts | 4 ++-- src/color-gradient/ColorGradientFilter.ts | 4 ++-- src/cross-hatch/CrossHatchFilter.ts | 4 ++-- src/crt/CRTFilter.ts | 4 ++-- src/glow/GlowFilter.ts | 4 ++-- src/grayscale/GrayscaleFilter.ts | 4 ++-- src/hsl-adjustment/HslAdjustmentFilter.ts | 4 ++-- src/tilt-shift/TiltShiftAxisFilter.ts | 4 ++-- src/twist/TwistFilter.ts | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/adjustment/AdjustmentFilter.ts b/src/adjustment/AdjustmentFilter.ts index beaa350f7..a9378dfd0 100644 --- a/src/adjustment/AdjustmentFilter.ts +++ b/src/adjustment/AdjustmentFilter.ts @@ -84,7 +84,7 @@ export class AdjustmentFilter extends Filter { options = { ...AdjustmentFilter.DEFAULT_OPTIONS, ...options }; - const gpuProgram = new GpuProgram({ + const gpuProgram = GpuProgram.from({ vertex: { source: wgslVertex, entryPoint: 'mainVertex', @@ -95,7 +95,7 @@ export class AdjustmentFilter extends Filter }, }); - const glProgram = new GlProgram({ + const glProgram = GlProgram.from({ vertex, fragment, name: 'adjustment-filter' diff --git a/src/advanced-bloom/ExtractBrightnessFilter.ts b/src/advanced-bloom/ExtractBrightnessFilter.ts index 4830a0bfb..842b982a4 100644 --- a/src/advanced-bloom/ExtractBrightnessFilter.ts +++ b/src/advanced-bloom/ExtractBrightnessFilter.ts @@ -31,7 +31,7 @@ export class ExtractBrightnessFilter extends Filter { options = { ...ExtractBrightnessFilter.DEFAULT_OPTIONS, ...options }; - const gpuProgram = new GpuProgram({ + const gpuProgram = GpuProgram.from({ vertex: { source: wgslVertex, entryPoint: 'mainVertex', @@ -42,7 +42,7 @@ export class ExtractBrightnessFilter extends Filter }, }); - const glProgram = new GlProgram({ + const glProgram = GlProgram.from({ vertex, fragment, name: 'extract-brightness-filter', diff --git a/src/bevel/BevelFilter.ts b/src/bevel/BevelFilter.ts index 925b107b0..b99d04f89 100644 --- a/src/bevel/BevelFilter.ts +++ b/src/bevel/BevelFilter.ts @@ -78,7 +78,7 @@ export class BevelFilter extends Filter const rotation = (options.rotation ?? 45) * DEG_TO_RAD; - const gpuProgram = new GpuProgram({ + const gpuProgram = GpuProgram.from({ vertex: { source: wgslVertex, entryPoint: 'mainVertex', @@ -89,7 +89,7 @@ export class BevelFilter extends Filter }, }); - const glProgram = new GlProgram({ + const glProgram = GlProgram.from({ vertex, fragment, name: 'bevel-filter', diff --git a/src/color-gradient/ColorGradientFilter.ts b/src/color-gradient/ColorGradientFilter.ts index 6bf276fac..88ac5ffcf 100644 --- a/src/color-gradient/ColorGradientFilter.ts +++ b/src/color-gradient/ColorGradientFilter.ts @@ -97,7 +97,7 @@ export class ColorGradientFilter extends Filter throw new Error('ColorGradientFilter requires at least 2 color stops.'); } - const gpuProgram = new GpuProgram({ + const gpuProgram = GpuProgram.from({ vertex: { source, entryPoint: 'mainVertex', @@ -108,7 +108,7 @@ export class ColorGradientFilter extends Filter }, }); - const glProgram = new GlProgram({ + const glProgram = GlProgram.from({ vertex, fragment, name: 'color-gradient-filter', diff --git a/src/cross-hatch/CrossHatchFilter.ts b/src/cross-hatch/CrossHatchFilter.ts index 837e8c76b..5369ddef7 100644 --- a/src/cross-hatch/CrossHatchFilter.ts +++ b/src/cross-hatch/CrossHatchFilter.ts @@ -15,7 +15,7 @@ export class CrossHatchFilter extends Filter { constructor() { - const gpuProgram = new GpuProgram({ + const gpuProgram = GpuProgram.from({ vertex: { source: wgslVertex, entryPoint: 'mainVertex', @@ -26,7 +26,7 @@ export class CrossHatchFilter extends Filter }, }); - const glProgram = new GlProgram({ + const glProgram = GlProgram.from({ vertex, fragment, name: 'cross-hatch-filter', diff --git a/src/crt/CRTFilter.ts b/src/crt/CRTFilter.ts index 09d5fe8e9..bad27d434 100644 --- a/src/crt/CRTFilter.ts +++ b/src/crt/CRTFilter.ts @@ -116,7 +116,7 @@ export class CRTFilter extends Filter { options = { ...CRTFilter.DEFAULT_OPTIONS, ...options }; - const gpuProgram = new GpuProgram({ + const gpuProgram = GpuProgram.from({ vertex: { source: wgslVertex, entryPoint: 'mainVertex', @@ -127,7 +127,7 @@ export class CRTFilter extends Filter }, }); - const glProgram = new GlProgram({ + const glProgram = GlProgram.from({ vertex, fragment, name: 'crt-filter', diff --git a/src/glow/GlowFilter.ts b/src/glow/GlowFilter.ts index ac1d0eb09..d81e5ad0d 100644 --- a/src/glow/GlowFilter.ts +++ b/src/glow/GlowFilter.ts @@ -92,7 +92,7 @@ export class GlowFilter extends Filter const distance = options.distance ?? 10; const quality = options.quality ?? 0.1; - const gpuProgram = new GpuProgram({ + const gpuProgram = GpuProgram.from({ vertex: { source: wgslVertex, entryPoint: 'mainVertex', @@ -108,7 +108,7 @@ export class GlowFilter extends Filter * since we hard-assign them during creation to allow * for the values to be used in GLSL loops */ - const glProgram = new GlProgram({ + const glProgram = GlProgram.from({ vertex, fragment: fragment .replace(/__ANGLE_STEP_SIZE__/gi, `${(1 / quality / distance).toFixed(7)}`) diff --git a/src/grayscale/GrayscaleFilter.ts b/src/grayscale/GrayscaleFilter.ts index 10db4c08a..9d90eaedf 100644 --- a/src/grayscale/GrayscaleFilter.ts +++ b/src/grayscale/GrayscaleFilter.ts @@ -15,7 +15,7 @@ export class GrayscaleFilter extends Filter { constructor() { - const gpuProgram = new GpuProgram({ + const gpuProgram = GpuProgram.from({ vertex: { source: wgslVertex, entryPoint: 'mainVertex', @@ -26,7 +26,7 @@ export class GrayscaleFilter extends Filter }, }); - const glProgram = new GlProgram({ + const glProgram = GlProgram.from({ vertex, fragment, name: 'grayscale-filter', diff --git a/src/hsl-adjustment/HslAdjustmentFilter.ts b/src/hsl-adjustment/HslAdjustmentFilter.ts index 8dfdc1179..15fc953bc 100644 --- a/src/hsl-adjustment/HslAdjustmentFilter.ts +++ b/src/hsl-adjustment/HslAdjustmentFilter.ts @@ -64,7 +64,7 @@ export class HslAdjustmentFilter extends Filter { options = { ...HslAdjustmentFilter.DEFAULT_OPTIONS, ...options }; - const gpuProgram = new GpuProgram({ + const gpuProgram = GpuProgram.from({ vertex: { source: wgslVertex, entryPoint: 'mainVertex', @@ -75,7 +75,7 @@ export class HslAdjustmentFilter extends Filter }, }); - const glProgram = new GlProgram({ + const glProgram = GlProgram.from({ vertex, fragment, name: 'hsl-adjustment-filter', diff --git a/src/tilt-shift/TiltShiftAxisFilter.ts b/src/tilt-shift/TiltShiftAxisFilter.ts index eb0a544ea..abf16d25d 100644 --- a/src/tilt-shift/TiltShiftAxisFilter.ts +++ b/src/tilt-shift/TiltShiftAxisFilter.ts @@ -59,7 +59,7 @@ export class TiltShiftAxisFilter extends Filter { options = { ...TiltShiftAxisFilter.DEFAULT_OPTIONS, ...options } as TiltShiftAxisFilterOptions; - const gpuProgram = new GpuProgram({ + const gpuProgram = GpuProgram.from({ vertex: { source: wgslVertex, entryPoint: 'mainVertex', @@ -70,7 +70,7 @@ export class TiltShiftAxisFilter extends Filter }, }); - const glProgram = new GlProgram({ + const glProgram = GlProgram.from({ vertex, fragment, name: 'tilt-shift-axis-filter', diff --git a/src/twist/TwistFilter.ts b/src/twist/TwistFilter.ts index c96ad5029..c96314bb7 100644 --- a/src/twist/TwistFilter.ts +++ b/src/twist/TwistFilter.ts @@ -56,7 +56,7 @@ export class TwistFilter extends Filter { options = { ...TwistFilter.DEFAULT_OPTIONS, ...options }; - const gpuProgram = new GpuProgram({ + const gpuProgram = GpuProgram.from({ vertex: { source: wgslVertex, entryPoint: 'mainVertex', @@ -67,7 +67,7 @@ export class TwistFilter extends Filter }, }); - const glProgram = new GlProgram({ + const glProgram = GlProgram.from({ vertex, fragment, name: 'twist-filter',