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.
|
|
|
|
*/
|
2014-06-18 21:32:48 +00:00
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
#include "Benchmark.h"
|
2014-06-18 21:32:48 +00:00
|
|
|
|
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;
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
Benchmark::Benchmark() {
|
2009-01-19 20:08:35 +00:00
|
|
|
fForceAlpha = 0xFF;
|
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
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
const char* Benchmark::getName() {
|
2009-01-05 03:34:50 +00:00
|
|
|
return this->onGetName();
|
|
|
|
}
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
SkIPoint Benchmark::getSize() {
|
2009-01-05 03:34:50 +00:00
|
|
|
return this->onGetSize();
|
|
|
|
}
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
void Benchmark::preDraw() {
|
2012-08-13 14:03:31 +00:00
|
|
|
this->onPreDraw();
|
|
|
|
}
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
void Benchmark::draw(const int loops, SkCanvas* canvas) {
|
2013-12-03 18:17:16 +00:00
|
|
|
this->onDraw(loops, canvas);
|
2009-01-05 03:34:50 +00:00
|
|
|
}
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
void Benchmark::setupPaint(SkPaint* paint) {
|
2009-01-19 20:08:35 +00:00
|
|
|
paint->setAlpha(fForceAlpha);
|
2014-07-09 19:25:27 +00:00
|
|
|
paint->setAntiAlias(true);
|
|
|
|
paint->setFilterLevel(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
|
|
|
}
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
SkIPoint Benchmark::onGetSize() {
|
2010-02-22 19:50:13 +00:00
|
|
|
return SkIPoint::Make(640, 480);
|
2009-01-26 23:15:37 +00:00
|
|
|
}
|