| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 fGrid.setPatch(j, i, points, colors, texs); | 143 fGrid.setPatch(j, i, points, colors, texs); |
| 144 break; | 144 break; |
| 145 default: | 145 default: |
| 146 break; | 146 break; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 // override this method to change the shader | 152 // override this method to change the shader |
| 153 sk_sp<SkShader> createShader() { | 153 SkShader* createShader() { |
| 154 const SkColor colors[] = { | 154 const SkColor colors[] = { |
| 155 SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE, | 155 SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE, |
| 156 SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW, | 156 SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW, |
| 157 }; | 157 }; |
| 158 const SkPoint pts[] = { { 200.f / 4.f, 0.f }, { 3.f * 200.f / 4, 200.f }
}; | 158 const SkPoint pts[] = { { 200.f / 4.f, 0.f }, { 3.f * 200.f / 4, 200.f }
}; |
| 159 | 159 |
| 160 return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT
(colors), | 160 return SkGradientShader::CreateLinear(pts, colors, nullptr, |
| 161 SkShader::kMirror_TileMode); | 161 SK_ARRAY_COUNT(colors), |
| 162 SkShader::kMirror_TileMode); |
| 162 } | 163 } |
| 163 | 164 |
| 164 protected: | 165 protected: |
| 165 const char* onGetName() override { | 166 const char* onGetName() override { |
| 166 SkString vertexMode; | 167 SkString vertexMode; |
| 167 switch (fVertexMode) { | 168 switch (fVertexMode) { |
| 168 case kNone_VertexMode: | 169 case kNone_VertexMode: |
| 169 vertexMode.set("meshlines"); | 170 vertexMode.set("meshlines"); |
| 170 break; | 171 break; |
| 171 case kColors_VertexMode: | 172 case kColors_VertexMode: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 197 } | 198 } |
| 198 fName.printf("patch_grid_%s_%s", vertexMode.c_str(), size.c_str()); | 199 fName.printf("patch_grid_%s_%s", vertexMode.c_str(), size.c_str()); |
| 199 return fName.c_str(); | 200 return fName.c_str(); |
| 200 } | 201 } |
| 201 | 202 |
| 202 void onDelayedSetup() override { | 203 void onDelayedSetup() override { |
| 203 this->setGrid(); | 204 this->setGrid(); |
| 204 switch (fVertexMode) { | 205 switch (fVertexMode) { |
| 205 case kTexCoords_VertexMode: | 206 case kTexCoords_VertexMode: |
| 206 case kBoth_VertexMode: | 207 case kBoth_VertexMode: |
| 207 fPaint.setShader(createShader()); | 208 fPaint.setShader(createShader())->unref(); |
| 208 break; | 209 break; |
| 209 default: | 210 default: |
| 210 fPaint.setShader(nullptr); | 211 fPaint.setShader(nullptr); |
| 211 break; | 212 break; |
| 212 } | 213 } |
| 213 this->setupPaint(&fPaint); | 214 this->setupPaint(&fPaint); |
| 214 } | 215 } |
| 215 | 216 |
| 216 void onDraw(int loops, SkCanvas* canvas) override { | 217 void onDraw(int loops, SkCanvas* canvas) override { |
| 217 this->setScale(canvas); | 218 this->setScale(canvas); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 DEF_BENCH( return new PatchGridBench(PatchGridBench::kMedium_Size, | 250 DEF_BENCH( return new PatchGridBench(PatchGridBench::kMedium_Size, |
| 250 PatchGridBench::kBoth_VertexMode); ) | 251 PatchGridBench::kBoth_VertexMode); ) |
| 251 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, | 252 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, |
| 252 PatchGridBench::kNone_VertexMode); ) | 253 PatchGridBench::kNone_VertexMode); ) |
| 253 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, | 254 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, |
| 254 PatchGridBench::kColors_VertexMode); ) | 255 PatchGridBench::kColors_VertexMode); ) |
| 255 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, | 256 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, |
| 256 PatchGridBench::kTexCoords_VertexMode); ) | 257 PatchGridBench::kTexCoords_VertexMode); ) |
| 257 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, | 258 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, |
| 258 PatchGridBench::kBoth_VertexMode); ) | 259 PatchGridBench::kBoth_VertexMode); ) |
| OLD | NEW |