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