From cfd539bf4a6facee1d96e6aaca273d662e548563 Mon Sep 17 00:00:00 2001 From: Ramkumar Radhakrishnan Date: Thu, 20 Aug 2015 18:18:30 -0700 Subject: [PATCH] sf: This is a combination of following changes. Author: Prabhanjan Kandula SF: Add support for inverse mounted panels. Add 180 rotation in SF to account for inverse mounted panels. The framework will be unaffected and use policies for a 0 mounted panel. SF changes the global transform and silently induces the H,V flips. Similar flips are added to screenshots as well. CRs-Fixed: 894147 Change-Id: I6e9576ee734ee85097491eaa1e8e94cfb3731e0f Author: Ramkumar Radhakrishnan SF: Clear visible region of layer appropriately. Clear visible region of layer having layer stack id different than the display layer stack id to ensure that the layer won't be present on the wrong display layer list. Change-Id: I59289fea63ec7a2451d4715cfe7926ba34fdb8e3 Change-Id: I5ad08a6013aa173d621ee80c766a6e19e1086a35 --- services/surfaceflinger/DisplayDevice.cpp | 11 +++++++++++ services/surfaceflinger/DisplayDevice.h | 8 +++++++- services/surfaceflinger/SurfaceFlinger.cpp | 16 +++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index 13d44f39b..baff5ba59 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -90,6 +90,7 @@ DisplayDevice::DisplayDevice( { mNativeWindow = new Surface(producer, false); ANativeWindow* const window = mNativeWindow.get(); + char property[PROPERTY_VALUE_MAX]; /* * Create our display's surface @@ -140,6 +141,11 @@ DisplayDevice::DisplayDevice( break; } + mPanelInverseMounted = false; + // Check if panel is inverse mounted (contents show up HV flipped) + property_get("persist.panel.inversemounted", property, "0"); + mPanelInverseMounted = !!atoi(property); + // initialize the display orientation transform. setProjection(DisplayState::eOrientationDefault, mViewport, mFrame); } @@ -402,6 +408,11 @@ status_t DisplayDevice::orientationToTransfrom( default: return BAD_VALUE; } + + if (DISPLAY_PRIMARY == mHwcDisplayId && isPanelInverseMounted()) { + flags = flags ^ Transform::ROT_180; + } + tr->set(flags, w, h); return NO_ERROR; } diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h index 8695a44ec..f492a427a 100644 --- a/services/surfaceflinger/DisplayDevice.h +++ b/services/surfaceflinger/DisplayDevice.h @@ -126,6 +126,10 @@ public: int32_t getHwcDisplayId() const { return mHwcDisplayId; } const wp& getDisplayToken() const { return mDisplayToken; } + bool isPanelInverseMounted() const { + return mPanelInverseMounted; + } + // We pass in mustRecompose so we can keep VirtualDisplaySurface's state // machine happy without actually queueing a buffer if nothing has changed status_t beginFrame(bool mustRecompose) const; @@ -209,7 +213,7 @@ private: /* * Transaction state */ - static status_t orientationToTransfrom(int orientation, + status_t orientationToTransfrom(int orientation, int w, int h, Transform* tr); uint32_t mLayerStack; @@ -226,6 +230,8 @@ private: int mPowerMode; // Current active config int mActiveConfig; + // Panel is inverse mounted + int mPanelInverseMounted; }; }; // namespace android diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 3b4330d15..c5e50e88c 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3306,6 +3306,12 @@ void SurfaceFlinger::renderScreenImplLocked( // make sure to clear all GL error flags engine.checkErrors(); + if (DisplayDevice::DISPLAY_PRIMARY == hw->getDisplayType() && + hw->isPanelInverseMounted()) { + rotation = (Transform::orientation_flags) + (rotation ^ Transform::ROT_180); + } + // set-up our viewport engine.setViewportAndProjection( reqWidth, reqHeight, sourceCrop, hw_h, yswap, rotation); @@ -3508,8 +3514,16 @@ bool SurfaceFlinger::updateLayerVisibleNonTransparentRegion(const int& /*dpy*/, const Layer::State& s(layer->getDrawingState()); // only consider the layers on the given layer stack - if (s.layerStack != layerStack) + if (s.layerStack != layerStack) { + /* set the visible region as empty since we have removed the + * layerstack check in rebuildLayerStack() function + */ + Region visibleNonTransRegion; + visibleNonTransRegion.set(Rect(0,0)); + layer->setVisibleNonTransparentRegion(visibleNonTransRegion); + return true; + } return false; }