blob: eba1750d6497bf3dcf64d95528778e57f7a9ee71 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001/*
2 * Copyright 2011 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 */
tfarinabcbc1782014-06-18 14:32:48 -07007
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "bench/Benchmark.h"
tfarinabcbc1782014-06-18 14:32:48 -07009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/core/SkCanvas.h"
11#include "include/core/SkPaint.h"
12#include "include/utils/SkParse.h"
reed@android.com4bc19832009-01-19 20:08:35 +000013
reed@android.comf523e252009-01-26 23:15:37 +000014template BenchRegistry* BenchRegistry::gHead;
15
Brian Osman1e4a4da2018-08-08 14:27:25 -040016Benchmark::Benchmark() {}
reed@android.combd700c32009-01-05 03:34:50 +000017
tfarinaf168b862014-06-19 12:32:29 -070018const char* Benchmark::getName() {
reed@android.combd700c32009-01-05 03:34:50 +000019 return this->onGetName();
20}
21
mtklein96289052014-09-10 12:05:59 -070022const char* Benchmark::getUniqueName() {
23 return this->onGetUniqueName();
24}
25
tfarinaf168b862014-06-19 12:32:29 -070026SkIPoint Benchmark::getSize() {
reed@android.combd700c32009-01-05 03:34:50 +000027 return this->onGetSize();
28}
29
joshualitt8a6697a2015-09-30 12:11:07 -070030void Benchmark::delayedSetup() {
31 this->onDelayedSetup();
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +000032}
33
robertphillips5b693772014-11-21 06:19:36 -080034void Benchmark::perCanvasPreDraw(SkCanvas* canvas) {
35 this->onPerCanvasPreDraw(canvas);
36}
37
joshualitt8a6697a2015-09-30 12:11:07 -070038void Benchmark::preDraw(SkCanvas* canvas) {
39 this->onPreDraw(canvas);
40}
41
42void Benchmark::postDraw(SkCanvas* canvas) {
43 this->onPostDraw(canvas);
44}
45
robertphillips5b693772014-11-21 06:19:36 -080046void Benchmark::perCanvasPostDraw(SkCanvas* canvas) {
47 this->onPerCanvasPostDraw(canvas);
48}
49
mtkleina1ebeb22015-10-01 09:43:39 -070050void Benchmark::draw(int loops, SkCanvas* canvas) {
mtklein38c05872014-10-02 13:03:58 -070051 SkAutoCanvasRestore ar(canvas, true/*save now*/);
commit-bot@chromium.org33614712013-12-03 18:17:16 +000052 this->onDraw(loops, canvas);
reed@android.combd700c32009-01-05 03:34:50 +000053}
54
tfarinaf168b862014-06-19 12:32:29 -070055void Benchmark::setupPaint(SkPaint* paint) {
kelvinly762c7182014-07-09 12:25:27 -070056 paint->setAntiAlias(true);
reed@android.com4bc19832009-01-19 20:08:35 +000057}
58
tfarinaf168b862014-06-19 12:32:29 -070059SkIPoint Benchmark::onGetSize() {
reed@android.com0c9da392010-02-22 19:50:13 +000060 return SkIPoint::Make(640, 480);
reed@android.comf523e252009-01-26 23:15:37 +000061}