2009-01-05 06:34:50 +03:00
|
|
|
#include "SkBenchmark.h"
|
2009-01-19 23:08:35 +03:00
|
|
|
#include "SkPaint.h"
|
2010-02-22 22:50:13 +03:00
|
|
|
#include "SkParse.h"
|
2009-01-19 23:08:35 +03:00
|
|
|
|
2009-01-27 02:15:37 +03:00
|
|
|
template BenchRegistry* BenchRegistry::gHead;
|
|
|
|
|
2009-09-03 01:12:42 +04:00
|
|
|
SkBenchmark::SkBenchmark(void* defineDict) {
|
|
|
|
fDict = reinterpret_cast<const SkTDict<const char*>*>(defineDict);
|
2009-01-19 23:08:35 +03:00
|
|
|
fForceAlpha = 0xFF;
|
|
|
|
fForceAA = true;
|
2009-10-19 21:39:46 +04:00
|
|
|
fDither = SkTriState::kDefault;
|
2009-01-19 23:08:35 +03:00
|
|
|
}
|
2009-01-05 06:34:50 +03:00
|
|
|
|
|
|
|
const char* SkBenchmark::getName() {
|
|
|
|
return this->onGetName();
|
|
|
|
}
|
|
|
|
|
|
|
|
SkIPoint SkBenchmark::getSize() {
|
|
|
|
return this->onGetSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkBenchmark::draw(SkCanvas* canvas) {
|
|
|
|
this->onDraw(canvas);
|
|
|
|
}
|
|
|
|
|
2009-01-19 23:08:35 +03:00
|
|
|
void SkBenchmark::setupPaint(SkPaint* paint) {
|
|
|
|
paint->setAlpha(fForceAlpha);
|
|
|
|
paint->setAntiAlias(fForceAA);
|
2009-08-04 22:17:15 +04:00
|
|
|
paint->setFilterBitmap(fForceFilter);
|
2009-10-19 21:39:46 +04:00
|
|
|
|
|
|
|
if (SkTriState::kDefault != fDither) {
|
|
|
|
paint->setDither(SkTriState::kTrue == fDither);
|
|
|
|
}
|
2009-01-19 23:08:35 +03:00
|
|
|
}
|
|
|
|
|
2009-09-03 01:12:42 +04: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 22:50:13 +03: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-27 02:15:37 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2009-01-19 23:08:35 +03:00
|
|
|
|
2009-01-27 02:15:37 +03:00
|
|
|
SkIPoint SkBenchmark::onGetSize() {
|
2010-02-22 22:50:13 +03:00
|
|
|
return SkIPoint::Make(640, 480);
|
2009-01-27 02:15:37 +03:00
|
|
|
}
|