epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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 | */ |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 7 | #include "SkBenchmark.h" |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 8 | #include "SkPaint.h" |
reed@android.com | 0c9da39 | 2010-02-22 19:50:13 +0000 | [diff] [blame] | 9 | #include "SkParse.h" |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 10 | |
mtklein@google.com | c289743 | 2013-09-10 19:23:38 +0000 | [diff] [blame] | 11 | const char* SkTriState::Name[] = { "default", "true", "false" }; |
| 12 | |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 13 | template BenchRegistry* BenchRegistry::gHead; |
| 14 | |
scroggo@google.com | 111fd11 | 2013-09-25 21:42:12 +0000 | [diff] [blame] | 15 | SkString SkBenchmark::gResourcePath; |
| 16 | |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 17 | SkBenchmark::SkBenchmark() { |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 18 | fForceAlpha = 0xFF; |
| 19 | fForceAA = true; |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 20 | fForceFilter = false; |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame] | 21 | fDither = SkTriState::kDefault; |
reed@google.com | ef77ec2 | 2013-05-29 15:39:54 +0000 | [diff] [blame] | 22 | fOrMask = fClearMask = 0; |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 23 | } |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 24 | |
| 25 | const char* SkBenchmark::getName() { |
| 26 | return this->onGetName(); |
| 27 | } |
| 28 | |
| 29 | SkIPoint SkBenchmark::getSize() { |
| 30 | return this->onGetSize(); |
| 31 | } |
| 32 | |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 33 | void SkBenchmark::preDraw() { |
| 34 | this->onPreDraw(); |
| 35 | } |
| 36 | |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 37 | void SkBenchmark::draw(const int loops, SkCanvas* canvas) { |
| 38 | this->onDraw(loops, canvas); |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 39 | } |
| 40 | |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 41 | void SkBenchmark::postDraw() { |
| 42 | this->onPostDraw(); |
| 43 | } |
| 44 | |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 45 | void SkBenchmark::setupPaint(SkPaint* paint) { |
| 46 | paint->setAlpha(fForceAlpha); |
| 47 | paint->setAntiAlias(fForceAA); |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 48 | paint->setFilterLevel(fForceFilter ? SkPaint::kLow_FilterLevel |
| 49 | : SkPaint::kNone_FilterLevel); |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame] | 50 | |
reed@google.com | ef77ec2 | 2013-05-29 15:39:54 +0000 | [diff] [blame] | 51 | paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask); |
| 52 | |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame] | 53 | if (SkTriState::kDefault != fDither) { |
| 54 | paint->setDither(SkTriState::kTrue == fDither); |
| 55 | } |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 56 | } |
| 57 | |
reed@android.com | 0c9da39 | 2010-02-22 19:50:13 +0000 | [diff] [blame] | 58 | |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 59 | /////////////////////////////////////////////////////////////////////////////// |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 60 | |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 61 | SkIPoint SkBenchmark::onGetSize() { |
reed@android.com | 0c9da39 | 2010-02-22 19:50:13 +0000 | [diff] [blame] | 62 | return SkIPoint::Make(640, 480); |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 63 | } |