Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f5690bb authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Add debug logs for display lists." into honeycomb

parents bfbb089c ffac7fc5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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
+50 −4
Original line number Diff line number Diff line
@@ -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);
}
+15 −4
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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);
Loading