summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger/Layer.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2011-07-19 15:24:46 -0700
committerMathias Agopian <mathias@google.com>2011-07-19 15:24:46 -0700
commitf07b8a3f691be39083fb5163f9456bcfa566f93f (patch)
tree885f9fcbb020c630c2b0ea20b13ca2ee850e5f3b /services/surfaceflinger/Layer.cpp
parentff86f37b95327538b97b6b8ef5d3c6ed0cd7f902 (diff)
downloadframeworks_base-f07b8a3f691be39083fb5163f9456bcfa566f93f.zip
frameworks_base-f07b8a3f691be39083fb5163f9456bcfa566f93f.tar.gz
frameworks_base-f07b8a3f691be39083fb5163f9456bcfa566f93f.tar.bz2
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.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index c29aeca..e0268fa 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();
+ }
}
}
}