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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.h

Issue 1812273003: Eliminate copies of encoded image data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 11 matching lines...) Expand all
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #ifndef ImageDecoder_h 27 #ifndef ImageDecoder_h
28 #define ImageDecoder_h 28 #define ImageDecoder_h
29 29
30 #include "SkColorPriv.h" 30 #include "SkColorPriv.h"
31 #include "platform/PlatformExport.h" 31 #include "platform/PlatformExport.h"
32 #include "platform/SharedBuffer.h"
33 #include "platform/graphics/ImageOrientation.h" 32 #include "platform/graphics/ImageOrientation.h"
34 #include "platform/image-decoders/ImageAnimation.h" 33 #include "platform/image-decoders/ImageAnimation.h"
35 #include "platform/image-decoders/ImageFrame.h" 34 #include "platform/image-decoders/ImageFrame.h"
35 #include "platform/image-decoders/SegmentReader.h"
36 #include "public/platform/Platform.h" 36 #include "public/platform/Platform.h"
37 #include "wtf/Assertions.h" 37 #include "wtf/Assertions.h"
38 #include "wtf/PassOwnPtr.h" 38 #include "wtf/PassOwnPtr.h"
39 #include "wtf/RefPtr.h" 39 #include "wtf/RefPtr.h"
40 #include "wtf/Threading.h" 40 #include "wtf/Threading.h"
41 #include "wtf/Vector.h" 41 #include "wtf/Vector.h"
42 #include "wtf/text/WTFString.h" 42 #include "wtf/text/WTFString.h"
43 43
44 #if USE(QCMSLIB) 44 #if USE(QCMSLIB)
45 #include "qcms.h" 45 #include "qcms.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 , m_sizeAvailable(false) 92 , m_sizeAvailable(false)
93 , m_isAllDataReceived(false) 93 , m_isAllDataReceived(false)
94 , m_failed(false) { } 94 , m_failed(false) { }
95 95
96 virtual ~ImageDecoder() { } 96 virtual ~ImageDecoder() { }
97 97
98 // Returns a caller-owned decoder of the appropriate type. Returns 0 if 98 // Returns a caller-owned decoder of the appropriate type. Returns 0 if
99 // we can't sniff a supported type from the provided data (possibly 99 // we can't sniff a supported type from the provided data (possibly
100 // because there isn't enough data yet). 100 // because there isn't enough data yet).
101 // Sets m_maxDecodedBytes to Platform::maxImageDecodedBytes(). 101 // Sets m_maxDecodedBytes to Platform::maxImageDecodedBytes().
102 static PassOwnPtr<ImageDecoder> create(const SharedBuffer& data, AlphaOption , GammaAndColorProfileOption); 102 static PassOwnPtr<ImageDecoder> create(const SegmentReader& data, AlphaOptio n, GammaAndColorProfileOption);
103 103
104 virtual String filenameExtension() const = 0; 104 virtual String filenameExtension() const = 0;
105 105
106 bool isAllDataReceived() const { return m_isAllDataReceived; } 106 bool isAllDataReceived() const { return m_isAllDataReceived; }
107 107
108 void setData(SharedBuffer* data, bool allDataReceived) 108 void setData(SegmentReader* data, bool allDataReceived)
Peter Kasting 2016/03/23 02:42:59 This takes ownership from the caller. It should e
f(malita) 2016/03/23 16:41:58 +1 Not new to this CL, but setData should take a
scroggo_chromium 2016/03/24 13:59:45 Since my CL did not introduce this pattern, do you
f(malita) 2016/03/24 16:48:37 Yeah, we should do that separately.
109 { 109 {
110 if (m_failed) 110 if (m_failed)
111 return; 111 return;
112 m_data = data; 112 m_data = data;
113 m_isAllDataReceived = allDataReceived; 113 m_isAllDataReceived = allDataReceived;
114 onSetData(data); 114 onSetData(data);
115 } 115 }
116 116
117 virtual void onSetData(SharedBuffer* data) { } 117 virtual void onSetData(SegmentReader* data) { }
118 118
119 bool isSizeAvailable() 119 bool isSizeAvailable()
120 { 120 {
121 if (m_failed) 121 if (m_failed)
122 return false; 122 return false;
123 if (!m_sizeAvailable) 123 if (!m_sizeAvailable)
124 decodeSize(); 124 decodeSize();
125 return isDecodedSizeAvailable(); 125 return isDecodedSizeAvailable();
126 } 126 }
127 127
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // returns that number. 327 // returns that number.
328 virtual size_t decodeFrameCount() { return 1; } 328 virtual size_t decodeFrameCount() { return 1; }
329 329
330 // Performs any additional setup of the requested frame after it has been 330 // Performs any additional setup of the requested frame after it has been
331 // initially created, e.g. setting a duration or disposal method. 331 // initially created, e.g. setting a duration or disposal method.
332 virtual void initializeNewFrame(size_t) { } 332 virtual void initializeNewFrame(size_t) { }
333 333
334 // Decodes the requested frame. 334 // Decodes the requested frame.
335 virtual void decode(size_t) = 0; 335 virtual void decode(size_t) = 0;
336 336
337 RefPtr<SharedBuffer> m_data; // The encoded data. 337 RefPtr<SegmentReader> m_data; // The encoded data.
338 Vector<ImageFrame, 1> m_frameBufferCache; 338 Vector<ImageFrame, 1> m_frameBufferCache;
339 bool m_premultiplyAlpha; 339 bool m_premultiplyAlpha;
340 bool m_ignoreGammaAndColorProfile; 340 bool m_ignoreGammaAndColorProfile;
341 ImageOrientation m_orientation; 341 ImageOrientation m_orientation;
342 342
343 // The maximum amount of memory a decoded image should require. Ideally, 343 // The maximum amount of memory a decoded image should require. Ideally,
344 // image decoders should downsample large images to fit under this limit 344 // image decoders should downsample large images to fit under this limit
345 // (and then return the downsampled size from decodedSize()). Ignoring 345 // (and then return the downsampled size from decodedSize()). Ignoring
346 // this limit can cause excessive memory use or even crashes on low- 346 // this limit can cause excessive memory use or even crashes on low-
347 // memory devices. 347 // memory devices.
(...skipping 11 matching lines...) Expand all
359 359
360 IntSize m_size; 360 IntSize m_size;
361 bool m_sizeAvailable; 361 bool m_sizeAvailable;
362 bool m_isAllDataReceived; 362 bool m_isAllDataReceived;
363 bool m_failed; 363 bool m_failed;
364 }; 364 };
365 365
366 } // namespace blink 366 } // namespace blink
367 367
368 #endif 368 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698