From ee1c4f9cd58b780b77d3dd6658558d2e372b7f9c Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Sat, 31 Aug 2019 13:35:36 +0200 Subject: [PATCH] Add doMetering parameter --- .../cameraview/engine/MockCameraEngine.java | 4 ++-- .../otaliastudios/cameraview/engine/Camera1Engine.java | 4 ++-- .../otaliastudios/cameraview/engine/Camera2Engine.java | 4 ++-- .../otaliastudios/cameraview/engine/CameraEngine.java | 9 ++++----- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/MockCameraEngine.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/MockCameraEngine.java index 3b320da7..12dcd5e4 100644 --- a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/MockCameraEngine.java +++ b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/MockCameraEngine.java @@ -123,12 +123,12 @@ public class MockCameraEngine extends CameraEngine { } @Override - protected void onTakePicture(@NonNull PictureResult.Stub stub) { + protected void onTakePicture(@NonNull PictureResult.Stub stub, boolean doMetering) { } @Override - protected void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio) { + protected void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio, boolean doMetering) { } diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera1Engine.java b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera1Engine.java index 7a181fd2..6b48c404 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera1Engine.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera1Engine.java @@ -297,7 +297,7 @@ public class Camera1Engine extends CameraEngine implements @WorkerThread @Override - protected void onTakePicture(@NonNull PictureResult.Stub stub) { + protected void onTakePicture(@NonNull PictureResult.Stub stub, boolean doMetering) { stub.rotation = getAngles().offset(Reference.SENSOR, Reference.OUTPUT, Axis.RELATIVE_TO_SENSOR); stub.size = getPictureSize(Reference.OUTPUT); mPictureRecorder = new Full1PictureRecorder(stub, Camera1Engine.this, mCamera); @@ -306,7 +306,7 @@ public class Camera1Engine extends CameraEngine implements @WorkerThread @Override - protected void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio) { + protected void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio, boolean doMetering) { stub.size = getUncroppedSnapshotSize(Reference.OUTPUT); // Not the real size: it will be cropped to match the view ratio stub.rotation = getAngles().offset(Reference.SENSOR, Reference.OUTPUT, Axis.RELATIVE_TO_SENSOR); // Actually it will be rotated and set to 0. diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java index 8e1c9f9b..e54ec203 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java @@ -610,7 +610,7 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv @WorkerThread @Override - protected void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio) { + protected void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio, boolean doMetering) { stub.size = getUncroppedSnapshotSize(Reference.OUTPUT); // Not the real size: it will be cropped to match the view ratio stub.rotation = getAngles().offset(Reference.SENSOR, Reference.OUTPUT, Axis.RELATIVE_TO_SENSOR); // Actually it will be rotated and set to 0. if (mPreview instanceof GlCameraPreview) { @@ -622,7 +622,7 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv } @Override - protected void onTakePicture(@NonNull PictureResult.Stub stub) { + protected void onTakePicture(@NonNull PictureResult.Stub stub, boolean doMetering) { stub.rotation = getAngles().offset(Reference.SENSOR, Reference.OUTPUT, Axis.RELATIVE_TO_SENSOR); stub.size = getPictureSize(Reference.OUTPUT); try { diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java index 27acdd47..0af40837 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java @@ -1088,7 +1088,6 @@ public abstract class CameraEngine implements public void run() { LOG.v("takePicture", "performing. BindState:", getBindState(), "isTakingPicture:", isTakingPicture()); if (mMode == Mode.VIDEO) { - // Could redirect to takePictureSnapshot, but it's better if people know what they are doing. throw new IllegalStateException("Can't take hq pictures while in VIDEO mode"); } if (getBindState() < STATE_STARTED) return; @@ -1096,7 +1095,7 @@ public abstract class CameraEngine implements stub.isSnapshot = false; stub.location = mLocation; stub.facing = mFacing; - onTakePicture(stub); + onTakePicture(stub, mPictureMetering); } }); } @@ -1120,7 +1119,7 @@ public abstract class CameraEngine implements // Leave the other parameters to subclasses. //noinspection ConstantConditions AspectRatio ratio = AspectRatio.of(getPreviewSurfaceSize(Reference.OUTPUT)); - onTakePictureSnapshot(stub, ratio); + onTakePictureSnapshot(stub, ratio, mPictureSnapshotMetering); } }); } @@ -1241,10 +1240,10 @@ public abstract class CameraEngine implements } @WorkerThread - protected abstract void onTakePicture(@NonNull PictureResult.Stub stub); + protected abstract void onTakePicture(@NonNull PictureResult.Stub stub, boolean doMetering); @WorkerThread - protected abstract void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio); + protected abstract void onTakePictureSnapshot(@NonNull PictureResult.Stub stub, @NonNull AspectRatio outputRatio, boolean doMetering); @WorkerThread protected abstract void onTakeVideoSnapshot(@NonNull VideoResult.Stub stub, @NonNull AspectRatio outputRatio);