| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBenchmark.h" | 8 #include "Benchmark.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkPaint.h" | |
| 11 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| 12 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
| 12 #include "SkPaint.h" |
| 13 #include "SkRandom.h" | 13 #include "SkRandom.h" |
| 14 #include "SkString.h" | 14 #include "SkString.h" |
| 15 #include "sk_tool_utils.h" | 15 #include "sk_tool_utils.h" |
| 16 | 16 |
| 17 static int conv6ToByte(int x) { | 17 static int conv6ToByte(int x) { |
| 18 return x * 0xFF / 5; | 18 return x * 0xFF / 5; |
| 19 } | 19 } |
| 20 | 20 |
| 21 static int convByteTo6(int x) { | 21 static int convByteTo6(int x) { |
| 22 return x * 5 / 255; | 22 return x * 5 / 255; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 /* Variants for bitmaps | 64 /* Variants for bitmaps |
| 65 | 65 |
| 66 - src depth (32 w+w/o alpha), 565, 4444, index, a8 | 66 - src depth (32 w+w/o alpha), 565, 4444, index, a8 |
| 67 - paint options: filtering, dither, alpha | 67 - paint options: filtering, dither, alpha |
| 68 - matrix options: translate, scale, rotate, persp | 68 - matrix options: translate, scale, rotate, persp |
| 69 - tiling: none, repeat, mirror, clamp | 69 - tiling: none, repeat, mirror, clamp |
| 70 | 70 |
| 71 */ | 71 */ |
| 72 | 72 |
| 73 class BitmapBench : public SkBenchmark { | 73 class BitmapBench : public Benchmark { |
| 74 const SkColorType fColorType; | 74 const SkColorType fColorType; |
| 75 const SkAlphaType fAlphaType; | 75 const SkAlphaType fAlphaType; |
| 76 const bool fForceUpdate; //bitmap marked as dirty before each draw.
forces bitmap to be updated on device cache | 76 const bool fForceUpdate; //bitmap marked as dirty before each draw.
forces bitmap to be updated on device cache |
| 77 const bool fIsVolatile; | 77 const bool fIsVolatile; |
| 78 | 78 |
| 79 SkBitmap fBitmap; | 79 SkBitmap fBitmap; |
| 80 SkPaint fPaint; | 80 SkPaint fPaint; |
| 81 SkString fName; | 81 SkString fName; |
| 82 | 82 |
| 83 enum { W = 128 }; | 83 enum { W = 128 }; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 SkRect r; | 162 SkRect r; |
| 163 r.set(0, 0, SkIntToScalar(w), SkIntToScalar(h)); | 163 r.set(0, 0, SkIntToScalar(w), SkIntToScalar(h)); |
| 164 p.setStyle(SkPaint::kStroke_Style); | 164 p.setStyle(SkPaint::kStroke_Style); |
| 165 p.setStrokeWidth(SkIntToScalar(4)); | 165 p.setStrokeWidth(SkIntToScalar(4)); |
| 166 p.setColor(SK_ColorBLUE); | 166 p.setColor(SK_ColorBLUE); |
| 167 canvas.drawRect(r, p); | 167 canvas.drawRect(r, p); |
| 168 } | 168 } |
| 169 | 169 |
| 170 private: | 170 private: |
| 171 typedef SkBenchmark INHERITED; | 171 typedef Benchmark INHERITED; |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 /** Explicitly invoke some filter types to improve coverage of acceleration | 174 /** Explicitly invoke some filter types to improve coverage of acceleration |
| 175 procs. */ | 175 procs. */ |
| 176 | 176 |
| 177 enum Flags { | 177 enum Flags { |
| 178 kScale_Flag = 1 << 0, | 178 kScale_Flag = 1 << 0, |
| 179 kRotate_Flag = 1 << 1, | 179 kRotate_Flag = 1 << 1, |
| 180 kBilerp_Flag = 1 << 2, | 180 kBilerp_Flag = 1 << 2, |
| 181 kBicubic_Flag = 1 << 3, | 181 kBicubic_Flag = 1 << 3, |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, t
rue, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); ) | 372 DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, t
rue, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); ) |
| 373 | 373 |
| 374 DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kPremul_SkAlphaType, f
alse, false, kScale_Flag | kBilerp_Flag | kBicubic_Flag); ) | 374 DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kPremul_SkAlphaType, f
alse, false, kScale_Flag | kBilerp_Flag | kBicubic_Flag); ) |
| 375 DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kPremul_SkAlphaType, f
alse, false, kScale_Flag | kRotate_Flag | kBilerp_Flag | kBicubic_Flag); ) | 375 DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kPremul_SkAlphaType, f
alse, false, kScale_Flag | kRotate_Flag | kBilerp_Flag | kBicubic_Flag); ) |
| 376 | 376 |
| 377 // source alpha tests -> S32A_Opaque_BlitRow32_{arm,neon} | 377 // source alpha tests -> S32A_Opaque_BlitRow32_{arm,neon} |
| 378 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kOpaque_Sou
rceAlpha, kN32_SkColorType); ) | 378 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kOpaque_Sou
rceAlpha, kN32_SkColorType); ) |
| 379 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kTransparen
t_SourceAlpha, kN32_SkColorType); ) | 379 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kTransparen
t_SourceAlpha, kN32_SkColorType); ) |
| 380 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kTwoStripes
_SourceAlpha, kN32_SkColorType); ) | 380 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kTwoStripes
_SourceAlpha, kN32_SkColorType); ) |
| 381 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kThreeStrip
es_SourceAlpha, kN32_SkColorType); ) | 381 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kThreeStrip
es_SourceAlpha, kN32_SkColorType); ) |
| OLD | NEW |