| 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 "SkCodecImageGenerator.h" | 8 #include "SkCodecImageGenerator.h" |
| 9 #include "SkPM4fPriv.h" |
| 9 | 10 |
| 10 SkImageGenerator* SkCodecImageGenerator::NewFromEncodedCodec(SkData* data) { | 11 SkImageGenerator* SkCodecImageGenerator::NewFromEncodedCodec(SkData* data) { |
| 11 SkCodec* codec = SkCodec::NewFromData(data); | 12 SkCodec* codec = SkCodec::NewFromData(data); |
| 12 if (nullptr == codec) { | 13 if (nullptr == codec) { |
| 13 return nullptr; | 14 return nullptr; |
| 14 } | 15 } |
| 15 | 16 |
| 16 return new SkCodecImageGenerator(codec, data); | 17 return new SkCodecImageGenerator(codec, data); |
| 17 } | 18 } |
| 18 | 19 |
| 19 // FIXME: We should expose information about the encoded format on the | 20 // FIXME: We should expose information about the encoded format on the |
| 20 // SkImageGenerator, so the client can interpret the encoded | 21 // SkImageGenerator, so the client can interpret the encoded |
| 21 // format and request an output format. For now, as a workaround, | 22 // format and request an output format. For now, as a workaround, |
| 22 // we guess what output format the client wants. | 23 // we guess what output format the client wants. |
| 23 static SkImageInfo fix_info(const SkCodec& codec) { | 24 static SkImageInfo fix_info(const SkCodec& codec) { |
| 24 const SkImageInfo& info = codec.getInfo(); | 25 const SkImageInfo& info = codec.getInfo(); |
| 25 SkAlphaType alphaType = (kUnpremul_SkAlphaType == info.alphaType()) ? kPremu
l_SkAlphaType : | 26 SkAlphaType alphaType = (kUnpremul_SkAlphaType == info.alphaType()) ? kPremu
l_SkAlphaType : |
| 26 info.alphaType(); | 27 info.alphaType(); |
| 27 | 28 |
| 28 // Crudely guess that the presence of a color space means sRGB. | 29 SkColorProfileType profileType = kLinear_SkColorProfileType; |
| 29 SkColorProfileType profileType = (codec.getColorSpace()) ? kSRGB_SkColorProf
ileType : | 30 // Crudely guess that the presence of a color space means sRGB, or obey the
global sRGB |
| 30 kLinear_SkColorProfileType; | 31 // selector. |
| 32 if (gTreatSkColorAsSRGB || codec.getColorSpace()) { |
| 33 profileType = kSRGB_SkColorProfileType; |
| 34 } |
| 31 | 35 |
| 32 return SkImageInfo::Make(info.width(), info.height(), info.colorType(), alph
aType, profileType); | 36 return SkImageInfo::Make(info.width(), info.height(), info.colorType(), alph
aType, profileType); |
| 33 } | 37 } |
| 34 | 38 |
| 35 SkCodecImageGenerator::SkCodecImageGenerator(SkCodec* codec, SkData* data) | 39 SkCodecImageGenerator::SkCodecImageGenerator(SkCodec* codec, SkData* data) |
| 36 : INHERITED(fix_info(*codec)) | 40 : INHERITED(fix_info(*codec)) |
| 37 , fCodec(codec) | 41 , fCodec(codec) |
| 38 , fData(SkRef(data)) | 42 , fData(SkRef(data)) |
| 39 {} | 43 {} |
| 40 | 44 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 65 SkCodec::Result result = fCodec->getYUV8Planes(sizeInfo, planes); | 69 SkCodec::Result result = fCodec->getYUV8Planes(sizeInfo, planes); |
| 66 | 70 |
| 67 switch (result) { | 71 switch (result) { |
| 68 case SkCodec::kSuccess: | 72 case SkCodec::kSuccess: |
| 69 case SkCodec::kIncompleteInput: | 73 case SkCodec::kIncompleteInput: |
| 70 return true; | 74 return true; |
| 71 default: | 75 default: |
| 72 return false; | 76 return false; |
| 73 } | 77 } |
| 74 } | 78 } |
| OLD | NEW |