tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
tomhudson | 573ae01 | 2015-03-27 12:22:01 -0700 | [diff] [blame] | 10 | /* These functions are only compiled in the Android Framework. */ |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 11 | |
| 12 | HWUITarget::HWUITarget(const Config& c, Benchmark* bench) : Target(c) { } |
| 13 | |
| 14 | void HWUITarget::setup() { |
tomhudson | 3c8ceb7 | 2015-10-26 07:21:31 -0700 | [diff] [blame] | 15 | this->renderer.fence(); |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | SkCanvas* HWUITarget::beginTiming(SkCanvas* canvas) { |
tomhudson | 573ae01 | 2015-03-27 12:22:01 -0700 | [diff] [blame] | 19 | SkCanvas* targetCanvas = this->renderer.prepareToDraw(); |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 20 | 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); |
tomhudson | 573ae01 | 2015-03-27 12:22:01 -0700 | [diff] [blame] | 25 | } |
| 26 | |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 27 | return canvas; |
| 28 | } |
| 29 | |
| 30 | void HWUITarget::endTiming() { |
tomhudson | 573ae01 | 2015-03-27 12:22:01 -0700 | [diff] [blame] | 31 | this->renderer.finishDrawing(); |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | void HWUITarget::fence() { |
tomhudson | 3c8ceb7 | 2015-10-26 07:21:31 -0700 | [diff] [blame] | 35 | this->renderer.fence(); |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 36 | } |
| 37 | |
cdalton | d416a5b | 2015-06-23 13:23:44 -0700 | [diff] [blame] | 38 | bool HWUITarget::needsFrameTiming(int* frameLag) const { |
| 39 | extern int FLAGS_gpuFrameLag; |
| 40 | *frameLag = FLAGS_gpuFrameLag; |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 41 | return true; |
| 42 | } |
| 43 | |
| 44 | bool HWUITarget::init(SkImageInfo info, Benchmark* bench) { |
tomhudson | 3c8ceb7 | 2015-10-26 07:21:31 -0700 | [diff] [blame] | 45 | this->renderer.initialize(bench->getSize().x(), bench->getSize().y()); |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 46 | return true; |
| 47 | } |
| 48 | |
| 49 | bool HWUITarget::capturePixels(SkBitmap* bmp) { |
tomhudson | 573ae01 | 2015-03-27 12:22:01 -0700 | [diff] [blame] | 50 | return this->renderer.capturePixels(bmp); |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 51 | } |