diff options
author | Romain Guy <romainguy@google.com> | 2011-01-13 17:21:49 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2011-01-13 17:22:58 -0800 |
commit | ffac7fc5042296a459d0f5a450dbfe20917093dc (patch) | |
tree | 27a86c15331cd38d7d072e1c2b7bf8829cceeb90 | |
parent | 462433ae94ff33f9591d910b662e63b821549cad (diff) | |
download | frameworks_base-ffac7fc5042296a459d0f5a450dbfe20917093dc.zip frameworks_base-ffac7fc5042296a459d0f5a450dbfe20917093dc.tar.gz frameworks_base-ffac7fc5042296a459d0f5a450dbfe20917093dc.tar.bz2 |
Add debug logs for display lists.
Change-Id: I7bae8fd96e9eccb51f29f73e4069b4d3e6bdbdd7
-rw-r--r-- | libs/hwui/Debug.h | 3 | ||||
-rw-r--r-- | libs/hwui/DisplayListRenderer.cpp | 54 | ||||
-rw-r--r-- | libs/hwui/DisplayListRenderer.h | 19 | ||||
-rw-r--r-- | libs/hwui/OpenGLDebugRenderer.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/OpenGLDebugRenderer.h | 2 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 7 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.h | 2 |
7 files changed, 76 insertions, 13 deletions
diff --git a/libs/hwui/Debug.h b/libs/hwui/Debug.h index a194cbe..bdd8e73 100644 --- a/libs/hwui/Debug.h +++ b/libs/hwui/Debug.h @@ -47,4 +47,7 @@ // Turn on to display debug info about the layer renderer #define DEBUG_LAYER_RENDERER 0 +// Turn on to dump display list state +#define DEBUG_DISPLAY_LIST 0 + #endif // ANDROID_HWUI_DEBUG_H diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index 57df976..75b1671 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -81,6 +81,39 @@ void PathHeap::flatten(SkFlattenableWriteBuffer& buffer) const { // Display list /////////////////////////////////////////////////////////////////////////////// +const char* DisplayList::OP_NAMES[] = { + "AcquireContext", + "ReleaseContext", + "Save", + "Restore", + "RestoreToCount", + "SaveLayer", + "SaveLayerAlpha", + "Translate", + "Rotate", + "Scale", + "SetMatrix", + "ConcatMatrix", + "ClipRect", + "DrawDisplayList", + "DrawLayer", + "DrawBitmap", + "DrawBitmapMatrix", + "DrawBitmapRect", + "DrawPatch", + "DrawColor", + "DrawRect", + "DrawPath", + "DrawLines", + "DrawText", + "ResetShader", + "SetupShader", + "ResetColorFilter", + "SetupColorFilter", + "ResetShadow", + "SetupShadow" +}; + DisplayList::DisplayList(const DisplayListRenderer& recorder) { initFromDisplayListRenderer(recorder); } @@ -173,14 +206,25 @@ void DisplayList::init() { mPathHeap = NULL; } -void DisplayList::replay(OpenGLRenderer& renderer) { +void DisplayList::replay(OpenGLRenderer& renderer, uint32_t level) { TextContainer text; mReader.rewind(); - int saveCount = renderer.getSaveCount() - 1; +#if DEBUG_DISPLAY_LIST + uint32_t count = (level + 1) * 2; + char indent[count + 1]; + for (uint32_t i = 0; i < count; i++) { + indent[i] = ' '; + } + indent[count] = '\0'; + DISPLAY_LIST_LOGD("%sStart display list (%p)", (char*) indent + 2, this); +#endif + int saveCount = renderer.getSaveCount() - 1; while (!mReader.eof()) { int op = mReader.readInt(); + DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]); + switch (op) { case AcquireContext: { renderer.acquireContext(); @@ -238,7 +282,7 @@ void DisplayList::replay(OpenGLRenderer& renderer) { } break; case DrawDisplayList: { - renderer.drawDisplayList(getDisplayList()); + renderer.drawDisplayList(getDisplayList(), level + 1); } break; case DrawLayer: { @@ -326,6 +370,8 @@ void DisplayList::replay(OpenGLRenderer& renderer) { break; } } + + DISPLAY_LIST_LOGD("%sDone", (char*) indent + 2); } /////////////////////////////////////////////////////////////////////////////// @@ -482,7 +528,7 @@ bool DisplayListRenderer::clipRect(float left, float top, float right, float bot return OpenGLRenderer::clipRect(left, top, right, bottom, op); } -void DisplayListRenderer::drawDisplayList(DisplayList* displayList) { +void DisplayListRenderer::drawDisplayList(DisplayList* displayList, uint32_t level) { addOp(DisplayList::DrawDisplayList); addDisplayList(displayList); } diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index 0822725..cc52309 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -39,6 +39,13 @@ namespace uirenderer { #define MIN_WRITER_SIZE 16384 #define HEAP_BLOCK_SIZE 4096 +// Debug +#if DEBUG_DISPLAY_LIST + #define DISPLAY_LIST_LOGD(...) LOGD(__VA_ARGS__) +#else + #define DISPLAY_LIST_LOGD(...) +#endif + /////////////////////////////////////////////////////////////////////////////// // Helpers /////////////////////////////////////////////////////////////////////////////// @@ -78,8 +85,10 @@ public: DisplayList(const DisplayListRenderer& recorder); ~DisplayList(); + // IMPORTANT: Update the intialization of OP_NAMES in the .cpp file + // when modifying this file enum Op { - AcquireContext, + AcquireContext = 0, ReleaseContext, Save, Restore, @@ -108,12 +117,14 @@ public: ResetColorFilter, SetupColorFilter, ResetShadow, - SetupShadow + SetupShadow, }; + static const char* OP_NAMES[]; + void initFromDisplayListRenderer(const DisplayListRenderer& recorder); - void replay(OpenGLRenderer& renderer); + void replay(OpenGLRenderer& renderer, uint32_t level = 0); private: void init(); @@ -245,7 +256,7 @@ public: bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op); - void drawDisplayList(DisplayList* displayList); + void drawDisplayList(DisplayList* displayList, uint32_t level = 0); void drawLayer(Layer* layer, float x, float y, SkPaint* paint); void drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint); void drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint); diff --git a/libs/hwui/OpenGLDebugRenderer.cpp b/libs/hwui/OpenGLDebugRenderer.cpp index f71e5d6..29bcde8 100644 --- a/libs/hwui/OpenGLDebugRenderer.cpp +++ b/libs/hwui/OpenGLDebugRenderer.cpp @@ -48,7 +48,7 @@ int OpenGLDebugRenderer::saveLayer(float left, float top, float right, float bot return OpenGLRenderer::saveLayer(left, top, right, bottom, p, flags); } -void OpenGLDebugRenderer::drawDisplayList(DisplayList* displayList) { +void OpenGLDebugRenderer::drawDisplayList(DisplayList* displayList, uint32_t level) { mPrimitivesCount++; StopWatch w("drawDisplayList"); OpenGLRenderer::drawDisplayList(displayList); diff --git a/libs/hwui/OpenGLDebugRenderer.h b/libs/hwui/OpenGLDebugRenderer.h index 1cef267..aefa7bf 100644 --- a/libs/hwui/OpenGLDebugRenderer.h +++ b/libs/hwui/OpenGLDebugRenderer.h @@ -40,7 +40,7 @@ public: int saveLayer(float left, float top, float right, float bottom, SkPaint* p, int flags); - void drawDisplayList(DisplayList* displayList); + void drawDisplayList(DisplayList* displayList, uint32_t level = 0); void drawLayer(Layer* layer, float x, float y, SkPaint* paint); void drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint); void drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint); diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 7f7deec..758bcdc 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -569,6 +569,9 @@ void OpenGLRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) { composeLayerRect(layer, rect, true); } + drawColorRect(rect.left, rect.top, rect.right, rect.bottom, 0x7fff0000, + SkXfermode::kSrcOver_Mode, true); + if (fboLayer) { // Detach the texture from the FBO glBindFramebuffer(GL_FRAMEBUFFER, current->fbo); @@ -1024,11 +1027,11 @@ void OpenGLRenderer::finishDrawTexture() { // Drawing /////////////////////////////////////////////////////////////////////////////// -void OpenGLRenderer::drawDisplayList(DisplayList* displayList) { +void OpenGLRenderer::drawDisplayList(DisplayList* displayList, uint32_t level) { // All the usual checks and setup operations (quickReject, setupDraw, etc.) // will be performed by the display list itself if (displayList) { - displayList->replay(*this); + displayList->replay(*this, level); } } diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index da27dac..8cec8f1 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -94,7 +94,7 @@ public: bool quickReject(float left, float top, float right, float bottom); virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op); - virtual void drawDisplayList(DisplayList* displayList); + virtual void drawDisplayList(DisplayList* displayList, uint32_t level = 0); virtual void drawLayer(Layer* layer, float x, float y, SkPaint* paint); virtual void drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint); virtual void drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint); |