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

Commit de973073 authored by Matt Sarett's avatar Matt Sarett
Browse files

Make FrameInfoVisualizer use an IRenderPipeline to draw

Removing the direct uses of the BakedOpRenderer should make
it easier for the SkiaGL pipeline to take advantage of these
debugging features.

Test: Verified that debug.hwui.show_dirty_regions and
debug.hwui.profile still behave as expected.

BUG:32370375

Change-Id: I2818bda4a18ec183c9c39ca080ad34a4dc89b5cd
parent d80812b8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ hwui_src_files := \
    PathParser.cpp \
    PathTessellator.cpp \
    PixelBuffer.cpp \
    ProfileRenderer.cpp \
    Program.cpp \
    ProgramCache.cpp \
    Properties.cpp \
+13 −12
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include "FrameInfoVisualizer.h"

#include "BakedOpRenderer.h"
#include "IProfileRenderer.h"
#include "utils/Color.h"

#include <cutils/compiler.h>
@@ -88,7 +89,7 @@ void FrameInfoVisualizer::unionDirty(SkRect* dirty) {
    }
}

void FrameInfoVisualizer::draw(ContentRenderer* renderer) {
void FrameInfoVisualizer::draw(IProfileRenderer& renderer) {
    RETURN_IF_DISABLED();

    if (mShowDirtyRegions) {
@@ -96,8 +97,8 @@ void FrameInfoVisualizer::draw(ContentRenderer* renderer) {
        if (mFlashToggle) {
            SkPaint paint;
            paint.setColor(0x7fff0000);
            renderer->drawRect(mDirtyRegion.fLeft, mDirtyRegion.fTop,
                    mDirtyRegion.fRight, mDirtyRegion.fBottom, &paint);
            renderer.drawRect(mDirtyRegion.fLeft, mDirtyRegion.fTop,
                    mDirtyRegion.fRight, mDirtyRegion.fBottom, paint);
        }
    }

@@ -111,7 +112,7 @@ void FrameInfoVisualizer::draw(ContentRenderer* renderer) {
        info.markSwapBuffers();
        info.markFrameCompleted();

        initializeRects(renderer->getViewportHeight(), renderer->getViewportWidth());
        initializeRects(renderer.getViewportHeight(), renderer.getViewportWidth());
        drawGraph(renderer);
        drawThreshold(renderer);
    }
@@ -194,26 +195,26 @@ void FrameInfoVisualizer::nextBarSegment(FrameInfoIndex start, FrameInfoIndex en
    }
}

void FrameInfoVisualizer::drawGraph(ContentRenderer* renderer) {
void FrameInfoVisualizer::drawGraph(IProfileRenderer& renderer) {
    SkPaint paint;
    for (size_t i = 0; i < Bar.size(); i++) {
        nextBarSegment(Bar[i].start, Bar[i].end);
        paint.setColor(Bar[i].color & BAR_FAST_MASK);
        renderer->drawRects(mFastRects.get(), mNumFastRects * 4, &paint);
        renderer.drawRects(mFastRects.get(), mNumFastRects * 4, paint);
        paint.setColor(Bar[i].color & BAR_JANKY_MASK);
        renderer->drawRects(mJankyRects.get(), mNumJankyRects * 4, &paint);
        renderer.drawRects(mJankyRects.get(), mNumJankyRects * 4, paint);
    }
}

void FrameInfoVisualizer::drawThreshold(ContentRenderer* renderer) {
void FrameInfoVisualizer::drawThreshold(IProfileRenderer& renderer) {
    SkPaint paint;
    paint.setColor(THRESHOLD_COLOR);
    float yLocation = renderer->getViewportHeight() - (FRAME_THRESHOLD * mVerticalUnit);
    renderer->drawRect(0.0f,
    float yLocation = renderer.getViewportHeight() - (FRAME_THRESHOLD * mVerticalUnit);
    renderer.drawRect(0.0f,
            yLocation - mThresholdStroke/2,
            renderer->getViewportWidth(),
            renderer.getViewportWidth(),
            yLocation + mThresholdStroke/2,
            &paint);
            paint);
}

bool FrameInfoVisualizer::consumeProperties() {
+4 −5
Original line number Diff line number Diff line
@@ -28,8 +28,7 @@
namespace android {
namespace uirenderer {

class BakedOpRenderer;
typedef BakedOpRenderer ContentRenderer;
class IProfileRenderer;

// TODO: This is a bit awkward as it needs to match the thing in CanvasContext
// A better abstraction here would be nice but iterators are painful
@@ -47,7 +46,7 @@ public:
    void setDensity(float density);

    void unionDirty(SkRect* dirty);
    void draw(ContentRenderer* renderer);
    void draw(IProfileRenderer& renderer);

    void dumpData(int fd);

@@ -57,8 +56,8 @@ private:

    void initializeRects(const int baseline, const int width);
    void nextBarSegment(FrameInfoIndex start, FrameInfoIndex end);
    void drawGraph(ContentRenderer* renderer);
    void drawThreshold(ContentRenderer* renderer);
    void drawGraph(IProfileRenderer& renderer);
    void drawThreshold(IProfileRenderer& renderer);

    inline float durationMS(size_t index, FrameInfoIndex start, FrameInfoIndex end) {
        float duration = mFrameSource[index].duration(start, end) * 0.000001f;
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "SkPaint.h"

namespace android {
namespace uirenderer {

class IProfileRenderer {
public:
    virtual void drawRect(float left, float top, float right, float bottom,
            const SkPaint& paint) = 0;
    virtual void drawRects(const float* rects, int count, const SkPaint& paint) = 0;
    virtual uint32_t getViewportWidth() = 0;
    virtual uint32_t getViewportHeight() = 0;

    virtual ~IProfileRenderer() {}
};

} /* namespace uirenderer */
} /* namespace android */
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "ProfileRenderer.h"

namespace android {
namespace uirenderer {

void ProfileRenderer::drawRect(float left, float top, float right, float bottom,
        const SkPaint& paint) {
    mRenderer.drawRect(left, top, right, bottom, &paint);
}

void ProfileRenderer::drawRects(const float* rects, int count, const SkPaint& paint) {
    mRenderer.drawRects(rects, count, &paint);
}

uint32_t ProfileRenderer::getViewportWidth() {
    return mRenderer.getViewportWidth();
}

uint32_t ProfileRenderer::getViewportHeight() {
    return mRenderer.getViewportHeight();
}

} /* namespace uirenderer */
} /* namespace android */
Loading