diff options
author | Romain Guy <romainguy@google.com> | 2013-08-09 14:06:29 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2013-08-09 14:06:29 -0700 |
commit | 9b5a1a28c327e6113d68302b1f0eed1d1c6f6183 (patch) | |
tree | 6b6bb3bc658bf948b5211e7bbde72a19140dba6e /libs/hwui | |
parent | d81a15c6b77c94109d0a08bc7355f62301fe9234 (diff) | |
download | frameworks_base-9b5a1a28c327e6113d68302b1f0eed1d1c6f6183.zip frameworks_base-9b5a1a28c327e6113d68302b1f0eed1d1c6f6183.tar.gz frameworks_base-9b5a1a28c327e6113d68302b1f0eed1d1c6f6183.tar.bz2 |
Take shadow bounds into account for quick rejects
Bug #8634346
Change-Id: I995c5205c2959d8e4da638ae47fedcda92eb1b36
Diffstat (limited to 'libs/hwui')
-rw-r--r-- | libs/hwui/DisplayListOp.h | 15 | ||||
-rw-r--r-- | libs/hwui/DisplayListRenderer.cpp | 8 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.h | 8 |
3 files changed, 28 insertions, 3 deletions
diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h index 1b52b65..42e11d0 100644 --- a/libs/hwui/DisplayListOp.h +++ b/libs/hwui/DisplayListOp.h @@ -249,11 +249,16 @@ public: } // default empty constructor for bounds, to be overridden in child constructor body - DrawBoundedOp(SkPaint* paint) - : DrawOp(paint) {} + DrawBoundedOp(SkPaint* paint): DrawOp(paint) { } bool getLocalBounds(Rect& localBounds) { localBounds.set(mLocalBounds); + if (state.mDrawModifiers.mHasShadow) { + Rect shadow(mLocalBounds); + shadow.translate(state.mDrawModifiers.mShadowDx, state.mDrawModifiers.mShadowDy); + shadow.outset(state.mDrawModifiers.mShadowRadius); + localBounds.unionWith(shadow); + } return true; } @@ -1442,8 +1447,10 @@ public: } virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty) { + Rect bounds; + getLocalBounds(bounds); return renderer.drawText(mText, mBytesCount, mCount, mX, mY, - mPositions, getPaint(renderer), mTotalAdvance, mLocalBounds); + mPositions, getPaint(renderer), mTotalAdvance, bounds); } virtual status_t multiDraw(OpenGLRenderer& renderer, Rect& dirty, @@ -1454,6 +1461,8 @@ public: renderer.restoreDisplayState(ops[i]->state, true); // restore all but the clip DrawTextOp& op = *((DrawTextOp*)ops[i]); + // quickReject() will not occure in drawText() so we can use mLocalBounds + // directly, we do not need to account for shadow by calling getLocalBounds() status |= renderer.drawText(op.mText, op.mBytesCount, op.mCount, op.mX, op.mY, op.mPositions, op.getPaint(renderer), op.mTotalAdvance, op.mLocalBounds, drawOpMode); diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index ba4c2a0..90dcf93 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -464,10 +464,12 @@ void DisplayListRenderer::setupColorFilter(SkiaColorFilter* filter) { void DisplayListRenderer::resetShadow() { addStateOp(new (alloc()) ResetShadowOp()); + OpenGLRenderer::resetShadow(); } void DisplayListRenderer::setupShadow(float radius, float dx, float dy, int color) { addStateOp(new (alloc()) SetupShadowOp(radius, dx, dy, color)); + OpenGLRenderer::setupShadow(radius, dx, dy, color); } void DisplayListRenderer::resetPaintFilter() { @@ -503,11 +505,17 @@ void DisplayListRenderer::addStateOp(StateOp* op) { void DisplayListRenderer::addDrawOp(DrawOp* op) { Rect localBounds; + if (mDrawModifiers.mHasShadow) { + op->state.mDrawModifiers = mDrawModifiers; + } if (op->getLocalBounds(localBounds)) { bool rejected = quickRejectNoScissor(localBounds.left, localBounds.top, localBounds.right, localBounds.bottom); op->setQuickRejected(rejected); } + if (mDrawModifiers.mHasShadow) { + op->state.mDrawModifiers.reset(); + } mHasDrawOps = true; addOpInternal(op); } diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index 1c3bfdc..54f6d76 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -52,6 +52,14 @@ namespace android { namespace uirenderer { struct DrawModifiers { + DrawModifiers() { + reset(); + } + + void reset() { + memset(this, 0, sizeof(DrawModifiers)); + } + SkiaShader* mShader; SkiaColorFilter* mColorFilter; float mOverrideLayerAlpha; |