From 1989af22b5aa94430c7a43e13f3307d25be8c837 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 2 Dec 2010 21:32:29 -0800 Subject: [3171580] Fix two typos related to fixed-size buffers mFixedSize was never set, this bug was introduced during some "cleanup", in practice this could cause some issues when a fixed-size buffer was used and the window was resized. Layer::drawForSreenShot() had a typo that had no effect. mFixedSize was used to determine if filtering was needed, which was a bit too conservative and created a dependency between filtering and "fixed size" states which should exist. Now we enable filtering based on the size of the buffer vs. the size of the layer. Change-Id: I32044e91b0c944c1b137efdceb3f01dfaa78119d --- services/surfaceflinger/Layer.cpp | 23 +++++++++++------------ services/surfaceflinger/Layer.h | 1 + services/surfaceflinger/LayerBase.cpp | 12 ++++-------- services/surfaceflinger/LayerBase.h | 4 +++- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 5018fb3c437f..81cb15def5ba 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -57,7 +57,7 @@ Layer::Layer(SurfaceFlinger* flinger, mSecure(false), mTextureManager(), mBufferManager(mTextureManager), - mWidth(0), mHeight(0), mFixedSize(false) + mWidth(0), mHeight(0), mNeedsScaling(false), mFixedSize(false) { } @@ -216,13 +216,10 @@ slowpath: void Layer::drawForSreenShot() const { - bool currentFixedSize = mFixedSize; - bool currentBlending = mNeedsBlending; - const_cast(this)->mFixedSize = false; - const_cast(this)->mFixedSize = true; + const bool currentFiltering = mNeedsFiltering; + const_cast(this)->mNeedsFiltering = true; LayerBase::drawForSreenShot(); - const_cast(this)->mFixedSize = currentFixedSize; - const_cast(this)->mNeedsBlending = currentBlending; + const_cast(this)->mNeedsFiltering = currentFiltering; } void Layer::onDraw(const Region& clip) const @@ -260,11 +257,10 @@ void Layer::onDraw(const Region& clip) const bool Layer::needsFiltering() const { if (!(mFlags & DisplayHardware::SLOW_CONFIG)) { - // NOTE: there is a race here, because mFixedSize is updated in a - // binder transaction. however, it doesn't really matter since it is - // evaluated each time we draw. To be perfectly correct, this flag - // would have to be associated with a buffer. - if (mFixedSize) + // if our buffer is not the same size than ourselves, + // we need filtering. + Mutex::Autolock _l(mLock); + if (mNeedsScaling) return true; } return LayerBase::needsFiltering(); @@ -321,6 +317,7 @@ sp Layer::requestBuffer(int index, Mutex::Autolock _l(mLock); // zero means default + mFixedSize = reqWidth && reqHeight; if (!reqFormat) reqFormat = mFormat; if (!reqWidth) reqWidth = mWidth; if (!reqHeight) reqHeight = mHeight; @@ -334,6 +331,7 @@ sp Layer::requestBuffer(int index, mReqWidth = reqWidth; mReqHeight = reqHeight; mReqFormat = reqFormat; + mNeedsScaling = mWidth != mReqWidth || mHeight != mReqHeight; lcblk->reallocateAllExcept(index); } @@ -457,6 +455,7 @@ void Layer::setBufferSize(uint32_t w, uint32_t h) { Mutex::Autolock _l(mLock); mWidth = w; mHeight = h; + mNeedsScaling = mWidth != mReqWidth || mHeight != mReqHeight; } bool Layer::isFixedSize() const { diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index 263c372716e2..a93fcb13b8ae 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -230,6 +230,7 @@ private: uint32_t mReqWidth; uint32_t mReqHeight; uint32_t mReqFormat; + bool mNeedsScaling; bool mFixedSize; }; diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp index 64eed4b55f7c..79c6d0d62f9d 100644 --- a/services/surfaceflinger/LayerBase.cpp +++ b/services/surfaceflinger/LayerBase.cpp @@ -216,14 +216,10 @@ uint32_t LayerBase::doTransaction(uint32_t flags) flags |= eVisibleRegion; this->contentDirty = true; - mNeedsFiltering = false; - if (!(mFlags & DisplayHardware::SLOW_CONFIG)) { - // we may use linear filtering, if the matrix scales us - const uint8_t type = temp.transform.getType(); - if (!temp.transform.preserveRects() || (type >= Transform::SCALE)) { - mNeedsFiltering = true; - } - } + // we may use linear filtering, if the matrix scales us + const uint8_t type = temp.transform.getType(); + mNeedsFiltering = (!temp.transform.preserveRects() || + (type >= Transform::SCALE)); } // Commit the transaction diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h index d688f6523d7a..633df96542a5 100644 --- a/services/surfaceflinger/LayerBase.h +++ b/services/surfaceflinger/LayerBase.h @@ -185,7 +185,9 @@ public: /** * needsLinearFiltering - true if this surface needs filtering */ - virtual bool needsFiltering() const { return mNeedsFiltering; } + virtual bool needsFiltering() const { + return (!(mFlags & DisplayHardware::SLOW_CONFIG)) && mNeedsFiltering; + } /** * isSecure - true if this surface is secure, that is if it prevents -- cgit v1.2.3-59-g8ed1b From e33811512eb061338792dbb0dbd37a1b8e4e1079 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 2 Dec 2010 15:19:36 -0800 Subject: [3253328, 3171580] Treat GONE and INVISIBLE views the same when calculating transparent regions We only used to check for INVISIBLE, which prevented some Surfaceview optimization to take place. Change-Id: I244b54696d861a022ca1c334ff61ab7efb899587 --- core/java/android/view/ViewGroup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index b9864ba3b140..2b71b4a492e0 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -3304,7 +3304,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager boolean noneOfTheChildrenAreTransparent = true; for (int i = 0; i < count; i++) { final View child = children[i]; - if ((child.mViewFlags & VISIBILITY_MASK) != GONE || child.getAnimation() != null) { + if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE || child.getAnimation() != null) { if (!child.gatherTransparentRegion(region)) { noneOfTheChildrenAreTransparent = false; } -- cgit v1.2.3-59-g8ed1b