2011-07-28 14:26:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2009-01-05 03:34:50 +00:00
|
|
|
#include "SkBenchmark.h"
|
2009-01-19 20:08:35 +00:00
|
|
|
#include "SkPaint.h"
|
2010-02-22 19:50:13 +00:00
|
|
|
#include "SkParse.h"
|
2009-01-19 20:08:35 +00:00
|
|
|
|
2012-06-21 20:25:03 +00:00
|
|
|
SK_DEFINE_INST_COUNT(SkBenchmark)
|
|
|
|
|
2009-01-26 23:15:37 +00:00
|
|
|
template BenchRegistry* BenchRegistry::gHead;
|
|
|
|
|
2009-09-02 21:12:42 +00:00
|
|
|
SkBenchmark::SkBenchmark(void* defineDict) {
|
|
|
|
fDict = reinterpret_cast<const SkTDict<const char*>*>(defineDict);
|
2009-01-19 20:08:35 +00:00
|
|
|
fForceAlpha = 0xFF;
|
|
|
|
fForceAA = true;
|
2009-10-19 17:39:46 +00:00
|
|
|
fDither = SkTriState::kDefault;
|
2010-04-27 15:47:34 +00:00
|
|
|
fHasStrokeWidth = false;
|
2012-09-13 15:50:24 +00:00
|
|
|
fIsRendering = true;
|
2009-01-19 20:08:35 +00:00
|
|
|
}
|
2009-01-05 03:34:50 +00:00
|
|
|
|
|
|
|
const char* SkBenchmark::getName() {
|
|
|
|
return this->onGetName();
|
|
|
|
}
|
|
|
|
|
|
|
|
SkIPoint SkBenchmark::getSize() {
|
|
|
|
return this->onGetSize();
|
|
|
|
}
|
|
|
|
|
2012-08-13 14:03:31 +00:00
|
|
|
void SkBenchmark::preDraw() {
|
|
|
|
this->onPreDraw();
|
|
|
|
}
|
|
|
|
|
2009-01-05 03:34:50 +00:00
|
|
|
void SkBenchmark::draw(SkCanvas* canvas) {
|
|
|
|
this->onDraw(canvas);
|
|
|
|
}
|
|
|
|
|
2012-08-13 14:03:31 +00:00
|
|
|
void SkBenchmark::postDraw() {
|
|
|
|
this->onPostDraw();
|
|
|
|
}
|
|
|
|
|
2009-01-19 20:08:35 +00:00
|
|
|
void SkBenchmark::setupPaint(SkPaint* paint) {
|
|
|
|
paint->setAlpha(fForceAlpha);
|
|
|
|
paint->setAntiAlias(fForceAA);
|
2009-08-04 18:17:15 +00:00
|
|
|
paint->setFilterBitmap(fForceFilter);
|
2009-10-19 17:39:46 +00:00
|
|
|
|
|
|
|
if (SkTriState::kDefault != fDither) {
|
|
|
|
paint->setDither(SkTriState::kTrue == fDither);
|
|
|
|
}
|
2009-01-19 20:08:35 +00:00
|
|
|
}
|
|
|
|
|
2009-09-02 21:12:42 +00:00
|
|
|
const char* SkBenchmark::findDefine(const char* key) const {
|
|
|
|
if (fDict) {
|
|
|
|
const char* value;
|
|
|
|
if (fDict->find(key, &value)) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-02-22 19:50:13 +00:00
|
|
|
bool SkBenchmark::findDefine32(const char* key, int32_t* value) const {
|
|
|
|
const char* valueStr = this->findDefine(key);
|
|
|
|
if (valueStr) {
|
|
|
|
SkParse::FindS32(valueStr, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SkBenchmark::findDefineScalar(const char* key, SkScalar* value) const {
|
|
|
|
const char* valueStr = this->findDefine(key);
|
|
|
|
if (valueStr) {
|
|
|
|
SkParse::FindScalar(valueStr, value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-01-26 23:15:37 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2009-01-19 20:08:35 +00:00
|
|
|
|
2009-01-26 23:15:37 +00:00
|
|
|
SkIPoint SkBenchmark::onGetSize() {
|
2010-02-22 19:50:13 +00:00
|
|
|
return SkIPoint::Make(640, 480);
|
2009-01-26 23:15:37 +00:00
|
|
|
}
|