blob: ae614f04f9c4a3ab1141243f091aa78a1ca253ea [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;
19 fForceAA = true;
reed@google.com44699382013-10-31 17:28:30 +000020 fForceFilter = false;
reed@android.com4e635f92009-10-19 17:39:46 +000021 fDither = SkTriState::kDefault;
reed@google.comef77ec22013-05-29 15:39:54 +000022 fOrMask = fClearMask = 0;
reed@android.com4bc19832009-01-19 20:08:35 +000023}
reed@android.combd700c32009-01-05 03:34:50 +000024
tfarinaf168b862014-06-19 12:32:29 -070025const char* Benchmark::getName() {
reed@android.combd700c32009-01-05 03:34:50 +000026 return this->onGetName();
27}
28
tfarinaf168b862014-06-19 12:32:29 -070029SkIPoint Benchmark::getSize() {
reed@android.combd700c32009-01-05 03:34:50 +000030 return this->onGetSize();
31}
32
tfarinaf168b862014-06-19 12:32:29 -070033void Benchmark::preDraw() {
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +000034 this->onPreDraw();
35}
36
tfarinaf168b862014-06-19 12:32:29 -070037void Benchmark::draw(const int loops, SkCanvas* canvas) {
commit-bot@chromium.org33614712013-12-03 18:17:16 +000038 this->onDraw(loops, canvas);
reed@android.combd700c32009-01-05 03:34:50 +000039}
40
tfarinaf168b862014-06-19 12:32:29 -070041void Benchmark::setupPaint(SkPaint* paint) {
reed@android.com4bc19832009-01-19 20:08:35 +000042 paint->setAlpha(fForceAlpha);
43 paint->setAntiAlias(fForceAA);
reed@google.com44699382013-10-31 17:28:30 +000044 paint->setFilterLevel(fForceFilter ? SkPaint::kLow_FilterLevel
45 : SkPaint::kNone_FilterLevel);
reed@android.com4e635f92009-10-19 17:39:46 +000046
reed@google.comef77ec22013-05-29 15:39:54 +000047 paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask);
48
reed@android.com4e635f92009-10-19 17:39:46 +000049 if (SkTriState::kDefault != fDither) {
50 paint->setDither(SkTriState::kTrue == fDither);
51 }
reed@android.com4bc19832009-01-19 20:08:35 +000052}
53
tfarinaf168b862014-06-19 12:32:29 -070054SkIPoint Benchmark::onGetSize() {
reed@android.com0c9da392010-02-22 19:50:13 +000055 return SkIPoint::Make(640, 480);
reed@android.comf523e252009-01-26 23:15:37 +000056}