OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 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 |
| 9 #ifndef CpuWrappedBenchmark_DEFINED |
| 10 #define CpuWrappedBenchmark_DEFINED |
| 11 |
| 12 #include "Benchmark.h" |
| 13 #include "SkSurface.h" |
| 14 |
| 15 class CpuWrappedBenchmark : public Benchmark { |
| 16 public: |
| 17 // Takes ownership of caller's ref on `bench`. |
| 18 explicit CpuWrappedBenchmark(Benchmark* bench) : fBench(bench) {} |
| 19 |
| 20 const char* onGetName() override { return fBench->getName(); } |
| 21 const char* onGetUniqueName() override { return fBench->getUniqueName(); } |
| 22 |
| 23 void onDraw(int loops, SkCanvas* canvas) override { |
| 24 // TODO: use onPreDraw() to move offscreen allocation/deallocation out o
f timing. |
| 25 SkAutoTUnref<SkSurface> offscreen(SkSurface::NewRaster(canvas->imageInfo
())); |
| 26 |
| 27 fBench->draw(loops, offscreen->getCanvas()); |
| 28 SkAutoTUnref<SkImage> image(offscreen->newImageSnapshot()); |
| 29 canvas->drawImage(image, 0,0); |
| 30 } |
| 31 |
| 32 private: |
| 33 SkAutoTUnref<Benchmark> fBench; |
| 34 }; |
| 35 |
| 36 #endif//CpuWrappedBenchmark_DEFINED |
OLD | NEW |