blob: 432d5be6432e87771702a05a3c7aefb9d94e0f60 [file] [log] [blame]
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkBenchmark.h"
#include "SkPaint.h"
#include "SkParse.h"
const char* SkTriState::Name[] = { "default", "true", "false" };
SK_DEFINE_INST_COUNT(SkBenchmark)
template BenchRegistry* BenchRegistry::gHead;
SkString SkBenchmark::gResourcePath;
SkBenchmark::SkBenchmark() {
fForceAlpha = 0xFF;
fForceAA = true;
fForceFilter = false;
fDither = SkTriState::kDefault;
fIsRendering = true;
fOrMask = fClearMask = 0;
fLoops = 1;
}
const char* SkBenchmark::getName() {
return this->onGetName();
}
SkIPoint SkBenchmark::getSize() {
return this->onGetSize();
}
void SkBenchmark::preDraw() {
this->onPreDraw();
}
void SkBenchmark::draw(SkCanvas* canvas) {
this->onDraw(canvas);
}
void SkBenchmark::postDraw() {
this->onPostDraw();
}
void SkBenchmark::setupPaint(SkPaint* paint) {
paint->setAlpha(fForceAlpha);
paint->setAntiAlias(fForceAA);
paint->setFilterLevel(fForceFilter ? SkPaint::kLow_FilterLevel
: SkPaint::kNone_FilterLevel);
paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask);
if (SkTriState::kDefault != fDither) {
paint->setDither(SkTriState::kTrue == fDither);
}
}
///////////////////////////////////////////////////////////////////////////////
SkIPoint SkBenchmark::onGetSize() {
return SkIPoint::Make(640, 480);
}