blob: 26a7a3bb32458282182bfdd222001a209fede1d8 [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
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +000013SK_DEFINE_INST_COUNT(SkBenchmark)
14
reed@android.comf523e252009-01-26 23:15:37 +000015template BenchRegistry* BenchRegistry::gHead;
16
scroggo@google.com111fd112013-09-25 21:42:12 +000017SkString SkBenchmark::gResourcePath;
18
mtklein@google.com410e6e82013-09-13 19:52:27 +000019SkBenchmark::SkBenchmark() {
reed@android.com4bc19832009-01-19 20:08:35 +000020 fForceAlpha = 0xFF;
21 fForceAA = true;
reed@google.com44699382013-10-31 17:28:30 +000022 fForceFilter = false;
reed@android.com4e635f92009-10-19 17:39:46 +000023 fDither = SkTriState::kDefault;
reed@google.comef77ec22013-05-29 15:39:54 +000024 fOrMask = fClearMask = 0;
mtklein@google.comc2897432013-09-10 19:23:38 +000025 fLoops = 1;
reed@android.com4bc19832009-01-19 20:08:35 +000026}
reed@android.combd700c32009-01-05 03:34:50 +000027
28const char* SkBenchmark::getName() {
29 return this->onGetName();
30}
31
32SkIPoint SkBenchmark::getSize() {
33 return this->onGetSize();
34}
35
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +000036void SkBenchmark::preDraw() {
37 this->onPreDraw();
38}
39
reed@android.combd700c32009-01-05 03:34:50 +000040void SkBenchmark::draw(SkCanvas* canvas) {
41 this->onDraw(canvas);
42}
43
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +000044void SkBenchmark::postDraw() {
45 this->onPostDraw();
46}
47
reed@android.com4bc19832009-01-19 20:08:35 +000048void SkBenchmark::setupPaint(SkPaint* paint) {
49 paint->setAlpha(fForceAlpha);
50 paint->setAntiAlias(fForceAA);
reed@google.com44699382013-10-31 17:28:30 +000051 paint->setFilterLevel(fForceFilter ? SkPaint::kLow_FilterLevel
52 : SkPaint::kNone_FilterLevel);
reed@android.com4e635f92009-10-19 17:39:46 +000053
reed@google.comef77ec22013-05-29 15:39:54 +000054 paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask);
55
reed@android.com4e635f92009-10-19 17:39:46 +000056 if (SkTriState::kDefault != fDither) {
57 paint->setDither(SkTriState::kTrue == fDither);
58 }
reed@android.com4bc19832009-01-19 20:08:35 +000059}
60
reed@android.com0c9da392010-02-22 19:50:13 +000061
reed@android.comf523e252009-01-26 23:15:37 +000062///////////////////////////////////////////////////////////////////////////////
reed@android.com4bc19832009-01-19 20:08:35 +000063
reed@android.comf523e252009-01-26 23:15:37 +000064SkIPoint SkBenchmark::onGetSize() {
reed@android.com0c9da392010-02-22 19:50:13 +000065 return SkIPoint::Make(640, 480);
reed@android.comf523e252009-01-26 23:15:37 +000066}