blob: cb6f09d654befd81b50b0937a69ddd1e0780df60 [file] [log] [blame]
tomhudsond968a6f2015-03-26 11:28:06 -07001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "nanobenchAndroid.h"
9
tomhudson573ae012015-03-27 12:22:01 -070010/* These functions are only compiled in the Android Framework. */
tomhudsond968a6f2015-03-26 11:28:06 -070011
12HWUITarget::HWUITarget(const Config& c, Benchmark* bench) : Target(c) { }
13
14void HWUITarget::setup() {
tomhudson3c8ceb72015-10-26 07:21:31 -070015 this->renderer.fence();
tomhudsond968a6f2015-03-26 11:28:06 -070016}
17
18SkCanvas* HWUITarget::beginTiming(SkCanvas* canvas) {
tomhudson573ae012015-03-27 12:22:01 -070019 SkCanvas* targetCanvas = this->renderer.prepareToDraw();
tomhudsond968a6f2015-03-26 11:28:06 -070020 if (targetCanvas) {
21 this->fc.reset(targetCanvas);
22 canvas = &this->fc;
23 // This might minimally distort timing, but canvas isn't valid outside the timer.
24 canvas->clear(SK_ColorWHITE);
tomhudson573ae012015-03-27 12:22:01 -070025 }
26
tomhudsond968a6f2015-03-26 11:28:06 -070027 return canvas;
28}
29
30void HWUITarget::endTiming() {
tomhudson573ae012015-03-27 12:22:01 -070031 this->renderer.finishDrawing();
tomhudsond968a6f2015-03-26 11:28:06 -070032}
33
34void HWUITarget::fence() {
tomhudson3c8ceb72015-10-26 07:21:31 -070035 this->renderer.fence();
tomhudsond968a6f2015-03-26 11:28:06 -070036}
37
cdaltond416a5b2015-06-23 13:23:44 -070038bool HWUITarget::needsFrameTiming(int* frameLag) const {
39 extern int FLAGS_gpuFrameLag;
40 *frameLag = FLAGS_gpuFrameLag;
tomhudsond968a6f2015-03-26 11:28:06 -070041 return true;
42}
43
44bool HWUITarget::init(SkImageInfo info, Benchmark* bench) {
tomhudson3c8ceb72015-10-26 07:21:31 -070045 this->renderer.initialize(bench->getSize().x(), bench->getSize().y());
tomhudsond968a6f2015-03-26 11:28:06 -070046 return true;
47}
48
49bool HWUITarget::capturePixels(SkBitmap* bmp) {
tomhudson573ae012015-03-27 12:22:01 -070050 return this->renderer.capturePixels(bmp);
tomhudsond968a6f2015-03-26 11:28:06 -070051}