| 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 "SkPaint.h" | 10 #include "SkPaint.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 static SkString to_lower(const char* str) { | 60 static SkString to_lower(const char* str) { |
| 61 SkString lower(str); | 61 SkString lower(str); |
| 62 for (size_t i = 0; i < lower.size(); i++) { | 62 for (size_t i = 0; i < lower.size(); i++) { |
| 63 lower[i] = tolower(lower[i]); | 63 lower[i] = tolower(lower[i]); |
| 64 } | 64 } |
| 65 return lower; | 65 return lower; |
| 66 } | 66 } |
| 67 | 67 |
| 68 class RotRectBench: public Benchmark { | 68 class RotRectBench: public Benchmark { |
| 69 public: | 69 public: |
| 70 RotRectBench(bool aa, ColorType ct, SkXfermode::Mode mode) | 70 RotRectBench(bool aa, ColorType ct, SkBlendMode mode) |
| 71 : fAA(aa) | 71 : fAA(aa) |
| 72 , fColorType(ct) | 72 , fColorType(ct) |
| 73 , fMode(mode) { | 73 , fMode(mode) { |
| 74 this->makeName(); | 74 this->makeName(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 protected: | 77 protected: |
| 78 const char* onGetName() override { return fName.c_str(); } | 78 const char* onGetName() override { return fName.c_str(); } |
| 79 | 79 |
| 80 void onDraw(int loops, SkCanvas* canvas) override { | 80 void onDraw(int loops, SkCanvas* canvas) override { |
| 81 SkPaint paint; | 81 SkPaint paint; |
| 82 paint.setAntiAlias(fAA); | 82 paint.setAntiAlias(fAA); |
| 83 paint.setXfermodeMode(fMode); | 83 paint.setBlendMode(fMode); |
| 84 SkColor color = start_color(fColorType); | 84 SkColor color = start_color(fColorType); |
| 85 | 85 |
| 86 int w = this->getSize().x(); | 86 int w = this->getSize().x(); |
| 87 int h = this->getSize().y(); | 87 int h = this->getSize().y(); |
| 88 | 88 |
| 89 static const SkScalar kRectW = 25.1f; | 89 static const SkScalar kRectW = 25.1f; |
| 90 static const SkScalar kRectH = 25.9f; | 90 static const SkScalar kRectH = 25.9f; |
| 91 | 91 |
| 92 SkMatrix rotate; | 92 SkMatrix rotate; |
| 93 // This value was chosen so that we frequently hit the axis-aligned case
. | 93 // This value was chosen so that we frequently hit the axis-aligned case
. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 case kChangingTransparent_ColorType: | 140 case kChangingTransparent_ColorType: |
| 141 fName.append("_changing_transparent"); | 141 fName.append("_changing_transparent"); |
| 142 break; | 142 break; |
| 143 case kAlternatingOpaqueAndTransparent_ColorType: | 143 case kAlternatingOpaqueAndTransparent_ColorType: |
| 144 fName.append("_alternating_transparent_and_opaque"); | 144 fName.append("_alternating_transparent_and_opaque"); |
| 145 break; | 145 break; |
| 146 } | 146 } |
| 147 fName.appendf("_%s", to_lower(SkXfermode::ModeName(fMode)).c_str()); | 147 fName.appendf("_%s", to_lower(SkXfermode::ModeName(fMode)).c_str()); |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool fAA; | 150 bool fAA; |
| 151 ColorType fColorType; | 151 ColorType fColorType; |
| 152 SkXfermode::Mode fMode; | 152 SkBlendMode fMode; |
| 153 SkString fName; | 153 SkString fName; |
| 154 | 154 |
| 155 typedef Benchmark INHERITED; | 155 typedef Benchmark INHERITED; |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 // Choose kSrcOver because it always allows coverage and alpha to be conflated.
kSrc only allows | 158 // Choose kSrcOver because it always allows coverage and alpha to be conflated.
kSrc only allows |
| 159 // conflation when opaque, and kDarken because it isn't possilbe with standard G
L blending. | 159 // conflation when opaque, and kDarken because it isn't possilbe with standard G
L blending. |
| 160 DEF_BENCH(return new RotRectBench(true, kConstantOpaque_ColorType,
SkXfermode::kSrcOver_Mode);) | 160 DEF_BENCH(return new RotRectBench(true, kConstantOpaque_ColorType,
SkBlendMode::kSrcOver);) |
| 161 DEF_BENCH(return new RotRectBench(true, kConstantTransparent_ColorType,
SkXfermode::kSrcOver_Mode);) | 161 DEF_BENCH(return new RotRectBench(true, kConstantTransparent_ColorType,
SkBlendMode::kSrcOver);) |
| 162 DEF_BENCH(return new RotRectBench(true, kChangingOpaque_ColorType,
SkXfermode::kSrcOver_Mode);) | 162 DEF_BENCH(return new RotRectBench(true, kChangingOpaque_ColorType,
SkBlendMode::kSrcOver);) |
| 163 DEF_BENCH(return new RotRectBench(true, kChangingTransparent_ColorType,
SkXfermode::kSrcOver_Mode);) | 163 DEF_BENCH(return new RotRectBench(true, kChangingTransparent_ColorType,
SkBlendMode::kSrcOver);) |
| 164 DEF_BENCH(return new RotRectBench(true, kAlternatingOpaqueAndTransparent_ColorT
ype, SkXfermode::kSrcOver_Mode);) | 164 DEF_BENCH(return new RotRectBench(true, kAlternatingOpaqueAndTransparent_ColorT
ype, SkBlendMode::kSrcOver);) |
| 165 | 165 |
| 166 DEF_BENCH(return new RotRectBench(false, kConstantOpaque_ColorType,
SkXfermode::kSrcOver_Mode);) | 166 DEF_BENCH(return new RotRectBench(false, kConstantOpaque_ColorType,
SkBlendMode::kSrcOver);) |
| 167 DEF_BENCH(return new RotRectBench(false, kConstantTransparent_ColorType,
SkXfermode::kSrcOver_Mode);) | 167 DEF_BENCH(return new RotRectBench(false, kConstantTransparent_ColorType,
SkBlendMode::kSrcOver);) |
| 168 DEF_BENCH(return new RotRectBench(false, kChangingOpaque_ColorType,
SkXfermode::kSrcOver_Mode);) | 168 DEF_BENCH(return new RotRectBench(false, kChangingOpaque_ColorType,
SkBlendMode::kSrcOver);) |
| 169 DEF_BENCH(return new RotRectBench(false, kChangingTransparent_ColorType,
SkXfermode::kSrcOver_Mode);) | 169 DEF_BENCH(return new RotRectBench(false, kChangingTransparent_ColorType,
SkBlendMode::kSrcOver);) |
| 170 DEF_BENCH(return new RotRectBench(false, kAlternatingOpaqueAndTransparent_ColorT
ype, SkXfermode::kSrcOver_Mode);) | 170 DEF_BENCH(return new RotRectBench(false, kAlternatingOpaqueAndTransparent_ColorT
ype, SkBlendMode::kSrcOver);) |
| 171 | 171 |
| 172 DEF_BENCH(return new RotRectBench(true, kConstantOpaque_ColorType,
SkXfermode::kSrc_Mode);) | 172 DEF_BENCH(return new RotRectBench(true, kConstantOpaque_ColorType,
SkBlendMode::kSrc);) |
| 173 DEF_BENCH(return new RotRectBench(true, kConstantTransparent_ColorType,
SkXfermode::kSrc_Mode);) | 173 DEF_BENCH(return new RotRectBench(true, kConstantTransparent_ColorType,
SkBlendMode::kSrc);) |
| 174 DEF_BENCH(return new RotRectBench(true, kChangingOpaque_ColorType,
SkXfermode::kSrc_Mode);) | 174 DEF_BENCH(return new RotRectBench(true, kChangingOpaque_ColorType,
SkBlendMode::kSrc);) |
| 175 DEF_BENCH(return new RotRectBench(true, kChangingTransparent_ColorType,
SkXfermode::kSrc_Mode);) | 175 DEF_BENCH(return new RotRectBench(true, kChangingTransparent_ColorType,
SkBlendMode::kSrc);) |
| 176 DEF_BENCH(return new RotRectBench(true, kAlternatingOpaqueAndTransparent_ColorT
ype, SkXfermode::kSrc_Mode);) | 176 DEF_BENCH(return new RotRectBench(true, kAlternatingOpaqueAndTransparent_ColorT
ype, SkBlendMode::kSrc);) |
| 177 | 177 |
| 178 DEF_BENCH(return new RotRectBench(false, kConstantOpaque_ColorType,
SkXfermode::kSrc_Mode);) | 178 DEF_BENCH(return new RotRectBench(false, kConstantOpaque_ColorType,
SkBlendMode::kSrc);) |
| 179 DEF_BENCH(return new RotRectBench(false, kConstantTransparent_ColorType,
SkXfermode::kSrc_Mode);) | 179 DEF_BENCH(return new RotRectBench(false, kConstantTransparent_ColorType,
SkBlendMode::kSrc);) |
| 180 DEF_BENCH(return new RotRectBench(false, kChangingOpaque_ColorType,
SkXfermode::kSrc_Mode);) | 180 DEF_BENCH(return new RotRectBench(false, kChangingOpaque_ColorType,
SkBlendMode::kSrc);) |
| 181 DEF_BENCH(return new RotRectBench(false, kChangingTransparent_ColorType,
SkXfermode::kSrc_Mode);) | 181 DEF_BENCH(return new RotRectBench(false, kChangingTransparent_ColorType,
SkBlendMode::kSrc);) |
| 182 DEF_BENCH(return new RotRectBench(false, kAlternatingOpaqueAndTransparent_ColorT
ype, SkXfermode::kSrc_Mode);) | 182 DEF_BENCH(return new RotRectBench(false, kAlternatingOpaqueAndTransparent_ColorT
ype, SkBlendMode::kSrc);) |
| 183 | 183 |
| 184 DEF_BENCH(return new RotRectBench(true, kConstantOpaque_ColorType,
SkXfermode::kDarken_Mode);) | 184 DEF_BENCH(return new RotRectBench(true, kConstantOpaque_ColorType,
SkBlendMode::kDarken);) |
| 185 DEF_BENCH(return new RotRectBench(true, kConstantTransparent_ColorType,
SkXfermode::kDarken_Mode);) | 185 DEF_BENCH(return new RotRectBench(true, kConstantTransparent_ColorType,
SkBlendMode::kDarken);) |
| 186 DEF_BENCH(return new RotRectBench(true, kChangingOpaque_ColorType,
SkXfermode::kDarken_Mode);) | 186 DEF_BENCH(return new RotRectBench(true, kChangingOpaque_ColorType,
SkBlendMode::kDarken);) |
| 187 DEF_BENCH(return new RotRectBench(true, kChangingTransparent_ColorType,
SkXfermode::kDarken_Mode);) | 187 DEF_BENCH(return new RotRectBench(true, kChangingTransparent_ColorType,
SkBlendMode::kDarken);) |
| 188 DEF_BENCH(return new RotRectBench(true, kAlternatingOpaqueAndTransparent_ColorT
ype, SkXfermode::kDarken_Mode);) | 188 DEF_BENCH(return new RotRectBench(true, kAlternatingOpaqueAndTransparent_ColorT
ype, SkBlendMode::kDarken);) |
| 189 | 189 |
| 190 DEF_BENCH(return new RotRectBench(false, kConstantOpaque_ColorType,
SkXfermode::kDarken_Mode);) | 190 DEF_BENCH(return new RotRectBench(false, kConstantOpaque_ColorType,
SkBlendMode::kDarken);) |
| 191 DEF_BENCH(return new RotRectBench(false, kConstantTransparent_ColorType,
SkXfermode::kDarken_Mode);) | 191 DEF_BENCH(return new RotRectBench(false, kConstantTransparent_ColorType,
SkBlendMode::kDarken);) |
| 192 DEF_BENCH(return new RotRectBench(false, kChangingOpaque_ColorType,
SkXfermode::kDarken_Mode);) | 192 DEF_BENCH(return new RotRectBench(false, kChangingOpaque_ColorType,
SkBlendMode::kDarken);) |
| 193 DEF_BENCH(return new RotRectBench(false, kChangingTransparent_ColorType,
SkXfermode::kDarken_Mode);) | 193 DEF_BENCH(return new RotRectBench(false, kChangingTransparent_ColorType,
SkBlendMode::kDarken);) |
| 194 DEF_BENCH(return new RotRectBench(false, kAlternatingOpaqueAndTransparent_ColorT
ype, SkXfermode::kDarken_Mode);) | 194 DEF_BENCH(return new RotRectBench(false, kAlternatingOpaqueAndTransparent_ColorT
ype, SkBlendMode::kDarken);) |
| OLD | NEW |