diff --git a/services/surfaceflinger/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware.cpp index 6a8a55dc7..f982794f3 100644 --- a/services/surfaceflinger/DisplayHardware.cpp +++ b/services/surfaceflinger/DisplayHardware.cpp @@ -233,48 +233,19 @@ void DisplayHardware::init(EGLConfig config) mHwc->setFrameBuffer(mDisplay, mSurface); } - // initialize the display orientation transform. - // it's a constant that should come from the display driver. - int displayOrientation = ISurfaceComposer::eOrientationDefault; - char property[PROPERTY_VALUE_MAX]; - if (property_get("ro.sf.hwrotation", property, NULL) > 0) { - //displayOrientation - switch (atoi(property)) { - case 90: - displayOrientation = ISurfaceComposer::eOrientation90; - break; - case 270: - displayOrientation = ISurfaceComposer::eOrientation270; - break; - } - } - - w = mDisplayWidth; - h = mDisplayHeight; - DisplayHardware::orientationToTransfrom(displayOrientation, w, h, - &mDisplayTransform); - if (displayOrientation & ISurfaceComposer::eOrientationSwapMask) { - mLogicalDisplayWidth = h; - mLogicalDisplayHeight = w; - } else { - mLogicalDisplayWidth = w; - mLogicalDisplayHeight = h; - } - DisplayHardware::setOrientation(ISurfaceComposer::eOrientationDefault); - // initialize the shared control block surface_flinger_cblk_t* const scblk = mFlinger->getControlBlock(); scblk->connected |= 1 << mDisplayId; display_cblk_t* dcblk = &scblk->displays[mDisplayId]; memset(dcblk, 0, sizeof(display_cblk_t)); - dcblk->w = w; // XXX: plane.getWidth(); - dcblk->h = h; // XXX: plane.getHeight(); dcblk->format = format; - dcblk->orientation = ISurfaceComposer::eOrientationDefault; dcblk->xdpi = mDpiX; dcblk->ydpi = mDpiY; dcblk->fps = mRefreshRate; dcblk->density = mDensity; + + // initialize the display orientation transform. + DisplayHardware::setOrientation(ISurfaceComposer::eOrientationDefault); } void DisplayHardware::setVSyncHandler(const sp& handler) { @@ -438,25 +409,25 @@ status_t DisplayHardware::orientationToTransfrom( return NO_ERROR; } -status_t DisplayHardware::setOrientation(int orientation) -{ - // If the rotation can be handled in hardware, this is where - // the magic should happen. +status_t DisplayHardware::setOrientation(int orientation) { + int w = mDisplayWidth; + int h = mDisplayHeight; - const int w = mLogicalDisplayWidth; - const int h = mLogicalDisplayHeight; - mUserDisplayWidth = w; - mUserDisplayHeight = h; - - Transform orientationTransform; - DisplayHardware::orientationToTransfrom(orientation, w, h, - &orientationTransform); + DisplayHardware::orientationToTransfrom( + orientation, w, h, &mGlobalTransform); if (orientation & ISurfaceComposer::eOrientationSwapMask) { - mUserDisplayWidth = h; - mUserDisplayHeight = w; + int tmp = w; + w = h; + h = tmp; } - mOrientation = orientation; - mGlobalTransform = mDisplayTransform * orientationTransform; + + // update the shared control block + surface_flinger_cblk_t* const scblk = mFlinger->getControlBlock(); + volatile display_cblk_t* dcblk = &scblk->displays[mDisplayId]; + dcblk->orientation = orientation; + dcblk->w = w; + dcblk->h = h; + return NO_ERROR; } diff --git a/services/surfaceflinger/DisplayHardware.h b/services/surfaceflinger/DisplayHardware.h index 029c3da09..a1a4764fc 100644 --- a/services/surfaceflinger/DisplayHardware.h +++ b/services/surfaceflinger/DisplayHardware.h @@ -91,8 +91,6 @@ public: status_t setOrientation(int orientation); int getOrientation() const { return mOrientation; } const Transform& getTransform() const { return mGlobalTransform; } - int getUserWidth() const { return mUserDisplayWidth; } - int getUserHeight() const { return mUserDisplayHeight; } void setVSyncHandler(const sp& handler); @@ -166,19 +164,13 @@ private: // this used to be in GraphicPlane static status_t orientationToTransfrom(int orientation, int w, int h, Transform* tr); - Transform mGlobalTransform; - Transform mDisplayTransform; - int mOrientation; - int mLogicalDisplayWidth; - int mLogicalDisplayHeight; - int mUserDisplayWidth; - int mUserDisplayHeight; - - mutable Mutex mLock; + Transform mGlobalTransform; + int mOrientation; /* * protected by mLock */ + mutable Mutex mLock; wp mVSyncHandler; }; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index b70c720d7..8f9432534 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -805,14 +805,7 @@ Region SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) const int dpy = 0; // TODO: should be a parameter DisplayHardware& hw(const_cast(getDisplayHardware(dpy))); - const int orientation = mCurrentState.orientation; - hw.setOrientation(orientation); - - // update the shared control block - volatile display_cblk_t* dcblk = mServerCblk->displays + dpy; - dcblk->orientation = orientation; - dcblk->w = hw.getUserWidth(); - dcblk->h = hw.getUserHeight(); + hw.setOrientation(mCurrentState.orientation); // FIXME: mVisibleRegionsDirty & mDirtyRegion should this be per DisplayHardware? mVisibleRegionsDirty = true;