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