| 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 15 matching lines...) Expand all Loading... |
| 26 #include "platform/graphics/DeferredImageDecoder.h" | 26 #include "platform/graphics/DeferredImageDecoder.h" |
| 27 | 27 |
| 28 #include "platform/RuntimeEnabledFeatures.h" | 28 #include "platform/RuntimeEnabledFeatures.h" |
| 29 #include "platform/SharedBuffer.h" | 29 #include "platform/SharedBuffer.h" |
| 30 #include "platform/graphics/DecodingImageGenerator.h" | 30 #include "platform/graphics/DecodingImageGenerator.h" |
| 31 #include "platform/graphics/ImageDecodingStore.h" | 31 #include "platform/graphics/ImageDecodingStore.h" |
| 32 #include "platform/graphics/ImageFrameGenerator.h" | 32 #include "platform/graphics/ImageFrameGenerator.h" |
| 33 #include "platform/graphics/skia/SkiaUtils.h" | 33 #include "platform/graphics/skia/SkiaUtils.h" |
| 34 #include "platform/image-decoders/SegmentReader.h" | 34 #include "platform/image-decoders/SegmentReader.h" |
| 35 #include "third_party/skia/include/core/SkImage.h" | 35 #include "third_party/skia/include/core/SkImage.h" |
| 36 #include "wtf/PtrUtil.h" | 36 #include "wtf/PassOwnPtr.h" |
| 37 #include <memory> | |
| 38 | 37 |
| 39 namespace blink { | 38 namespace blink { |
| 40 | 39 |
| 41 struct DeferredFrameData { | 40 struct DeferredFrameData { |
| 42 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 41 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 43 WTF_MAKE_NONCOPYABLE(DeferredFrameData); | 42 WTF_MAKE_NONCOPYABLE(DeferredFrameData); |
| 44 public: | 43 public: |
| 45 DeferredFrameData() | 44 DeferredFrameData() |
| 46 : m_orientation(DefaultImageOrientation) | 45 : m_orientation(DefaultImageOrientation) |
| 47 , m_duration(0) | 46 , m_duration(0) |
| 48 , m_isComplete(false) | 47 , m_isComplete(false) |
| 49 , m_frameBytes(0) | 48 , m_frameBytes(0) |
| 50 , m_uniqueID(DecodingImageGenerator::kNeedNewImageUniqueID) | 49 , m_uniqueID(DecodingImageGenerator::kNeedNewImageUniqueID) |
| 51 {} | 50 {} |
| 52 | 51 |
| 53 ImageOrientation m_orientation; | 52 ImageOrientation m_orientation; |
| 54 float m_duration; | 53 float m_duration; |
| 55 bool m_isComplete; | 54 bool m_isComplete; |
| 56 size_t m_frameBytes; | 55 size_t m_frameBytes; |
| 57 uint32_t m_uniqueID; | 56 uint32_t m_uniqueID; |
| 58 }; | 57 }; |
| 59 | 58 |
| 60 std::unique_ptr<DeferredImageDecoder> DeferredImageDecoder::create(const SharedB
uffer& data, ImageDecoder::AlphaOption alphaOption, ImageDecoder::GammaAndColorP
rofileOption colorOptions) | 59 PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::create(const SharedBuffer
& data, ImageDecoder::AlphaOption alphaOption, ImageDecoder::GammaAndColorProfil
eOption colorOptions) |
| 61 { | 60 { |
| 62 std::unique_ptr<ImageDecoder> actualDecoder = ImageDecoder::create(data, alp
haOption, colorOptions); | 61 OwnPtr<ImageDecoder> actualDecoder = ImageDecoder::create(data, alphaOption,
colorOptions); |
| 63 | 62 |
| 64 if (!actualDecoder) | 63 if (!actualDecoder) |
| 65 return nullptr; | 64 return nullptr; |
| 66 | 65 |
| 67 return wrapUnique(new DeferredImageDecoder(std::move(actualDecoder))); | 66 return adoptPtr(new DeferredImageDecoder(std::move(actualDecoder))); |
| 68 } | 67 } |
| 69 | 68 |
| 70 std::unique_ptr<DeferredImageDecoder> DeferredImageDecoder::createForTesting(std
::unique_ptr<ImageDecoder> actualDecoder) | 69 PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::createForTesting(PassOwnP
tr<ImageDecoder> actualDecoder) |
| 71 { | 70 { |
| 72 return wrapUnique(new DeferredImageDecoder(std::move(actualDecoder))); | 71 return adoptPtr(new DeferredImageDecoder(std::move(actualDecoder))); |
| 73 } | 72 } |
| 74 | 73 |
| 75 DeferredImageDecoder::DeferredImageDecoder(std::unique_ptr<ImageDecoder> actualD
ecoder) | 74 DeferredImageDecoder::DeferredImageDecoder(PassOwnPtr<ImageDecoder> actualDecode
r) |
| 76 : m_allDataReceived(false) | 75 : m_allDataReceived(false) |
| 77 , m_actualDecoder(std::move(actualDecoder)) | 76 , m_actualDecoder(std::move(actualDecoder)) |
| 78 , m_repetitionCount(cAnimationNone) | 77 , m_repetitionCount(cAnimationNone) |
| 79 , m_hasColorProfile(false) | 78 , m_hasColorProfile(false) |
| 80 , m_canYUVDecode(false) | 79 , m_canYUVDecode(false) |
| 81 , m_hasHotSpot(false) | 80 , m_hasHotSpot(false) |
| 82 { | 81 { |
| 83 } | 82 } |
| 84 | 83 |
| 85 DeferredImageDecoder::~DeferredImageDecoder() | 84 DeferredImageDecoder::~DeferredImageDecoder() |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 void DeferredImageDecoder::setData(SharedBuffer& data, bool allDataReceived) | 122 void DeferredImageDecoder::setData(SharedBuffer& data, bool allDataReceived) |
| 124 { | 123 { |
| 125 if (m_actualDecoder) { | 124 if (m_actualDecoder) { |
| 126 m_allDataReceived = allDataReceived; | 125 m_allDataReceived = allDataReceived; |
| 127 m_actualDecoder->setData(&data, allDataReceived); | 126 m_actualDecoder->setData(&data, allDataReceived); |
| 128 prepareLazyDecodedFrames(); | 127 prepareLazyDecodedFrames(); |
| 129 } | 128 } |
| 130 | 129 |
| 131 if (m_frameGenerator) { | 130 if (m_frameGenerator) { |
| 132 if (!m_rwBuffer) | 131 if (!m_rwBuffer) |
| 133 m_rwBuffer = wrapUnique(new SkRWBuffer(data.size())); | 132 m_rwBuffer = adoptPtr(new SkRWBuffer(data.size())); |
| 134 | 133 |
| 135 const char* segment = 0; | 134 const char* segment = 0; |
| 136 for (size_t length = data.getSomeData(segment, m_rwBuffer->size()); | 135 for (size_t length = data.getSomeData(segment, m_rwBuffer->size()); |
| 137 length; length = data.getSomeData(segment, m_rwBuffer->size())) | 136 length; length = data.getSomeData(segment, m_rwBuffer->size())) |
| 138 m_rwBuffer->append(segment, length); | 137 m_rwBuffer->append(segment, length); |
| 139 } | 138 } |
| 140 } | 139 } |
| 141 | 140 |
| 142 bool DeferredImageDecoder::isSizeAvailable() | 141 bool DeferredImageDecoder::isSizeAvailable() |
| 143 { | 142 { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 } | 324 } |
| 326 | 325 |
| 327 } // namespace blink | 326 } // namespace blink |
| 328 | 327 |
| 329 namespace WTF { | 328 namespace WTF { |
| 330 template<> struct VectorTraits<blink::DeferredFrameData> : public SimpleClassVec
torTraits<blink::DeferredFrameData> { | 329 template<> struct VectorTraits<blink::DeferredFrameData> : public SimpleClassVec
torTraits<blink::DeferredFrameData> { |
| 331 STATIC_ONLY(VectorTraits); | 330 STATIC_ONLY(VectorTraits); |
| 332 static const bool canInitializeWithMemset = false; // Not all DeferredFrameD
ata members initialize to 0. | 331 static const bool canInitializeWithMemset = false; // Not all DeferredFrameD
ata members initialize to 0. |
| 333 }; | 332 }; |
| 334 } | 333 } |
| OLD | NEW |