Modified: trunk/Source/WebCore/ChangeLog (251653 => 251654)
--- trunk/Source/WebCore/ChangeLog 2019-10-28 14:57:57 UTC (rev 251653)
+++ trunk/Source/WebCore/ChangeLog 2019-10-28 15:06:07 UTC (rev 251654)
@@ -1,3 +1,18 @@
+2019-10-28 Commit Queue <[email protected]>
+
+ Unreviewed, rolling out r251651.
+ https://bugs.webkit.org/show_bug.cgi?id=203488
+
+ It's causing crashes in several tests (Requested by KaL on
+ #webkit).
+
+ Reverted changeset:
+
+ "ImageDecoders: use a thread safe data buffer for Cairo
+ backing store"
+ https://bugs.webkit.org/show_bug.cgi?id=201727
+ https://trac.webkit.org/changeset/251651
+
2019-10-28 Charlie Turner <[email protected]>
ImageDecoders: use a thread safe data buffer for Cairo backing store
Modified: trunk/Source/WebCore/platform/graphics/ImageBackingStore.h (251653 => 251654)
--- trunk/Source/WebCore/platform/graphics/ImageBackingStore.h 2019-10-28 14:57:57 UTC (rev 251653)
+++ trunk/Source/WebCore/platform/graphics/ImageBackingStore.h 2019-10-28 15:06:07 UTC (rev 251654)
@@ -59,11 +59,15 @@
if (size.isEmpty())
return false;
- m_pixels = RGBAPixelBufferThreadSafeRefCounted::create(size);
+ Vector<char> buffer;
+ size_t bufferSize = size.area().unsafeGet() * sizeof(RGBA32);
- if (!m_pixels->isValid())
+ if (!buffer.tryReserveCapacity(bufferSize))
return false;
+ buffer.grow(bufferSize);
+ m_pixels = SharedBuffer::create(WTFMove(buffer));
+ m_pixelsPtr = reinterpret_cast<RGBA32*>(const_cast<char*>(m_pixels->data()));
m_size = size;
m_frameRect = IntRect(IntPoint(), m_size);
clear();
@@ -82,7 +86,7 @@
void clear()
{
- m_pixels->zeroPixelData();
+ memset(m_pixelsPtr, 0, (m_size.area() * sizeof(RGBA32)).unsafeGet());
}
void clearRect(const IntRect& rect)
@@ -129,7 +133,7 @@
RGBA32* pixelAt(int x, int y) const
{
ASSERT(inBounds(IntPoint(x, y)));
- return m_pixels->pixelAt(x, y);
+ return m_pixelsPtr + y * m_size.width() + x;
}
void setPixel(RGBA32* dest, unsigned r, unsigned g, unsigned b, unsigned a)
@@ -185,27 +189,6 @@
}
private:
- class RGBAPixelBufferThreadSafeRefCounted : public ThreadSafeRefCounted<RGBAPixelBufferThreadSafeRefCounted> {
- public:
- static Ref<RGBAPixelBufferThreadSafeRefCounted> create(const IntSize& initialSize) { return adoptRef(*new RGBAPixelBufferThreadSafeRefCounted(initialSize)); }
- void zeroPixelData() { m_pixels.fill(0); }
- RGBA32* pixelAt(int x, int y) const { return const_cast<unsigned*>(&m_pixels.data()[y * m_size.width() + x]); }
- const RGBA32* data() const { return m_pixels.data(); }
- bool isValid() const { return m_isValid; }
- private:
- RGBAPixelBufferThreadSafeRefCounted(const IntSize& initialSize)
- : m_size(initialSize)
- {
- unsigned bufferSize = initialSize.area().unsafeGet();
- m_isValid = m_pixels.tryReserveCapacity(bufferSize);
- if (m_isValid)
- m_pixels.resize(bufferSize);
- }
- IntSize m_size;
- Vector<RGBA32> m_pixels;
- bool m_isValid { false };
- };
-
ImageBackingStore(const IntSize& size, bool premultiplyAlpha = true)
: m_premultiplyAlpha(premultiplyAlpha)
{
@@ -218,6 +201,8 @@
, m_premultiplyAlpha(other.m_premultiplyAlpha)
{
ASSERT(!m_size.isEmpty() && !isOverSize(m_size));
+ m_pixels = SharedBuffer::create(other.m_pixels->data(), other.m_pixels->size());
+ m_pixelsPtr = reinterpret_cast<RGBA32*>(const_cast<char*>(m_pixels->data()));
}
bool inBounds(const IntPoint& point) const
@@ -241,8 +226,8 @@
return makeRGBA(r, g, b, a);
}
- RefPtr<RGBAPixelBufferThreadSafeRefCounted> m_pixels;
-
+ RefPtr<SharedBuffer> m_pixels;
+ RGBA32* m_pixelsPtr { nullptr };
IntSize m_size;
IntRect m_frameRect; // This will always just be the entire buffer except for GIF and PNG frames
bool m_premultiplyAlpha { true };
Modified: trunk/Source/WebCore/platform/image-decoders/cairo/ImageBackingStoreCairo.cpp (251653 => 251654)
--- trunk/Source/WebCore/platform/image-decoders/cairo/ImageBackingStoreCairo.cpp 2019-10-28 14:57:57 UTC (rev 251653)
+++ trunk/Source/WebCore/platform/image-decoders/cairo/ImageBackingStoreCairo.cpp 2019-10-28 15:06:07 UTC (rev 251654)
@@ -34,10 +34,10 @@
{
m_pixels->ref();
RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(
- reinterpret_cast<unsigned char*>(const_cast<uint32_t*>(m_pixels->data())),
+ reinterpret_cast<unsigned char*>(const_cast<uint32_t*>(m_pixelsPtr)),
CAIRO_FORMAT_ARGB32, size().width(), size().height(), size().width() * sizeof(uint32_t)));
static cairo_user_data_key_t s_surfaceDataKey;
- cairo_surface_set_user_data(surface.get(), &s_surfaceDataKey, m_pixels.get(), [](void* data) { static_cast<RGBAPixelBufferThreadSafeRefCounted*>(data)->deref(); });
+ cairo_surface_set_user_data(surface.get(), &s_surfaceDataKey, m_pixels.get(), [](void* data) { static_cast<SharedBuffer*>(data)->deref(); });
return surface;
}