blob: 9205ba97c958dae3a26c8a6cc6223dcea09427c7 [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
tfarinaf168b862014-06-19 12:32:29 -07008#include "Benchmark.h"
tfarinabcbc1782014-06-18 14:32:48 -07009
reed@android.com4bc19832009-01-19 20:08:35 +000010#include "SkPaint.h"
reed@android.com0c9da392010-02-22 19:50:13 +000011#include "SkParse.h"
reed@android.com4bc19832009-01-19 20:08:35 +000012
mtklein@google.comc2897432013-09-10 19:23:38 +000013const char* SkTriState::Name[] = { "default", "true", "false" };
14
reed@android.comf523e252009-01-26 23:15:37 +000015template BenchRegistry* BenchRegistry::gHead;
16
tfarinaf168b862014-06-19 12:32:29 -070017Benchmark::Benchmark() {
reed@android.com4bc19832009-01-19 20:08:35 +000018 fForceAlpha = 0xFF;
reed@android.com4e635f92009-10-19 17:39:46 +000019 fDither = SkTriState::kDefault;
reed@google.comef77ec22013-05-29 15:39:54 +000020 fOrMask = fClearMask = 0;
reed@android.com4bc19832009-01-19 20:08:35 +000021}
reed@android.combd700c32009-01-05 03:34:50 +000022
tfarinaf168b862014-06-19 12:32:29 -070023const char* Benchmark::getName() {
reed@android.combd700c32009-01-05 03:34:50 +000024 return this->onGetName();
25}
26
mtklein96289052014-09-10 12:05:59 -070027const char* Benchmark::getUniqueName() {
28 return this->onGetUniqueName();
29}
30
tfarinaf168b862014-06-19 12:32:29 -070031SkIPoint Benchmark::getSize() {
reed@android.combd700c32009-01-05 03:34:50 +000032 return this->onGetSize();
33}
34
tfarinaf168b862014-06-19 12:32:29 -070035void Benchmark::preDraw() {
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +000036 this->onPreDraw();
37}
38
tfarinaf168b862014-06-19 12:32:29 -070039void Benchmark::draw(const int loops, SkCanvas* canvas) {
commit-bot@chromium.org33614712013-12-03 18:17:16 +000040 this->onDraw(loops, canvas);
reed@android.combd700c32009-01-05 03:34:50 +000041}
42
tfarinaf168b862014-06-19 12:32:29 -070043void Benchmark::setupPaint(SkPaint* paint) {
reed@android.com4bc19832009-01-19 20:08:35 +000044 paint->setAlpha(fForceAlpha);
kelvinly762c7182014-07-09 12:25:27 -070045 paint->setAntiAlias(true);
46 paint->setFilterLevel(SkPaint::kNone_FilterLevel);
reed@android.com4e635f92009-10-19 17:39:46 +000047
reed@google.comef77ec22013-05-29 15:39:54 +000048 paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask);
49
reed@android.com4e635f92009-10-19 17:39:46 +000050 if (SkTriState::kDefault != fDither) {
51 paint->setDither(SkTriState::kTrue == fDither);
52 }
reed@android.com4bc19832009-01-19 20:08:35 +000053}
54
tfarinaf168b862014-06-19 12:32:29 -070055SkIPoint Benchmark::onGetSize() {
reed@android.com0c9da392010-02-22 19:50:13 +000056 return SkIPoint::Make(640, 480);
reed@android.comf523e252009-01-26 23:15:37 +000057}