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

Commit 4b52ba4c authored by Suman Mukherjee's avatar Suman Mukherjee Committed by Steve Kondik
Browse files

Camera: Rotate display if app doesn't use setDisplayOrientation.

Third party application not following setDisplayOrientation
logic properly and as a result preview used to come inverted.

Fix made to track setDisplayOrientation call invocation and
if no call had been made then, rotate the buffers accordingly.

Change-Id: I9eac28396c4ce8844bf6a4f19ee7650a620ff4a5
CRs-fixed: 575558
parent 68bf23a6
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ CameraClient::CameraClient(const sp<CameraService>& cameraService,
    mPreviewWindow = 0;
    mDestructionStarted = false;

    mIsOrientationSetByApp = false;

    // Callback is disabled by default
    mPreviewCallbackFlag = CAMERA_FRAME_CALLBACK_FLAG_NOOP;
    mOrientation = getOrientation(0, mCameraFacing == CAMERA_FACING_FRONT);
@@ -408,8 +410,13 @@ status_t CameraClient::startPreviewMode() {
    if (mPreviewWindow != 0) {
        native_window_set_scaling_mode(mPreviewWindow.get(),
                NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);
        if (!mIsOrientationSetByApp) {
            int orientationCorrection = getOrientation(0,mCameraFacing == CAMERA_FACING_FRONT);
            native_window_set_buffers_transform(mPreviewWindow.get(),
                mOrientation);
                                                mOrientation + orientationCorrection);
        } else {
            native_window_set_buffers_transform(mPreviewWindow.get(), mOrientation);
        }
    }

#if defined(OMAP_ICS_CAMERA) || defined(OMAP_ENHANCEMENT_BURST_CAPTURE)
@@ -469,6 +476,8 @@ void CameraClient::stopPreview() {
    disableMsgType(CAMERA_MSG_POSTVIEW_FRAME);
#endif

    mIsOrientationSetByApp = false;

    disableMsgType(CAMERA_MSG_PREVIEW_FRAME);
#ifdef QCOM_HARDWARE
    //Disable picture related message types
@@ -670,6 +679,8 @@ status_t CameraClient::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) {
        orientation = getOrientation(arg1, mCameraFacing == CAMERA_FACING_FRONT);
        if (orientation == -1) return BAD_VALUE;

        mIsOrientationSetByApp = true;

        if (mOrientation != orientation) {
            mOrientation = orientation;
            if (mPreviewWindow != 0) {
+2 −0
Original line number Diff line number Diff line
@@ -160,6 +160,8 @@ private:
    // This function keeps trying to grab mLock, or give up if the message
    // is found to be disabled. It returns true if mLock is grabbed.
    bool                    lockIfMessageWanted(int32_t msgType);

    bool                            mIsOrientationSetByApp;
};

}