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
|
|
|
|
2013-09-10 23:23:38 +04:00
|
|
|
const char* SkTriState::Name[] = { "default", "true", "false" };
|
|
|
|
|
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;
|
|
|
|
|
2013-09-13 23:52:27 +04:00
|
|
|
SkBenchmark::SkBenchmark() {
|
2009-01-19 23:08:35 +03:00
|
|
|
fForceAlpha = 0xFF;
|
|
|
|
fForceAA = true;
|
2009-10-19 21:39:46 +04:00
|
|
|
fDither = SkTriState::kDefault;
|
2012-09-13 19:50:24 +04:00
|
|
|
fIsRendering = true;
|
2013-05-29 19:39:54 +04:00
|
|
|
fOrMask = fClearMask = 0;
|
2013-09-10 23:23:38 +04:00
|
|
|
fLoops = 1;
|
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
|
|
|
|
2013-05-29 19:39:54 +04:00
|
|
|
paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-22 22:50:13 +03:00
|
|
|
|
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
|
|
|
}
|