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 | 7 |
8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 fPattern1.fName, fPattern2.fName, | 101 fPattern1.fName, fPattern2.fName, |
102 kRect_DrawType == drawType ? "rect" : "path"); | 102 kRect_DrawType == drawType ? "rect" : "path"); |
103 fDrawType = drawType; | 103 fDrawType = drawType; |
104 } | 104 } |
105 | 105 |
106 virtual ~AlternatingColorPatternBench() { | 106 virtual ~AlternatingColorPatternBench() { |
107 SkSafeUnref(fBmShader); | 107 SkSafeUnref(fBmShader); |
108 } | 108 } |
109 | 109 |
110 protected: | 110 protected: |
111 const char* onGetName() SK_OVERRIDE { | 111 const char* onGetName() override { |
112 return fName.c_str(); | 112 return fName.c_str(); |
113 } | 113 } |
114 | 114 |
115 virtual void onPreDraw() { | 115 virtual void onPreDraw() { |
116 int w = 40; | 116 int w = 40; |
117 int h = 40; | 117 int h = 40; |
118 makebm(&fBmp, w, h); | 118 makebm(&fBmp, w, h); |
119 fBmShader = SkShader::CreateBitmapShader(fBmp, | 119 fBmShader = SkShader::CreateBitmapShader(fBmp, |
120 SkShader::kRepeat_TileMode, | 120 SkShader::kRepeat_TileMode, |
121 SkShader::kRepeat_TileMode); | 121 SkShader::kRepeat_TileMode); |
(...skipping 17 matching lines...) Expand all Loading... |
139 fShaders[count] = fPattern1.fIsBitmap ? fBmShader : NULL; | 139 fShaders[count] = fPattern1.fIsBitmap ? fBmShader : NULL; |
140 } else { | 140 } else { |
141 fColors[count] = fPattern2.fColor; | 141 fColors[count] = fPattern2.fColor; |
142 fShaders[count] = fPattern2.fIsBitmap ? fBmShader : NULL; | 142 fShaders[count] = fPattern2.fIsBitmap ? fBmShader : NULL; |
143 } | 143 } |
144 ++count; | 144 ++count; |
145 } | 145 } |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 149 void onDraw(const int loops, SkCanvas* canvas) override { |
150 SkPaint paint; | 150 SkPaint paint; |
151 paint.setAntiAlias(false); | 151 paint.setAntiAlias(false); |
152 paint.setFilterQuality(kLow_SkFilterQuality); | 152 paint.setFilterQuality(kLow_SkFilterQuality); |
153 | 153 |
154 for (int i = 0; i < loops; ++i) { | 154 for (int i = 0; i < loops; ++i) { |
155 for (int j = 0; j < NUM_DRAWS; ++j) { | 155 for (int j = 0; j < NUM_DRAWS; ++j) { |
156 paint.setColor(fColors[j]); | 156 paint.setColor(fColors[j]); |
157 paint.setShader(fShaders[j]); | 157 paint.setShader(fShaders[j]); |
158 if (kRect_DrawType == fDrawType) { | 158 if (kRect_DrawType == fDrawType) { |
159 canvas->drawRect(fRects[j], paint); | 159 canvas->drawRect(fRects[j], paint); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench, | 191 DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench, |
192 (kOpaqueBitmap_ColorPattern, kOpaqueBitmap_ColorPat
tern, | 192 (kOpaqueBitmap_ColorPattern, kOpaqueBitmap_ColorPat
tern, |
193 kRect_DrawType)); ) | 193 kRect_DrawType)); ) |
194 DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench, | 194 DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench, |
195 (kAlphaBitmap_ColorPattern, kAlphaBitmap_ColorPatte
rn, | 195 (kAlphaBitmap_ColorPattern, kAlphaBitmap_ColorPatte
rn, |
196 kRect_DrawType)); ) | 196 kRect_DrawType)); ) |
197 DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench, | 197 DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench, |
198 (kOpaqueBitmap_ColorPattern, kAlphaBitmap_ColorPatt
ern, | 198 (kOpaqueBitmap_ColorPattern, kAlphaBitmap_ColorPatt
ern, |
199 kRect_DrawType)); ) | 199 kRect_DrawType)); ) |
200 | 200 |
OLD | NEW |