| 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 SkShader* createShader() { | 153 sk_sp<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::CreateLinear(pts, colors, nullptr, | 160 return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT
(colors), |
| 161 SK_ARRAY_COUNT(colors), | 161 SkShader::kMirror_TileMode); |
| 162 SkShader::kMirror_TileMode); | |
| 163 } | 162 } |
| 164 | 163 |
| 165 protected: | 164 protected: |
| 166 const char* onGetName() override { | 165 const char* onGetName() override { |
| 167 SkString vertexMode; | 166 SkString vertexMode; |
| 168 switch (fVertexMode) { | 167 switch (fVertexMode) { |
| 169 case kNone_VertexMode: | 168 case kNone_VertexMode: |
| 170 vertexMode.set("meshlines"); | 169 vertexMode.set("meshlines"); |
| 171 break; | 170 break; |
| 172 case kColors_VertexMode: | 171 case kColors_VertexMode: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 198 } | 197 } |
| 199 fName.printf("patch_grid_%s_%s", vertexMode.c_str(), size.c_str()); | 198 fName.printf("patch_grid_%s_%s", vertexMode.c_str(), size.c_str()); |
| 200 return fName.c_str(); | 199 return fName.c_str(); |
| 201 } | 200 } |
| 202 | 201 |
| 203 void onDelayedSetup() override { | 202 void onDelayedSetup() override { |
| 204 this->setGrid(); | 203 this->setGrid(); |
| 205 switch (fVertexMode) { | 204 switch (fVertexMode) { |
| 206 case kTexCoords_VertexMode: | 205 case kTexCoords_VertexMode: |
| 207 case kBoth_VertexMode: | 206 case kBoth_VertexMode: |
| 208 fPaint.setShader(createShader())->unref(); | 207 fPaint.setShader(createShader()); |
| 209 break; | 208 break; |
| 210 default: | 209 default: |
| 211 fPaint.setShader(nullptr); | 210 fPaint.setShader(nullptr); |
| 212 break; | 211 break; |
| 213 } | 212 } |
| 214 this->setupPaint(&fPaint); | 213 this->setupPaint(&fPaint); |
| 215 } | 214 } |
| 216 | 215 |
| 217 void onDraw(int loops, SkCanvas* canvas) override { | 216 void onDraw(int loops, SkCanvas* canvas) override { |
| 218 this->setScale(canvas); | 217 this->setScale(canvas); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 DEF_BENCH( return new PatchGridBench(PatchGridBench::kMedium_Size, | 249 DEF_BENCH( return new PatchGridBench(PatchGridBench::kMedium_Size, |
| 251 PatchGridBench::kBoth_VertexMode); ) | 250 PatchGridBench::kBoth_VertexMode); ) |
| 252 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, | 251 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, |
| 253 PatchGridBench::kNone_VertexMode); ) | 252 PatchGridBench::kNone_VertexMode); ) |
| 254 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, | 253 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, |
| 255 PatchGridBench::kColors_VertexMode); ) | 254 PatchGridBench::kColors_VertexMode); ) |
| 256 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, | 255 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, |
| 257 PatchGridBench::kTexCoords_VertexMode); ) | 256 PatchGridBench::kTexCoords_VertexMode); ) |
| 258 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, | 257 DEF_BENCH( return new PatchGridBench(PatchGridBench::kBig_Size, |
| 259 PatchGridBench::kBoth_VertexMode); ) | 258 PatchGridBench::kBoth_VertexMode); ) |
| OLD | NEW |