Home | History | Annotate | Download | only in bench
      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 }
     13 
     14 const char* SkBenchmark::getName() {
     15     return this->onGetName();
     16 }
     17 
     18 SkIPoint SkBenchmark::getSize() {
     19     return this->onGetSize();
     20 }
     21 
     22 void SkBenchmark::draw(SkCanvas* canvas) {
     23     this->onDraw(canvas);
     24 }
     25 
     26 void SkBenchmark::setupPaint(SkPaint* paint) {
     27     paint->setAlpha(fForceAlpha);
     28     paint->setAntiAlias(fForceAA);
     29     paint->setFilterBitmap(fForceFilter);
     30 
     31     if (SkTriState::kDefault != fDither) {
     32         paint->setDither(SkTriState::kTrue == fDither);
     33     }
     34 }
     35 
     36 const char* SkBenchmark::findDefine(const char* key) const {
     37     if (fDict) {
     38         const char* value;
     39         if (fDict->find(key, &value)) {
     40             return value;
     41         }
     42     }
     43     return NULL;
     44 }
     45 
     46 bool SkBenchmark::findDefine32(const char* key, int32_t* value) const {
     47     const char* valueStr = this->findDefine(key);
     48     if (valueStr) {
     49         SkParse::FindS32(valueStr, value);
     50         return true;
     51     }
     52     return false;
     53 }
     54 
     55 bool SkBenchmark::findDefineScalar(const char* key, SkScalar* value) const {
     56     const char* valueStr = this->findDefine(key);
     57     if (valueStr) {
     58         SkParse::FindScalar(valueStr, value);
     59         return true;
     60     }
     61     return false;
     62 }
     63 
     64 ///////////////////////////////////////////////////////////////////////////////
     65 
     66 SkIPoint SkBenchmark::onGetSize() {
     67     return SkIPoint::Make(640, 480);
     68 }
     69