OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 if (info.width() != getInfo().width() || info.height() != getInfo().height()
) | 63 if (info.width() != getInfo().width() || info.height() != getInfo().height()
) |
64 return false; | 64 return false; |
65 | 65 |
66 if (info.colorType() != getInfo().colorType()) { | 66 if (info.colorType() != getInfo().colorType()) { |
67 // blink::ImageFrame may have changed the owning SkBitmap to kOpaque_SkA
lphaType after fully decoding the image frame, | 67 // blink::ImageFrame may have changed the owning SkBitmap to kOpaque_SkA
lphaType after fully decoding the image frame, |
68 // so if we see a request for opaque, that is ok even if our initial alp
ha type was not opaque. | 68 // so if we see a request for opaque, that is ok even if our initial alp
ha type was not opaque. |
69 return false; | 69 return false; |
70 } | 70 } |
71 | 71 |
72 PlatformInstrumentation::willDecodeLazyPixelRef(m_generationId); | 72 PlatformInstrumentation::willDecodeLazyPixelRef(m_generationId); |
73 bool decoded = m_frameGenerator->decodeAndScale(getInfo(), m_frameIndex, pix
els, rowBytes); | 73 bool decoded = m_frameGenerator->decodeAndScale(info, m_frameIndex, pixels,
rowBytes, table, tableCount); |
74 PlatformInstrumentation::didDecodeLazyPixelRef(); | 74 PlatformInstrumentation::didDecodeLazyPixelRef(); |
75 | 75 |
76 return decoded; | 76 return decoded; |
77 } | 77 } |
78 | 78 |
79 bool DecodingImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3],
size_t rowBytes[3], SkYUVColorSpace* colorSpace) | 79 bool DecodingImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3],
size_t rowBytes[3], SkYUVColorSpace* colorSpace) |
80 { | 80 { |
81 if (!m_canYUVDecode) | 81 if (!m_canYUVDecode) |
82 return false; | 82 return false; |
83 | 83 |
(...skipping 22 matching lines...) Expand all Loading... |
106 // we only need the size, it doesn't really matter about premul or not, or g
amma settings. | 106 // we only need the size, it doesn't really matter about premul or not, or g
amma settings. |
107 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*buffer.get(), ImageDeco
der::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied); | 107 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*buffer.get(), ImageDeco
der::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied); |
108 if (!decoder) | 108 if (!decoder) |
109 return 0; | 109 return 0; |
110 | 110 |
111 decoder->setData(buffer.get(), true); | 111 decoder->setData(buffer.get(), true); |
112 if (!decoder->isSizeAvailable()) | 112 if (!decoder->isSizeAvailable()) |
113 return 0; | 113 return 0; |
114 | 114 |
115 const IntSize size = decoder->size(); | 115 const IntSize size = decoder->size(); |
116 const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.heigh
t()); | 116 const SkImageInfo info = decoder->canDecodeTo(0, ImageFrame::Index8) |
| 117 ? SkImageInfo::Make(size.width(), size.height(), kIndex_8_SkColorType, k
Premul_SkAlphaType) |
| 118 : SkImageInfo::MakeN32Premul(size.width(), size.height()); |
117 | 119 |
118 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak
e(size.width(), size.height()), buffer, true, false); | 120 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak
e(size.width(), size.height()), buffer, true, false); |
119 if (!frame) | 121 if (!frame) |
120 return 0; | 122 return 0; |
121 | 123 |
122 return new DecodingImageGenerator(frame, info, 0); | 124 return new DecodingImageGenerator(frame, info, 0); |
123 } | 125 } |
124 | 126 |
125 } // namespace blink | 127 } // namespace blink |
OLD | NEW |