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