| Index: src/utils/android/SkHwuiRenderer.cpp
|
| diff --git a/bench/nanobenchAndroid.cpp b/src/utils/android/SkHwuiRenderer.cpp
|
| similarity index 80%
|
| copy from bench/nanobenchAndroid.cpp
|
| copy to src/utils/android/SkHwuiRenderer.cpp
|
| index 8bda1c8625b50fee38cb7e70f5ea28502c4f9cb6..aac9180df0f92a156459157d5ecf55bd1e86c009 100644
|
| --- a/bench/nanobenchAndroid.cpp
|
| +++ b/src/utils/android/SkHwuiRenderer.cpp
|
| @@ -5,14 +5,12 @@
|
| * found in the LICENSE file.
|
| */
|
|
|
| -#include "nanobenchAndroid.h"
|
| +#include "SkHwuiRenderer.h"
|
|
|
| #include "AnimationContext.h"
|
| #include "IContextFactory.h"
|
| -#include "SkiaCanvasProxy.h"
|
| -#include "android/rect.h"
|
| -#include "android/native_window.h"
|
| -#include "renderthread/TimeLord.h"
|
| +#include "SkBitmap.h"
|
| +#include "gui/BufferQueue.h"
|
|
|
| namespace {
|
|
|
| @@ -29,45 +27,8 @@ public:
|
|
|
| }
|
|
|
| -HWUITarget::HWUITarget(const Config& c, Benchmark* bench) : Target(c) { }
|
| -
|
| -void HWUITarget::setup() {
|
| - this->proxy->fence();
|
| -}
|
| -
|
| -SkCanvas* HWUITarget::beginTiming(SkCanvas* canvas) {
|
| - this->renderer->prepare();
|
| - this->renderer->clipRect(0, 0, this->size.width(), this->size.height(),
|
| - SkRegion::Op::kReplace_Op);
|
| - SkCanvas* targetCanvas = this->renderer->asSkCanvas();
|
| - if (targetCanvas) {
|
| - this->fc.reset(targetCanvas);
|
| - canvas = &this->fc;
|
| - // This might minimally distort timing, but canvas isn't valid outside the timer.
|
| - canvas->clear(SK_ColorWHITE);
|
| - }
|
| - return canvas;
|
| -}
|
| -
|
| -void HWUITarget::endTiming() {
|
| - this->renderer->finish();
|
| - this->rootNode->setStagingDisplayList(this->renderer->finishRecording());
|
| - this->proxy->syncAndDrawFrame();
|
| - // Surprisingly, calling this->proxy->fence() here appears to make no difference to
|
| - // the timings we record.
|
| -}
|
| -
|
| -void HWUITarget::fence() {
|
| - this->proxy->fence();
|
| -}
|
| -
|
| -bool HWUITarget::needsFrameTiming() const {
|
| - return true;
|
| -}
|
| -
|
| -bool HWUITarget::init(SkImageInfo info, Benchmark* bench) {
|
| - // extracted from DMSrcSinkAndroid.cpp's HWUISink::draw()
|
| - size.set(bench->getSize().x(), bench->getSize().y());
|
| +void SkHwuiRenderer::initialize(SkISize size) {
|
| + this->size = size;
|
| android::BufferQueue::createBufferQueue(&this->producer, &this->consumer);
|
| this->cpuConsumer = new android::CpuConsumer(this->consumer, 1);
|
| this->cpuConsumer->setName(android::String8("SkiaBenchmarkClient"));
|
| @@ -97,14 +58,24 @@ bool HWUITarget::init(SkImageInfo info, Benchmark* bench) {
|
| 255 * 0.075f, 255 * 0.15f);
|
| this->renderer.reset(new android::uirenderer::DisplayListRenderer());
|
| this->renderer->setViewport(size.width(), size.height());
|
| +}
|
|
|
| - // Since we have no SkSurface for HWUI, other parts of the code base have to
|
| - // explicitly work around the fact that it may be invalid / have no SkCanvas.
|
| +SkCanvas* SkHwuiRenderer::prepareToDraw() {
|
| + this->renderer->prepare();
|
| + this->renderer->clipRect(0, 0, this->size.width(), this->size.height(),
|
| + SkRegion::Op::kReplace_Op);
|
| + return this->renderer->asSkCanvas();
|
| +}
|
|
|
| - return true;
|
| +void SkHwuiRenderer::finishDrawing() {
|
| + this->renderer->finish();
|
| + this->rootNode->setStagingDisplayList(this->renderer->finishRecording());
|
| + this->proxy->syncAndDrawFrame();
|
| + // Surprisingly, calling this->proxy->fence() here appears to make no difference to
|
| + // the timings we record.
|
| }
|
|
|
| -bool HWUITarget::capturePixels(SkBitmap* bmp) {
|
| +bool SkHwuiRenderer::capturePixels(SkBitmap* bmp) {
|
| SkImageInfo destinationConfig =
|
| SkImageInfo::Make(this->size.width(), this->size.height(),
|
| kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
| @@ -157,4 +128,3 @@ bool HWUITarget::capturePixels(SkBitmap* bmp) {
|
| return true;
|
| }
|
|
|
| -
|
|
|