Modified: trunk/Source/WebCore/ChangeLog (275779 => 275780)
--- trunk/Source/WebCore/ChangeLog 2021-04-09 22:04:59 UTC (rev 275779)
+++ trunk/Source/WebCore/ChangeLog 2021-04-09 22:09:13 UTC (rev 275780)
@@ -1,3 +1,24 @@
+2021-04-09 Fujii Hironori <[email protected]>
+
+ [Cairo][GPUP] GraphicsContextGLOpenGL::paintToCanvas can't paint into a remote canvas
+ https://bugs.webkit.org/show_bug.cgi?id=224271
+
+ Reviewed by Don Olmstead.
+
+ WebGL canvas tests were failing for WinCairo port since r274327
+ enabled GPU process for canvas rendering. In the current
+ implementation of WebKitTestRunner, 2D canvases are in GPU
+ process, while WebGL canvases are in WebContent process. Remote
+ canvases in GPU process failed to drawImage() with a WebGL canvas
+ what is in WebContent process.
+
+ GraphicsContextGLOpenGL::paintToCanvas of Cairo port was painting
+ directly into PlatformContextCairo. It also should use
+ GraphicsContext::drawNativeImage as well as CG port does.
+
+ * platform/graphics/cairo/GraphicsContextGLCairo.cpp:
+ (WebCore::GraphicsContextGLOpenGL::paintToCanvas):
+
2021-04-09 Jer Noble <[email protected]>
WTF SoftLinking macros can cause collisions with their target functions
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextGLCairo.cpp (275779 => 275780)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextGLCairo.cpp 2021-04-09 22:04:59 UTC (rev 275779)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextGLCairo.cpp 2021-04-09 22:09:13 UTC (rev 275780)
@@ -112,10 +112,6 @@
if (canvasSize.isEmpty())
return;
- PlatformContextCairo* platformContext = context.platformContext();
- if (!platformContext)
- return;
-
// Convert RGBA to BGRA. BGRA is CAIRO_FORMAT_ARGB32 on little-endian architectures.
size_t totalBytes = imageData->data()->byteLength();
uint8_t* pixels = imageData->data()->data();
@@ -130,26 +126,18 @@
}
}
- cairo_t* cr = platformContext->cr();
- platformContext->save();
+ auto imageSize = imageData->size();
- cairo_rectangle(cr, 0, 0, canvasSize.width(), canvasSize.height());
- cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
- cairo_paint(cr);
-
RefPtr<cairo_surface_t> imageSurface = adoptRef(cairo_image_surface_create_for_data(
imageData->data()->data(), CAIRO_FORMAT_ARGB32, imageData->width(), imageData->height(), imageData->width() * 4));
- // OpenGL keeps the pixels stored bottom up, so we need to flip the image here.
- cairo_translate(cr, 0, imageData->height());
- cairo_scale(cr, 1, -1);
+ auto image = NativeImage::create(WTFMove(imageSurface));
- cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
- cairo_set_source_surface(cr, imageSurface.get(), 0, 0);
- cairo_rectangle(cr, 0, 0, canvasSize.width(), -canvasSize.height());
-
- cairo_fill(cr);
- platformContext->restore();
+ GraphicsContextStateSaver stateSaver(context);
+ context.scale(FloatSize(1, -1));
+ context.translate(0, -imageSize.height());
+ context.setImageInterpolationQuality(InterpolationQuality::DoNotInterpolate);
+ context.drawNativeImage(*image, imageSize, FloatRect({ }, canvasSize), FloatRect({ }, imageSize), { CompositeOperator::Copy });
}
} // namespace WebCore