Home | History | Annotate | Download | only in bench
      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 "SkPaint.h"
     11 #include "SkParse.h"
     12 
     13 const char* SkTriState::Name[] = { "default", "true", "false" };
     14 
     15 template BenchRegistry* BenchRegistry::gHead;
     16 
     17 Benchmark::Benchmark() {
     18     fForceAlpha = 0xFF;
     19     fDither = SkTriState::kDefault;
     20     fOrMask = fClearMask = 0;
     21 }
     22 
     23 const char* Benchmark::getName() {
     24     return this->onGetName();
     25 }
     26 
     27 const char* Benchmark::getUniqueName() {
     28     return this->onGetUniqueName();
     29 }
     30 
     31 SkIPoint Benchmark::getSize() {
     32     return this->onGetSize();
     33 }
     34 
     35 void Benchmark::preDraw() {
     36     this->onPreDraw();
     37 }
     38 
     39 void Benchmark::draw(const int loops, SkCanvas* canvas) {
     40     this->onDraw(loops, canvas);
     41 }
     42 
     43 void Benchmark::setupPaint(SkPaint* paint) {
     44     paint->setAlpha(fForceAlpha);
     45     paint->setAntiAlias(true);
     46     paint->setFilterLevel(SkPaint::kNone_FilterLevel);
     47 
     48     paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask);
     49 
     50     if (SkTriState::kDefault != fDither) {
     51         paint->setDither(SkTriState::kTrue == fDither);
     52     }
     53 }
     54 
     55 SkIPoint Benchmark::onGetSize() {
     56     return SkIPoint::Make(640, 480);
     57 }
     58