| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkPaint.h" | 10 #include "SkPaint.h" |
| 11 #include "SkRandom.h" | 11 #include "SkRandom.h" |
| 12 #include "SkShader.h" | 12 #include "SkShader.h" |
| 13 #include "SkString.h" | 13 #include "SkString.h" |
| 14 | 14 |
| 15 #if SK_SUPPORT_GPU | |
| 16 #include "GrDrawTargetCaps.h" | |
| 17 #include "GrTest.h" | |
| 18 #endif | |
| 19 | |
| 20 enum Flags { | 15 enum Flags { |
| 21 kBig_Flag = 1 << 0, | 16 kBig_Flag = 1 << 0, |
| 22 kAA_Flag = 1 << 1 | 17 kAA_Flag = 1 << 1 |
| 23 }; | 18 }; |
| 24 | 19 |
| 25 #define FLAGS00 Flags(0) | 20 #define FLAGS00 Flags(0) |
| 26 #define FLAGS01 Flags(kBig_Flag) | 21 #define FLAGS01 Flags(kBig_Flag) |
| 27 #define FLAGS10 Flags(kAA_Flag) | 22 #define FLAGS10 Flags(kAA_Flag) |
| 28 #define FLAGS11 Flags(kBig_Flag | kAA_Flag) | 23 #define FLAGS11 Flags(kBig_Flag | kAA_Flag) |
| 29 | 24 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 path->moveTo(SkIntToScalar(points[base1] + xTrans), | 165 path->moveTo(SkIntToScalar(points[base1] + xTrans), |
| 171 SkIntToScalar(points[base1+1] + yTrans)); | 166 SkIntToScalar(points[base1+1] + yTrans)); |
| 172 path->conicTo(SkIntToScalar(points[base2] + xTrans), | 167 path->conicTo(SkIntToScalar(points[base2] + xTrans), |
| 173 SkIntToScalar(points[base2+1] + yTrans), | 168 SkIntToScalar(points[base2+1] + yTrans), |
| 174 SkIntToScalar(points[base3] + xTrans), | 169 SkIntToScalar(points[base3] + xTrans), |
| 175 SkIntToScalar(points[base3+1] + yTrans), | 170 SkIntToScalar(points[base3+1] + yTrans), |
| 176 weight); | 171 weight); |
| 177 } | 172 } |
| 178 } | 173 } |
| 179 | 174 |
| 180 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | |
| 181 #if SK_SUPPORT_GPU | |
| 182 GrContext* context = canvas->getGrContext(); | |
| 183 // This is a workaround for skbug.com/2078. See also skbug.com/2033. | |
| 184 if (context) { | |
| 185 GrTestTarget tt; | |
| 186 context->getTestTarget(&tt); | |
| 187 if (tt.target()->caps()->pathRenderingSupport()) { | |
| 188 return; | |
| 189 } | |
| 190 } | |
| 191 #endif | |
| 192 INHERITED::onDraw(loops, canvas); | |
| 193 } | |
| 194 | |
| 195 private: | 175 private: |
| 196 typedef HairlinePathBench INHERITED; | 176 typedef HairlinePathBench INHERITED; |
| 197 }; | 177 }; |
| 198 | 178 |
| 199 class CubicPathBench : public HairlinePathBench { | 179 class CubicPathBench : public HairlinePathBench { |
| 200 public: | 180 public: |
| 201 CubicPathBench(Flags flags) : INHERITED(flags) {} | 181 CubicPathBench(Flags flags) : INHERITED(flags) {} |
| 202 | 182 |
| 203 virtual void appendName(SkString* name) SK_OVERRIDE { | 183 virtual void appendName(SkString* name) SK_OVERRIDE { |
| 204 name->append("cubic"); | 184 name->append("cubic"); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 // Don't have default path renderer for conics yet on GPU, so must use AA | 229 // Don't have default path renderer for conics yet on GPU, so must use AA |
| 250 // DEF_BENCH( return new ConicPathBench(FLAGS00); ) | 230 // DEF_BENCH( return new ConicPathBench(FLAGS00); ) |
| 251 // DEF_BENCH( return new ConicPathBench(FLAGS01); ) | 231 // DEF_BENCH( return new ConicPathBench(FLAGS01); ) |
| 252 DEF_BENCH( return new ConicPathBench(FLAGS10); ) | 232 DEF_BENCH( return new ConicPathBench(FLAGS10); ) |
| 253 DEF_BENCH( return new ConicPathBench(FLAGS11); ) | 233 DEF_BENCH( return new ConicPathBench(FLAGS11); ) |
| 254 | 234 |
| 255 DEF_BENCH( return new CubicPathBench(FLAGS00); ) | 235 DEF_BENCH( return new CubicPathBench(FLAGS00); ) |
| 256 DEF_BENCH( return new CubicPathBench(FLAGS01); ) | 236 DEF_BENCH( return new CubicPathBench(FLAGS01); ) |
| 257 DEF_BENCH( return new CubicPathBench(FLAGS10); ) | 237 DEF_BENCH( return new CubicPathBench(FLAGS10); ) |
| 258 DEF_BENCH( return new CubicPathBench(FLAGS11); ) | 238 DEF_BENCH( return new CubicPathBench(FLAGS11); ) |
| OLD | NEW |