Modified: trunk/Source/WebCore/ChangeLog (104245 => 104246)
--- trunk/Source/WebCore/ChangeLog 2012-01-06 00:42:10 UTC (rev 104245)
+++ trunk/Source/WebCore/ChangeLog 2012-01-06 00:44:16 UTC (rev 104246)
@@ -1,3 +1,27 @@
+2012-01-05 Justin Novosad <[email protected]>
+
+ [Chromium] NativeImageSkia should mark SkBitmaps as immutable
+ https://bugs.webkit.org/show_bug.cgi?id=74962
+
+ Removed m_isDataComplete from class NativeImageSkia. Instead, data
+ completeness will be tracked through SkBitmap::setImmutable/
+ isImmutable. The immutable state signifies that the pixel data
+ will no longer change for the lifetime of the bitmap, which corresponds
+ to the semantic of the old m_isDataComplete member. setImmutable is
+ also called on the cached resized bitmap, since it too is invariant for
+ its life time. Temporary resized bitmaps are also marked as immutable
+ since they technically are.
+
+ Reviewed by Stephen White.
+
+ * platform/graphics/skia/NativeImageSkia.cpp:
+ (WebCore::NativeImageSkia::NativeImageSkia):
+ (WebCore::NativeImageSkia::resizedBitmap):
+ (WebCore::NativeImageSkia::shouldCacheResampling):
+ * platform/graphics/skia/NativeImageSkia.h:
+ (WebCore::NativeImageSkia::setDataComplete):
+ (WebCore::NativeImageSkia::isDataComplete):
+
2012-01-05 Sheriff Bot <[email protected]>
Unreviewed, rolling out r104231.
Modified: trunk/Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp (104245 => 104246)
--- trunk/Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp 2012-01-06 00:42:10 UTC (rev 104245)
+++ trunk/Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp 2012-01-06 00:44:16 UTC (rev 104246)
@@ -43,15 +43,13 @@
namespace WebCore {
NativeImageSkia::NativeImageSkia()
- : m_resizeRequests(0),
- m_isDataComplete(false)
+ : m_resizeRequests(0)
{
}
NativeImageSkia::NativeImageSkia(const SkBitmap& other)
: m_image(other),
- m_resizeRequests(0),
- m_isDataComplete(false)
+ m_resizeRequests(0)
{
}
@@ -78,7 +76,7 @@
TRACE_EVENT("NativeImageSkia::resizedBitmap", const_cast<NativeImageSkia*>(this), 0);
#endif
if (!hasResizedBitmap(srcSubset, destWidth, destHeight)) {
- bool shouldCache = m_isDataComplete
+ bool shouldCache = isDataComplete()
&& shouldCacheResampling(srcSubset, destWidth, destHeight, destVisibleSubset);
SkBitmap subset;
@@ -89,6 +87,7 @@
#endif
// Just resize the visible subset and return it.
SkBitmap resizedImage = skia::ImageOperations::Resize(subset, skia::ImageOperations::RESIZE_LANCZOS3, destWidth, destHeight, destVisibleSubset);
+ resizedImage.setImmutable();
return resizedImage;
} else {
#if PLATFORM(CHROMIUM)
@@ -96,6 +95,7 @@
#endif
m_resizedImage = skia::ImageOperations::Resize(subset, skia::ImageOperations::RESIZE_LANCZOS3, destWidth, destHeight);
}
+ m_resizedImage.setImmutable();
}
SkBitmap visibleBitmap;
@@ -124,7 +124,7 @@
// the future, were we know how much of the frame has been decoded, so when
// we incrementally draw more of the image, we only have to resample the
// parts that are changed.
- if (!m_isDataComplete)
+ if (!isDataComplete())
return false;
// If the destination bitmap is small, we'll always allow caching, since
Modified: trunk/Source/WebCore/platform/graphics/skia/NativeImageSkia.h (104245 => 104246)
--- trunk/Source/WebCore/platform/graphics/skia/NativeImageSkia.h 2012-01-06 00:42:10 UTC (rev 104245)
+++ trunk/Source/WebCore/platform/graphics/skia/NativeImageSkia.h 2012-01-06 00:44:16 UTC (rev 104246)
@@ -54,13 +54,14 @@
// resized version if there is one.
int decodedSize() const;
- // Sets the data complete flag. This is called by the image decoder when
- // all data is complete, and used by us to know whether we can cache
- // resized images.
- void setDataComplete() { m_isDataComplete = true; }
+ // Sets the immutable flag on the bitmap, indicating that the image data
+ // will not be modified any further. This is called by the image decoder
+ // when all data is complete, used by us to know whether we can cache
+ // resized images, and used by Skia for various optimizations.
+ void setDataComplete() { m_image.setImmutable(); }
// Returns true if the entire image has been decoded.
- bool isDataComplete() const { return m_isDataComplete; }
+ bool isDataComplete() const { return m_image.isImmutable(); }
// Get reference to the internal SkBitmap representing this image.
const SkBitmap& bitmap() const { return m_image; }
@@ -141,10 +142,6 @@
// image resizes.
mutable CachedImageInfo m_cachedImageInfo;
mutable int m_resizeRequests;
-
- // Set to true when the data is complete. Before the entire image has
- // loaded, we do not want to cache a resize.
- bool m_isDataComplete;
};
}