diff options
| author | 2011-07-19 15:24:46 -0700 | |
|---|---|---|
| committer | 2011-07-19 15:24:46 -0700 | |
| commit | 97c602c5af5f3ffd69009bf496d86347b71a2b4c (patch) | |
| tree | 2ce4b7b59ebb267abc76d9f8d3987beae24fda5c /services/surfaceflinger/Layer.cpp | |
| parent | 933389f75814bb62e8153528f9cff2cb329b77df (diff) | |
implement: "Add an ANativeWindow API for SurfaceFlinger to suggest an optimal buffer orientation"
Bug: 4487161
Change-Id: I883f34efe542c2a566d04966f873374f40c50092
Diffstat (limited to 'services/surfaceflinger/Layer.cpp')
| -rw-r--r-- | services/surfaceflinger/Layer.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index c29aecab96..e0268fa061 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -44,10 +44,6 @@ namespace android { -template <typename T> inline T min(T a, T b) { - return a<b ? a : b; -} - // --------------------------------------------------------------------------- Layer::Layer(SurfaceFlinger* flinger, @@ -457,13 +453,22 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) // FIXME: mPostedDirtyRegion = dirty & bounds mPostedDirtyRegion.set(front.w, front.h); - sp<GraphicBuffer> newFrontBuffer(mActiveBuffer); - if ((newFrontBuffer->getWidth() == front.requested_w && - newFrontBuffer->getHeight() == front.requested_h) || - isFixedSize()) + + if ((front.w != front.requested_w) || + (front.h != front.requested_h)) { - if ((front.w != front.requested_w) || - (front.h != front.requested_h)) + // check that we received a buffer of the right size + // (Take the buffer's orientation into account) + sp<GraphicBuffer> newFrontBuffer(mActiveBuffer); + uint32_t bufWidth = newFrontBuffer->getWidth(); + uint32_t bufHeight = newFrontBuffer->getHeight(); + if (mCurrentTransform & Transform::ROT_90) { + swap(bufWidth, bufHeight); + } + + if (isFixedSize() || + (bufWidth == front.requested_w && + bufHeight == front.requested_h)) { // Here we pretend the transaction happened by updating the // current and drawing states. Drawing state is only accessed @@ -483,10 +488,10 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) // recompute visible region recomputeVisibleRegions = true; - } - // we now have the correct size, unfreeze the screen - mFreezeLock.clear(); + // we now have the correct size, unfreeze the screen + mFreezeLock.clear(); + } } } } |