diff options
author | 2016-06-16 15:18:02 -0700 | |
---|---|---|
committer | 2016-06-21 16:28:41 -0700 | |
commit | 99e27f0bc236e38d88ff4f9912ede514a729b8eb (patch) | |
tree | 17bcbc4da8aeee91ac1ba9371a5c061974c24f5c | |
parent | f9d7e1a0aa05bb47527f054b85a36f16e7955088 (diff) |
Change setPositionAppliesWithResize to apply to all geometry.
To support seamless rotation, change setPositionAppliesWithResize
to also include the crop. As the transformation matrix is already
frozen during resize, this enables the window manager to set the
total geometry state before and after resize in a race free fashion.
Bug: 28823590
Change-Id: I3f8f0e162b7ef4e9403c1220c7e4191b3ef30526
-rw-r--r-- | include/gui/SurfaceComposerClient.h | 2 | ||||
-rw-r--r-- | include/gui/SurfaceControl.h | 7 | ||||
-rw-r--r-- | include/private/gui/LayerState.h | 2 | ||||
-rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 10 | ||||
-rw-r--r-- | libs/gui/SurfaceControl.cpp | 4 | ||||
-rw-r--r-- | services/surfaceflinger/Layer.cpp | 14 | ||||
-rw-r--r-- | services/surfaceflinger/Layer.h | 8 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 8 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger_hwc1.cpp | 8 |
9 files changed, 39 insertions, 24 deletions
diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h index 312e02f1dc..3d6051e8b6 100644 --- a/include/gui/SurfaceComposerClient.h +++ b/include/gui/SurfaceComposerClient.h @@ -140,7 +140,7 @@ public: const sp<IBinder>& handle, uint64_t frameNumber); status_t setOverrideScalingMode(const sp<IBinder>& id, int32_t overrideScalingMode); - status_t setPositionAppliesWithResize(const sp<IBinder>& id); + status_t setGeometryAppliesWithResize(const sp<IBinder>& id); status_t destroySurface(const sp<IBinder>& id); diff --git a/include/gui/SurfaceControl.h b/include/gui/SurfaceControl.h index fafd1948fe..043eb53646 100644 --- a/include/gui/SurfaceControl.h +++ b/include/gui/SurfaceControl.h @@ -73,10 +73,11 @@ public: status_t setCrop(const Rect& crop); status_t setFinalCrop(const Rect& crop); - // If the size changes in this transaction, position updates specified + // If the size changes in this transaction, all geometry updates specified // in this transaction will not complete until a buffer of the new size - // arrives. - status_t setPositionAppliesWithResize(); + // arrives. As some elements normally apply immediately, this enables + // freezing the total geometry of a surface until a resize is completed. + status_t setGeometryAppliesWithResize(); // Defers applying any changes made in this transaction until the Layer // identified by handle reaches the given frameNumber diff --git a/include/private/gui/LayerState.h b/include/private/gui/LayerState.h index 4885e05d04..4b3fcc6e2b 100644 --- a/include/private/gui/LayerState.h +++ b/include/private/gui/LayerState.h @@ -55,7 +55,7 @@ struct layer_state_t { eDeferTransaction = 0x00000200, eFinalCropChanged = 0x00000400, eOverrideScalingModeChanged = 0x00000800, - ePositionAppliesWithResize = 0x00001000, + eGeometryAppliesWithResize = 0x00001000, }; layer_state_t() diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 92ae41eec8..1620eb2b79 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -165,7 +165,7 @@ public: uint64_t frameNumber); status_t setOverrideScalingMode(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id, int32_t overrideScalingMode); - status_t setPositionAppliesWithResize(const sp<SurfaceComposerClient>& client, + status_t setGeometryAppliesWithResize(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id); void setDisplaySurface(const sp<IBinder>& token, @@ -445,7 +445,7 @@ status_t Composer::setOverrideScalingMode( return NO_ERROR; } -status_t Composer::setPositionAppliesWithResize( +status_t Composer::setGeometryAppliesWithResize( const sp<SurfaceComposerClient>& client, const sp<IBinder>& id) { Mutex::Autolock lock(mLock); @@ -453,7 +453,7 @@ status_t Composer::setPositionAppliesWithResize( if (!s) { return BAD_INDEX; } - s->what |= layer_state_t::ePositionAppliesWithResize; + s->what |= layer_state_t::eGeometryAppliesWithResize; return NO_ERROR; } @@ -699,9 +699,9 @@ status_t SurfaceComposerClient::setOverrideScalingMode( this, id, overrideScalingMode); } -status_t SurfaceComposerClient::setPositionAppliesWithResize( +status_t SurfaceComposerClient::setGeometryAppliesWithResize( const sp<IBinder>& id) { - return getComposer().setPositionAppliesWithResize(this, id); + return getComposer().setGeometryAppliesWithResize(this, id); } // ---------------------------------------------------------------------------- diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp index 4671e505aa..223e1f4ba2 100644 --- a/libs/gui/SurfaceControl.cpp +++ b/libs/gui/SurfaceControl.cpp @@ -112,10 +112,10 @@ status_t SurfaceControl::setPosition(float x, float y) { if (err < 0) return err; return mClient->setPosition(mHandle, x, y); } -status_t SurfaceControl::setPositionAppliesWithResize() { +status_t SurfaceControl::setGeometryAppliesWithResize() { status_t err = validate(); if (err < 0) return err; - return mClient->setPositionAppliesWithResize(mHandle); + return mClient->setGeometryAppliesWithResize(mHandle); } status_t SurfaceControl::setSize(uint32_t w, uint32_t h) { status_t err = validate(); diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index d732c0732e..3f70144904 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -1574,11 +1574,15 @@ bool Layer::setFlags(uint8_t flags, uint8_t mask) { setTransactionFlags(eTransactionNeeded); return true; } -bool Layer::setCrop(const Rect& crop) { + +bool Layer::setCrop(const Rect& crop, bool immediate) { if (mCurrentState.crop == crop) return false; mCurrentState.sequence++; - mCurrentState.crop = crop; + mCurrentState.requestedCrop = crop; + if (immediate) { + mCurrentState.crop = crop; + } mCurrentState.modified = true; setTransactionFlags(eTransactionNeeded); return true; @@ -1870,6 +1874,12 @@ Region Layer::latchBuffer(bool& recomputeVisibleRegions) recomputeVisibleRegions = true; } + if (front.crop != front.requestedCrop) { + front.crop = front.requestedCrop; + current.crop = front.requestedCrop; + recomputeVisibleRegions = true; + } + return false; } }; diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index 4257c37513..3ea38f0179 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -96,7 +96,9 @@ public: Transform transform; inline bool operator ==(const Geometry& rhs) const { - return (w == rhs.w && h == rhs.h); + return (w == rhs.w && h == rhs.h) && + (transform.tx() == rhs.transform.tx()) && + (transform.ty() == rhs.transform.ty()); } inline bool operator !=(const Geometry& rhs) const { return !operator ==(rhs); @@ -120,6 +122,8 @@ public: bool modified; Rect crop; + Rect requestedCrop; + Rect finalCrop; // If set, defers this state update until the Layer identified by handle @@ -156,7 +160,7 @@ public: bool setMatrix(const layer_state_t::matrix22_t& matrix); bool setTransparentRegionHint(const Region& transparent); bool setFlags(uint8_t flags, uint8_t mask); - bool setCrop(const Rect& crop); + bool setCrop(const Rect& crop, bool immediate); bool setFinalCrop(const Rect& crop); bool setLayerStack(uint32_t layerStack); void deferTransactionUntil(const sp<IBinder>& handle, uint64_t frameNumber); diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index fa61a9b528..9a2747da75 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2260,10 +2260,10 @@ uint32_t SurfaceFlinger::setClientStateLocked( sp<Layer> layer(client->getLayerUser(s.surface)); if (layer != 0) { const uint32_t what = s.what; - bool positionAppliesWithResize = - what & layer_state_t::ePositionAppliesWithResize; + bool geometryAppliesWithResize = + what & layer_state_t::eGeometryAppliesWithResize; if (what & layer_state_t::ePositionChanged) { - if (layer->setPosition(s.x, s.y, !positionAppliesWithResize)) { + if (layer->setPosition(s.x, s.y, !geometryAppliesWithResize)) { flags |= eTraversalNeeded; } } @@ -2300,7 +2300,7 @@ uint32_t SurfaceFlinger::setClientStateLocked( flags |= eTraversalNeeded; } if (what & layer_state_t::eCropChanged) { - if (layer->setCrop(s.crop)) + if (layer->setCrop(s.crop, !geometryAppliesWithResize)) flags |= eTraversalNeeded; } if (what & layer_state_t::eFinalCropChanged) { diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp index a86c69209f..83f7b08f27 100644 --- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp +++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp @@ -2263,10 +2263,10 @@ uint32_t SurfaceFlinger::setClientStateLocked( sp<Layer> layer(client->getLayerUser(s.surface)); if (layer != 0) { const uint32_t what = s.what; - bool positionAppliesWithResize = - what & layer_state_t::ePositionAppliesWithResize; + bool geometryAppliesWithResize = + what & layer_state_t::eGeometryAppliesWithResize; if (what & layer_state_t::ePositionChanged) { - if (layer->setPosition(s.x, s.y, !positionAppliesWithResize)) { + if (layer->setPosition(s.x, s.y, !geometryAppliesWithResize)) { flags |= eTraversalNeeded; } } @@ -2303,7 +2303,7 @@ uint32_t SurfaceFlinger::setClientStateLocked( flags |= eTraversalNeeded; } if (what & layer_state_t::eCropChanged) { - if (layer->setCrop(s.crop)) + if (layer->setCrop(s.crop, !geometryAppliesWithResize)) flags |= eTraversalNeeded; } if (what & layer_state_t::eFinalCropChanged) { |