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

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

Issue 2257513002: Refactor ImageDecoder factories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review 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 29 matching lines...) Expand all
40 namespace blink { 40 namespace blink {
41 41
42 class ImageFrameGenerator; 42 class ImageFrameGenerator;
43 class SharedBuffer; 43 class SharedBuffer;
44 struct DeferredFrameData; 44 struct DeferredFrameData;
45 45
46 class PLATFORM_EXPORT DeferredImageDecoder final { 46 class PLATFORM_EXPORT DeferredImageDecoder final {
47 WTF_MAKE_NONCOPYABLE(DeferredImageDecoder); 47 WTF_MAKE_NONCOPYABLE(DeferredImageDecoder);
48 USING_FAST_MALLOC(DeferredImageDecoder); 48 USING_FAST_MALLOC(DeferredImageDecoder);
49 public: 49 public:
50 static std::unique_ptr<DeferredImageDecoder> create(ImageDecoder::SniffResul t, ImageDecoder::AlphaOption, ImageDecoder::GammaAndColorProfileOption); 50 static std::unique_ptr<DeferredImageDecoder> create(PassRefPtr<SharedBuffer> data, bool dataComplete,
51 ImageDecoder::AlphaOption, ImageDecoder::GammaAndColorProfileOption);
51 52
52 static std::unique_ptr<DeferredImageDecoder> createForTesting(std::unique_pt r<ImageDecoder>); 53 static std::unique_ptr<DeferredImageDecoder> createForTesting(std::unique_pt r<ImageDecoder>);
53 54
54 ~DeferredImageDecoder(); 55 ~DeferredImageDecoder();
55 56
56 String filenameExtension() const; 57 String filenameExtension() const;
57 58
58 PassRefPtr<SkImage> createFrameAtIndex(size_t); 59 PassRefPtr<SkImage> createFrameAtIndex(size_t);
59 60
60 PassRefPtr<SharedBuffer> data(); 61 PassRefPtr<SharedBuffer> data();
61 void setData(SharedBuffer& data, bool allDataReceived); 62 void setData(PassRefPtr<SharedBuffer> data, bool allDataReceived);
62 63
63 bool isSizeAvailable(); 64 bool isSizeAvailable();
64 bool hasColorProfile() const; 65 bool hasColorProfile() const;
65 IntSize size() const; 66 IntSize size() const;
66 IntSize frameSizeAtIndex(size_t index) const; 67 IntSize frameSizeAtIndex(size_t index) const;
67 size_t frameCount(); 68 size_t frameCount();
68 int repetitionCount() const; 69 int repetitionCount() const;
69 size_t clearCacheExceptFrame(size_t index); 70 size_t clearCacheExceptFrame(size_t index);
70 bool frameHasAlphaAtIndex(size_t index) const; 71 bool frameHasAlphaAtIndex(size_t index) const;
71 bool frameIsCompleteAtIndex(size_t index) const; 72 bool frameIsCompleteAtIndex(size_t index) const;
72 float frameDurationAtIndex(size_t index) const; 73 float frameDurationAtIndex(size_t index) const;
73 size_t frameBytesAtIndex(size_t index) const; 74 size_t frameBytesAtIndex(size_t index) const;
74 ImageOrientation orientationAtIndex(size_t index) const; 75 ImageOrientation orientationAtIndex(size_t index) const;
75 bool hotSpot(IntPoint&) const; 76 bool hotSpot(IntPoint&) const;
76 77
77 private: 78 private:
78 explicit DeferredImageDecoder(std::unique_ptr<ImageDecoder> actualDecoder); 79 explicit DeferredImageDecoder(std::unique_ptr<ImageDecoder> actualDecoder);
79 80
80 friend class DeferredImageDecoderTest; 81 friend class DeferredImageDecoderTest;
81 ImageFrameGenerator* frameGenerator() { return m_frameGenerator.get(); } 82 ImageFrameGenerator* frameGenerator() { return m_frameGenerator.get(); }
82 83
83 void activateLazyDecoding(); 84 void activateLazyDecoding();
84 void prepareLazyDecodedFrames(); 85 void prepareLazyDecodedFrames();
85 86
86 PassRefPtr<SkImage> createFrameImageAtIndex(size_t index, bool knownToBeOpaq ue); 87 PassRefPtr<SkImage> createFrameImageAtIndex(size_t index, bool knownToBeOpaq ue);
87 88
89 void setDataInternal(PassRefPtr<SharedBuffer> data, bool allDataReceived, bo ol pushDataToDecoder);
90
88 // Copy of the data that is passed in, used by deferred decoding. 91 // Copy of the data that is passed in, used by deferred decoding.
89 // Allows creating readonly snapshots that may be read in another thread. 92 // Allows creating readonly snapshots that may be read in another thread.
90 std::unique_ptr<SkRWBuffer> m_rwBuffer; 93 std::unique_ptr<SkRWBuffer> m_rwBuffer;
91 bool m_allDataReceived; 94 bool m_allDataReceived;
92 std::unique_ptr<ImageDecoder> m_actualDecoder; 95 std::unique_ptr<ImageDecoder> m_actualDecoder;
93 96
94 String m_filenameExtension; 97 String m_filenameExtension;
95 IntSize m_size; 98 IntSize m_size;
96 int m_repetitionCount; 99 int m_repetitionCount;
97 bool m_hasColorProfile; 100 bool m_hasColorProfile;
98 bool m_canYUVDecode; 101 bool m_canYUVDecode;
99 bool m_hasHotSpot; 102 bool m_hasHotSpot;
100 IntPoint m_hotSpot; 103 IntPoint m_hotSpot;
101 104
102 // Caches frame state information. 105 // Caches frame state information.
103 Vector<DeferredFrameData> m_frameData; 106 Vector<DeferredFrameData> m_frameData;
104 RefPtr<ImageFrameGenerator> m_frameGenerator; 107 RefPtr<ImageFrameGenerator> m_frameGenerator;
105 }; 108 };
106 109
107 } // namespace blink 110 } // namespace blink
108 111
109 #endif 112 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698