Chromium Code Reviews| 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 "SkBenchmark.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 | 46 |
| 47 static uint8_t compute_666_index(SkPMColor c) { | 47 static uint8_t compute_666_index(SkPMColor c) { |
| 48 int r = SkGetPackedR32(c); | 48 int r = SkGetPackedR32(c); |
| 49 int g = SkGetPackedG32(c); | 49 int g = SkGetPackedG32(c); |
| 50 int b = SkGetPackedB32(c); | 50 int b = SkGetPackedB32(c); |
| 51 | 51 |
| 52 return conv_byte_to_6(r) * 36 + conv_byte_to_6(g) * 6 + conv_byte_to_6(b); | 52 return conv_byte_to_6(r) * 36 + conv_byte_to_6(g) * 6 + conv_byte_to_6(b); |
| 53 } | 53 } |
| 54 | 54 |
| 55 static void convert_to_index666(const SkBitmap& src, SkBitmap* dst) { | 55 static void convert_to_index666(const SkBitmap& src, SkBitmap* dst) { |
| 56 SkColorTable* ctable = new SkColorTable(216); | 56 SkPMColor storage[216]; |
| 57 SkPMColor* colors = ctable->lockColors(); | 57 SkPMColor* colors = storage; |
| 58 // rrr ggg bbb | 58 // rrr ggg bbb |
| 59 for (int r = 0; r < 6; r++) { | 59 for (int r = 0; r < 6; r++) { |
| 60 int rr = conv_6_to_byte(r); | 60 int rr = conv_6_to_byte(r); |
| 61 for (int g = 0; g < 6; g++) { | 61 for (int g = 0; g < 6; g++) { |
| 62 int gg = conv_6_to_byte(g); | 62 int gg = conv_6_to_byte(g); |
| 63 for (int b = 0; b < 6; b++) { | 63 for (int b = 0; b < 6; b++) { |
| 64 int bb = conv_6_to_byte(b); | 64 int bb = conv_6_to_byte(b); |
| 65 *colors++ = SkPreMultiplyARGB(0xFF, rr, gg, bb); | 65 *colors++ = SkPreMultiplyARGB(0xFF, rr, gg, bb); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 ctable->unlockColors(true); | 69 SkColorTable* ctable = new SkColorTable(storage, 216, kOpaque_SkAlphaType); |
|
scroggo
2013/10/09 18:33:42
We discussed in person, but for posterity:
This s
| |
| 70 dst->setConfig(SkBitmap::kIndex8_Config, src.width(), src.height()); | 70 dst->setConfig(SkBitmap::kIndex8_Config, src.width(), src.height()); |
| 71 dst->allocPixels(ctable); | 71 dst->allocPixels(ctable); |
| 72 ctable->unref(); | 72 ctable->unref(); |
| 73 | 73 |
| 74 SkAutoLockPixels alps(src); | 74 SkAutoLockPixels alps(src); |
| 75 SkAutoLockPixels alpd(*dst); | 75 SkAutoLockPixels alpd(*dst); |
| 76 | 76 |
| 77 for (int y = 0; y < src.height(); y++) { | 77 for (int y = 0; y < src.height(); y++) { |
| 78 const SkPMColor* srcP = src.getAddr32(0, y); | 78 const SkPMColor* srcP = src.getAddr32(0, y); |
| 79 uint8_t* dstP = dst->getAddr8(0, y); | 79 uint8_t* dstP = dst->getAddr8(0, y); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 } | 140 } |
| 141 | 141 |
| 142 private: | 142 private: |
| 143 typedef SkBenchmark INHERITED; | 143 typedef SkBenchmark INHERITED; |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 DEF_BENCH(return new RepeatTileBench(SkBitmap::kARGB_8888_Config, true)) | 146 DEF_BENCH(return new RepeatTileBench(SkBitmap::kARGB_8888_Config, true)) |
| 147 DEF_BENCH(return new RepeatTileBench(SkBitmap::kARGB_8888_Config, false)) | 147 DEF_BENCH(return new RepeatTileBench(SkBitmap::kARGB_8888_Config, false)) |
| 148 DEF_BENCH(return new RepeatTileBench(SkBitmap::kRGB_565_Config)) | 148 DEF_BENCH(return new RepeatTileBench(SkBitmap::kRGB_565_Config)) |
| 149 DEF_BENCH(return new RepeatTileBench(SkBitmap::kIndex8_Config)) | 149 DEF_BENCH(return new RepeatTileBench(SkBitmap::kIndex8_Config)) |
| OLD | NEW |