Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b76bed1 authored by Wu-cheng Li's avatar Wu-cheng Li Committed by Android (Google) Code Review
Browse files

Merge "Fix camera display orientation."

parents 5994359f b0f7d95b
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -320,6 +320,7 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
    // Callback is disabled by default
    mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
    mOrientation = 0;
    mPreviewWindowFlag = 0;
    mOrientationChanged = false;
    mPlayShutterSound = true;
    cameraService->setCameraBusy(cameraId);
@@ -508,6 +509,8 @@ status_t CameraService::Client::setPreviewDisplay(const sp<Surface>& surface) {
        if (mUseOverlay) {
            result = setOverlay();
        } else if (mPreviewWindow != 0) {
            native_window_set_buffers_transform(mPreviewWindow.get(),
                                                mPreviewWindowFlag);
            result = mHardware->setPreviewWindow(mPreviewWindow);
        }
    }
@@ -633,7 +636,10 @@ status_t CameraService::Client::startPreviewMode() {
        if (result != NO_ERROR) return result;
        result = mHardware->startPreview();
    } else {
        // XXX: Set the orientation of the ANativeWindow.
        if (mPreviewWindow != 0) {
            native_window_set_buffers_transform(mPreviewWindow.get(),
                                                mPreviewWindowFlag);
        }
        mHardware->setPreviewWindow(mPreviewWindow);
        result = mHardware->startPreview();
    }
@@ -818,15 +824,19 @@ status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t a
        switch (arg1) {
            case 0:
                orientation = ISurface::BufferHeap::ROT_0;
                mPreviewWindowFlag = 0;
                break;
            case 90:
                orientation = ISurface::BufferHeap::ROT_90;
                mPreviewWindowFlag = NATIVE_WINDOW_TRANSFORM_ROT_90;
                break;
            case 180:
                orientation = ISurface::BufferHeap::ROT_180;
                mPreviewWindowFlag = NATIVE_WINDOW_TRANSFORM_ROT_180;
                break;
            case 270:
                orientation = ISurface::BufferHeap::ROT_270;
                mPreviewWindowFlag = NATIVE_WINDOW_TRANSFORM_ROT_270;
                break;
            default:
                return BAD_VALUE;
+2 −0
Original line number Diff line number Diff line
@@ -166,6 +166,7 @@ private:
        sp<CameraService>               mCameraService;  // immutable after constructor
        sp<ICameraClient>               mCameraClient;
        int                             mCameraId;       // immutable after constructor
        int                             mCameraFacing;   // immutable after constructor
        pid_t                           mClientPid;
        sp<CameraHardwareInterface>     mHardware;       // cleared after disconnect()
        bool                            mUseOverlay;     // immutable after constructor
@@ -176,6 +177,7 @@ private:
        int                             mOrientation;     // Current display orientation
        // True if display orientation has been changed. This is only used in overlay.
        int                             mOrientationChanged;
        int                             mPreviewWindowFlag;
        bool                            mPlayShutterSound;

        // Ensures atomicity among the public methods