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"
|
|
|
|
|
|
|
|
#include "AnimationContext.h"
|
|
|
|
#include "IContextFactory.h"
|
|
|
|
#include "SkiaCanvasProxy.h"
|
|
|
|
#include "android/rect.h"
|
|
|
|
#include "android/native_window.h"
|
|
|
|
#include "renderthread/TimeLord.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-03-27 19:22:01 +00:00
|
|
|
this->renderer.proxy->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-03-27 19:22:01 +00:00
|
|
|
this->renderer.proxy->fence();
|
2015-03-26 18:28:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HWUITarget::needsFrameTiming() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HWUITarget::init(SkImageInfo info, Benchmark* bench) {
|
2015-03-27 19:22:01 +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
|
|
|
}
|
|
|
|
|
|
|
|
|