diff options
author | Steve Kondik <shade@chemlab.org> | 2016-02-28 17:20:23 +0000 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2016-04-14 01:03:49 -0700 |
commit | 57799db3c1757618e00d331fe659ac4058624352 (patch) | |
tree | a60a979b8deaff75f98a57ff2c38cc718899e98a /src/com/android/camera/PhotoModule.java | |
parent | a78d012468101b86c3937c5d4c6cb6ef48d04745 (diff) | |
download | android_packages_apps_Snap-57799db3c1757618e00d331fe659ac4058624352.tar.gz android_packages_apps_Snap-57799db3c1757618e00d331fe659ac4058624352.tar.bz2 android_packages_apps_Snap-57799db3c1757618e00d331fe659ac4058624352.zip |
Snap: Improve focusing
* Don't needlessly break touch-to-focus during various modes
* Set focus parameters immediately for better UX
Change-Id: I39b287562c3d2b62a1d5c8953577e366b11b8e15
Diffstat (limited to 'src/com/android/camera/PhotoModule.java')
-rw-r--r-- | src/com/android/camera/PhotoModule.java | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index dc372a303..65f0d61a9 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -141,11 +141,13 @@ public class PhotoModule private static final int SWITCH_TO_GCAM_MODULE = 12; private static final int ON_PREVIEW_STARTED = 13; private static final int UPDATE_GESTURES_UI = 14; + private static final int SET_FOCUS_RATIO = 15; // The subset of parameters we need to update in setCameraParameters(). private static final int UPDATE_PARAM_INITIALIZE = 1; private static final int UPDATE_PARAM_ZOOM = 2; private static final int UPDATE_PARAM_PREFERENCE = 4; + private static final int UPDATE_PARAM_FOCUS = 8; private static final int UPDATE_PARAM_ALL = -1; // This is the delay before we execute onResume tasks when coming @@ -490,6 +492,11 @@ public class PhotoModule updateGesturesUI(); break; } + + case SET_FOCUS_RATIO: { + mUI.getFocusRing().setRadiusRatio((Float)msg.obj); + break; + } } } } @@ -935,6 +942,14 @@ public class PhotoModule } } + @Override + public void setFocusRatio(float ratio) { + mHandler.removeMessages(SET_FOCUS_RATIO); + Message m = mHandler.obtainMessage(SET_FOCUS_RATIO); + m.obj = ratio; + mHandler.sendMessage(m); + } + // TODO: need to check cached background apps memory and longshot ION memory private boolean isLongshotNeedCancel() { if (SECONDARY_SERVER_MEM == 0) { @@ -1450,6 +1465,8 @@ public class PhotoModule @Override public void onAutoFocusMoving( boolean moving, CameraProxy camera) { + mCameraDevice.refreshParameters(); + mFocusManager.setParameters(mCameraDevice.getParameters()); mFocusManager.onAutoFocusMoving(moving); } } @@ -1665,7 +1682,7 @@ public class PhotoModule @Override public void setFocusParameters() { - setCameraParameters(UPDATE_PARAM_PREFERENCE); + setCameraParameters(UPDATE_PARAM_FOCUS); } private Location getLocationAccordPictureFormat(String pictureFormat) { @@ -2524,7 +2541,7 @@ public class PhotoModule mCameraDevice.cancelAutoFocus(); setCameraState(IDLE); mFocusManager.setAeAwbLock(false); - setCameraParameters(UPDATE_PARAM_PREFERENCE); + setFocusParameters(); } } @@ -3421,7 +3438,7 @@ public class PhotoModule // initialize focus mode if ((mManual3AEnabled & MANUAL_FOCUS) == 0) { mFocusManager.overrideFocusMode(null); - mParameters.setFocusMode(mFocusManager.getFocusMode(false)); + updateCameraParametersFocus(); } // Set picture size. @@ -3650,25 +3667,33 @@ public class PhotoModule } } - if (mContinuousFocusSupported && ApiHelper.HAS_AUTO_FOCUS_MOVE_CALLBACK) { - updateAutoFocusMoveCallback(); - } + enableAutoFocusMoveCallback(); + //QCom related parameters updated here. qcomUpdateCameraParametersPreference(); return doGcamModeSwitch; } @TargetApi(Build.VERSION_CODES.JELLY_BEAN) - private void updateAutoFocusMoveCallback() { - if (mParameters.getFocusMode().equals(CameraUtil.FOCUS_MODE_CONTINUOUS_PICTURE) || - mParameters.getFocusMode().equals(CameraUtil.FOCUS_MODE_MW_CONTINUOUS_PICTURE)) { - mCameraDevice.setAutoFocusMoveCallback(mHandler, - (CameraAFMoveCallback) mAutoFocusMoveCallback); - } else { - mCameraDevice.setAutoFocusMoveCallback(null, null); + private void enableAutoFocusMoveCallback() { + if (mContinuousFocusSupported && ApiHelper.HAS_AUTO_FOCUS_MOVE_CALLBACK) { + if (mParameters.getFocusMode().equals(CameraUtil.FOCUS_MODE_CONTINUOUS_PICTURE)) { + mCameraDevice.setAutoFocusMoveCallback(mHandler, + (CameraAFMoveCallback) mAutoFocusMoveCallback); + } else { + mCameraDevice.setAutoFocusMoveCallback(null, null); + } } } + private void updateCameraParametersFocus() { + setAutoExposureLockIfSupported(); + setAutoWhiteBalanceLockIfSupported(); + setFocusAreasIfSupported(); + setMeteringAreasIfSupported(); + mParameters.setFocusMode(mFocusManager.getFocusMode(false)); + } + // We separate the parameters into several subsets, so we can update only // the subsets actually need updating. The PREFERENCE set needs extra // locking because the preference can be changed from GLThread as well. @@ -3691,8 +3716,14 @@ public class PhotoModule doModeSwitch = updateCameraParametersPreference(); } - CameraUtil.dumpParameters(mParameters); + if ((updateSet & UPDATE_PARAM_FOCUS) != 0) { + updateCameraParametersFocus(); + } + mCameraDevice.setParameters(mParameters); + mParameters = mCameraDevice.getParameters(); + mFocusManager.setParameters(mParameters); + CameraUtil.dumpParameters(mParameters); // Switch to gcam module if HDR+ was selected if (doModeSwitch && !mIsImageCaptureIntent) { |