| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 void SubsetTranslateBench::onDraw(const int n, SkCanvas* canvas) { | 56 void SubsetTranslateBench::onDraw(const int n, SkCanvas* canvas) { |
| 57 // When the color type is kIndex8, we will need to store the color table. I
f it is | 57 // When the color type is kIndex8, we will need to store the color table. I
f it is |
| 58 // used, it will be initialized by the codec. | 58 // used, it will be initialized by the codec. |
| 59 int colorCount; | 59 int colorCount; |
| 60 SkPMColor colors[256]; | 60 SkPMColor colors[256]; |
| 61 if (fUseCodec) { | 61 if (fUseCodec) { |
| 62 for (int count = 0; count < n; count++) { | 62 for (int count = 0; count < n; count++) { |
| 63 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplica
te())); | 63 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplica
te())); |
| 64 const SkImageInfo info = codec->getInfo().makeColorType(fColorType); | 64 const SkImageInfo info = codec->getInfo().makeColorType(fColorType); |
| 65 SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowByte
s())); | 65 SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowByte
s())); |
| 66 SkScanlineDecoder* scanlineDecoder = codec->getScanlineDecoder( | 66 SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(codec->getScanlineD
ecoder( |
| 67 info, NULL, colors, &colorCount); | 67 info, NULL, colors, &colorCount)); |
| 68 | 68 |
| 69 SkBitmap bitmap; | 69 SkBitmap bitmap; |
| 70 // Note that we use the same bitmap for all of the subsets. | 70 // Note that we use the same bitmap for all of the subsets. |
| 71 // It might be larger than necessary for the end subsets. | 71 // It might be larger than necessary for the end subsets. |
| 72 SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight); | 72 SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight); |
| 73 alloc_pixels(&bitmap, subsetInfo, colors, colorCount); | 73 alloc_pixels(&bitmap, subsetInfo, colors, colorCount); |
| 74 | 74 |
| 75 for (int x = 0; x < info.width(); x += fSubsetWidth) { | 75 for (int x = 0; x < info.width(); x += fSubsetWidth) { |
| 76 for (int y = 0; y < info.height(); y += fSubsetHeight) { | 76 for (int y = 0; y < info.height(); y += fSubsetHeight) { |
| 77 scanlineDecoder->skipScanlines(y); | 77 scanlineDecoder->skipScanlines(y); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 const uint32_t currSubsetHeight = y + (int) fSubsetHeight >
height ? | 117 const uint32_t currSubsetHeight = y + (int) fSubsetHeight >
height ? |
| 118 height - y : fSubsetHeight; | 118 height - y : fSubsetHeight; |
| 119 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth, | 119 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth, |
| 120 currSubsetHeight); | 120 currSubsetHeight); |
| 121 decoder->decodeSubset(&bitmap, rect, fColorType); | 121 decoder->decodeSubset(&bitmap, rect, fColorType); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 } | 126 } |
| OLD | NEW |