OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SubsetTranslateBench.h" | 8 #include "SubsetTranslateBench.h" |
9 #include "SubsetBenchPriv.h" | 9 #include "SubsetBenchPriv.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 for (int count = 0; count < n; count++) { | 61 for (int count = 0; count < n; count++) { |
62 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplica te())); | 62 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplica te())); |
63 const SkImageInfo info = codec->getInfo().makeColorType(fColorType); | 63 const SkImageInfo info = codec->getInfo().makeColorType(fColorType); |
64 SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowByte s())); | 64 SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowByte s())); |
65 SkScanlineDecoder* scanlineDecoder = codec->getScanlineDecoder( | 65 SkScanlineDecoder* scanlineDecoder = codec->getScanlineDecoder( |
66 info, NULL, colors, &colorCount); | 66 info, NULL, colors, &colorCount); |
67 | 67 |
68 SkBitmap bitmap; | 68 SkBitmap bitmap; |
69 // Note that we use the same bitmap for all of the subsets. | 69 // Note that we use the same bitmap for all of the subsets. |
70 // It might be larger than necessary for the end subsets. | 70 // It might be larger than necessary for the end subsets. |
71 bitmap.allocPixels(info.makeWH(fSubsetWidth, fSubsetHeight)); | 71 if (kIndex_8_SkColorType == fColorType) { |
scroggo
2015/06/30 16:40:19
This code is almost exactly the same. Can we write
msarett
2015/06/30 18:40:28
Yes there is, good idea.
| |
72 bitmap.allocPixels(info.makeWH(fSubsetWidth, fSubsetHeight), NUL L, | |
73 SkNEW_ARGS(SkColorTable, (colors, colorCount))); | |
74 } else { | |
75 bitmap.allocPixels(info.makeWH(fSubsetWidth, fSubsetHeight)); | |
76 } | |
72 | 77 |
73 for (int x = 0; x < info.width(); x += fSubsetWidth) { | 78 for (int x = 0; x < info.width(); x += fSubsetWidth) { |
74 for (int y = 0; y < info.height(); y += fSubsetHeight) { | 79 for (int y = 0; y < info.height(); y += fSubsetHeight) { |
75 scanlineDecoder->skipScanlines(y); | 80 scanlineDecoder->skipScanlines(y); |
76 const uint32_t currSubsetWidth = | 81 const uint32_t currSubsetWidth = |
77 x + (int) fSubsetWidth > info.width() ? | 82 x + (int) fSubsetWidth > info.width() ? |
78 info.width() - x : fSubsetWidth; | 83 info.width() - x : fSubsetWidth; |
79 const uint32_t currSubsetHeight = | 84 const uint32_t currSubsetHeight = |
80 y + (int) fSubsetHeight > info.height() ? | 85 y + (int) fSubsetHeight > info.height() ? |
81 info.height() - y : fSubsetHeight; | 86 info.height() - y : fSubsetHeight; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 const uint32_t currSubsetHeight = y + (int) fSubsetHeight > height ? | 120 const uint32_t currSubsetHeight = y + (int) fSubsetHeight > height ? |
116 height - y : fSubsetHeight; | 121 height - y : fSubsetHeight; |
117 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth, | 122 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth, |
118 currSubsetHeight); | 123 currSubsetHeight); |
119 decoder->decodeSubset(&bitmap, rect, fColorType); | 124 decoder->decodeSubset(&bitmap, rect, fColorType); |
120 } | 125 } |
121 } | 126 } |
122 } | 127 } |
123 } | 128 } |
124 } | 129 } |
OLD | NEW |