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

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: Rebase Created 4 years, 8 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 15 matching lines...) Expand all
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" 32 #include "platform/SharedBuffer.h"
33 #include "platform/graphics/ImageOrientation.h" 33 #include "platform/graphics/ImageOrientation.h"
34 #include "platform/image-decoders/ImageAnimation.h" 34 #include "platform/image-decoders/ImageAnimation.h"
35 #include "platform/image-decoders/ImageFrame.h" 35 #include "platform/image-decoders/ImageFrame.h"
36 #include "platform/image-decoders/SegmentReader.h"
36 #include "public/platform/Platform.h" 37 #include "public/platform/Platform.h"
37 #include "wtf/Assertions.h" 38 #include "wtf/Assertions.h"
38 #include "wtf/PassOwnPtr.h" 39 #include "wtf/PassOwnPtr.h"
39 #include "wtf/RefPtr.h" 40 #include "wtf/RefPtr.h"
40 #include "wtf/Threading.h" 41 #include "wtf/Threading.h"
41 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
42 #include "wtf/text/WTFString.h" 43 #include "wtf/text/WTFString.h"
43 44
44 #if USE(QCMSLIB) 45 #if USE(QCMSLIB)
45 #include "qcms.h" 46 #include "qcms.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 , m_sizeAvailable(false) 116 , m_sizeAvailable(false)
116 , m_isAllDataReceived(false) 117 , m_isAllDataReceived(false)
117 , m_failed(false) { } 118 , m_failed(false) { }
118 119
119 virtual ~ImageDecoder() { } 120 virtual ~ImageDecoder() { }
120 121
121 // Returns a caller-owned decoder of the appropriate type. Returns 0 if 122 // Returns a caller-owned decoder of the appropriate type. Returns 0 if
122 // we can't sniff a supported type from the provided data (possibly 123 // we can't sniff a supported type from the provided data (possibly
123 // because there isn't enough data yet). 124 // because there isn't enough data yet).
124 // Sets m_maxDecodedBytes to Platform::maxImageDecodedBytes(). 125 // Sets m_maxDecodedBytes to Platform::maxImageDecodedBytes().
125 static PassOwnPtr<ImageDecoder> create(const SharedBuffer& data, AlphaOption , GammaAndColorProfileOption); 126 static PassOwnPtr<ImageDecoder> create(const char* data, size_t length, Alph aOption, GammaAndColorProfileOption);
127 static PassOwnPtr<ImageDecoder> create(const SharedBuffer&, AlphaOption, Gam maAndColorProfileOption);
128 static PassOwnPtr<ImageDecoder> create(const SegmentReader&, AlphaOption, Ga mmaAndColorProfileOption);
126 129
127 virtual String filenameExtension() const = 0; 130 virtual String filenameExtension() const = 0;
128 131
129 bool isAllDataReceived() const { return m_isAllDataReceived; } 132 bool isAllDataReceived() const { return m_isAllDataReceived; }
130 133
131 void setData(SharedBuffer* data, bool allDataReceived) 134 void setData(PassRefPtr<SegmentReader> data, bool allDataReceived)
132 { 135 {
133 if (m_failed) 136 if (m_failed)
134 return; 137 return;
135 m_data = data; 138 m_data = data;
136 m_isAllDataReceived = allDataReceived; 139 m_isAllDataReceived = allDataReceived;
137 onSetData(data); 140 onSetData(m_data.get());
138 } 141 }
139 142
140 virtual void onSetData(SharedBuffer* data) { } 143 void setData(PassRefPtr<SharedBuffer> data, bool allDataReceived)
144 {
145 setData(SegmentReader::createFromSharedBuffer(data), allDataReceived);
146 }
147
148 virtual void onSetData(SegmentReader* data) { }
141 149
142 bool isSizeAvailable() 150 bool isSizeAvailable()
143 { 151 {
144 if (m_failed) 152 if (m_failed)
145 return false; 153 return false;
146 if (!m_sizeAvailable) 154 if (!m_sizeAvailable)
147 decodeSize(); 155 decodeSize();
148 return isDecodedSizeAvailable(); 156 return isDecodedSizeAvailable();
149 } 157 }
150 158
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // returns that number. 311 // returns that number.
304 virtual size_t decodeFrameCount() { return 1; } 312 virtual size_t decodeFrameCount() { return 1; }
305 313
306 // Performs any additional setup of the requested frame after it has been 314 // Performs any additional setup of the requested frame after it has been
307 // initially created, e.g. setting a duration or disposal method. 315 // initially created, e.g. setting a duration or disposal method.
308 virtual void initializeNewFrame(size_t) { } 316 virtual void initializeNewFrame(size_t) { }
309 317
310 // Decodes the requested frame. 318 // Decodes the requested frame.
311 virtual void decode(size_t) = 0; 319 virtual void decode(size_t) = 0;
312 320
313 RefPtr<SharedBuffer> m_data; // The encoded data. 321 RefPtr<SegmentReader> m_data; // The encoded data.
314 Vector<ImageFrame, 1> m_frameBufferCache; 322 Vector<ImageFrame, 1> m_frameBufferCache;
315 bool m_premultiplyAlpha; 323 bool m_premultiplyAlpha;
316 bool m_ignoreGammaAndColorProfile; 324 bool m_ignoreGammaAndColorProfile;
317 ImageOrientation m_orientation; 325 ImageOrientation m_orientation;
318 326
319 // The maximum amount of memory a decoded image should require. Ideally, 327 // The maximum amount of memory a decoded image should require. Ideally,
320 // image decoders should downsample large images to fit under this limit 328 // image decoders should downsample large images to fit under this limit
321 // (and then return the downsampled size from decodedSize()). Ignoring 329 // (and then return the downsampled size from decodedSize()). Ignoring
322 // this limit can cause excessive memory use or even crashes on low- 330 // this limit can cause excessive memory use or even crashes on low-
323 // memory devices. 331 // memory devices.
(...skipping 15 matching lines...) Expand all
339 bool m_failed; 347 bool m_failed;
340 348
341 #if USE(QCMSLIB) 349 #if USE(QCMSLIB)
342 OwnPtr<qcms_transform> m_sourceToOutputDeviceColorTransform; 350 OwnPtr<qcms_transform> m_sourceToOutputDeviceColorTransform;
343 #endif 351 #endif
344 }; 352 };
345 353
346 } // namespace blink 354 } // namespace blink
347 355
348 #endif 356 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698