blob: d995415632d500fe563dbabcd860f5e2b0b8251d [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 */
reed@android.combd700c32009-01-05 03:34:50 +00007#include "SkBenchmark.h"
reed@android.com4bc19832009-01-19 20:08:35 +00008#include "SkPaint.h"
reed@android.com0c9da392010-02-22 19:50:13 +00009#include "SkParse.h"
reed@android.com4bc19832009-01-19 20:08:35 +000010
mtklein@google.comc2897432013-09-10 19:23:38 +000011const char* SkTriState::Name[] = { "default", "true", "false" };
12
reed@android.comf523e252009-01-26 23:15:37 +000013template BenchRegistry* BenchRegistry::gHead;
14
scroggo@google.com111fd112013-09-25 21:42:12 +000015SkString SkBenchmark::gResourcePath;
16
mtklein@google.com410e6e82013-09-13 19:52:27 +000017SkBenchmark::SkBenchmark() {
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
25const char* SkBenchmark::getName() {
26 return this->onGetName();
27}
28
29SkIPoint SkBenchmark::getSize() {
30 return this->onGetSize();
31}
32
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +000033void SkBenchmark::preDraw() {
34 this->onPreDraw();
35}
36
commit-bot@chromium.org33614712013-12-03 18:17:16 +000037void SkBenchmark::draw(const int loops, SkCanvas* canvas) {
38 this->onDraw(loops, canvas);
reed@android.combd700c32009-01-05 03:34:50 +000039}
40
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +000041void SkBenchmark::postDraw() {
42 this->onPostDraw();
43}
44
reed@android.com4bc19832009-01-19 20:08:35 +000045void SkBenchmark::setupPaint(SkPaint* paint) {
46 paint->setAlpha(fForceAlpha);
47 paint->setAntiAlias(fForceAA);
reed@google.com44699382013-10-31 17:28:30 +000048 paint->setFilterLevel(fForceFilter ? SkPaint::kLow_FilterLevel
49 : SkPaint::kNone_FilterLevel);
reed@android.com4e635f92009-10-19 17:39:46 +000050
reed@google.comef77ec22013-05-29 15:39:54 +000051 paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask);
52
reed@android.com4e635f92009-10-19 17:39:46 +000053 if (SkTriState::kDefault != fDither) {
54 paint->setDither(SkTriState::kTrue == fDither);
55 }
reed@android.com4bc19832009-01-19 20:08:35 +000056}
57
reed@android.com0c9da392010-02-22 19:50:13 +000058
reed@android.comf523e252009-01-26 23:15:37 +000059///////////////////////////////////////////////////////////////////////////////
reed@android.com4bc19832009-01-19 20:08:35 +000060
reed@android.comf523e252009-01-26 23:15:37 +000061SkIPoint SkBenchmark::onGetSize() {
reed@android.com0c9da392010-02-22 19:50:13 +000062 return SkIPoint::Make(640, 480);
reed@android.comf523e252009-01-26 23:15:37 +000063}