diff options
| author | 2016-05-15 11:27:47 -0700 | |
|---|---|---|
| committer | 2016-06-07 11:42:32 -0700 | |
| commit | 82364e3cea0bf88fa8147766433329b3dd5148b8 (patch) | |
| tree | 8c02d094dc655a958de9f941c38325348c7e1b3c /services/surfaceflinger/Layer.cpp | |
| parent | d224e6111bf4532fb1c1fc021c20285b38bc80ec (diff) | |
SurfaceFlinger: Add mode to apply position with resize.
For some cases, like scaled windows with shadows,
we need to be able to apply the position concurrent with
window resize. This is because the scaling of the shadows causes
the top left coordinate of the non shadow surface content
to change before and after the resize.
Bug: 28899837
Change-Id: I522eacfbbcd79707dc1e5ab71901a263b3004ba9
Diffstat (limited to 'services/surfaceflinger/Layer.cpp')
| -rw-r--r-- | services/surfaceflinger/Layer.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index b5d3262056..02477239b7 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -95,7 +95,8 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client, mQueueItems(), mLastFrameNumberReceived(0), mUpdateTexImageFailed(false), - mAutoRefresh(false) + mAutoRefresh(false), + mFreezePositionUpdates(false) { #ifdef USE_HWC2 ALOGV("Creating Layer %s", name.string()); @@ -1415,11 +1416,9 @@ uint32_t Layer::doTransaction(uint32_t flags) { c.requested.w, c.requested.h); } + const bool resizePending = (c.requested.w != c.active.w) || + (c.requested.h != c.active.h); if (!isFixedSize()) { - - const bool resizePending = (c.requested.w != c.active.w) || - (c.requested.h != c.active.h); - if (resizePending && mSidebandStream == NULL) { // don't let Layer::doTransaction update the drawing state // if we have a pending resize, unless we are in fixed-size mode. @@ -1443,8 +1442,16 @@ uint32_t Layer::doTransaction(uint32_t flags) { if (flags & eDontUpdateGeometryState) { } else { Layer::State& editCurrentState(getCurrentState()); - editCurrentState.active = editCurrentState.requested; - c.active = c.requested; + if (mFreezePositionUpdates) { + float tx = c.active.transform.tx(); + float ty = c.active.transform.ty(); + c.active = c.requested; + c.active.transform.set(tx, ty); + editCurrentState.active = c.active; + } else { + editCurrentState.active = editCurrentState.requested; + c.active = c.requested; + } } if (s.active != c.active) { @@ -1491,7 +1498,7 @@ uint32_t Layer::setTransactionFlags(uint32_t flags) { return android_atomic_or(flags, &mTransactionFlags); } -bool Layer::setPosition(float x, float y) { +bool Layer::setPosition(float x, float y, bool immediate) { if (mCurrentState.requested.transform.tx() == x && mCurrentState.requested.transform.ty() == y) return false; mCurrentState.sequence++; @@ -1500,12 +1507,16 @@ bool Layer::setPosition(float x, float y) { // we want to apply the position portion of the transform matrix immediately, // but still delay scaling when resizing a SCALING_MODE_FREEZE layer. mCurrentState.requested.transform.set(x, y); - mCurrentState.active.transform.set(x, y); + if (immediate && !mFreezePositionUpdates) { + mCurrentState.active.transform.set(x, y); + } + mFreezePositionUpdates = mFreezePositionUpdates || !immediate; mCurrentState.modified = true; setTransactionFlags(eTransactionNeeded); return true; } + bool Layer::setLayer(uint32_t z) { if (mCurrentState.z == z) return false; @@ -1585,6 +1596,7 @@ bool Layer::setOverrideScalingMode(int32_t scalingMode) { if (scalingMode == mOverrideScalingMode) return false; mOverrideScalingMode = scalingMode; + setTransactionFlags(eTransactionNeeded); return true; } @@ -2004,6 +2016,7 @@ Region Layer::latchBuffer(bool& recomputeVisibleRegions) if (bufWidth != uint32_t(oldActiveBuffer->width) || bufHeight != uint32_t(oldActiveBuffer->height)) { recomputeVisibleRegions = true; + mFreezePositionUpdates = false; } } |