From bea57f312dbbeef1d35cb41948605a41b3f30662 Mon Sep 17 00:00:00 2001 From: Ramakant Singh Date: Tue, 8 Sep 2015 18:57:25 +0530 Subject: sf : Fix vertices & texture coordinates computation. Compute crop and display frame for GPU composition also in the same way it's done for HWC and compute vertices and texture coordinates for GPU composition. This avoids pixel shifts in output of GPU composition & overlays. Change-Id: I0d31b1e4a81049fff72109d1a210e7cbd945cfe9 --- services/surfaceflinger/Layer.cpp | 60 ++++++++++++++++++++++++++++++++++----- services/surfaceflinger/Layer.h | 3 +- 2 files changed, 55 insertions(+), 8 deletions(-) (limited to 'services') diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 2549863..93e6bda 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -84,7 +84,8 @@ Layer::Layer(SurfaceFlinger* flinger, const sp& client, mQueueItemCondition(), mQueueItems(), mLastFrameNumberReceived(0), - mUpdateTexImageFailed(false) + mUpdateTexImageFailed(false), + mTransformHint(0) { mCurrentCrop.makeInvalid(); mFlinger->getRenderEngine().genTextures(1, &mTextureName); @@ -753,8 +754,19 @@ void Layer::drawWithOpenGL(const sp& hw, * minimal value)? Or, we could make GL behave like HWC -- but this feel * like more of a hack. */ - const Rect win(computeBounds()); - + Rect win(s.active.w, s.active.h); + if(!s.active.crop.isEmpty()) { + win = s.active.crop; + } +#ifdef QTI_BSP + win = s.transform.transform(win); + win.intersect(hw->getViewport(), &win); + win = s.transform.inverse().transform(win); + win.intersect(Rect(s.active.w, s.active.h), &win); + win = reduce(win, s.activeTransparentRegion); +#else + win = reduce(win, s.activeTransparentRegion); +#endif float left = float(win.left) / float(s.active.w); float top = float(win.top) / float(s.active.h); float right = float(win.right) / float(s.active.w); @@ -821,16 +833,49 @@ void Layer::computeGeometry(const sp& hw, Mesh& mesh, bool useIdentityTransform) const { const Layer::State& s(getDrawingState()); - const Transform tr(useIdentityTransform ? + Transform tr(useIdentityTransform ? hw->getTransform() : hw->getTransform() * s.transform); const uint32_t hw_h = hw->getHeight(); Rect win(s.active.w, s.active.h); if (!s.active.crop.isEmpty()) { win.intersect(s.active.crop, &win); } - // subtract the transparent region and snap to the bounds +#ifdef QTI_BSP + win = s.transform.transform(win); + win.intersect(hw->getViewport(), &win); + win = s.transform.inverse().transform(win); + win.intersect(Rect(s.active.w, s.active.h), &win); win = reduce(win, s.activeTransparentRegion); - + const Transform bufferOrientation(mCurrentTransform); + Transform transform(tr * s.transform * bufferOrientation); + if (mSurfaceFlingerConsumer->getTransformToDisplayInverse()) { + uint32_t invTransform = hw->getOrientationTransform(); + uint32_t t_orientation = transform.getOrientation(); + if (invTransform & NATIVE_WINDOW_TRANSFORM_ROT_90) { + invTransform ^= NATIVE_WINDOW_TRANSFORM_FLIP_V | + NATIVE_WINDOW_TRANSFORM_FLIP_H; + bool is_h_flipped = (t_orientation & + NATIVE_WINDOW_TRANSFORM_FLIP_H) != 0; + bool is_v_flipped = (t_orientation & + NATIVE_WINDOW_TRANSFORM_FLIP_V) != 0; + if (is_h_flipped != is_v_flipped) { + t_orientation ^= NATIVE_WINDOW_TRANSFORM_FLIP_V | + NATIVE_WINDOW_TRANSFORM_FLIP_H; + } + transform = Transform(t_orientation) * Transform(invTransform); + } + } + const uint32_t orientation = transform.getOrientation(); + if (!(mTransformHint | mCurrentTransform | orientation)) { + tr = hw->getTransform(); + if (!useIdentityTransform) { + win = s.transform.transform(win); + win.intersect(hw->getViewport(), &win); + } + } +#else + win = reduce(win, s.activeTransparentRegion); +#endif Mesh::VertexArray position(mesh.getPositionArray()); position[0] = tr.transform(win.left, win.top); position[1] = tr.transform(win.left, win.bottom); @@ -1451,7 +1496,7 @@ uint32_t Layer::getEffectiveUsage(uint32_t usage) const return usage; } -void Layer::updateTransformHint(const sp& hw) const { +void Layer::updateTransformHint(const sp& hw) { uint32_t orientation = 0; if (!mFlinger->mDebugDisableTransformHint) { // The transform hint is used to improve performance, but we can @@ -1464,6 +1509,7 @@ void Layer::updateTransformHint(const sp& hw) const { } } mSurfaceFlingerConsumer->setTransformHint(orientation); + mTransformHint = orientation; } // ---------------------------------------------------------------------------- diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index e2cb791..196ef3e 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -299,7 +299,7 @@ public: // Updates the transform hint in our SurfaceFlingerConsumer to match // the current orientation of the display device. - void updateTransformHint(const sp& hw) const; + void updateTransformHint(const sp& hw) ; /* ------------------------------------------------------------------------ * Extensions @@ -451,6 +451,7 @@ private: Vector mQueueItems; uint64_t mLastFrameNumberReceived; bool mUpdateTexImageFailed; // This is only modified from the main thread + uint32_t mTransformHint; }; // --------------------------------------------------------------------------- -- cgit v1.1