OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkTileImageFilter.h" | 9 #include "SkTileImageFilter.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 protected: | 33 protected: |
34 const char* onGetName() override { | 34 const char* onGetName() override { |
35 return fName.c_str(); | 35 return fName.c_str(); |
36 } | 36 } |
37 | 37 |
38 void onDraw(int loops, SkCanvas* canvas) override { | 38 void onDraw(int loops, SkCanvas* canvas) override { |
39 SkPaint paint; | 39 SkPaint paint; |
40 SkAutoTUnref<SkImageFilter> tile(SkTileImageFilter::Create( | 40 paint.setImageFilter(SkTileImageFilter::Make(SkRect::MakeWH(50, 50), |
41 SkRect::MakeWH(50, 50), | 41 SkRect::MakeWH(WIDTH, HEIGH
T), |
42 SkRect::MakeWH(WIDTH, HEIGHT), | 42 nullptr)); |
43 nullptr)); | |
44 paint.setImageFilter(tile); | |
45 | 43 |
46 for (int i = 0; i < loops; i++) { | 44 for (int i = 0; i < loops; i++) { |
47 if (fTileSize > 0) { | 45 if (fTileSize > 0) { |
48 for (int y = 0; y < HEIGHT; y += fTileSize) { | 46 for (int y = 0; y < HEIGHT; y += fTileSize) { |
49 for (int x = 0; x < WIDTH; x += fTileSize) { | 47 for (int x = 0; x < WIDTH; x += fTileSize) { |
50 canvas->save(); | 48 canvas->save(); |
51 SkIRect clipIRect = SkIRect::MakeXYWH(x, y, fTileSize, f
TileSize); | 49 SkIRect clipIRect = SkIRect::MakeXYWH(x, y, fTileSize, f
TileSize); |
52 canvas->clipRect(SkRect::Make(clipIRect)); | 50 canvas->clipRect(SkRect::Make(clipIRect)); |
53 canvas->drawRect(SkRect::MakeWH(WIDTH, HEIGHT), paint); | 51 canvas->drawRect(SkRect::MakeWH(WIDTH, HEIGHT), paint); |
54 canvas->restore(); | 52 canvas->restore(); |
55 } | 53 } |
56 } | 54 } |
57 } else { | 55 } else { |
58 canvas->drawRect(SkRect::MakeWH(WIDTH, HEIGHT), paint); | 56 canvas->drawRect(SkRect::MakeWH(WIDTH, HEIGHT), paint); |
59 } | 57 } |
60 } | 58 } |
61 } | 59 } |
62 | 60 |
63 private: | 61 private: |
64 SkString fName; | 62 SkString fName; |
65 // Note: this is the tile size used for tiled rendering, not for the size | 63 // Note: this is the tile size used for tiled rendering, not for the size |
66 // of the SkTileImageFilter source rect. | 64 // of the SkTileImageFilter source rect. |
67 int fTileSize; | 65 int fTileSize; |
68 typedef Benchmark INHERITED; | 66 typedef Benchmark INHERITED; |
69 }; | 67 }; |
70 | 68 |
71 DEF_BENCH(return new TileImageFilterBench(0);) | 69 DEF_BENCH(return new TileImageFilterBench(0);) |
72 DEF_BENCH(return new TileImageFilterBench(32);) | 70 DEF_BENCH(return new TileImageFilterBench(32);) |
73 DEF_BENCH(return new TileImageFilterBench(64);) | 71 DEF_BENCH(return new TileImageFilterBench(64);) |
OLD | NEW |