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