Modified: trunk/Source/WebCore/ChangeLog (253674 => 253675)
--- trunk/Source/WebCore/ChangeLog 2019-12-18 08:38:01 UTC (rev 253674)
+++ trunk/Source/WebCore/ChangeLog 2019-12-18 09:02:46 UTC (rev 253675)
@@ -1,3 +1,23 @@
+2019-12-18 Chris Lord <[email protected]>
+
+ [GTK][WPE] OffscreenCanvas worker tests that call drawImage crash in debug builds
+ https://bugs.webkit.org/show_bug.cgi?id=205339
+
+ Reviewed by Carlos Garcia Campos.
+
+ Don't unnecessarily create an Image object in the Cairo graphics
+ backend when using drawImage/drawPattern. Doing so calls code that
+ isn't safe to use off-main-thread and causes OffscreenCanvas worker
+ tests to crash in debug builds.
+
+ No new tests, no behavioral changes.
+
+ * platform/graphics/cairo/ImageBufferCairo.cpp:
+ (WebCore::cairoSurfaceCopy):
+ (WebCore::cairoSurfaceCoerceToImage):
+ (WebCore::ImageBuffer::draw):
+ (WebCore::ImageBuffer::drawPattern):
+
2019-12-17 Simon Fraser <[email protected]>
Remove iOS #ifdefs around unobscuredContentSize
Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (253674 => 253675)
--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp 2019-12-18 08:38:01 UTC (rev 253674)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp 2019-12-18 09:02:46 UTC (rev 253675)
@@ -225,12 +225,8 @@
#endif
static RefPtr<cairo_surface_t>
-cairoSurfaceCoerceToImage(cairo_surface_t* surface)
+cairoSurfaceCopy(cairo_surface_t* surface)
{
- if (cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_IMAGE
- && cairo_surface_get_content(surface) == CAIRO_CONTENT_COLOR_ALPHA)
- return surface;
-
auto copy = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
cairo_image_surface_get_width(surface),
cairo_image_surface_get_height(surface)));
@@ -243,6 +239,16 @@
return copy;
}
+static RefPtr<cairo_surface_t>
+cairoSurfaceCoerceToImage(cairo_surface_t* surface)
+{
+ if (cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_IMAGE
+ && cairo_surface_get_content(surface) == CAIRO_CONTENT_COLOR_ALPHA)
+ return surface;
+
+ return cairoSurfaceCopy(surface);
+}
+
Vector<uint8_t> ImageBuffer::toBGRAData() const
{
auto surface = cairoSurfaceCoerceToImage(m_data.m_surface.get());
@@ -356,16 +362,27 @@
void ImageBuffer::draw(GraphicsContext& destinationContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
{
- BackingStoreCopy copyMode = &destinationContext == &context() ? CopyBackingStore : DontCopyBackingStore;
- RefPtr<Image> image = copyImage(copyMode);
- destinationContext.drawImage(*image, destRect, srcRect, options);
+ if (destinationContext.paintingDisabled())
+ return;
+
+ if (auto surface = nativeImage()) {
+ if (&destinationContext == &context())
+ surface = cairoSurfaceCopy(surface.get());
+
+ InterpolationQualityMaintainer interpolationQualityForThisScope(destinationContext, options.interpolationQuality());
+ const auto& destinationContextState = destinationContext.state();
+ drawNativeImage(*destinationContext.platformContext(), surface.get(), destRect, srcRect, { options, destinationContextState.imageInterpolationQuality }, destinationContextState.alpha, WebCore::Cairo::ShadowState(destinationContextState));
+ }
}
void ImageBuffer::drawPattern(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
+ const FloatPoint& phase, const FloatSize&, const ImagePaintingOptions& options)
{
- if (RefPtr<Image> image = copyImage(DontCopyBackingStore))
- image->drawPattern(context, destRect, srcRect, patternTransform, phase, spacing, options);
+ if (context.paintingDisabled())
+ return;
+
+ if (auto surface = nativeImage())
+ Cairo::drawPattern(*context.platformContext(), surface.get(), m_size, destRect, srcRect, patternTransform, phase, options);
}
void ImageBuffer::platformTransformColorSpace(const std::array<uint8_t, 256>& lookUpTable)