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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 return; | 221 return; |
222 | 222 |
223 m_size = m_actualDecoder->size(); | 223 m_size = m_actualDecoder->size(); |
224 m_filenameExtension = m_actualDecoder->filenameExtension(); | 224 m_filenameExtension = m_actualDecoder->filenameExtension(); |
225 // JPEG images support YUV decoding: other decoders do not, WEBP could in fu
ture. | 225 // JPEG images support YUV decoding: other decoders do not, WEBP could in fu
ture. |
226 m_canYUVDecode = RuntimeEnabledFeatures::decodeToYUVEnabled() && (m_filename
Extension == "jpg"); | 226 m_canYUVDecode = RuntimeEnabledFeatures::decodeToYUVEnabled() && (m_filename
Extension == "jpg"); |
227 m_hasColorProfile = m_actualDecoder->hasColorProfile(); | 227 m_hasColorProfile = m_actualDecoder->hasColorProfile(); |
228 | 228 |
229 const bool isSingleFrame = m_actualDecoder->repetitionCount() == cAnimationN
one || (m_allDataReceived && m_actualDecoder->frameCount() == 1u); | 229 const bool isSingleFrame = m_actualDecoder->repetitionCount() == cAnimationN
one || (m_allDataReceived && m_actualDecoder->frameCount() == 1u); |
230 m_frameGenerator = ImageFrameGenerator::create(SkISize::Make(m_actualDecoder
->decodedSize().width(), m_actualDecoder->decodedSize().height()), m_data, m_all
DataReceived, !isSingleFrame); | 230 m_frameGenerator = ImageFrameGenerator::create(SkISize::Make(m_actualDecoder
->decodedSize().width(), m_actualDecoder->decodedSize().height()), m_data, m_all
DataReceived, !isSingleFrame); |
| 231 // GIF images support Index8 decoding: other decoders do not. |
| 232 m_frameGenerator->setDecoderCanDecodeToIndex8(m_filenameExtension == "gif"); |
231 } | 233 } |
232 | 234 |
233 void DeferredImageDecoder::prepareLazyDecodedFrames() | 235 void DeferredImageDecoder::prepareLazyDecodedFrames() |
234 { | 236 { |
235 if (!s_enabled | 237 if (!s_enabled |
236 || !m_actualDecoder | 238 || !m_actualDecoder |
237 || !m_actualDecoder->isSizeAvailable() | 239 || !m_actualDecoder->isSizeAvailable() |
238 || m_actualDecoder->filenameExtension() == "ico") | 240 || m_actualDecoder->filenameExtension() == "ico") |
239 return; | 241 return; |
240 | 242 |
(...skipping 20 matching lines...) Expand all Loading... |
261 m_frameData[lastFrame].m_isComplete = m_actualDecoder->frameIsCompleteAt
Index(lastFrame); | 263 m_frameData[lastFrame].m_isComplete = m_actualDecoder->frameIsCompleteAt
Index(lastFrame); |
262 } | 264 } |
263 | 265 |
264 if (m_allDataReceived) { | 266 if (m_allDataReceived) { |
265 m_repetitionCount = m_actualDecoder->repetitionCount(); | 267 m_repetitionCount = m_actualDecoder->repetitionCount(); |
266 m_actualDecoder.clear(); | 268 m_actualDecoder.clear(); |
267 m_data = nullptr; | 269 m_data = nullptr; |
268 } | 270 } |
269 } | 271 } |
270 | 272 |
271 inline SkImageInfo imageInfoFrom(const SkISize& decodedSize, bool knownToBeOpaqu
e) | 273 static inline SkImageInfo imageInfoFrom(const SkISize& decodedSize, bool knownTo
BeOpaque) |
272 { | 274 { |
273 return SkImageInfo::MakeN32(decodedSize.width(), decodedSize.height(), known
ToBeOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); | 275 return SkImageInfo::MakeN32(decodedSize.width(), decodedSize.height(), known
ToBeOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); |
274 } | 276 } |
275 | 277 |
276 PassRefPtr<SkImage> DeferredImageDecoder::createFrameImageAtIndex(size_t index,
bool knownToBeOpaque) const | 278 PassRefPtr<SkImage> DeferredImageDecoder::createFrameImageAtIndex(size_t index,
bool knownToBeOpaque) const |
277 { | 279 { |
278 const SkISize& decodedSize = m_frameGenerator->getFullSize(); | 280 const SkISize& decodedSize = m_frameGenerator->getFullSize(); |
279 ASSERT(decodedSize.width() > 0); | 281 ASSERT(decodedSize.width() > 0); |
280 ASSERT(decodedSize.height() > 0); | 282 ASSERT(decodedSize.height() > 0); |
281 | 283 |
282 DecodingImageGenerator* generator = new DecodingImageGenerator(m_frameGenera
tor, imageInfoFrom(decodedSize, knownToBeOpaque), index); | 284 const SkImageInfo info = m_frameGenerator->canDecodeTo(index, kIndex_8_SkCol
orType) |
283 RefPtr<SkImage> image = adoptRef(SkImage::NewFromGenerator(generator)); // S
kImage takes ownership of the generator. | 285 ? SkImageInfo::Make(decodedSize.width(), decodedSize.height(), kIndex_8_
SkColorType, |
| 286 knownToBeOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType) |
| 287 : imageInfoFrom(decodedSize, knownToBeOpaque); |
| 288 |
| 289 DecodingImageGenerator* generator = new DecodingImageGenerator(m_frameGenera
tor, info, index); |
| 290 RefPtr<SkImage> image = adoptRef(SkImage::NewFromGenerator(generator)); |
284 if (!image) | 291 if (!image) |
285 return nullptr; | 292 return nullptr; |
286 | 293 |
287 generator->setGenerationId(image->uniqueID()); | 294 generator->setGenerationId(image->uniqueID()); |
288 generator->setCanYUVDecode(m_canYUVDecode); | 295 generator->setCanYUVDecode(m_canYUVDecode); |
289 | 296 |
290 return image.release(); | 297 return image.release(); |
291 } | 298 } |
292 | 299 |
293 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const | 300 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const |
294 { | 301 { |
295 // TODO: Implement. | 302 // TODO: Implement. |
296 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; | 303 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; |
297 } | 304 } |
298 | 305 |
299 } // namespace blink | 306 } // namespace blink |
OLD | NEW |