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 SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight); |
| 72 alloc_pixels(&bitmap, subsetInfo, colors, colorCount); |
72 | 73 |
73 for (int x = 0; x < info.width(); x += fSubsetWidth) { | 74 for (int x = 0; x < info.width(); x += fSubsetWidth) { |
74 for (int y = 0; y < info.height(); y += fSubsetHeight) { | 75 for (int y = 0; y < info.height(); y += fSubsetHeight) { |
75 scanlineDecoder->skipScanlines(y); | 76 scanlineDecoder->skipScanlines(y); |
76 const uint32_t currSubsetWidth = | 77 const uint32_t currSubsetWidth = |
77 x + (int) fSubsetWidth > info.width() ? | 78 x + (int) fSubsetWidth > info.width() ? |
78 info.width() - x : fSubsetWidth; | 79 info.width() - x : fSubsetWidth; |
79 const uint32_t currSubsetHeight = | 80 const uint32_t currSubsetHeight = |
80 y + (int) fSubsetHeight > info.height() ? | 81 y + (int) fSubsetHeight > info.height() ? |
81 info.height() - y : fSubsetHeight; | 82 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 ? | 116 const uint32_t currSubsetHeight = y + (int) fSubsetHeight >
height ? |
116 height - y : fSubsetHeight; | 117 height - y : fSubsetHeight; |
117 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth, | 118 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth, |
118 currSubsetHeight); | 119 currSubsetHeight); |
119 decoder->decodeSubset(&bitmap, rect, fColorType); | 120 decoder->decodeSubset(&bitmap, rect, fColorType); |
120 } | 121 } |
121 } | 122 } |
122 } | 123 } |
123 } | 124 } |
124 } | 125 } |
OLD | NEW |