1 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 */ 8 #include "SkBenchmark.h" 9 #include "SkPaint.h" 10 #include "SkParse.h" 11 12 template BenchRegistry* BenchRegistry::gHead; 13 SkBenchmark(void * defineDict)14SkBenchmark::SkBenchmark(void* defineDict) { 15 fDict = reinterpret_cast<const SkTDict<const char*>*>(defineDict); 16 fForceAlpha = 0xFF; 17 fForceAA = true; 18 fDither = SkTriState::kDefault; 19 fHasStrokeWidth = false; 20 } 21 getName()22const char* SkBenchmark::getName() { 23 return this->onGetName(); 24 } 25 getSize()26SkIPoint SkBenchmark::getSize() { 27 return this->onGetSize(); 28 } 29 draw(SkCanvas * canvas)30void SkBenchmark::draw(SkCanvas* canvas) { 31 this->onDraw(canvas); 32 } 33 setupPaint(SkPaint * paint)34void SkBenchmark::setupPaint(SkPaint* paint) { 35 paint->setAlpha(fForceAlpha); 36 paint->setAntiAlias(fForceAA); 37 paint->setFilterBitmap(fForceFilter); 38 39 if (SkTriState::kDefault != fDither) { 40 paint->setDither(SkTriState::kTrue == fDither); 41 } 42 } 43 findDefine(const char * key) const44const char* SkBenchmark::findDefine(const char* key) const { 45 if (fDict) { 46 const char* value; 47 if (fDict->find(key, &value)) { 48 return value; 49 } 50 } 51 return NULL; 52 } 53 findDefine32(const char * key,int32_t * value) const54bool SkBenchmark::findDefine32(const char* key, int32_t* value) const { 55 const char* valueStr = this->findDefine(key); 56 if (valueStr) { 57 SkParse::FindS32(valueStr, value); 58 return true; 59 } 60 return false; 61 } 62 findDefineScalar(const char * key,SkScalar * value) const63bool SkBenchmark::findDefineScalar(const char* key, SkScalar* value) const { 64 const char* valueStr = this->findDefine(key); 65 if (valueStr) { 66 SkParse::FindScalar(valueStr, value); 67 return true; 68 } 69 return false; 70 } 71 72 /////////////////////////////////////////////////////////////////////////////// 73 onGetSize()74SkIPoint SkBenchmark::onGetSize() { 75 return SkIPoint::Make(640, 480); 76 } 77