diff options
author | Chris Craik <ccraik@google.com> | 2014-08-19 22:36:32 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-19 02:43:23 +0000 |
commit | 83f75c88a0f0dce2e7d92348d5a498caf32cbdbd (patch) | |
tree | fceb673a1a8743c7fec278dc953301cb18ed0a7c /libs | |
parent | 1553a528a5e2a2eeb94318601943fad2d9484bb3 (diff) | |
parent | 947eabf42d835d0dfb0daa2fe6d869139c7000d6 (diff) | |
download | frameworks_base-83f75c88a0f0dce2e7d92348d5a498caf32cbdbd.zip frameworks_base-83f75c88a0f0dce2e7d92348d5a498caf32cbdbd.tar.gz frameworks_base-83f75c88a0f0dce2e7d92348d5a498caf32cbdbd.tar.bz2 |
Merge "Early reject drawText calls that will not draw" into lmp-dev
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/DisplayListOp.h | 6 | ||||
-rw-r--r-- | libs/hwui/DisplayListRenderer.cpp | 2 | ||||
-rwxr-xr-x | libs/hwui/OpenGLRenderer.cpp | 26 | ||||
-rw-r--r-- | libs/hwui/Renderer.h | 12 |
4 files changed, 32 insertions, 14 deletions
diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h index 1032a75..5f533a7 100644 --- a/libs/hwui/DisplayListOp.h +++ b/libs/hwui/DisplayListOp.h @@ -1001,6 +1001,8 @@ class DrawStrokableOp : public DrawBoundedOp { public: DrawStrokableOp(float left, float top, float right, float bottom, const SkPaint* paint) : DrawBoundedOp(left, top, right, bottom, paint) {}; + DrawStrokableOp(const Rect& localBounds, const SkPaint* paint) + : DrawBoundedOp(localBounds, paint) {}; virtual bool getLocalBounds(Rect& localBounds) { localBounds.set(mLocalBounds); @@ -1339,11 +1341,11 @@ private: const float* mPositions; }; -class DrawTextOp : public DrawBoundedOp { +class DrawTextOp : public DrawStrokableOp { public: DrawTextOp(const char* text, int bytesCount, int count, float x, float y, const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds) - : DrawBoundedOp(bounds, paint), mText(text), mBytesCount(bytesCount), mCount(count), + : DrawStrokableOp(bounds, paint), mText(text), mBytesCount(bytesCount), mCount(count), mX(x), mY(y), mPositions(positions), mTotalAdvance(totalAdvance) { mPrecacheTransform = SkMatrix::InvalidMatrix(); } diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index 94162fc..9a9c544 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -376,7 +376,7 @@ status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int cou float x, float y, const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds, DrawOpMode drawOpMode) { - if (!text || count <= 0) return DrawGlInfo::kStatusDone; + if (!text || count <= 0 || paintWillNotDrawText(*paint)) return DrawGlInfo::kStatusDone; text = refText(text, bytesCount); positions = refBuffer<float>(positions, count * 2); diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 721ab3d..bbf0551 100755 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -2518,8 +2518,9 @@ status_t OpenGLRenderer::drawShape(float left, float top, const PathTexture* tex status_t OpenGLRenderer::drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, const SkPaint* p) { - if (currentSnapshot()->isIgnored() || quickRejectSetupScissor(left, top, right, bottom, p) || - (p->getAlpha() == 0 && getXfermode(p->getXfermode()) != SkXfermode::kClear_Mode)) { + if (currentSnapshot()->isIgnored() + || quickRejectSetupScissor(left, top, right, bottom, p) + || paintWillNotDraw(*p)) { return DrawGlInfo::kStatusDone; } @@ -2536,9 +2537,9 @@ status_t OpenGLRenderer::drawRoundRect(float left, float top, float right, float } status_t OpenGLRenderer::drawCircle(float x, float y, float radius, const SkPaint* p) { - if (currentSnapshot()->isIgnored() || quickRejectSetupScissor(x - radius, y - radius, - x + radius, y + radius, p) || - (p->getAlpha() == 0 && getXfermode(p->getXfermode()) != SkXfermode::kClear_Mode)) { + if (currentSnapshot()->isIgnored() + || quickRejectSetupScissor(x - radius, y - radius, x + radius, y + radius, p) + || paintWillNotDraw(*p)) { return DrawGlInfo::kStatusDone; } if (p->getPathEffect() != 0) { @@ -2558,8 +2559,9 @@ status_t OpenGLRenderer::drawCircle(float x, float y, float radius, const SkPain status_t OpenGLRenderer::drawOval(float left, float top, float right, float bottom, const SkPaint* p) { - if (currentSnapshot()->isIgnored() || quickRejectSetupScissor(left, top, right, bottom, p) || - (p->getAlpha() == 0 && getXfermode(p->getXfermode()) != SkXfermode::kClear_Mode)) { + if (currentSnapshot()->isIgnored() + || quickRejectSetupScissor(left, top, right, bottom, p) + || paintWillNotDraw(*p)) { return DrawGlInfo::kStatusDone; } @@ -2580,8 +2582,9 @@ status_t OpenGLRenderer::drawOval(float left, float top, float right, float bott status_t OpenGLRenderer::drawArc(float left, float top, float right, float bottom, float startAngle, float sweepAngle, bool useCenter, const SkPaint* p) { - if (currentSnapshot()->isIgnored() || quickRejectSetupScissor(left, top, right, bottom, p) || - (p->getAlpha() == 0 && getXfermode(p->getXfermode()) != SkXfermode::kClear_Mode)) { + if (currentSnapshot()->isIgnored() + || quickRejectSetupScissor(left, top, right, bottom, p) + || paintWillNotDraw(*p)) { return DrawGlInfo::kStatusDone; } @@ -2614,8 +2617,9 @@ status_t OpenGLRenderer::drawArc(float left, float top, float right, float botto status_t OpenGLRenderer::drawRect(float left, float top, float right, float bottom, const SkPaint* p) { - if (currentSnapshot()->isIgnored() || quickRejectSetupScissor(left, top, right, bottom, p) || - (p->getAlpha() == 0 && getXfermode(p->getXfermode()) != SkXfermode::kClear_Mode)) { + if (currentSnapshot()->isIgnored() + || quickRejectSetupScissor(left, top, right, bottom, p) + || paintWillNotDraw(*p)) { return DrawGlInfo::kStatusDone; } diff --git a/libs/hwui/Renderer.h b/libs/hwui/Renderer.h index f5cd266..6d4bb4a 100644 --- a/libs/hwui/Renderer.h +++ b/libs/hwui/Renderer.h @@ -67,6 +67,18 @@ public: return resultMode; } + // TODO: move to a method on android:Paint + static inline bool paintWillNotDraw(const SkPaint& paint) { + return paint.getAlpha() == 0 + && getXfermode(paint.getXfermode()) != SkXfermode::kClear_Mode; + } + + // TODO: move to a method on android:Paint + static inline bool paintWillNotDrawText(const SkPaint& paint) { + return paint.getAlpha() == 0 + && paint.getLooper() == NULL + && getXfermode(paint.getXfermode()) == SkXfermode::kSrcOver_Mode; + } // ---------------------------------------------------------------------------- // Frame state operations // ---------------------------------------------------------------------------- |