• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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  */
7 #include "SkBenchmark.h"
8 #include "SkPaint.h"
9 #include "SkParse.h"
10 
11 const char* SkTriState::Name[] = { "default", "true", "false" };
12 
13 template BenchRegistry* BenchRegistry::gHead;
14 
15 SkString SkBenchmark::gResourcePath;
16 
SkBenchmark()17 SkBenchmark::SkBenchmark() {
18     fForceAlpha = 0xFF;
19     fForceAA = true;
20     fForceFilter = false;
21     fDither = SkTriState::kDefault;
22     fOrMask = fClearMask = 0;
23 }
24 
getName()25 const char* SkBenchmark::getName() {
26     return this->onGetName();
27 }
28 
getSize()29 SkIPoint SkBenchmark::getSize() {
30     return this->onGetSize();
31 }
32 
preDraw()33 void SkBenchmark::preDraw() {
34     this->onPreDraw();
35 }
36 
draw(const int loops,SkCanvas * canvas)37 void SkBenchmark::draw(const int loops, SkCanvas* canvas) {
38     this->onDraw(loops, canvas);
39 }
40 
postDraw()41 void SkBenchmark::postDraw() {
42     this->onPostDraw();
43 }
44 
setupPaint(SkPaint * paint)45 void SkBenchmark::setupPaint(SkPaint* paint) {
46     paint->setAlpha(fForceAlpha);
47     paint->setAntiAlias(fForceAA);
48     paint->setFilterLevel(fForceFilter ? SkPaint::kLow_FilterLevel
49                                        : SkPaint::kNone_FilterLevel);
50 
51     paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask);
52 
53     if (SkTriState::kDefault != fDither) {
54         paint->setDither(SkTriState::kTrue == fDither);
55     }
56 }
57 
58 
59 ///////////////////////////////////////////////////////////////////////////////
60 
onGetSize()61 SkIPoint SkBenchmark::onGetSize() {
62     return SkIPoint::Make(640, 480);
63 }
64