| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "SkBenchmark.h" | 8 #include "Benchmark.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| 11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
| 12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
| 13 #include "SkShader.h" | 13 #include "SkShader.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 void draw_into_bitmap(const SkBitmap& bm) { | 17 static void draw_into_bitmap(const SkBitmap& bm) { |
| 18 const int w = bm.width(); | 18 const int w = bm.width(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 for (int y = 0; y < src.height(); y++) { | 75 for (int y = 0; y < src.height(); y++) { |
| 76 const SkPMColor* srcP = src.getAddr32(0, y); | 76 const SkPMColor* srcP = src.getAddr32(0, y); |
| 77 uint8_t* dstP = dst->getAddr8(0, y); | 77 uint8_t* dstP = dst->getAddr8(0, y); |
| 78 for (int x = src.width() - 1; x >= 0; --x) { | 78 for (int x = src.width() - 1; x >= 0; --x) { |
| 79 *dstP++ = compute_666_index(*srcP++); | 79 *dstP++ = compute_666_index(*srcP++); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 class RepeatTileBench : public SkBenchmark { | 84 class RepeatTileBench : public Benchmark { |
| 85 const SkColorType fColorType; | 85 const SkColorType fColorType; |
| 86 const SkAlphaType fAlphaType; | 86 const SkAlphaType fAlphaType; |
| 87 SkPaint fPaint; | 87 SkPaint fPaint; |
| 88 SkString fName; | 88 SkString fName; |
| 89 SkBitmap fBitmap; | 89 SkBitmap fBitmap; |
| 90 public: | 90 public: |
| 91 RepeatTileBench(SkColorType ct, SkAlphaType at = kPremul_SkAlphaType) | 91 RepeatTileBench(SkColorType ct, SkAlphaType at = kPremul_SkAlphaType) |
| 92 : fColorType(ct), fAlphaType(at) | 92 : fColorType(ct), fAlphaType(at) |
| 93 { | 93 { |
| 94 const int w = 50; | 94 const int w = 50; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 130 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
| 131 SkPaint paint(fPaint); | 131 SkPaint paint(fPaint); |
| 132 this->setupPaint(&paint); | 132 this->setupPaint(&paint); |
| 133 | 133 |
| 134 for (int i = 0; i < loops; i++) { | 134 for (int i = 0; i < loops; i++) { |
| 135 canvas->drawPaint(paint); | 135 canvas->drawPaint(paint); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 private: | 139 private: |
| 140 typedef SkBenchmark INHERITED; | 140 typedef Benchmark INHERITED; |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 DEF_BENCH(return new RepeatTileBench(kN32_SkColorType, kOpaque_SkAlphaType)) | 143 DEF_BENCH(return new RepeatTileBench(kN32_SkColorType, kOpaque_SkAlphaType)) |
| 144 DEF_BENCH(return new RepeatTileBench(kN32_SkColorType, kPremul_SkAlphaType)) | 144 DEF_BENCH(return new RepeatTileBench(kN32_SkColorType, kPremul_SkAlphaType)) |
| 145 DEF_BENCH(return new RepeatTileBench(kRGB_565_SkColorType, kOpaque_SkAlphaType)) | 145 DEF_BENCH(return new RepeatTileBench(kRGB_565_SkColorType, kOpaque_SkAlphaType)) |
| 146 DEF_BENCH(return new RepeatTileBench(kIndex_8_SkColorType, kPremul_SkAlphaType)) | 146 DEF_BENCH(return new RepeatTileBench(kIndex_8_SkColorType, kPremul_SkAlphaType)) |
| OLD | NEW |