Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.h

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Rebasing... Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef DeferredImageDecoder_h 26 #ifndef DeferredImageDecoder_h
27 #define DeferredImageDecoder_h 27 #define DeferredImageDecoder_h
28 28
29 #include "platform/PlatformExport.h" 29 #include "platform/PlatformExport.h"
30 #include "platform/geometry/IntSize.h" 30 #include "platform/geometry/IntSize.h"
31 #include "platform/image-decoders/ImageDecoder.h" 31 #include "platform/image-decoders/ImageDecoder.h"
32 #include "third_party/skia/include/core/SkRWBuffer.h" 32 #include "third_party/skia/include/core/SkRWBuffer.h"
33 #include "third_party/skia/include/core/SkRefCnt.h"
33 #include "wtf/Allocator.h" 34 #include "wtf/Allocator.h"
34 #include "wtf/Forward.h" 35 #include "wtf/Forward.h"
35 #include "wtf/Vector.h" 36 #include "wtf/Vector.h"
36 #include <memory> 37 #include <memory>
37 38
38 class SkImage; 39 class SkImage;
39 40
40 namespace blink { 41 namespace blink {
41 42
42 class ImageFrameGenerator; 43 class ImageFrameGenerator;
43 class SharedBuffer; 44 class SharedBuffer;
44 struct DeferredFrameData; 45 struct DeferredFrameData;
45 46
46 class PLATFORM_EXPORT DeferredImageDecoder final { 47 class PLATFORM_EXPORT DeferredImageDecoder final {
47 WTF_MAKE_NONCOPYABLE(DeferredImageDecoder); 48 WTF_MAKE_NONCOPYABLE(DeferredImageDecoder);
48 USING_FAST_MALLOC(DeferredImageDecoder); 49 USING_FAST_MALLOC(DeferredImageDecoder);
49 public: 50 public:
50 static std::unique_ptr<DeferredImageDecoder> create(PassRefPtr<SharedBuffer> data, bool dataComplete, 51 static std::unique_ptr<DeferredImageDecoder> create(PassRefPtr<SharedBuffer> data, bool dataComplete,
51 ImageDecoder::AlphaOption, ImageDecoder::GammaAndColorProfileOption); 52 ImageDecoder::AlphaOption, ImageDecoder::GammaAndColorProfileOption);
52 53
53 static std::unique_ptr<DeferredImageDecoder> createForTesting(std::unique_pt r<ImageDecoder>); 54 static std::unique_ptr<DeferredImageDecoder> createForTesting(std::unique_pt r<ImageDecoder>);
54 55
55 ~DeferredImageDecoder(); 56 ~DeferredImageDecoder();
56 57
57 String filenameExtension() const; 58 String filenameExtension() const;
58 59
59 PassRefPtr<SkImage> createFrameAtIndex(size_t); 60 sk_sp<SkImage> createFrameAtIndex(size_t);
60 61
61 PassRefPtr<SharedBuffer> data(); 62 PassRefPtr<SharedBuffer> data();
62 void setData(PassRefPtr<SharedBuffer> data, bool allDataReceived); 63 void setData(PassRefPtr<SharedBuffer> data, bool allDataReceived);
63 64
64 bool isSizeAvailable(); 65 bool isSizeAvailable();
65 bool hasColorProfile() const; 66 bool hasColorProfile() const;
66 IntSize size() const; 67 IntSize size() const;
67 IntSize frameSizeAtIndex(size_t index) const; 68 IntSize frameSizeAtIndex(size_t index) const;
68 size_t frameCount(); 69 size_t frameCount();
69 int repetitionCount() const; 70 int repetitionCount() const;
70 size_t clearCacheExceptFrame(size_t index); 71 size_t clearCacheExceptFrame(size_t index);
71 bool frameHasAlphaAtIndex(size_t index) const; 72 bool frameHasAlphaAtIndex(size_t index) const;
72 bool frameIsCompleteAtIndex(size_t index) const; 73 bool frameIsCompleteAtIndex(size_t index) const;
73 float frameDurationAtIndex(size_t index) const; 74 float frameDurationAtIndex(size_t index) const;
74 size_t frameBytesAtIndex(size_t index) const; 75 size_t frameBytesAtIndex(size_t index) const;
75 ImageOrientation orientationAtIndex(size_t index) const; 76 ImageOrientation orientationAtIndex(size_t index) const;
76 bool hotSpot(IntPoint&) const; 77 bool hotSpot(IntPoint&) const;
77 78
78 private: 79 private:
79 explicit DeferredImageDecoder(std::unique_ptr<ImageDecoder> actualDecoder); 80 explicit DeferredImageDecoder(std::unique_ptr<ImageDecoder> actualDecoder);
80 81
81 friend class DeferredImageDecoderTest; 82 friend class DeferredImageDecoderTest;
82 ImageFrameGenerator* frameGenerator() { return m_frameGenerator.get(); } 83 ImageFrameGenerator* frameGenerator() { return m_frameGenerator.get(); }
83 84
84 void activateLazyDecoding(); 85 void activateLazyDecoding();
85 void prepareLazyDecodedFrames(); 86 void prepareLazyDecodedFrames();
86 87
87 PassRefPtr<SkImage> createFrameImageAtIndex(size_t index, bool knownToBeOpaq ue); 88 sk_sp<SkImage> createFrameImageAtIndex(size_t index, bool knownToBeOpaque);
88 89
89 void setDataInternal(PassRefPtr<SharedBuffer> data, bool allDataReceived, bo ol pushDataToDecoder); 90 void setDataInternal(PassRefPtr<SharedBuffer> data, bool allDataReceived, bo ol pushDataToDecoder);
90 91
91 // Copy of the data that is passed in, used by deferred decoding. 92 // Copy of the data that is passed in, used by deferred decoding.
92 // Allows creating readonly snapshots that may be read in another thread. 93 // Allows creating readonly snapshots that may be read in another thread.
93 std::unique_ptr<SkRWBuffer> m_rwBuffer; 94 std::unique_ptr<SkRWBuffer> m_rwBuffer;
94 bool m_allDataReceived; 95 bool m_allDataReceived;
95 std::unique_ptr<ImageDecoder> m_actualDecoder; 96 std::unique_ptr<ImageDecoder> m_actualDecoder;
96 97
97 String m_filenameExtension; 98 String m_filenameExtension;
98 IntSize m_size; 99 IntSize m_size;
99 int m_repetitionCount; 100 int m_repetitionCount;
100 bool m_hasColorProfile; 101 bool m_hasColorProfile;
101 bool m_canYUVDecode; 102 bool m_canYUVDecode;
102 bool m_hasHotSpot; 103 bool m_hasHotSpot;
103 IntPoint m_hotSpot; 104 IntPoint m_hotSpot;
104 105
105 // Caches frame state information. 106 // Caches frame state information.
106 Vector<DeferredFrameData> m_frameData; 107 Vector<DeferredFrameData> m_frameData;
107 RefPtr<ImageFrameGenerator> m_frameGenerator; 108 RefPtr<ImageFrameGenerator> m_frameGenerator;
108 }; 109 };
109 110
110 } // namespace blink 111 } // namespace blink
111 112
112 #endif 113 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698