Changeset 199821 in webkit
- Timestamp:
- Apr 21, 2016 10:02:57 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r199819 r199821 1 2016-04-21 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 REGRESSION(198782): ImageSource::subsamplingLevelForScale() does not cache the MaximumSubsamplingLevel for this ImageSource 4 https://bugs.webkit.org/show_bug.cgi?id=156766 5 6 Reviewed by Darin Adler. 7 8 Ensure the MaximumSubsamplingLevel for the ImageSource is calculated 9 only once and is cached for subsequent uses. 10 11 The image subsampling is on by default only for iOS. So the and this 12 patch currently affects the iOS port. 13 14 * platform/graphics/ImageSource.cpp: 15 (WebCore::ImageSource::cacheMetadata): Cache m_maximumSubsamplingLevel. 16 Use m_frameCount as a flag for having_the_cache_done. 17 (WebCore::ImageSource::subsamplingLevelForScale): Call cacheMetadata() 18 before using m_maximumSubsamplingLevel. 19 (WebCore::ImageSource::frameCount): Call cacheMetadata() before returning 20 m_frameCount. 21 * platform/graphics/ImageSource.h: 22 1 23 2016-04-21 Antoine Quint <graouts@apple.com> 2 24 -
trunk/Source/WebCore/platform/graphics/ImageSource.cpp
r199764 r199821 105 105 } 106 106 107 SubsamplingLevel ImageSource::subsamplingLevelForScale(float scale) const 107 void ImageSource::cacheMetadata() 108 { 109 if (m_frameCount || !isSizeAvailable()) 110 return; 111 112 m_frameCount = m_decoder->frameCount(); 113 m_maximumSubsamplingLevel = calculateMaximumSubsamplingLevel(); 114 } 115 116 SubsamplingLevel ImageSource::subsamplingLevelForScale(float scale) 108 117 { 109 118 if (!(scale > 0 && scale <= 1)) 110 119 return 0; 111 120 112 SubsamplingLevel maximumSubsamplingLevel = calculateMaximumSubsamplingLevel();113 if (!m aximumSubsamplingLevel)121 cacheMetadata(); 122 if (!m_maximumSubsamplingLevel) 114 123 return 0; 115 124 116 125 // There are four subsampling levels: 0 = 1x, 1 = 0.5x, 2 = 0.25x, 3 = 0.125x. 117 126 SubsamplingLevel result = std::ceil(std::log2(1 / scale)); 118 return std::min(result, m aximumSubsamplingLevel);127 return std::min(result, m_maximumSubsamplingLevel); 119 128 } 120 129 … … 139 148 } 140 149 141 size_t ImageSource::frameCount() const 142 { 143 return initialized() ? m_decoder->frameCount() : 0; 150 size_t ImageSource::frameCount() 151 { 152 cacheMetadata(); 153 return m_frameCount; 144 154 } 145 155 -
trunk/Source/WebCore/platform/graphics/ImageSource.h
r199764 r199821 111 111 void setData(SharedBuffer* data, bool allDataReceived); 112 112 113 SubsamplingLevel subsamplingLevelForScale(float) const;113 SubsamplingLevel subsamplingLevelForScale(float); 114 114 void setAllowSubsampling(bool allowSubsampling) { m_allowSubsampling = allowSubsampling; } 115 115 static size_t bytesDecodedToDetermineProperties(); … … 120 120 IntSize sizeRespectingOrientation() const; 121 121 122 size_t frameCount() const;122 size_t frameCount(); 123 123 int repetitionCount(); 124 124 String filenameExtension() const; … … 146 146 void clearFrameBufferCache(size_t); 147 147 SubsamplingLevel calculateMaximumSubsamplingLevel() const; 148 void cacheMetadata(); 148 149 void dump(TextStream&) const; 149 150 150 151 std::unique_ptr<ImageDecoder> m_decoder; 152 153 size_t m_frameCount { 0 }; 154 SubsamplingLevel m_maximumSubsamplingLevel { 0 }; 151 155 152 156 // The default value of m_allowSubsampling should be the same as defaultImageSubsamplingEnabled in Settings.cpp
Note: See TracChangeset
for help on using the changeset viewer.