epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 8 | #include "SkBenchmark.h" |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 9 | #include "SkPaint.h" |
reed@android.com | 0c9da39 | 2010-02-22 19:50:13 +0000 | [diff] [blame] | 10 | #include "SkParse.h" |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 11 | |
mtklein@google.com | c289743 | 2013-09-10 19:23:38 +0000 | [diff] [blame^] | 12 | const char* SkTriState::Name[] = { "default", "true", "false" }; |
| 13 | |
robertphillips@google.com | 15e9d3e | 2012-06-21 20:25:03 +0000 | [diff] [blame] | 14 | SK_DEFINE_INST_COUNT(SkBenchmark) |
| 15 | |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 16 | template BenchRegistry* BenchRegistry::gHead; |
| 17 | |
mtklein@google.com | c289743 | 2013-09-10 19:23:38 +0000 | [diff] [blame^] | 18 | SkBenchmark::SkBenchmark(void* /*ignored*/) { |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 19 | fForceAlpha = 0xFF; |
| 20 | fForceAA = true; |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame] | 21 | fDither = SkTriState::kDefault; |
tomhudson@google.com | 9dc2713 | 2012-09-13 15:50:24 +0000 | [diff] [blame] | 22 | fIsRendering = true; |
reed@google.com | ef77ec2 | 2013-05-29 15:39:54 +0000 | [diff] [blame] | 23 | fOrMask = fClearMask = 0; |
mtklein@google.com | c289743 | 2013-09-10 19:23:38 +0000 | [diff] [blame^] | 24 | fLoops = 1; |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 25 | } |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 26 | |
| 27 | const char* SkBenchmark::getName() { |
| 28 | return this->onGetName(); |
| 29 | } |
| 30 | |
| 31 | SkIPoint SkBenchmark::getSize() { |
| 32 | return this->onGetSize(); |
| 33 | } |
| 34 | |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 35 | void SkBenchmark::preDraw() { |
| 36 | this->onPreDraw(); |
| 37 | } |
| 38 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 39 | void SkBenchmark::draw(SkCanvas* canvas) { |
| 40 | this->onDraw(canvas); |
| 41 | } |
| 42 | |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 43 | void SkBenchmark::postDraw() { |
| 44 | this->onPostDraw(); |
| 45 | } |
| 46 | |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 47 | void SkBenchmark::setupPaint(SkPaint* paint) { |
| 48 | paint->setAlpha(fForceAlpha); |
| 49 | paint->setAntiAlias(fForceAA); |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 50 | paint->setFilterBitmap(fForceFilter); |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame] | 51 | |
reed@google.com | ef77ec2 | 2013-05-29 15:39:54 +0000 | [diff] [blame] | 52 | paint->setFlags((paint->getFlags() & ~fClearMask) | fOrMask); |
| 53 | |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame] | 54 | if (SkTriState::kDefault != fDither) { |
| 55 | paint->setDither(SkTriState::kTrue == fDither); |
| 56 | } |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 57 | } |
| 58 | |
reed@android.com | 0c9da39 | 2010-02-22 19:50:13 +0000 | [diff] [blame] | 59 | |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 60 | /////////////////////////////////////////////////////////////////////////////// |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 61 | |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 62 | SkIPoint SkBenchmark::onGetSize() { |
reed@android.com | 0c9da39 | 2010-02-22 19:50:13 +0000 | [diff] [blame] | 63 | return SkIPoint::Make(640, 480); |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 64 | } |