2015-03-26 18:28:06 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
|
|
|
|
2015-03-27 19:22:01 +00:00
|
|
|
/* These functions are only compiled in the Android Framework. */
|
2015-03-26 18:28:06 +00:00
|
|
|
|
|
|
|
HWUITarget::HWUITarget(const Config& c, Benchmark* bench) : Target(c) { }
|
|
|
|
|
|
|
|
void HWUITarget::setup() {
|
2015-10-26 14:21:31 +00:00
|
|
|
this->renderer.fence();
|
2015-03-26 18:28:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SkCanvas* HWUITarget::beginTiming(SkCanvas* canvas) {
|
2015-03-27 19:22:01 +00:00
|
|
|
SkCanvas* targetCanvas = this->renderer.prepareToDraw();
|
2015-03-26 18:28:06 +00:00
|
|
|
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);
|
2015-03-27 19:22:01 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 18:28:06 +00:00
|
|
|
return canvas;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HWUITarget::endTiming() {
|
2015-03-27 19:22:01 +00:00
|
|
|
this->renderer.finishDrawing();
|
2015-03-26 18:28:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HWUITarget::fence() {
|
2015-10-26 14:21:31 +00:00
|
|
|
this->renderer.fence();
|
2015-03-26 18:28:06 +00:00
|
|
|
}
|
|
|
|
|
2015-06-23 20:23:44 +00:00
|
|
|
bool HWUITarget::needsFrameTiming(int* frameLag) const {
|
|
|
|
extern int FLAGS_gpuFrameLag;
|
|
|
|
*frameLag = FLAGS_gpuFrameLag;
|
2015-03-26 18:28:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HWUITarget::init(SkImageInfo info, Benchmark* bench) {
|
2015-10-26 14:21:31 +00:00
|
|
|
this->renderer.initialize(bench->getSize().x(), bench->getSize().y());
|
2015-03-26 18:28:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HWUITarget::capturePixels(SkBitmap* bmp) {
|
2015-03-27 19:22:01 +00:00
|
|
|
return this->renderer.capturePixels(bmp);
|
2015-03-26 18:28:06 +00:00
|
|
|
}
|