• 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 
8 #include "Benchmark.h"
9 
10 #include "SkCanvas.h"
11 #include "SkPaint.h"
12 #include "SkParse.h"
13 
14 const char* SkTriState::Name[] = { "default", "true", "false" };
15 
16 template BenchRegistry* BenchRegistry::gHead;
17 
Benchmark()18 Benchmark::Benchmark() {
19     fForceAlpha = 0xFF;
20     fDither = SkTriState::kDefault;
21     fOrMask = fClearMask = 0;
22 }
23 
getName()24 const char* Benchmark::getName() {
25     return this->onGetName();
26 }
27 
getUniqueName()28 const char* Benchmark::getUniqueName() {
29     return this->onGetUniqueName();
30 }
31 
getSize()32 SkIPoint Benchmark::getSize() {
33     return this->onGetSize();
34 }
35 
delayedSetup()36 void Benchmark::delayedSetup() {
37     this->onDelayedSetup();
38 }
39 
perCanvasPreDraw(SkCanvas * canvas)40 void Benchmark::perCanvasPreDraw(SkCanvas* canvas) {
41     this->onPerCanvasPreDraw(canvas);
42 }
43 
preDraw(SkCanvas * canvas)44 void Benchmark::preDraw(SkCanvas* canvas) {
45     this->onPreDraw(canvas);
46 }
47 
postDraw(SkCanvas * canvas)48 void Benchmark::postDraw(SkCanvas* canvas) {
49     this->onPostDraw(canvas);
50 }
51 
perCanvasPostDraw(SkCanvas * canvas)52 void Benchmark::perCanvasPostDraw(SkCanvas* canvas) {
53     this->onPerCanvasPostDraw(canvas);
54 }
55 
draw(int loops,SkCanvas * canvas)56 void Benchmark::draw(int loops, SkCanvas* canvas) {
57     SkAutoCanvasRestore ar(canvas, true/*save now*/);
58     this->onDraw(loops, canvas);
59 }
60 
setupPaint(SkPaint * paint)61 void Benchmark::setupPaint(SkPaint* paint) {
62     paint->setAlpha(fForceAlpha);
63     paint->setAntiAlias(true);
64     paint->setFilterQuality(kNone_SkFilterQuality);
65 
66     paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask);
67 
68     if (SkTriState::kDefault != fDither) {
69         paint->setDither(SkTriState::kTrue == fDither);
70     }
71 }
72 
onGetSize()73 SkIPoint Benchmark::onGetSize() {
74     return SkIPoint::Make(640, 480);
75 }
76