2011-07-28 18:26:00 +04: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 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
|
|
|
|
2012-06-22 00:25:03 +04:00
|
|
|
SK_DEFINE_INST_COUNT(SkBenchmark)
|
|
|
|
|
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;
|
2010-04-27 19:47:34 +04:00
|
|
|
fHasStrokeWidth = false;
|
2012-09-13 19:50:24 +04:00
|
|
|
fIsRendering = true;
|
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();
|
|
|
|
}
|
|
|
|
|
2012-08-13 18:03:31 +04:00
|
|
|
void SkBenchmark::preDraw() {
|
|
|
|
this->onPreDraw();
|
|
|
|
}
|
|
|
|
|
2009-01-05 06:34:50 +03:00
|
|
|
void SkBenchmark::draw(SkCanvas* canvas) {
|
|
|
|
this->onDraw(canvas);
|
|
|
|
}
|
|
|
|
|
2012-08-13 18:03:31 +04:00
|
|
|
void SkBenchmark::postDraw() {
|
|
|
|
this->onPostDraw();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|