OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "Benchmark.h" | 7 #include "Benchmark.h" |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkColorCubeFilter.h" | 9 #include "SkColorCubeFilter.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 return "colorcube"; | 31 return "colorcube"; |
32 } | 32 } |
33 | 33 |
34 void onDelayedSetup() override { | 34 void onDelayedSetup() override { |
35 if (!SkToBool(fCubeData)) { | 35 if (!SkToBool(fCubeData)) { |
36 this->makeCubeData(); | 36 this->makeCubeData(); |
37 this->make_bitmap(); | 37 this->make_bitmap(); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 void onDraw(const int loops, SkCanvas* canvas) override { | 41 void onDraw(int loops, SkCanvas* canvas) override { |
42 this->test(loops, canvas); | 42 this->test(loops, canvas); |
43 } | 43 } |
44 | 44 |
45 SkIPoint onGetSize() override { | 45 SkIPoint onGetSize() override { |
46 return SkIPoint::Make(fSize.width(), fSize.height()); | 46 return SkIPoint::Make(fSize.width(), fSize.height()); |
47 } | 47 } |
48 | 48 |
49 private: | 49 private: |
50 static SkShader* MakeLinear(const SkISize& size) { | 50 static SkShader* MakeLinear(const SkISize& size) { |
51 const SkPoint pts[2] = { | 51 const SkPoint pts[2] = { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 for (int r = 0; r < fCubeDimension; ++r) { | 86 for (int r = 0; r < fCubeDimension; ++r) { |
87 for (int g = 0; g < fCubeDimension; ++g) { | 87 for (int g = 0; g < fCubeDimension; ++g) { |
88 for (int b = 0; b < fCubeDimension; ++b) { | 88 for (int b = 0; b < fCubeDimension; ++b) { |
89 pixels[(fCubeDimension * ((fCubeDimension * b) + g)) + r] = | 89 pixels[(fCubeDimension * ((fCubeDimension * b) + g)) + r] = |
90 SkColorSetARGB(0xFF, lut[r], lut[g], lut[b]); | 90 SkColorSetARGB(0xFF, lut[r], lut[g], lut[b]); |
91 } | 91 } |
92 } | 92 } |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 void test(const int loops, SkCanvas* canvas) { | 96 void test(int loops, SkCanvas* canvas) { |
97 SkPaint paint; | 97 SkPaint paint; |
98 for (int i = 0; i < loops; i++) { | 98 for (int i = 0; i < loops; i++) { |
99 SkAutoTUnref<SkColorFilter> colorCube( | 99 SkAutoTUnref<SkColorFilter> colorCube( |
100 SkColorCubeFilter::Create(fCubeData, fCubeDimension)); | 100 SkColorCubeFilter::Create(fCubeData, fCubeDimension)); |
101 paint.setColorFilter(colorCube); | 101 paint.setColorFilter(colorCube); |
102 canvas->drawBitmap(fBitmap, 0, 0, &paint); | 102 canvas->drawBitmap(fBitmap, 0, 0, &paint); |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 typedef Benchmark INHERITED; | 106 typedef Benchmark INHERITED; |
107 }; | 107 }; |
108 | 108 |
109 /////////////////////////////////////////////////////////////////////////////// | 109 /////////////////////////////////////////////////////////////////////////////// |
110 | 110 |
111 DEF_BENCH( return new ColorCubeBench(); ) | 111 DEF_BENCH( return new ColorCubeBench(); ) |
OLD | NEW |