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