diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/filter/MultiFilter.java b/cameraview/src/main/java/com/otaliastudios/cameraview/filter/MultiFilter.java index 1caa82a4..ea03a1ac 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/filter/MultiFilter.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/filter/MultiFilter.java @@ -63,7 +63,6 @@ public class MultiFilter implements Filter, OneParameterFilter, TwoParameterFilt * Creates a new group with the given filters. * @param filters children */ - @SuppressWarnings("WeakerAccess") public MultiFilter(@NonNull Filter... filters) { this(Arrays.asList(filters)); } diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/internal/GlTextureDrawer.java b/cameraview/src/main/java/com/otaliastudios/cameraview/internal/GlTextureDrawer.java index ff955e0b..24c956d5 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/internal/GlTextureDrawer.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/internal/GlTextureDrawer.java @@ -63,11 +63,12 @@ public class GlTextureDrawer { mTextureTransform = textureTransform; } - public void draw(long timestampUs) { + public void draw(final long timestampUs) { if (mPendingFilter != null) { release(); mFilter = mPendingFilter; mPendingFilter = null; + } if (mProgramHandle == -1) { @@ -75,20 +76,16 @@ public class GlTextureDrawer { mFilter.getVertexShader(), mFilter.getFragmentShader()); mFilter.onCreate(mProgramHandle); + Egloo.checkGlError("program creation"); } - Egloo.checkGlError("draw start"); - // Select the program and the active texture. GLES20.glUseProgram(mProgramHandle); - Egloo.checkGlError("glUseProgram"); - GLES20.glActiveTexture(mTexture.getUnit()); - GLES20.glBindTexture(mTexture.getTarget(), mTexture.getId()); - - // Draw and release. + Egloo.checkGlError("glUseProgram(handle)"); + mTexture.bind(); mFilter.draw(timestampUs, mTextureTransform); - GLES20.glBindTexture(mTexture.getTarget(), 0); + mTexture.unbind(); GLES20.glUseProgram(0); - Egloo.checkGlError("draw end"); + Egloo.checkGlError("glUseProgram(0)"); } public void release() { diff --git a/demo/src/main/java/com/otaliastudios/cameraview/demo/CameraActivity.java b/demo/src/main/java/com/otaliastudios/cameraview/demo/CameraActivity.java index cba4cbad..0364c87a 100644 --- a/demo/src/main/java/com/otaliastudios/cameraview/demo/CameraActivity.java +++ b/demo/src/main/java/com/otaliastudios/cameraview/demo/CameraActivity.java @@ -372,13 +372,13 @@ public class CameraActivity extends AppCompatActivity implements View.OnClickLis message(filter.toString(), false); // Normal behavior: - camera.setFilter(filter.newInstance()); + // camera.setFilter(filter.newInstance()); // To test MultiFilter: - // DuotoneFilter duotone = new DuotoneFilter(); - // duotone.setFirstColor(Color.RED); - // duotone.setSecondColor(Color.GREEN); - // camera.setFilter(new MultiFilter(duotone, filter.newInstance())); + DuotoneFilter duotone = new DuotoneFilter(); + duotone.setFirstColor(Color.RED); + duotone.setSecondColor(Color.GREEN); + camera.setFilter(new MultiFilter(duotone, filter.newInstance())); } @Override