Changeset 44825 in webkit
- Timestamp:
- Jun 18, 2009 2:29:11 PM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r44821 r44825 1 2009-06-18 Peter Kasting <pkasting@google.com> 2 3 Reviewed by Eric Seidel. 4 5 https://bugs.webkit.org/show_bug.cgi?id=26460 part one 6 Make isSizeAvailable non-const, since it's not logically const (it 7 triggers lazy decoding), and simplify all the implementations (without 8 changing behavior; just make less verbose). Remove some other 9 inappropriate consts, which enables the removal of all the mutable 10 declarations in the decoders. 11 12 * platform/image-decoders/ImageDecoder.h: 13 (WebCore::ImageDecoder::isSizeAvailable): 14 (WebCore::ImageDecoder::setSize): Make public to avoid needing a friend declaration in the JPEG decoder, and because the ICO/BMP decoders will soon need this. 15 * platform/image-decoders/gif/GIFImageDecoder.cpp: 16 (WebCore::GIFImageDecoder::isSizeAvailable): 17 (WebCore::GIFImageDecoder::repetitionCount): 18 (WebCore::GIFImageDecoder::decode): 19 * platform/image-decoders/gif/GIFImageDecoder.h: 20 * platform/image-decoders/ico/ICOImageDecoder.cpp: 21 (WebCore::ICOImageDecoder::isSizeAvailable): 22 * platform/image-decoders/ico/ICOImageDecoder.h: 23 * platform/image-decoders/jpeg/JPEGImageDecoder.cpp: 24 (WebCore::JPEGImageDecoder::isSizeAvailable): 25 (WebCore::JPEGImageDecoder::decode): 26 * platform/image-decoders/jpeg/JPEGImageDecoder.h: 27 * platform/image-decoders/png/PNGImageDecoder.cpp: 28 (WebCore::PNGImageDecoder::isSizeAvailable): 29 (WebCore::PNGImageDecoder::decode): 30 * platform/image-decoders/png/PNGImageDecoder.h: 31 * platform/image-decoders/xbm/XBMImageDecoder.cpp: 32 (WebCore::XBMImageDecoder::isSizeAvailable): 33 (WebCore::XBMImageDecoder::frameBufferAtIndex): 34 (WebCore::XBMImageDecoder::decode): 35 * platform/image-decoders/xbm/XBMImageDecoder.h: Rename decodeXBM() to decode() for consistency with the JPEG/PNG decoders, and in the future the ICO/BMP decoders. 36 1 37 2009-06-17 Brent Fulgham <bfulgham@webkit.org> 2 38 -
trunk/WebCore/platform/image-decoders/ImageDecoder.h
r44669 r44825 201 201 // seen a failure. Decoders may want to override this to lazily decode 202 202 // enough of the image to get the size. 203 virtual bool isSizeAvailable() const203 virtual bool isSizeAvailable() 204 204 { 205 205 return !m_failed && m_sizeAvailable; … … 212 212 ASSERT(!m_failed); 213 213 return m_size; 214 } 215 216 // Called by the image decoders to set their decoded size, this also check 217 // the size for validity. It will return true if the size was set, or false 218 // if there is an error. On error, the m_failed flag will be set and the 219 // caller should immediately stop decoding. 220 virtual bool setSize(unsigned width, unsigned height) 221 { 222 if (isOverSize(width, height)) { 223 m_failed = true; 224 return false; 225 } 226 m_size = IntSize(width, height); 227 m_sizeAvailable = true; 228 return true; 214 229 } 215 230 … … 242 257 243 258 protected: 244 // Called by the image decoders to set their decoded size, this also check245 // the size for validity. It will return true if the size was set, or false246 // if there is an error. On error, the m_failed flag will be set and the247 // caller should immediately stop decoding.248 bool setSize(unsigned width, unsigned height)249 {250 if (isOverSize(width, height)) {251 m_failed = true;252 return false;253 }254 m_size = IntSize(width, height);255 m_sizeAvailable = true;256 return true;257 }258 259 259 RefPtr<SharedBuffer> m_data; // The encoded data. 260 260 Vector<RGBA32Buffer> m_frameBufferCache; 261 mutablebool m_failed;261 bool m_failed; 262 262 263 263 private: -
trunk/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
r44631 r44825 114 114 115 115 // Whether or not the size information has been decoded yet. 116 bool GIFImageDecoder::isSizeAvailable() const 117 { 118 // If we have pending data to decode, send it to the GIF reader now. 119 if (!ImageDecoder::isSizeAvailable() && m_reader) { 120 if (m_failed) 121 return false; 122 123 // The decoder will go ahead and aggressively consume everything up until the first 124 // size is encountered. 125 decode(GIFSizeQuery, 0); 126 } 116 bool GIFImageDecoder::isSizeAvailable() 117 { 118 if (!ImageDecoder::isSizeAvailable() && !failed() && m_reader) 119 decode(GIFSizeQuery, 0); 127 120 128 121 return ImageDecoder::isSizeAvailable(); … … 153 146 154 147 // The number of repetitions to perform for an animation loop. 155 int GIFImageDecoder::repetitionCount() const148 int GIFImageDecoder::repetitionCount() 156 149 { 157 150 // This value can arrive at any point in the image data stream. Most GIFs … … 238 231 239 232 // Feed data to the GIF reader. 240 void GIFImageDecoder::decode(GIFQuery query, unsigned haltAtFrame) const233 void GIFImageDecoder::decode(GIFQuery query, unsigned haltAtFrame) 241 234 { 242 235 if (m_failed) -
trunk/WebCore/platform/image-decoders/gif/GIFImageDecoder.h
r44553 r44825 45 45 46 46 // Whether or not the size information has been decoded yet. 47 virtual bool isSizeAvailable() const;47 virtual bool isSizeAvailable(); 48 48 49 49 // The total number of frames for the image. Will scan the image data for the answer … … 52 52 53 53 // The number of repetitions to perform for an animation loop. 54 virtual int repetitionCount() const;54 virtual int repetitionCount(); 55 55 56 56 virtual RGBA32Buffer* frameBufferAtIndex(size_t index); … … 80 80 bool m_frameCountValid; 81 81 bool m_currentBufferSawAlpha; 82 mutableint m_repetitionCount;83 mutableGIFImageDecoderPrivate* m_reader;82 int m_repetitionCount; 83 GIFImageDecoderPrivate* m_reader; 84 84 }; 85 85 -
trunk/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp
r44634 r44825 81 81 } 82 82 83 bool ICOImageDecoder::isSizeAvailable() const83 bool ICOImageDecoder::isSizeAvailable() 84 84 { 85 85 return (m_imageType == PNG) ? m_pngDecoder.isSizeAvailable() : -
trunk/WebCore/platform/image-decoders/ico/ICOImageDecoder.h
r44634 r44825 55 55 56 56 // ImageDecoder 57 virtual bool isSizeAvailable() const;57 virtual bool isSizeAvailable(); 58 58 virtual IntSize size() const; 59 59 -
trunk/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
r44631 r44825 410 410 411 411 // Whether or not the size information has been decoded yet. 412 bool JPEGImageDecoder::isSizeAvailable() const 413 { 414 // If we have pending data to decode, send it to the JPEG reader now. 415 if (!ImageDecoder::isSizeAvailable() && m_reader) { 416 if (m_failed) 417 return false; 418 419 // The decoder will go ahead and aggressively consume everything up until the 420 // size is encountered. 421 decode(true); 422 } 412 bool JPEGImageDecoder::isSizeAvailable() 413 { 414 if (!ImageDecoder::isSizeAvailable() && !failed() && m_reader) 415 decode(true); 423 416 424 417 return ImageDecoder::isSizeAvailable(); … … 441 434 442 435 // Feed data to the JPEG reader. 443 void JPEGImageDecoder::decode(bool sizeOnly) const436 void JPEGImageDecoder::decode(bool sizeOnly) 444 437 { 445 438 if (m_failed) -
trunk/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h
r44553 r44825 45 45 46 46 // Whether or not the size information has been decoded yet. 47 virtual bool isSizeAvailable() const;47 virtual bool isSizeAvailable(); 48 48 49 49 virtual RGBA32Buffer* frameBufferAtIndex(size_t index); … … 51 51 virtual bool supportsAlpha() const { return false; } 52 52 53 void decode(bool sizeOnly = false) const;53 void decode(bool sizeOnly = false); 54 54 55 55 JPEGImageReader* reader() { return m_reader; } … … 59 59 60 60 private: 61 friend class JPEGImageReader; 62 mutable JPEGImageReader* m_reader; 61 JPEGImageReader* m_reader; 63 62 }; 64 63 -
trunk/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
r44631 r44825 161 161 162 162 // Whether or not the size information has been decoded yet. 163 bool PNGImageDecoder::isSizeAvailable() const 164 { 165 // If we have pending data to decode, send it to the PNG reader now. 166 if (!ImageDecoder::isSizeAvailable() && m_reader) { 167 if (m_failed) 168 return false; 169 170 // The decoder will go ahead and aggressively consume everything up until the 171 // size is encountered. 172 decode(true); 173 } 163 bool PNGImageDecoder::isSizeAvailable() 164 { 165 if (!ImageDecoder::isSizeAvailable() && !failed() && m_reader) 166 decode(true); 174 167 175 168 return ImageDecoder::isSizeAvailable(); … … 192 185 193 186 // Feed data to the PNG reader. 194 void PNGImageDecoder::decode(bool sizeOnly) const187 void PNGImageDecoder::decode(bool sizeOnly) 195 188 { 196 189 if (m_failed) -
trunk/WebCore/platform/image-decoders/png/PNGImageDecoder.h
r44167 r44825 45 45 46 46 // Whether or not the size information has been decoded yet. 47 virtual bool isSizeAvailable() const;47 virtual bool isSizeAvailable(); 48 48 49 49 virtual RGBA32Buffer* frameBufferAtIndex(size_t index); 50 50 51 void decode(bool sizeOnly = false) const;51 void decode(bool sizeOnly = false); 52 52 53 53 PNGImageReader* reader() { return m_reader; } … … 60 60 61 61 private: 62 mutablePNGImageReader* m_reader;62 PNGImageReader* m_reader; 63 63 }; 64 64 -
trunk/WebCore/platform/image-decoders/xbm/XBMImageDecoder.cpp
r44646 r44825 57 57 } 58 58 59 bool XBMImageDecoder::isSizeAvailable() const 60 { 61 // This method should either (a) not be const, or (b) not be expected to 62 // do anything that changes m_sizeAvailable. The png and jpeg decoders 63 // get around this with callbacks from external libraries. 64 // 65 // FIXME: Find out if we can patch webkit to take care of this. 59 bool XBMImageDecoder::isSizeAvailable() 60 { 66 61 if (!ImageDecoder::isSizeAvailable() && !m_failed) 67 const_cast<XBMImageDecoder*>(this)->decodeXBM(true);68 69 return !m_failed &&ImageDecoder::isSizeAvailable();62 decode(true); 63 64 return ImageDecoder::isSizeAvailable(); 70 65 } 71 66 … … 80 75 // Attempt to get the size if we don't have it yet. 81 76 if (!ImageDecoder::isSizeAvailable()) 82 decode XBM(true);77 decode(true); 83 78 84 79 // Initialize the framebuffer if needed. … … 98 93 // Keep trying to decode until we've got the entire image. 99 94 if (buffer.status() == RGBA32Buffer::FramePartial) 100 decode XBM(false);95 decode(false); 101 96 102 97 return &buffer; … … 262 257 263 258 // Decode as much as we can of the XBM file. 264 void XBMImageDecoder::decode XBM(bool sizeOnly)259 void XBMImageDecoder::decode(bool sizeOnly) 265 260 { 266 261 if (failed()) -
trunk/WebCore/platform/image-decoders/xbm/XBMImageDecoder.h
r44643 r44825 46 46 virtual void setData(SharedBuffer* data, bool allDataReceived); 47 47 // Whether or not the size information has been decoded yet. 48 virtual bool isSizeAvailable() const;48 virtual bool isSizeAvailable(); 49 49 virtual RGBA32Buffer* frameBufferAtIndex(size_t index); 50 50 … … 66 66 bool decodeDatum(uint16_t* result); 67 67 bool decodeData(); 68 void decode XBM(bool sizeOnly);68 void decode(bool sizeOnly); 69 69 70 70 // FIXME: Copying all the XBM data just so we can NULL-terminate, just
Note: See TracChangeset
for help on using the changeset viewer.