From e65b7a33c05a46b874f82251d0d971e558025f5e Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Thu, 23 Jan 2020 13:53:24 -0300 Subject: [PATCH] BaseFilter changes --- .../cameraview/filter/BaseFilter.java | 14 +++++++++----- .../cameraview/filter/SimpleFilter.java | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/filter/BaseFilter.java b/cameraview/src/main/java/com/otaliastudios/cameraview/filter/BaseFilter.java index 143d51e1..1fa2d937 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/filter/BaseFilter.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/filter/BaseFilter.java @@ -8,7 +8,6 @@ import com.otaliastudios.cameraview.size.Size; import com.otaliastudios.opengl.draw.GlDrawable; import com.otaliastudios.opengl.draw.GlRect; import com.otaliastudios.opengl.program.GlTextureProgram; -import com.otaliastudios.opengl.texture.GlTexture; /** * A base implementation of {@link Filter} that just leaves the fragment shader to subclasses. @@ -122,13 +121,17 @@ public abstract class BaseFilter implements Filter { @Override public void onCreate(int programHandle) { - program = new GlTextureProgram( - programHandle, + program = onCreateProgram(programHandle); + } + + @SuppressWarnings("WeakerAccess") + @NonNull + protected GlTextureProgram onCreateProgram(int programHandle) { + return new GlTextureProgram(programHandle, vertexPositionName, vertexModelViewProjectionMatrixName, vertexTextureCoordinateName, - vertexTransformMatrixName - ); + vertexTransformMatrixName); } @Override @@ -195,6 +198,7 @@ public abstract class BaseFilter implements Filter { return copy; } + @NonNull protected BaseFilter onCopy() { try { return getClass().newInstance(); diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/filter/SimpleFilter.java b/cameraview/src/main/java/com/otaliastudios/cameraview/filter/SimpleFilter.java index eda5ec3e..ca8d4b15 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/filter/SimpleFilter.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/filter/SimpleFilter.java @@ -33,6 +33,7 @@ public final class SimpleFilter extends BaseFilter { return fragmentShader; } + @NonNull @Override protected BaseFilter onCopy() { return new SimpleFilter(fragmentShader);