573ae01295
Duplicate code from the HWUI backends for DM and nanobench moves into a single place, saving a hundred lines or more of cut-and-paste. There's some indication that this increases the incidence of SkCanvas "Unable to find device for layer." warnings, but no clear degradation in test results. R=djsollen@google.com,mtklein@google.com BUG=skia:3589 Review URL: https://codereview.chromium.org/1036303002
59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
/*
|
|
* Copyright 2015 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "nanobenchAndroid.h"
|
|
|
|
#include "AnimationContext.h"
|
|
#include "IContextFactory.h"
|
|
#include "SkiaCanvasProxy.h"
|
|
#include "android/rect.h"
|
|
#include "android/native_window.h"
|
|
#include "renderthread/TimeLord.h"
|
|
|
|
/* These functions are only compiled in the Android Framework. */
|
|
|
|
HWUITarget::HWUITarget(const Config& c, Benchmark* bench) : Target(c) { }
|
|
|
|
void HWUITarget::setup() {
|
|
this->renderer.proxy->fence();
|
|
}
|
|
|
|
SkCanvas* HWUITarget::beginTiming(SkCanvas* canvas) {
|
|
SkCanvas* targetCanvas = this->renderer.prepareToDraw();
|
|
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.finishDrawing();
|
|
}
|
|
|
|
void HWUITarget::fence() {
|
|
this->renderer.proxy->fence();
|
|
}
|
|
|
|
bool HWUITarget::needsFrameTiming() const {
|
|
return true;
|
|
}
|
|
|
|
bool HWUITarget::init(SkImageInfo info, Benchmark* bench) {
|
|
this->renderer.initialize({bench->getSize().x(), bench->getSize().y()});
|
|
return true;
|
|
}
|
|
|
|
bool HWUITarget::capturePixels(SkBitmap* bmp) {
|
|
return this->renderer.capturePixels(bmp);
|
|
}
|
|
|
|
|