OSDN Git Service

Unify orientation calculation logic.
authorSenpo Hu <senpo@google.com>
Tue, 18 Nov 2014 06:56:31 +0000 (22:56 -0800)
committerSenpo Hu <senpo@google.com>
Wed, 19 Nov 2014 23:13:31 +0000 (15:13 -0800)
commit0bdc4b54a18c18d7094b2e4cea1e238005c5c4a2
tree656251e6c49f9da4ce00176c07a76a09cd0afcb5
parent77f7eda5a0608256f266c3ba952b2042791c7209
Unify orientation calculation logic.

Camera API takes clockwise degrees for JPEG rotation and
OrientationEventListener reports clockwise device orientation.
The easiest formula of calculating output image rotation degree is:
    "camera sensor orientation" + "device orientation"

Since front cameras face in opposite direction. The result needs to be mirrored
for front camera.

Detailed changes:
* Refactor OrientationManager to remove unnecessary complexity.
  * Add OrientationManager.DeviceOrientation enum and
    OrientationManager.getDeviceOrientation
  * Remove CameraUtil.roundOrientation.
  * Fix the weird calculation which is hard to understand in
    CameraUtil.getJpegRotation and add CameraUtil.getImageRotation
* Clean up image rotation logic in all modules:
  * Always look up the current device orientation via OrientationManager.getDeviceOrientation
  * Fix the doc for copyImagePlaneToBitmap() which actually rotates image
    counterclockwise.
* Clean up CameraActivity:
  * Remove CameraActivity.onOrientationChanged and
    ModuleController.onOrientationChanged. Any individual module which
    wants to listen orientation change should register itself to
    OrientationManager. Now only VideoModule needs to do that.

Bug: 17443789
Change-Id: I6d54cac5bde950acae0c3226448c27a816266df0
12 files changed:
src/com/android/camera/CameraActivity.java
src/com/android/camera/CaptureModule.java
src/com/android/camera/PhotoModule.java
src/com/android/camera/VideoModule.java
src/com/android/camera/VideoUI.java
src/com/android/camera/app/OrientationManager.java
src/com/android/camera/app/OrientationManagerImpl.java
src/com/android/camera/module/ModuleController.java
src/com/android/camera/one/v2/OneCameraZslImpl.java
src/com/android/camera/util/CameraUtil.java
src/com/android/camera/util/JpegUtilNative.java
src/com/android/camera/widget/VideoRecordingHints.java