diff options
author | Romain Guy <romainguy@google.com> | 2013-01-04 19:23:42 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-01-04 19:24:10 -0800 |
commit | 9acd1b4fa897f3a007dd23dc1f0471b151fa03ad (patch) | |
tree | 4d27cd6bd64e25dede0a2db629a0cdef30cebb15 /libs | |
parent | 6c3c8a3c9a9176aaa68f1061a2e18a6b2fba0f74 (diff) | |
parent | 672433d90fab7383cd28beac9d4485b566a90940 (diff) | |
download | frameworks_base-9acd1b4fa897f3a007dd23dc1f0471b151fa03ad.zip frameworks_base-9acd1b4fa897f3a007dd23dc1f0471b151fa03ad.tar.gz frameworks_base-9acd1b4fa897f3a007dd23dc1f0471b151fa03ad.tar.bz2 |
Merge "Add visual profiling feature"
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/DisplayListRenderer.cpp | 25 | ||||
-rw-r--r-- | libs/hwui/DisplayListRenderer.h | 2 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 73 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.h | 5 |
4 files changed, 104 insertions, 1 deletions
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index 7a38b40..747856c 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -64,6 +64,7 @@ const char* DisplayList::OP_NAMES[] = { "DrawTextOnPath", "DrawPosText", "DrawText", + "DrawRects", "ResetShader", "SetupShader", "ResetColorFilter", @@ -633,6 +634,13 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) { text.text(), text.length(), count, paint); } break; + case DrawRects: { + int32_t count = 0; + float* rects = getFloats(count); + SkPaint* paint = getPaint(renderer); + ALOGD("%s%s %d, %p", (char*) indent, OP_NAMES[op], count / 4, paint); + } + break; case ResetShader: { ALOGD("%s%s", (char*) indent, OP_NAMES[op]); } @@ -1277,6 +1285,14 @@ status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flag x, y, positions, paint, length); } break; + case DrawRects: { + int32_t count = 0; + float* rects = getFloats(count); + SkPaint* paint = getPaint(renderer); + DISPLAY_LIST_LOGD("%s%s %d, %p", (char*) indent, OP_NAMES[op], count, paint); + drawGlStatus |= renderer.drawRects(rects, count / 4, paint); + } + break; case ResetShader: { DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]); renderer.resetShader(); @@ -1814,6 +1830,15 @@ status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int cou return DrawGlInfo::kStatusDone; } +status_t DisplayListRenderer::drawRects(const float* rects, int count, SkPaint* paint) { + if (count <= 0) return DrawGlInfo::kStatusDone; + + addOp(DisplayList::DrawRects); + addFloats(rects, count * 4); + addPaint(paint); + return DrawGlInfo::kStatusDone; +} + void DisplayListRenderer::resetShader() { addOp(DisplayList::ResetShader); } diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index e42def5..fb01753 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -106,6 +106,7 @@ public: DrawTextOnPath, DrawPosText, DrawText, + DrawRects, ResetShader, SetupShader, ResetColorFilter, @@ -608,6 +609,7 @@ public: const float* positions, SkPaint* paint); virtual status_t drawText(const char* text, int bytesCount, int count, float x, float y, const float* positions, SkPaint* paint, float length); + virtual status_t drawRects(const float* rects, int count, SkPaint* paint); virtual void resetShader(); virtual void setupShader(SkiaShader* shader); diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 094e9ab..8756805 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -1254,7 +1254,8 @@ bool OpenGLRenderer::quickRejectNoScissor(float left, float top, float right, fl return !clip.intersects(transformed); } -bool OpenGLRenderer::quickRejectPreStroke(float left, float top, float right, float bottom, SkPaint* paint) { +bool OpenGLRenderer::quickRejectPreStroke(float left, float top, float right, float bottom, + SkPaint* paint) { if (paint->getStyle() != SkPaint::kFill_Style) { float outset = paint->getStrokeWidth() * 0.5f; return quickReject(left - outset, top - outset, right + outset, bottom + outset); @@ -3045,6 +3046,76 @@ void OpenGLRenderer::drawTextDecorations(const char* text, int bytesCount, float } } +status_t OpenGLRenderer::drawRects(const float* rects, int count, SkPaint* paint) { + if (mSnapshot->isIgnored()) { + return DrawGlInfo::kStatusDone; + } + + float left = FLT_MAX; + float top = FLT_MAX; + float right = FLT_MIN; + float bottom = FLT_MIN; + + int vertexCount = 0; + Vertex mesh[count * 6]; + Vertex* vertex = mesh; + + for (int i = 0; i < count; i++) { + int index = i * 4; + float l = rects[index + 0]; + float t = rects[index + 1]; + float r = rects[index + 2]; + float b = rects[index + 3]; + + if (!quickRejectNoScissor(left, top, right, bottom)) { + Vertex::set(vertex++, l, b); + Vertex::set(vertex++, l, t); + Vertex::set(vertex++, r, t); + Vertex::set(vertex++, l, b); + Vertex::set(vertex++, r, t); + Vertex::set(vertex++, r, b); + + vertexCount += 6; + + left = fminf(left, l); + top = fminf(top, t); + right = fmaxf(right, r); + bottom = fmaxf(bottom, b); + } + } + + if (count == 0) return DrawGlInfo::kStatusDone; + + int color = paint->getColor(); + // If a shader is set, preserve only the alpha + if (mShader) { + color |= 0x00ffffff; + } + SkXfermode::Mode mode = getXfermode(paint->getXfermode()); + + setupDraw(); + setupDrawNoTexture(); + setupDrawColor(color, ((color >> 24) & 0xFF) * mSnapshot->alpha); + setupDrawShader(); + setupDrawColorFilter(); + setupDrawBlending(mode); + setupDrawProgram(); + setupDrawDirtyRegionsDisabled(); + setupDrawModelView(0.0f, 0.0f, 1.0f, 1.0f); + setupDrawColorUniforms(); + setupDrawShaderUniforms(); + setupDrawColorFilterUniforms(); + setupDrawVertices((GLvoid*) &mesh[0].position[0]); + + if (hasLayer()) { + dirtyLayer(left, top, right, bottom, *mSnapshot->transform); + } + + glDrawArrays(GL_TRIANGLES, 0, vertexCount); + + return DrawGlInfo::kStatusDrew; +} + void OpenGLRenderer::drawColorRect(float left, float top, float right, float bottom, int color, SkXfermode::Mode mode, bool ignoreTransform) { // If a shader is set, preserve only the alpha diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index 3cafed3..5520edb 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -201,6 +201,7 @@ public: const float* positions, SkPaint* paint); virtual status_t drawText(const char* text, int bytesCount, int count, float x, float y, const float* positions, SkPaint* paint, float length = -1.0f); + virtual status_t drawRects(const float* rects, int count, SkPaint* paint); virtual void resetShader(); virtual void setupShader(SkiaShader* shader); @@ -216,6 +217,10 @@ public: SkPaint* filterPaint(SkPaint* paint); + ANDROID_API bool isCurrentTransformSimple() { + return mSnapshot->transform->isSimple(); + } + /** * Sets the alpha on the current snapshot. This alpha value will be modulated * with other alpha values when drawing primitives. |