Home | History | Annotate | Download | only in bench
      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 
     10 /* These functions are only compiled in the Android Framework. */
     11 
     12 HWUITarget::HWUITarget(const Config& c, Benchmark* bench) : Target(c) { }
     13 
     14 void HWUITarget::setup() {
     15     this->renderer.fence();
     16 }
     17 
     18 SkCanvas* HWUITarget::beginTiming(SkCanvas* canvas) {
     19     SkCanvas* targetCanvas = this->renderer.prepareToDraw();
     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);
     25     }
     26 
     27     return canvas;
     28 }
     29 
     30 void HWUITarget::endTiming() {
     31     this->renderer.finishDrawing();
     32 }
     33 
     34 void HWUITarget::fence() {
     35     this->renderer.fence();
     36 }
     37 
     38 bool HWUITarget::needsFrameTiming(int* frameLag) const {
     39     extern int FLAGS_gpuFrameLag;
     40     *frameLag = FLAGS_gpuFrameLag;
     41     return true;
     42 }
     43 
     44 bool HWUITarget::init(SkImageInfo info, Benchmark* bench) {
     45     this->renderer.initialize(bench->getSize().x(), bench->getSize().y());
     46     return true;
     47 }
     48 
     49 bool HWUITarget::capturePixels(SkBitmap* bmp) {
     50     return this->renderer.capturePixels(bmp);
     51 }
     52 
     53 
     54