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
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
const char* SkTriState::Name[] = { "default", "true", "false" };
|
|
|
|
|
2009-01-26 23:15:37 +00:00
|
|
|
template BenchRegistry* BenchRegistry::gHead;
|
|
|
|
|
2013-09-25 21:42:12 +00:00
|
|
|
SkString SkBenchmark::gResourcePath;
|
|
|
|
|
2013-09-13 19:52:27 +00:00
|
|
|
SkBenchmark::SkBenchmark() {
|
2009-01-19 20:08:35 +00:00
|
|
|
fForceAlpha = 0xFF;
|
|
|
|
fForceAA = true;
|
2013-10-31 17:28:30 +00:00
|
|
|
fForceFilter = false;
|
2009-10-19 17:39:46 +00:00
|
|
|
fDither = SkTriState::kDefault;
|
2013-05-29 15:39:54 +00:00
|
|
|
fOrMask = fClearMask = 0;
|
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();
|
|
|
|
}
|
|
|
|
|
2013-12-03 18:17:16 +00:00
|
|
|
void SkBenchmark::draw(const int loops, SkCanvas* canvas) {
|
|
|
|
this->onDraw(loops, canvas);
|
2009-01-05 03:34:50 +00:00
|
|
|
}
|
|
|
|
|
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);
|
2013-10-31 17:28:30 +00:00
|
|
|
paint->setFilterLevel(fForceFilter ? SkPaint::kLow_FilterLevel
|
|
|
|
: SkPaint::kNone_FilterLevel);
|
2009-10-19 17:39:46 +00:00
|
|
|
|
2013-05-29 15:39:54 +00:00
|
|
|
paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-22 19:50:13 +00:00
|
|
|
|
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
|
|
|
}
|