| 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 "bench/Benchmark.h" |
| 9 |
|
| 10 |
#include "include/core/SkCanvas.h" |
| 11 |
#include "include/core/SkPaint.h" |
| 12 |
#include "include/utils/SkParse.h" |
| 13 |
|
| 14 |
template BenchRegistry* BenchRegistry::gHead; |
| 15 |
|
| 16 |
Benchmark::Benchmark() {} |
| 17 |
|
| 18 |
const char* Benchmark::getName() { |
| 19 |
return this->onGetName(); |
| 20 |
} |
| 21 |
|
| 22 |
const char* Benchmark::getUniqueName() { |
| 23 |
return this->onGetUniqueName(); |
| 24 |
} |
| 25 |
|
| 26 |
SkISize Benchmark::getSize() { |
| 27 |
return this->onGetSize(); |
| 28 |
} |
| 29 |
|
| 30 |
void Benchmark::delayedSetup() { |
| 31 |
this->onDelayedSetup(); |
| 32 |
} |
| 33 |
|
| 34 |
void Benchmark::perCanvasPreDraw(SkCanvas* canvas) { |
| 35 |
this->onPerCanvasPreDraw(canvas); |
| 36 |
} |
| 37 |
|
| 38 |
void Benchmark::preDraw(SkCanvas* canvas) { |
| 39 |
this->onPreDraw(canvas); |
| 40 |
} |
| 41 |
|
| 42 |
void Benchmark::postDraw(SkCanvas* canvas) { |
| 43 |
this->onPostDraw(canvas); |
| 44 |
} |
| 45 |
|
| 46 |
void Benchmark::perCanvasPostDraw(SkCanvas* canvas) { |
| 47 |
this->onPerCanvasPostDraw(canvas); |
| 48 |
} |
| 49 |
|
| 50 |
void Benchmark::draw(int loops, SkCanvas* canvas, std::function<void()> submitFrame) { |
| 51 |
SkAutoCanvasRestore ar(canvas, true/*save now*/); |
| 52 |
if (this->submitsInternalFrames()) { |
| 53 |
this->onDrawFrame(loops, canvas, std::move(submitFrame)); |
| 54 |
} else { |
| 55 |
this->onDraw(loops, canvas); |
| 56 |
if (submitFrame) { |
| 57 |
submitFrame(); |
| 58 |
} |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
void Benchmark::setupPaint(SkPaint* paint) { |
| 63 |
paint->setAntiAlias(true); |
| 64 |
} |
| 65 |
|
| 66 |
SkISize Benchmark::onGetSize() { |
| 67 |
return SkISize::Make(640, 480); |
| 68 |
} |