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 "SkAndroidCodec.h" | 8 #include "SkAndroidCodec.h" |
9 #include "SkBitmapRegionCodec.h" | 9 #include "SkBitmapRegionCodec.h" |
10 #include "SkBitmapRegionDecoderPriv.h" | 10 #include "SkBitmapRegionDecoderPriv.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // Ask the codec for a scaled subset | 45 // Ask the codec for a scaled subset |
46 if (!fCodec->getSupportedSubset(&subset)) { | 46 if (!fCodec->getSupportedSubset(&subset)) { |
47 SkCodecPrintf("Error: Could not get subset.\n"); | 47 SkCodecPrintf("Error: Could not get subset.\n"); |
48 return false; | 48 return false; |
49 } | 49 } |
50 SkISize scaledSize = fCodec->getSampledSubsetDimensions(sampleSize, subset); | 50 SkISize scaledSize = fCodec->getSampledSubsetDimensions(sampleSize, subset); |
51 | 51 |
52 // Create the image info for the decode | 52 // Create the image info for the decode |
53 SkColorType dstColorType = fCodec->computeOutputColorType(prefColorType); | 53 SkColorType dstColorType = fCodec->computeOutputColorType(prefColorType); |
54 SkAlphaType dstAlphaType = fCodec->computeOutputAlphaType(requireUnpremul); | 54 SkAlphaType dstAlphaType = fCodec->computeOutputAlphaType(requireUnpremul); |
55 SkImageInfo decodeInfo = fCodec->getInfo().makeWH(scaledSize.width(), scaled
Size.height()) | 55 |
56 .makeColorType(dstColorType) | 56 // Enable legacy behavior to avoid any gamma correction. Android's assets a
re |
57 .makeAlphaType(dstAlphaType); | 57 // adjusted to expect a non-gamma correct premultiply. |
| 58 sk_sp<SkColorSpace> colorSpace = nullptr; |
| 59 SkImageInfo decodeInfo = SkImageInfo::Make(scaledSize.width(), scaledSize.he
ight(), |
| 60 dstColorType, dstAlphaType, color
Space); |
58 | 61 |
59 // Construct a color table for the decode if necessary | 62 // Construct a color table for the decode if necessary |
60 SkAutoTUnref<SkColorTable> colorTable(nullptr); | 63 SkAutoTUnref<SkColorTable> colorTable(nullptr); |
61 int maxColors = 256; | 64 int maxColors = 256; |
62 SkPMColor colors[256]; | 65 SkPMColor colors[256]; |
63 if (kIndex_8_SkColorType == dstColorType) { | 66 if (kIndex_8_SkColorType == dstColorType) { |
64 colorTable.reset(new SkColorTable(colors, maxColors)); | 67 colorTable.reset(new SkColorTable(colors, maxColors)); |
65 } | 68 } |
66 | 69 |
67 // Initialize the destination bitmap | 70 // Initialize the destination bitmap |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 if (kIndex_8_SkColorType == dstColorType) { | 130 if (kIndex_8_SkColorType == dstColorType) { |
128 colorTable->dangerous_overwriteColors(colors, maxColors); | 131 colorTable->dangerous_overwriteColors(colors, maxColors); |
129 } | 132 } |
130 | 133 |
131 return true; | 134 return true; |
132 } | 135 } |
133 | 136 |
134 bool SkBitmapRegionCodec::conversionSupported(SkColorType colorType) { | 137 bool SkBitmapRegionCodec::conversionSupported(SkColorType colorType) { |
135 return conversion_possible(fCodec->getInfo().makeColorType(colorType), fCode
c->getInfo()); | 138 return conversion_possible(fCodec->getInfo().makeColorType(colorType), fCode
c->getInfo()); |
136 } | 139 } |
OLD | NEW |