| OLD | NEW |
| 1 #include "DMSrcSink.h" | 1 #include "DMSrcSink.h" |
| 2 #include "SamplePipeControllers.h" | 2 #include "SamplePipeControllers.h" |
| 3 #include "SkCommonFlags.h" | 3 #include "SkCommonFlags.h" |
| 4 #include "SkCodec.h" | 4 #include "SkCodec.h" |
| 5 #include "SkDocument.h" | 5 #include "SkDocument.h" |
| 6 #include "SkError.h" | 6 #include "SkError.h" |
| 7 #include "SkMultiPictureDraw.h" | 7 #include "SkMultiPictureDraw.h" |
| 8 #include "SkNullCanvas.h" | 8 #include "SkNullCanvas.h" |
| 9 #include "SkOSFile.h" | 9 #include "SkOSFile.h" |
| 10 #include "SkPictureData.h" | 10 #include "SkPictureData.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); | 50 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); |
| 51 if (!encoded) { | 51 if (!encoded) { |
| 52 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); | 52 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 55 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
| 56 if (!codec) { | 56 if (!codec) { |
| 57 return SkStringPrintf("Couldn't decode %s.", fPath.c_str()); | 57 return SkStringPrintf("Couldn't decode %s.", fPath.c_str()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 SkImageInfo decodeInfo; | 60 SkImageInfo decodeInfo = codec->getInfo().makeColorType(canvasInfo.colorType
()); |
| 61 if (!codec->getInfo(&decodeInfo)) { | |
| 62 return SkStringPrintf("Couldn't getInfo %s.", fPath.c_str()); | |
| 63 } | |
| 64 | |
| 65 decodeInfo = decodeInfo.makeColorType(canvasInfo.colorType()); | |
| 66 if (decodeInfo.alphaType() == kUnpremul_SkAlphaType) { | 61 if (decodeInfo.alphaType() == kUnpremul_SkAlphaType) { |
| 67 // FIXME: Currently we cannot draw unpremultiplied sources. | 62 // FIXME: Currently we cannot draw unpremultiplied sources. |
| 68 decodeInfo = decodeInfo.makeAlphaType(kPremul_SkAlphaType); | 63 decodeInfo = decodeInfo.makeAlphaType(kPremul_SkAlphaType); |
| 69 } | 64 } |
| 70 | 65 |
| 71 SkBitmap bitmap; | 66 SkBitmap bitmap; |
| 72 if (!bitmap.tryAllocPixels(decodeInfo)) { | 67 if (!bitmap.tryAllocPixels(decodeInfo)) { |
| 73 return SkStringPrintf("Image(%s) is too large (%d x %d)\n", fPath.c_str(
), | 68 return SkStringPrintf("Image(%s) is too large (%d x %d)\n", fPath.c_str(
), |
| 74 decodeInfo.width(), decodeInfo.height()); | 69 decodeInfo.width(), decodeInfo.height()); |
| 75 } | 70 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 86 return Error::Nonfatal("Incompatible colortype conversion"); | 81 return Error::Nonfatal("Incompatible colortype conversion"); |
| 87 default: | 82 default: |
| 88 // Everything else is considered a failure. | 83 // Everything else is considered a failure. |
| 89 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str()); | 84 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str()); |
| 90 } | 85 } |
| 91 } | 86 } |
| 92 | 87 |
| 93 SkISize CodecSrc::size() const { | 88 SkISize CodecSrc::size() const { |
| 94 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); | 89 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); |
| 95 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 90 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
| 96 SkImageInfo info; | 91 return codec->getInfo().dimensions(); |
| 97 if (codec && codec->getInfo(&info)) { | |
| 98 return info.dimensions(); | |
| 99 } | |
| 100 return SkISize::Make(0,0); | |
| 101 } | 92 } |
| 102 | 93 |
| 103 Name CodecSrc::name() const { | 94 Name CodecSrc::name() const { |
| 104 return SkOSPath::Basename(fPath.c_str()); | 95 return SkOSPath::Basename(fPath.c_str()); |
| 105 } | 96 } |
| 106 | 97 |
| 107 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 98 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 108 | 99 |
| 109 ImageSrc::ImageSrc(Path path, int divisor) : fPath(path), fDivisor(divisor) {} | 100 ImageSrc::ImageSrc(Path path, int divisor) : fPath(path), fDivisor(divisor) {} |
| 110 | 101 |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 surfaces.unrefAll(); | 574 surfaces.unrefAll(); |
| 584 return ""; | 575 return ""; |
| 585 } | 576 } |
| 586 SkISize size() const SK_OVERRIDE { return fSize; } | 577 SkISize size() const SK_OVERRIDE { return fSize; } |
| 587 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou
ld be calling this. | 578 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou
ld be calling this. |
| 588 } proxy(fW, fH, pic, src.size()); | 579 } proxy(fW, fH, pic, src.size()); |
| 589 return fSink->draw(proxy, bitmap, stream, log); | 580 return fSink->draw(proxy, bitmap, stream, log); |
| 590 } | 581 } |
| 591 | 582 |
| 592 } // namespace DM | 583 } // namespace DM |
| OLD | NEW |