Title: [199821] trunk/Source/WebCore
- Revision
- 199821
- Author
- commit-qu...@webkit.org
- Date
- 2016-04-21 10:02:57 -0700 (Thu, 21 Apr 2016)
Log Message
REGRESSION(198782): ImageSource::subsamplingLevelForScale() does not cache the MaximumSubsamplingLevel for this ImageSource
https://bugs.webkit.org/show_bug.cgi?id=156766
Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2016-04-21
Reviewed by Darin Adler.
Ensure the MaximumSubsamplingLevel for the ImageSource is calculated
only once and is cached for subsequent uses.
The image subsampling is on by default only for iOS. So the and this
patch currently affects the iOS port.
* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::cacheMetadata): Cache m_maximumSubsamplingLevel.
Use m_frameCount as a flag for having_the_cache_done.
(WebCore::ImageSource::subsamplingLevelForScale): Call cacheMetadata()
before using m_maximumSubsamplingLevel.
(WebCore::ImageSource::frameCount): Call cacheMetadata() before returning
m_frameCount.
* platform/graphics/ImageSource.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (199820 => 199821)
--- trunk/Source/WebCore/ChangeLog 2016-04-21 16:44:50 UTC (rev 199820)
+++ trunk/Source/WebCore/ChangeLog 2016-04-21 17:02:57 UTC (rev 199821)
@@ -1,3 +1,25 @@
+2016-04-21 Said Abou-Hallawa <sabouhall...@apple.com>
+
+ REGRESSION(198782): ImageSource::subsamplingLevelForScale() does not cache the MaximumSubsamplingLevel for this ImageSource
+ https://bugs.webkit.org/show_bug.cgi?id=156766
+
+ Reviewed by Darin Adler.
+
+ Ensure the MaximumSubsamplingLevel for the ImageSource is calculated
+ only once and is cached for subsequent uses.
+
+ The image subsampling is on by default only for iOS. So the and this
+ patch currently affects the iOS port.
+
+ * platform/graphics/ImageSource.cpp:
+ (WebCore::ImageSource::cacheMetadata): Cache m_maximumSubsamplingLevel.
+ Use m_frameCount as a flag for having_the_cache_done.
+ (WebCore::ImageSource::subsamplingLevelForScale): Call cacheMetadata()
+ before using m_maximumSubsamplingLevel.
+ (WebCore::ImageSource::frameCount): Call cacheMetadata() before returning
+ m_frameCount.
+ * platform/graphics/ImageSource.h:
+
2016-04-21 Antoine Quint <grao...@apple.com>
Creating a large number of WebGL contexts should recycle older contexts
Modified: trunk/Source/WebCore/platform/graphics/ImageSource.cpp (199820 => 199821)
--- trunk/Source/WebCore/platform/graphics/ImageSource.cpp 2016-04-21 16:44:50 UTC (rev 199820)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.cpp 2016-04-21 17:02:57 UTC (rev 199821)
@@ -104,18 +104,27 @@
return maxSubsamplingLevel;
}
-SubsamplingLevel ImageSource::subsamplingLevelForScale(float scale) const
+void ImageSource::cacheMetadata()
{
+ if (m_frameCount || !isSizeAvailable())
+ return;
+
+ m_frameCount = m_decoder->frameCount();
+ m_maximumSubsamplingLevel = calculateMaximumSubsamplingLevel();
+}
+
+SubsamplingLevel ImageSource::subsamplingLevelForScale(float scale)
+{
if (!(scale > 0 && scale <= 1))
return 0;
- SubsamplingLevel maximumSubsamplingLevel = calculateMaximumSubsamplingLevel();
- if (!maximumSubsamplingLevel)
+ cacheMetadata();
+ if (!m_maximumSubsamplingLevel)
return 0;
// There are four subsampling levels: 0 = 1x, 1 = 0.5x, 2 = 0.25x, 3 = 0.125x.
SubsamplingLevel result = std::ceil(std::log2(1 / scale));
- return std::min(result, maximumSubsamplingLevel);
+ return std::min(result, m_maximumSubsamplingLevel);
}
size_t ImageSource::bytesDecodedToDetermineProperties()
@@ -138,9 +147,10 @@
return frameSizeAtIndex(0, 0, RespectImageOrientation);
}
-size_t ImageSource::frameCount() const
+size_t ImageSource::frameCount()
{
- return initialized() ? m_decoder->frameCount() : 0;
+ cacheMetadata();
+ return m_frameCount;
}
int ImageSource::repetitionCount()
Modified: trunk/Source/WebCore/platform/graphics/ImageSource.h (199820 => 199821)
--- trunk/Source/WebCore/platform/graphics/ImageSource.h 2016-04-21 16:44:50 UTC (rev 199820)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.h 2016-04-21 17:02:57 UTC (rev 199821)
@@ -110,7 +110,7 @@
void setData(SharedBuffer* data, bool allDataReceived);
- SubsamplingLevel subsamplingLevelForScale(float) const;
+ SubsamplingLevel subsamplingLevelForScale(float);
void setAllowSubsampling(bool allowSubsampling) { m_allowSubsampling = allowSubsampling; }
static size_t bytesDecodedToDetermineProperties();
@@ -119,7 +119,7 @@
IntSize size() const;
IntSize sizeRespectingOrientation() const;
- size_t frameCount() const;
+ size_t frameCount();
int repetitionCount();
String filenameExtension() const;
Optional<IntPoint> hotSpot() const;
@@ -145,9 +145,13 @@
private:
void clearFrameBufferCache(size_t);
SubsamplingLevel calculateMaximumSubsamplingLevel() const;
+ void cacheMetadata();
void dump(TextStream&) const;
std::unique_ptr<ImageDecoder> m_decoder;
+
+ size_t m_frameCount { 0 };
+ SubsamplingLevel m_maximumSubsamplingLevel { 0 };
// The default value of m_allowSubsampling should be the same as defaultImageSubsamplingEnabled in Settings.cpp
#if PLATFORM(IOS)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes