diff options
author | Romain Guy <romainguy@google.com> | 2010-12-09 17:47:21 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2010-12-09 17:47:21 -0800 |
commit | af636ebf5feb2837683fbfe965040cb706b32ec1 (patch) | |
tree | d0173871a1535d549cc1649daa2e1c2262671a52 | |
parent | 3eb3106137aa23ceb19c5817fa43bbe545636430 (diff) | |
download | frameworks_base-af636ebf5feb2837683fbfe965040cb706b32ec1.zip frameworks_base-af636ebf5feb2837683fbfe965040cb706b32ec1.tar.gz frameworks_base-af636ebf5feb2837683fbfe965040cb706b32ec1.tar.bz2 |
Don't set the invisible flag when saving an empty layer.
Bug #3270371
Change-Id: I65e85671c2fb70d74553c91213e5e759e0ac64ee
-rw-r--r-- | core/java/android/view/View.java | 6 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 22 | ||||
-rw-r--r-- | libs/hwui/Snapshot.h | 17 |
3 files changed, 33 insertions, 12 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index ad96686..da12d46 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -6421,6 +6421,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility mPrivateFlags &= ~DRAWING_CACHE_VALID; final ViewParent p = mParent; final AttachInfo ai = mAttachInfo; + if (p != null && ai != null && ai.mHardwareAccelerated) { + // fast-track for GL-enabled applications; just invalidate the whole hierarchy + // with a null dirty rect, which tells the ViewRoot to redraw everything + p.invalidateChild(this, null); + return; + } if (p != null && ai != null) { final int scrollX = mScrollX; final int scrollY = mScrollY; diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index b357973..8bfc8d4 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -268,7 +268,7 @@ int OpenGLRenderer::saveLayer(float left, float top, float right, float bottom, const GLuint previousFbo = mSnapshot->fbo; const int count = saveSnapshot(flags); - if (!mSnapshot->invisible) { + if (!mSnapshot->isIgnored()) { int alpha = 255; SkXfermode::Mode mode; @@ -385,13 +385,17 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top, if (bounds.isEmpty() || bounds.getWidth() > mCaches.maxTextureSize || bounds.getHeight() > mCaches.maxTextureSize) { - snapshot->invisible = true; + if (fboLayer) { + snapshot->invisible = true; + } else { + snapshot->empty = true; + } } else { snapshot->invisible = snapshot->invisible || (alpha <= ALPHA_THRESHOLD && fboLayer); } // Bail out if we won't draw in this snapshot - if (snapshot->invisible) { + if (snapshot->invisible || snapshot->empty) { return false; } @@ -731,7 +735,7 @@ void OpenGLRenderer::setupDraw() { } void OpenGLRenderer::clearLayerRegions() { - if (mLayers.size() == 0 || mSnapshot->invisible) return; + if (mLayers.size() == 0 || mSnapshot->isIgnored()) return; Rect clipRect(*mSnapshot->clipRect); clipRect.snapToPixelBoundaries(); @@ -809,7 +813,7 @@ const Rect& OpenGLRenderer::getClipBounds() { } bool OpenGLRenderer::quickReject(float left, float top, float right, float bottom) { - if (mSnapshot->invisible) { + if (mSnapshot->isIgnored()) { return true; } @@ -988,7 +992,7 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) { // TODO: Should do quickReject for each line - if (mSnapshot->invisible) return; + if (mSnapshot->isIgnored()) return; const bool isAA = paint->isAntiAlias(); const float strokeWidth = paint->getStrokeWidth() * 0.5f; @@ -1112,7 +1116,7 @@ void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) { void OpenGLRenderer::drawColor(int color, SkXfermode::Mode mode) { // No need to check against the clip, we fill the clip region - if (mSnapshot->invisible) return; + if (mSnapshot->isIgnored()) return; Rect& clip(*mSnapshot->clipRect); clip.snapToPixelBoundaries(); @@ -1150,7 +1154,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, if (text == NULL || count == 0 || (paint->getAlpha() == 0 && paint->getXfermode() == NULL)) { return; } - if (mSnapshot->invisible) return; + if (mSnapshot->isIgnored()) return; paint->setAntiAlias(true); @@ -1253,7 +1257,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, } void OpenGLRenderer::drawPath(SkPath* path, SkPaint* paint) { - if (mSnapshot->invisible) return; + if (mSnapshot->isIgnored()) return; GLuint textureUnit = 0; glActiveTexture(gTextureUnits[textureUnit]); diff --git a/libs/hwui/Snapshot.h b/libs/hwui/Snapshot.h index 9f78063..9898df4 100644 --- a/libs/hwui/Snapshot.h +++ b/libs/hwui/Snapshot.h @@ -43,7 +43,7 @@ namespace uirenderer { */ class Snapshot: public LightRefBase<Snapshot> { public: - Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0), invisible(false) { + Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0), invisible(false), empty(false) { transform = &mTransformRoot; clipRect = &mClipRectRoot; region = NULL; @@ -55,7 +55,7 @@ public: */ Snapshot(const sp<Snapshot>& s, int saveFlags): flags(0), previous(s), layer(NULL), fbo(s->fbo), - invisible(s->invisible), viewport(s->viewport), height(s->height) { + invisible(s->invisible), empty(false), viewport(s->viewport), height(s->height) { if (saveFlags & SkCanvas::kMatrix_SaveFlag) { mTransformRoot.load(*s->transform); transform = &mTransformRoot; @@ -203,6 +203,10 @@ public: flags |= Snapshot::kFlagClipSet | Snapshot::kFlagDirtyLocalClip; } + bool isIgnored() const { + return invisible || empty; + } + /** * Dirty flags. */ @@ -225,11 +229,18 @@ public: /** * Indicates that this snapshot is invisible and nothing should be drawn - * inside it. + * inside it. This flag is set only when the layer clips drawing to its + * bounds and is passed to subsequent snapshots. */ bool invisible; /** + * If set to true, the layer will not be composited. This is similar to + * invisible but this flag is not passed to subsequent snapshots. + */ + bool empty; + + /** * Current viewport. */ Rect viewport; |