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

Commit c93c6aa5 authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "Object-based DisplayList recording"

parents cae3d9f0 2af4635e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1868,7 +1868,7 @@ public abstract class HardwareRenderer {
                mDebugDataProvider.setupGraphPaint(mProfilePaint, i);
                switch (graphType) {
                    case GraphDataProvider.GRAPH_TYPE_BARS:
                        mGlCanvas.drawRects(mProfileShapes[i], count, mProfilePaint);
                        mGlCanvas.drawRects(mProfileShapes[i], count * 4, mProfilePaint);
                        break;
                    case GraphDataProvider.GRAPH_TYPE_LINES:
                        mGlCanvas.drawLines(mProfileShapes[i], 0, count * 4, mProfilePaint);
+1 −1
Original line number Diff line number Diff line
@@ -479,7 +479,7 @@ static void android_view_GLES20Canvas_drawRegionAsRects(JNIEnv* env, jobject cla
            rects.push(r.fTop);
            rects.push(r.fRight);
            rects.push(r.fBottom);
            count++;
            count += 4;
            it.next();
        }
        renderer->drawRects(rects.array(), count, paint);
+13 −26
Original line number Diff line number Diff line
@@ -18,9 +18,8 @@

// BUFFER_SIZE size must be one more than a multiple of COMMAND_SIZE to ensure
// that mStart always points at the next command, not just the next item
#define COMMAND_SIZE 2
#define NUM_COMMANDS 50
#define BUFFER_SIZE ((NUM_COMMANDS * COMMAND_SIZE) + 1)
#define BUFFER_SIZE ((NUM_COMMANDS) + 1)

/**
 * DisplayListLogBuffer is a utility class which logs the most recent display
@@ -57,7 +56,7 @@ namespace uirenderer {


DisplayListLogBuffer::DisplayListLogBuffer() {
    mBufferFirst = (int*) malloc(BUFFER_SIZE * sizeof(int));
    mBufferFirst = (OpLog*) malloc(BUFFER_SIZE * sizeof(OpLog));
    mStart = mBufferFirst;
    mBufferLast = mBufferFirst + BUFFER_SIZE - 1;
    mEnd = mStart;
@@ -71,42 +70,30 @@ DisplayListLogBuffer::~DisplayListLogBuffer() {
 * Called from DisplayListRenderer to output the current buffer into the
 * specified FILE. This only happens in a dumpsys/bugreport operation.
 */
void DisplayListLogBuffer::outputCommands(FILE *file, const char* opNames[])
void DisplayListLogBuffer::outputCommands(FILE *file)
{
    int *tmpBufferPtr = mStart;
    OpLog* tmpBufferPtr = mStart;
    while (true) {
        if (tmpBufferPtr == mEnd) {
            break;
        }
        int level = *tmpBufferPtr++;
        OpLog* nextOp = tmpBufferPtr++;
        if (tmpBufferPtr > mBufferLast) {
            tmpBufferPtr = mBufferFirst;
        }
        int op = *tmpBufferPtr++;
        if (tmpBufferPtr > mBufferLast) {
            tmpBufferPtr = mBufferFirst;
        }
        uint32_t count = (level + 1) * 2;
        char indent[count + 1];
        for (uint32_t i = 0; i < count; i++) {
            indent[i] = ' ';
        }
        indent[count] = '\0';
        fprintf(file, "%s%s\n", indent, opNames[op]);
    }
}

void DisplayListLogBuffer::writeCommand(int level, int op) {
    writeInt(level);
    writeInt(op);
        fprintf(file, "%*s%s\n", tmpBufferPtr->level*2, "", tmpBufferPtr->label);
    }
}

/**
 * Store the given value in the buffer and increment/wrap the mEnd
 * and mStart values as appropriate.
 * Store the given level and label in the buffer and increment/wrap the mEnd
 * and mStart values as appropriate. Label should point to static memory.
 */
void DisplayListLogBuffer::writeInt(int value) {
    *((int*)mEnd) = value;
void DisplayListLogBuffer::writeCommand(int level, const char* label) {
    mEnd->level = level;
    mEnd->label = label;

    if (mEnd == mBufferLast) {
        mEnd = mBufferFirst;
    } else {
+11 −7
Original line number Diff line number Diff line
@@ -31,19 +31,23 @@ class DisplayListLogBuffer: public Singleton<DisplayListLogBuffer> {
    friend class Singleton<DisplayListLogBuffer>;

public:
    void writeCommand(int level, int op);
    void writeInt(int value);
    void outputCommands(FILE *file, const char* opNames[]);
    void writeCommand(int level, const char* label);
    void outputCommands(FILE *file);

    bool isEmpty() {
        return (mStart == mEnd);
    }

    struct OpLog {
        int level;
        const char* label;
    };

private:
    int *mBufferFirst; // where the memory starts
    int* mStart;       // where the current command stream starts
    int* mEnd;         // where the current commands end
    int* mBufferLast;  // where the buffer memory ends
    OpLog* mBufferFirst; // where the memory starts
    OpLog* mStart;       // where the current command stream starts
    OpLog* mEnd;         // where the current commands end
    OpLog* mBufferLast;  // where the buffer memory ends

};

+1138 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading