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
This commit is contained in:
Matt Sarett
2016-10-25 11:07:40 -04:00
parent d80812b882
commit de97307362
7 changed files with 137 additions and 18 deletions

View File

@@ -80,6 +80,7 @@ hwui_src_files := \
PathParser.cpp \
PathTessellator.cpp \
PixelBuffer.cpp \
ProfileRenderer.cpp \
Program.cpp \
ProgramCache.cpp \
Properties.cpp \

View File

@@ -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() {

View File

@@ -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;

View File

@@ -0,0 +1,34 @@
/*
* 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 */

View File

@@ -0,0 +1,40 @@
/*
* 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 */

View File

@@ -0,0 +1,42 @@
/*
* 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 "IProfileRenderer.h"
#include "BakedOpRenderer.h"
namespace android {
namespace uirenderer {
class ProfileRenderer : public IProfileRenderer {
public:
ProfileRenderer(BakedOpRenderer& renderer)
: mRenderer(renderer) {
}
void drawRect(float left, float top, float right, float bottom, const SkPaint& paint) override;
void drawRects(const float* rects, int count, const SkPaint& paint) override;
uint32_t getViewportWidth() override;
uint32_t getViewportHeight() override;
virtual ~ProfileRenderer() {}
private:
BakedOpRenderer& mRenderer;
};
} /* namespace uirenderer */
} /* namespace android */

View File

@@ -18,6 +18,7 @@
#include "DeferredLayerUpdater.h"
#include "EglManager.h"
#include "ProfileRenderer.h"
#include "renderstate/RenderState.h"
#include "Readback.h"
@@ -76,7 +77,8 @@ bool OpenGLPipeline::draw(const Frame& frame, const SkRect& screenDirty, const S
BakedOpRenderer renderer(caches, mRenderThread.renderState(),
opaque, lightInfo);
frameBuilder.replayBakedOps<BakedOpDispatcher>(renderer);
profiler->draw(&renderer);
ProfileRenderer profileRenderer(renderer);
profiler->draw(profileRenderer);
drew = renderer.didDraw();
// post frame cleanup