| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 SkShader* fShaders[NUM_DRAWS]; | 88 SkShader* fShaders[NUM_DRAWS]; |
| 89 | 89 |
| 90 SkString fName; | 90 SkString fName; |
| 91 ColorPatternData fPattern1; | 91 ColorPatternData fPattern1; |
| 92 ColorPatternData fPattern2; | 92 ColorPatternData fPattern2; |
| 93 DrawType fDrawType; | 93 DrawType fDrawType; |
| 94 SkBitmap fBmp; | 94 SkBitmap fBmp; |
| 95 | 95 |
| 96 | 96 |
| 97 AlternatingColorPatternBench(ColorPattern pattern1, ColorPattern pattern2, D
rawType drawType) | 97 AlternatingColorPatternBench(ColorPattern pattern1, ColorPattern pattern2, D
rawType drawType) |
| 98 : fBmShader(NULL) { | 98 : fBmShader(nullptr) { |
| 99 fPattern1 = gColorPatterns[pattern1]; | 99 fPattern1 = gColorPatterns[pattern1]; |
| 100 fPattern2 = gColorPatterns[pattern2]; | 100 fPattern2 = gColorPatterns[pattern2]; |
| 101 fName.printf("colorPattern_%s_%s_%s", | 101 fName.printf("colorPattern_%s_%s_%s", |
| 102 fPattern1.fName, fPattern2.fName, | 102 fPattern1.fName, fPattern2.fName, |
| 103 kRect_DrawType == drawType ? "rect" : "path"); | 103 kRect_DrawType == drawType ? "rect" : "path"); |
| 104 fDrawType = drawType; | 104 fDrawType = drawType; |
| 105 } | 105 } |
| 106 | 106 |
| 107 virtual ~AlternatingColorPatternBench() { | 107 virtual ~AlternatingColorPatternBench() { |
| 108 SkSafeUnref(fBmShader); | 108 SkSafeUnref(fBmShader); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 130 fRects[count].set(SkIntToScalar(x), SkIntToScalar(y), | 130 fRects[count].set(SkIntToScalar(x), SkIntToScalar(y), |
| 131 SkIntToScalar(x + w), SkIntToScalar(y + h)
); | 131 SkIntToScalar(x + w), SkIntToScalar(y + h)
); |
| 132 } else { | 132 } else { |
| 133 fPaths[count].moveTo(SkIntToScalar(x), SkIntToScalar(y)); | 133 fPaths[count].moveTo(SkIntToScalar(x), SkIntToScalar(y)); |
| 134 fPaths[count].rLineTo(SkIntToScalar(w), 0); | 134 fPaths[count].rLineTo(SkIntToScalar(w), 0); |
| 135 fPaths[count].rLineTo(0, SkIntToScalar(h)); | 135 fPaths[count].rLineTo(0, SkIntToScalar(h)); |
| 136 fPaths[count].rLineTo(SkIntToScalar(-w + 1), 0); | 136 fPaths[count].rLineTo(SkIntToScalar(-w + 1), 0); |
| 137 } | 137 } |
| 138 if (0 == count % 2) { | 138 if (0 == count % 2) { |
| 139 fColors[count] = fPattern1.fColor; | 139 fColors[count] = fPattern1.fColor; |
| 140 fShaders[count] = fPattern1.fIsBitmap ? fBmShader : NULL; | 140 fShaders[count] = fPattern1.fIsBitmap ? fBmShader : nullptr; |
| 141 } else { | 141 } else { |
| 142 fColors[count] = fPattern2.fColor; | 142 fColors[count] = fPattern2.fColor; |
| 143 fShaders[count] = fPattern2.fIsBitmap ? fBmShader : NULL; | 143 fShaders[count] = fPattern2.fIsBitmap ? fBmShader : nullptr; |
| 144 } | 144 } |
| 145 ++count; | 145 ++count; |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 void onDraw(const int loops, SkCanvas* canvas) override { | 150 void onDraw(const int loops, SkCanvas* canvas) override { |
| 151 SkPaint paint; | 151 SkPaint paint; |
| 152 paint.setAntiAlias(false); | 152 paint.setAntiAlias(false); |
| 153 paint.setFilterQuality(kLow_SkFilterQuality); | 153 paint.setFilterQuality(kLow_SkFilterQuality); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 DEF_BENCH(return new AlternatingColorPatternBench(kOpaqueBitmap_ColorPattern, | 192 DEF_BENCH(return new AlternatingColorPatternBench(kOpaqueBitmap_ColorPattern, |
| 193 kOpaqueBitmap_ColorPattern, | 193 kOpaqueBitmap_ColorPattern, |
| 194 kRect_DrawType);) | 194 kRect_DrawType);) |
| 195 DEF_BENCH(return new AlternatingColorPatternBench(kAlphaBitmap_ColorPattern, | 195 DEF_BENCH(return new AlternatingColorPatternBench(kAlphaBitmap_ColorPattern, |
| 196 kAlphaBitmap_ColorPattern, | 196 kAlphaBitmap_ColorPattern, |
| 197 kRect_DrawType);) | 197 kRect_DrawType);) |
| 198 DEF_BENCH(return new AlternatingColorPatternBench(kOpaqueBitmap_ColorPattern, | 198 DEF_BENCH(return new AlternatingColorPatternBench(kOpaqueBitmap_ColorPattern, |
| 199 kAlphaBitmap_ColorPattern, | 199 kAlphaBitmap_ColorPattern, |
| 200 kRect_DrawType);) | 200 kRect_DrawType);) |
| OLD | NEW |