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 #include "AnimationContext.h"
     11 #include "IContextFactory.h"
     12 #include "SkiaCanvasProxy.h"
     13 #include "android/rect.h"
     14 #include "android/native_window.h"
     15 #include "renderthread/TimeLord.h"
     16 
     17 /* These functions are only compiled in the Android Framework. */
     18 
     19 HWUITarget::HWUITarget(const Config& c, Benchmark* bench) : Target(c) { }
     20 
     21 void HWUITarget::setup() {
     22     this->renderer.proxy->fence();
     23 }
     24 
     25 SkCanvas* HWUITarget::beginTiming(SkCanvas* canvas) {
     26     SkCanvas* targetCanvas = this->renderer.prepareToDraw();
     27     if (targetCanvas) {
     28         this->fc.reset(targetCanvas);
     29         canvas = &this->fc;
     30         // This might minimally distort timing, but canvas isn't valid outside the timer.
     31         canvas->clear(SK_ColorWHITE);
     32     }
     33 
     34     return canvas;
     35 }
     36 
     37 void HWUITarget::endTiming() {
     38     this->renderer.finishDrawing();
     39 }
     40 
     41 void HWUITarget::fence() {
     42     this->renderer.proxy->fence();
     43 }
     44 
     45 bool HWUITarget::needsFrameTiming() const {
     46     return true;
     47 }
     48 
     49 bool HWUITarget::init(SkImageInfo info, Benchmark* bench) {
     50     this->renderer.initialize({bench->getSize().x(), bench->getSize().y()});
     51     return true;
     52 }
     53 
     54 bool HWUITarget::capturePixels(SkBitmap* bmp) {
     55     return this->renderer.capturePixels(bmp);
     56 }
     57 
     58 
     59