blob: 4d361e74164d6abd8330007d1d0e2728238cb7bb [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
reed@android.combd700c32009-01-05 03:34:50 +00008#include "SkBenchmark.h"
reed@android.com4bc19832009-01-19 20:08:35 +00009#include "SkPaint.h"
reed@android.com0c9da392010-02-22 19:50:13 +000010#include "SkParse.h"
reed@android.com4bc19832009-01-19 20:08:35 +000011
mtklein@google.comc2897432013-09-10 19:23:38 +000012const char* SkTriState::Name[] = { "default", "true", "false" };
13
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +000014SK_DEFINE_INST_COUNT(SkBenchmark)
15
reed@android.comf523e252009-01-26 23:15:37 +000016template BenchRegistry* BenchRegistry::gHead;
17
mtklein@google.com410e6e82013-09-13 19:52:27 +000018SkBenchmark::SkBenchmark() {
reed@android.com4bc19832009-01-19 20:08:35 +000019 fForceAlpha = 0xFF;
20 fForceAA = true;
reed@android.com4e635f92009-10-19 17:39:46 +000021 fDither = SkTriState::kDefault;
tomhudson@google.com9dc27132012-09-13 15:50:24 +000022 fIsRendering = true;
reed@google.comef77ec22013-05-29 15:39:54 +000023 fOrMask = fClearMask = 0;
mtklein@google.comc2897432013-09-10 19:23:38 +000024 fLoops = 1;
reed@android.com4bc19832009-01-19 20:08:35 +000025}
reed@android.combd700c32009-01-05 03:34:50 +000026
27const char* SkBenchmark::getName() {
28 return this->onGetName();
29}
30
31SkIPoint SkBenchmark::getSize() {
32 return this->onGetSize();
33}
34
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +000035void SkBenchmark::preDraw() {
36 this->onPreDraw();
37}
38
reed@android.combd700c32009-01-05 03:34:50 +000039void SkBenchmark::draw(SkCanvas* canvas) {
40 this->onDraw(canvas);
41}
42
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +000043void SkBenchmark::postDraw() {
44 this->onPostDraw();
45}
46
reed@android.com4bc19832009-01-19 20:08:35 +000047void SkBenchmark::setupPaint(SkPaint* paint) {
48 paint->setAlpha(fForceAlpha);
49 paint->setAntiAlias(fForceAA);
reed@android.com29348cb2009-08-04 18:17:15 +000050 paint->setFilterBitmap(fForceFilter);
reed@android.com4e635f92009-10-19 17:39:46 +000051
reed@google.comef77ec22013-05-29 15:39:54 +000052 paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask);
53
reed@android.com4e635f92009-10-19 17:39:46 +000054 if (SkTriState::kDefault != fDither) {
55 paint->setDither(SkTriState::kTrue == fDither);
56 }
reed@android.com4bc19832009-01-19 20:08:35 +000057}
58
reed@android.com0c9da392010-02-22 19:50:13 +000059
reed@android.comf523e252009-01-26 23:15:37 +000060///////////////////////////////////////////////////////////////////////////////
reed@android.com4bc19832009-01-19 20:08:35 +000061
reed@android.comf523e252009-01-26 23:15:37 +000062SkIPoint SkBenchmark::onGetSize() {
reed@android.com0c9da392010-02-22 19:50:13 +000063 return SkIPoint::Make(640, 480);
reed@android.comf523e252009-01-26 23:15:37 +000064}