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()18Benchmark::Benchmark() { 19 fForceAlpha = 0xFF; 20 fDither = SkTriState::kDefault; 21 fOrMask = fClearMask = 0; 22 } 23 getName()24const char* Benchmark::getName() { 25 return this->onGetName(); 26 } 27 getUniqueName()28const char* Benchmark::getUniqueName() { 29 return this->onGetUniqueName(); 30 } 31 getSize()32SkIPoint Benchmark::getSize() { 33 return this->onGetSize(); 34 } 35 delayedSetup()36void Benchmark::delayedSetup() { 37 this->onDelayedSetup(); 38 } 39 perCanvasPreDraw(SkCanvas * canvas)40void Benchmark::perCanvasPreDraw(SkCanvas* canvas) { 41 this->onPerCanvasPreDraw(canvas); 42 } 43 preDraw(SkCanvas * canvas)44void Benchmark::preDraw(SkCanvas* canvas) { 45 this->onPreDraw(canvas); 46 } 47 postDraw(SkCanvas * canvas)48void Benchmark::postDraw(SkCanvas* canvas) { 49 this->onPostDraw(canvas); 50 } 51 perCanvasPostDraw(SkCanvas * canvas)52void Benchmark::perCanvasPostDraw(SkCanvas* canvas) { 53 this->onPerCanvasPostDraw(canvas); 54 } 55 draw(int loops,SkCanvas * canvas)56void Benchmark::draw(int loops, SkCanvas* canvas) { 57 SkAutoCanvasRestore ar(canvas, true/*save now*/); 58 this->onDraw(loops, canvas); 59 } 60 setupPaint(SkPaint * paint)61void 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()73SkIPoint Benchmark::onGetSize() { 74 return SkIPoint::Make(640, 480); 75 } 76