Changeset 54978 in webkit
- Timestamp:
- Feb 18, 2010 11:35:16 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r54974 r54978 1 2010-02-17 Peter Kasting <pkasting@google.com> 2 3 Reviewed by Adam Barth. 4 5 Rework PNG-in-ICO decoding to copy the decoded framebuffer into the ICO 6 decoder, making the logic less crazy and more like the other decoders. 7 https://bugs.webkit.org/show_bug.cgi?id=28751 8 9 * platform/image-decoders/ImageDecoder.cpp: 10 (WebCore::RGBA32Buffer::operator=): 11 * platform/image-decoders/ImageDecoder.h: 12 (WebCore::RGBA32Buffer::RGBA32Buffer): 13 * platform/image-decoders/ico/ICOImageDecoder.cpp: 14 (WebCore::ICOImageDecoder::frameBufferAtIndex): 15 (WebCore::ICOImageDecoder::decodeAtIndex): 16 * platform/image-decoders/ico/ICOImageDecoder.h: 17 * platform/image-decoders/qt/RGBA32BufferQt.cpp: 18 (WebCore::RGBA32Buffer::operator=): 19 * platform/image-decoders/skia/ImageDecoderSkia.cpp: 20 (WebCore::RGBA32Buffer::operator=): 21 1 22 2010-02-18 Pavel Feldman <pfeldman@chromium.org> 2 23 -
trunk/WebCore/platform/image-decoders/ImageDecoder.cpp
r54836 r54978 98 98 } 99 99 100 RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other) 101 { 102 if (this == &other) 103 return *this; 104 105 copyBitmapData(other); 106 setRect(other.rect()); 107 setStatus(other.status()); 108 setDuration(other.duration()); 109 setDisposalMethod(other.disposalMethod()); 110 return *this; 111 } 112 100 113 void RGBA32Buffer::clear() 101 114 { … … 150 163 { 151 164 m_status = status; 152 }153 154 RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other)155 {156 if (this == &other)157 return *this;158 159 copyBitmapData(other);160 setRect(other.rect());161 setStatus(other.status());162 setDuration(other.duration());163 setDisposalMethod(other.disposalMethod());164 return *this;165 165 } 166 166 -
trunk/WebCore/platform/image-decoders/ImageDecoder.h
r54823 r54978 70 70 RGBA32Buffer(); 71 71 72 // For backends which refcount their data, this constructor doesn't need 73 // to create a new copy of the image data, only increase the ref count. 74 // 75 // This exists because ImageDecoder keeps a Vector<RGBA32Buffer>, and 76 // Vector requires this constructor. 77 RGBA32Buffer(const RGBA32Buffer& other) 78 { 79 operator=(other); 80 } 72 RGBA32Buffer(const RGBA32Buffer& other) { operator=(other); } 73 74 // For backends which refcount their data, this operator doesn't need to 75 // create a new copy of the image data, only increase the ref count. 76 RGBA32Buffer& operator=(const RGBA32Buffer& other); 81 77 82 78 // Deletes the pixel data entirely; used by ImageDecoder to save memory … … 140 136 141 137 private: 142 RGBA32Buffer& operator=(const RGBA32Buffer& other);143 144 138 int width() const; 145 139 int height() const; -
trunk/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp
r54823 r54978 116 116 return 0; 117 117 118 // Determine the image type, and if this is a BMP, decode. 119 decode(index, false); 120 121 // PNGs decode into their own framebuffers, so only use our internal cache 122 // for non-PNGs (BMP or unknown). 123 if (!m_pngDecoders[index]) 124 return &m_frameBufferCache[index]; 125 126 // Fail if the size the PNGImageDecoder calculated does not match the size 127 // in the directory. 128 if (m_pngDecoders[index]->isSizeAvailable()) { 129 const IntSize pngSize(m_pngDecoders[index]->size()); 130 const IconDirectoryEntry& dirEntry = m_dirEntries[index]; 131 if (pngSize != dirEntry.m_size) { 132 setFailed(); 133 m_pngDecoders[index]->setFailed(); 134 } 135 } 136 137 return m_pngDecoders[index]->frameBufferAtIndex(0); 118 RGBA32Buffer* buffer = &m_frameBufferCache[index]; 119 if (buffer->status() != RGBA32Buffer::FrameComplete) 120 decode(index, false); 121 return buffer; 138 122 } 139 123 … … 185 169 ASSERT(index < m_dirEntries.size()); 186 170 const IconDirectoryEntry& dirEntry = m_dirEntries[index]; 187 if (!m_bmpReaders[index] && !m_pngDecoders[index]) { 188 // Image type unknown. 189 const ImageType imageType = imageTypeAtIndex(index); 190 if (imageType == BMP) { 171 const ImageType imageType = imageTypeAtIndex(index); 172 if (imageType == Unknown) 173 return false; // Not enough data to determine image type yet. 174 175 if (imageType == BMP) { 176 if (!m_bmpReaders[index]) { 191 177 // We need to have already sized m_frameBufferCache before this, and 192 178 // we must not resize it again later (see caution in frameCount()). … … 195 181 m_bmpReaders[index]->setData(m_data.get()); 196 182 m_bmpReaders[index]->setBuffer(&m_frameBufferCache[index]); 197 } else if (imageType == PNG) {198 m_pngDecoders[index].set(new PNGImageDecoder());199 setDataForPNGDecoderAtIndex(index);200 } else {201 // Not enough data to determine image type yet.202 return false;203 183 } 204 }205 206 if (m_bmpReaders[index]) {207 184 m_frameSize = dirEntry.m_size; 208 185 bool result = m_bmpReaders[index]->decodeBMP(false); … … 211 188 } 212 189 213 // For PNGs, we're now done; further decoding will happen when calling 214 // frameBufferAtIndex() on the PNG decoder. 215 return true; 190 if (!m_pngDecoders[index]) { 191 m_pngDecoders[index].set(new PNGImageDecoder()); 192 setDataForPNGDecoderAtIndex(index); 193 } 194 // Fail if the size the PNGImageDecoder calculated does not match the size 195 // in the directory. 196 if (m_pngDecoders[index]->isSizeAvailable() && (m_pngDecoders[index]->size() != dirEntry.m_size)) { 197 setFailed(); 198 return false; 199 } 200 m_frameBufferCache[index] = *m_pngDecoders[index]->frameBufferAtIndex(0); 201 if (!m_pngDecoders[index]->failed()) 202 return true; 203 setFailed(); 204 return false; 216 205 } 217 206 -
trunk/WebCore/platform/image-decoders/ico/ICOImageDecoder.h
r54823 r54978 87 87 // after calculating the image size. If decoding fails but there is no 88 88 // more data coming, sets the "decode failure" flag. 89 //90 // NOTE: If the desired entry is a PNG, this doesn't actually trigger91 // decoding, it merely ensures the decoder is created and ready to92 // decode. The caller will then call a function on the PNGImageDecoder93 // that actually triggers decoding.94 89 void decode(size_t index, bool onlySize); 95 90 -
trunk/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp
r54823 r54978 41 41 , m_disposalMethod(DisposeNotSpecified) 42 42 { 43 } 44 45 RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other) 46 { 47 if (this == &other) 48 return *this; 49 50 copyBitmapData(other); 51 setRect(other.rect()); 52 setStatus(other.status()); 53 setDuration(other.duration()); 54 setDisposalMethod(other.disposalMethod()); 55 return *this; 43 56 } 44 57 … … 116 129 } 117 130 118 RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other)119 {120 if (this == &other)121 return *this;122 123 copyBitmapData(other);124 setRect(other.rect());125 setStatus(other.status());126 setDuration(other.duration());127 setDisposalMethod(other.disposalMethod());128 return *this;129 }130 131 131 int RGBA32Buffer::width() const 132 132 { -
trunk/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp
r53884 r54978 35 35 , m_disposalMethod(DisposeNotSpecified) 36 36 { 37 } 38 39 RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other) 40 { 41 if (this == &other) 42 return *this; 43 44 m_bitmap = other.m_bitmap; 45 // Keep the pixels locked since we will be writing directly into the 46 // bitmap throughout this object's lifetime. 47 m_bitmap.lockPixels(); 48 setRect(other.rect()); 49 setStatus(other.status()); 50 setDuration(other.duration()); 51 setDisposalMethod(other.disposalMethod()); 52 return *this; 37 53 } 38 54 … … 99 115 } 100 116 101 RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other)102 {103 if (this == &other)104 return *this;105 106 m_bitmap = other.m_bitmap;107 // Keep the pixels locked since we will be writing directly into the108 // bitmap throughout this object's lifetime.109 m_bitmap.lockPixels();110 setRect(other.rect());111 setStatus(other.status());112 setDuration(other.duration());113 setDisposalMethod(other.disposalMethod());114 return *this;115 }116 117 117 int RGBA32Buffer::width() const 118 118 {
Note: See TracChangeset
for help on using the changeset viewer.