1/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "Benchmark.h"
9
10#include "SkPaint.h"
11#include "SkParse.h"
12
13const char* SkTriState::Name[] = { "default", "true", "false" };
14
15template BenchRegistry* BenchRegistry::gHead;
16
17Benchmark::Benchmark() {
18    fForceAlpha = 0xFF;
19    fDither = SkTriState::kDefault;
20    fOrMask = fClearMask = 0;
21}
22
23const char* Benchmark::getName() {
24    return this->onGetName();
25}
26
27const char* Benchmark::getUniqueName() {
28    return this->onGetUniqueName();
29}
30
31SkIPoint Benchmark::getSize() {
32    return this->onGetSize();
33}
34
35void Benchmark::preDraw() {
36    this->onPreDraw();
37}
38
39void Benchmark::draw(const int loops, SkCanvas* canvas) {
40    this->onDraw(loops, canvas);
41}
42
43void Benchmark::setupPaint(SkPaint* paint) {
44    paint->setAlpha(fForceAlpha);
45    paint->setAntiAlias(true);
46    paint->setFilterLevel(SkPaint::kNone_FilterLevel);
47
48    paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask);
49
50    if (SkTriState::kDefault != fDither) {
51        paint->setDither(SkTriState::kTrue == fDither);
52    }
53}
54
55SkIPoint Benchmark::onGetSize() {
56    return SkIPoint::Make(640, 480);
57}
58