OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkImage.h" | 10 #include "SkImage.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 // create an Image reflecting the canvas (gpu or cpu) | 32 // create an Image reflecting the canvas (gpu or cpu) |
33 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); | 33 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); |
34 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); | 34 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); |
35 canvas->drawColor(SK_ColorRED); | 35 canvas->drawColor(SK_ColorRED); |
36 fImage.reset(surface->newImageSnapshot()); | 36 fImage.reset(surface->newImageSnapshot()); |
37 | 37 |
38 // create a cpu-backed Surface | 38 // create a cpu-backed Surface |
39 fRasterSurface.reset(SkSurface::NewRaster(info)); | 39 fRasterSurface.reset(SkSurface::NewRaster(info)); |
40 } | 40 } |
41 | 41 |
42 void onDraw(const int loops, SkCanvas*) override { | 42 void onDraw(int loops, SkCanvas*) override { |
43 for (int i = 0; i < loops; i++) { | 43 for (int i = 0; i < loops; i++) { |
44 for (int inner = 0; inner < 10; ++inner) { | 44 for (int inner = 0; inner < 10; ++inner) { |
45 fRasterSurface->getCanvas()->drawImage(fImage, 0, 0); | 45 fRasterSurface->getCanvas()->drawImage(fImage, 0, 0); |
46 } | 46 } |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 private: | 50 private: |
51 SkString fName; | 51 SkString fName; |
52 SkAutoTUnref<SkImage> fImage; | 52 SkAutoTUnref<SkImage> fImage; |
53 SkAutoTUnref<SkSurface> fRasterSurface; | 53 SkAutoTUnref<SkSurface> fRasterSurface; |
54 | 54 |
55 typedef Benchmark INHERITED; | 55 typedef Benchmark INHERITED; |
56 }; | 56 }; |
57 | 57 |
58 | 58 |
59 DEF_BENCH( return new Image2RasterBench; ) | 59 DEF_BENCH( return new Image2RasterBench; ) |
OLD | NEW |