Changeset 238275 in webkit
- Timestamp:
- Nov 16, 2018 2:57:17 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r238274 r238275 1 2018-11-16 Zan Dobersek <zdobersek@igalia.com> 2 3 ScalableImageDecoder: don't forcefully decode image data when querying frame completeness, duration 4 https://bugs.webkit.org/show_bug.cgi?id=191354 5 6 Reviewed by Michael Catanzaro. 7 8 ScalableImageDecoder::frameIsCompleteAtIndex() should only check the 9 index validity and, if the index is valid, check for completeness of the 10 corresponding frame. ScalableImageDecoder::frameDurationAtIndex() should 11 also only retrieve duration for already-complete frames. 12 13 Both methods avoid calling ScalableImageDecoder::frameBufferAtIndex() 14 as that method goes on and decodes image data to determine specific 15 information. The ImageSource class that's querying this information 16 doesn't anticipate this, and doesn't handle the increased memory 17 consumption of the decoded data, leaving MemoryCache in the blind about 18 the image resource's actual amount of consumed memory. ImageSource can 19 instead gracefully handle any incomplete frame by marking the decoding 20 status for this frame as only partial. 21 22 * platform/image-decoders/ScalableImageDecoder.cpp: 23 (WebCore::ScalableImageDecoder::frameIsCompleteAtIndex const): 24 (WebCore::ScalableImageDecoder::frameHasAlphaAtIndex const): 25 (WebCore::ScalableImageDecoder::frameDurationAtIndex const): 26 1 27 2018-11-16 Antoine Quint <graouts@apple.com> 2 28 -
trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp
r230522 r238275 174 174 { 175 175 LockHolder lockHolder(m_mutex); 176 // FIXME(176089): asking whether enough data has been appended for a decode177 // operation to succeed should not require decoding the entire frame.178 // This function should be implementable in a way that allows const. 179 auto * buffer = const_cast<ScalableImageDecoder*>(this)->frameBufferAtIndex(index);180 return buffer && buffer->isComplete();176 if (index >= m_frameBufferCache.size()) 177 return false; 178 179 auto& frame = m_frameBufferCache[index]; 180 return frame.isComplete(); 181 181 } 182 182 … … 186 186 if (m_frameBufferCache.size() <= index) 187 187 return true; 188 if (m_frameBufferCache[index].isComplete()) 189 return m_frameBufferCache[index].hasAlpha(); 190 return true; 188 189 auto& frame = m_frameBufferCache[index]; 190 if (!frame.isComplete()) 191 return true; 192 return frame.hasAlpha(); 191 193 } 192 194 … … 203 205 { 204 206 LockHolder lockHolder(m_mutex); 205 // FIXME(176089): asking for the duration of a sub-image should not require decoding 206 // the entire frame. This function should be implementable in a way that 207 // allows const. 208 auto* buffer = const_cast<ScalableImageDecoder*>(this)->frameBufferAtIndex(index); 209 if (!buffer || buffer->isInvalid()) 207 if (index >= m_frameBufferCache.size()) 210 208 return 0_s; 211 209 210 auto& frame = m_frameBufferCache[index]; 211 if (!frame.isComplete()) 212 return 0_s; 213 212 214 // Many annoying ads specify a 0 duration to make an image flash as quickly as possible. 213 215 // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify 214 216 // a duration of <= 10 ms. See <rdar://problem/7689300> and <http://webkit.org/b/36082> 215 217 // for more information. 216 if (buffer->duration() < 11_ms) 218 auto duration = frame.duration(); 219 if (duration < 11_ms) 217 220 return 100_ms; 218 return buffer->duration();221 return duration; 219 222 } 220 223
Note: See TracChangeset
for help on using the changeset viewer.