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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 321 |
322 sk_sp<SkROBuffer> roBuffer(m_rwBuffer->newRBufferSnapshot()); | 322 sk_sp<SkROBuffer> roBuffer(m_rwBuffer->newRBufferSnapshot()); |
323 RefPtr<SegmentReader> segmentReader = | 323 RefPtr<SegmentReader> segmentReader = |
324 SegmentReader::createFromSkROBuffer(std::move(roBuffer)); | 324 SegmentReader::createFromSkROBuffer(std::move(roBuffer)); |
325 | 325 |
326 SkImageInfo info = SkImageInfo::MakeN32( | 326 SkImageInfo info = SkImageInfo::MakeN32( |
327 decodedSize.width(), decodedSize.height(), | 327 decodedSize.width(), decodedSize.height(), |
328 knownToBeOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType, | 328 knownToBeOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType, |
329 m_colorSpaceForSkImages); | 329 m_colorSpaceForSkImages); |
330 | 330 |
331 DecodingImageGenerator* generator = new DecodingImageGenerator( | 331 auto generator = WTF::makeUnique<DecodingImageGenerator>( |
332 m_frameGenerator, info, std::move(segmentReader), m_allDataReceived, | 332 m_frameGenerator, info, std::move(segmentReader), m_allDataReceived, |
333 index, m_frameData[index].m_uniqueID); | 333 index, m_frameData[index].m_uniqueID); |
334 sk_sp<SkImage> image = SkImage::MakeFromGenerator( | 334 generator->setCanYUVDecode(m_canYUVDecode); |
335 generator); // SkImage takes ownership of the generator. | 335 sk_sp<SkImage> image = SkImage::MakeFromGenerator(std::move(generator)); |
336 if (!image) | 336 if (!image) |
337 return nullptr; | 337 return nullptr; |
338 | 338 |
339 // We can consider decoded bitmap constant and reuse uniqueID only after all | 339 // We can consider decoded bitmap constant and reuse uniqueID only after all |
340 // data is received. We reuse it also for multiframe images when image data | 340 // data is received. We reuse it also for multiframe images when image data |
341 // is partially received but the frame data is fully received. | 341 // is partially received but the frame data is fully received. |
342 if (m_allDataReceived || m_frameData[index].m_isComplete) { | 342 if (m_allDataReceived || m_frameData[index].m_isComplete) { |
343 DCHECK(m_frameData[index].m_uniqueID == | 343 DCHECK(m_frameData[index].m_uniqueID == |
344 DecodingImageGenerator::kNeedNewImageUniqueID || | 344 DecodingImageGenerator::kNeedNewImageUniqueID || |
345 m_frameData[index].m_uniqueID == image->uniqueID()); | 345 m_frameData[index].m_uniqueID == image->uniqueID()); |
346 m_frameData[index].m_uniqueID = image->uniqueID(); | 346 m_frameData[index].m_uniqueID = image->uniqueID(); |
347 } | 347 } |
348 | 348 |
349 generator->setCanYUVDecode(m_canYUVDecode); | |
350 | |
351 return image; | 349 return image; |
352 } | 350 } |
353 | 351 |
354 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const { | 352 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const { |
355 if (m_actualDecoder) | 353 if (m_actualDecoder) |
356 return m_actualDecoder->hotSpot(hotSpot); | 354 return m_actualDecoder->hotSpot(hotSpot); |
357 if (m_hasHotSpot) | 355 if (m_hasHotSpot) |
358 hotSpot = m_hotSpot; | 356 hotSpot = m_hotSpot; |
359 return m_hasHotSpot; | 357 return m_hasHotSpot; |
360 } | 358 } |
361 | 359 |
362 } // namespace blink | 360 } // namespace blink |
363 | 361 |
364 namespace WTF { | 362 namespace WTF { |
365 template <> | 363 template <> |
366 struct VectorTraits<blink::DeferredFrameData> | 364 struct VectorTraits<blink::DeferredFrameData> |
367 : public SimpleClassVectorTraits<blink::DeferredFrameData> { | 365 : public SimpleClassVectorTraits<blink::DeferredFrameData> { |
368 STATIC_ONLY(VectorTraits); | 366 STATIC_ONLY(VectorTraits); |
369 static const bool canInitializeWithMemset = | 367 static const bool canInitializeWithMemset = |
370 false; // Not all DeferredFrameData members initialize to 0. | 368 false; // Not all DeferredFrameData members initialize to 0. |
371 }; | 369 }; |
372 } | 370 } |
OLD | NEW |