Title: [283331] trunk/Source/WebCore
Revision
283331
Author
drou...@apple.com
Date
2021-09-30 13:21:45 -0700 (Thu, 30 Sep 2021)

Log Message

[GPU Process] support rendering Apple Pay buttons
https://bugs.webkit.org/show_bug.cgi?id=230648
<rdar://problem/72061985>

Reviewed by Tim Horton.

* rendering/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::paintApplePayButton):
Instead of drawing directly into the `GraphicsContext::platformContext` (which will not be
valid in the WebProcess when DOM rendering happens in the GPUProcess), first draw into a
temporary `ImageBuffer` and then consume it to draw into the actual/used `GraphicsContext`.
While it is possible to create a dedicated display list item for this, we don't want to do
that because `PKDrawApplePayButtonWithCornerRadius` involves dealing with PDFs, which are
not as secure as we'd like for use in the GPUProcess.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (283330 => 283331)


--- trunk/Source/WebCore/ChangeLog	2021-09-30 20:17:03 UTC (rev 283330)
+++ trunk/Source/WebCore/ChangeLog	2021-09-30 20:21:45 UTC (rev 283331)
@@ -1,3 +1,20 @@
+2021-09-30  Devin Rousso  <drou...@apple.com>
+
+        [GPU Process] support rendering Apple Pay buttons
+        https://bugs.webkit.org/show_bug.cgi?id=230648
+        <rdar://problem/72061985>
+
+        Reviewed by Tim Horton.
+
+        * rendering/RenderThemeCocoa.mm:
+        (WebCore::RenderThemeCocoa::paintApplePayButton):
+        Instead of drawing directly into the `GraphicsContext::platformContext` (which will not be
+        valid in the WebProcess when DOM rendering happens in the GPUProcess), first draw into a
+        temporary `ImageBuffer` and then consume it to draw into the actual/used `GraphicsContext`.
+        While it is possible to create a dedicated display list item for this, we don't want to do
+        that because `PKDrawApplePayButtonWithCornerRadius` involves dealing with PDFs, which are
+        not as secure as we'd like for use in the GPUProcess.
+
 2021-09-30  Chris Dumez  <cdu...@apple.com>
 
         Web Audio panner node quality deteriorates over time

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (283330 => 283331)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp	2021-09-30 20:17:03 UTC (rev 283330)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp	2021-09-30 20:21:45 UTC (rev 283331)
@@ -277,7 +277,7 @@
 
 AffineTransform Recorder::getCTM(GraphicsContext::IncludeDeviceScale) const
 {
-    // FIXME: Respect the given value of IncludeDeviceScale.
+    // FIXME: <https://webkit.org/b/230647> ([GPU Process] add support for `IncludeDeviceScale` inside `DisplayList::Recorder::getCTM`)
     return currentState().ctm;
 }
 

Modified: trunk/Source/WebCore/rendering/RenderThemeCocoa.mm (283330 => 283331)


--- trunk/Source/WebCore/rendering/RenderThemeCocoa.mm	2021-09-30 20:17:03 UTC (rev 283330)
+++ trunk/Source/WebCore/rendering/RenderThemeCocoa.mm	2021-09-30 20:21:45 UTC (rev 283331)
@@ -28,6 +28,7 @@
 
 #import "GraphicsContextCG.h"
 #import "HTMLInputElement.h"
+#import "ImageBuffer.h"
 #import "RenderText.h"
 #import "UserAgentScripts.h"
 #import "UserAgentStyleSheets.h"
@@ -151,10 +152,11 @@
 
 bool RenderThemeCocoa::paintApplePayButton(const RenderObject& renderer, const PaintInfo& paintInfo, const IntRect& paintRect)
 {
-    GraphicsContextStateSaver stateSaver(paintInfo.context());
+    auto& destinationContext = paintInfo.context();
 
-    paintInfo.context().setShouldSmoothFonts(true);
-    paintInfo.context().scale(FloatSize(1, -1));
+    auto imageBuffer = ImageBuffer::createCompatibleBuffer(paintRect.size(), destinationContext);
+    if (!imageBuffer)
+        return false;
 
     auto& style = renderer.style();
     auto largestCornerRadius = std::max<CGFloat>({
@@ -168,7 +170,13 @@
         floatValueForLength(style.borderBottomRightRadius().width, paintRect.width())
     });
 
-    PKDrawApplePayButtonWithCornerRadius(paintInfo.context().platformContext(), CGRectMake(paintRect.x(), -paintRect.maxY(), paintRect.width(), paintRect.height()), 1.0, largestCornerRadius, toPKPaymentButtonType(style.applePayButtonType()), toPKPaymentButtonStyle(style.applePayButtonStyle()), style.computedLocale());
+    auto& imageContext = imageBuffer->context();
+    imageContext.setShouldSmoothFonts(true);
+    imageContext.setShouldSubpixelQuantizeFonts(false);
+    imageContext.scale(FloatSize(1, -1));
+    PKDrawApplePayButtonWithCornerRadius(imageContext.platformContext(), CGRectMake(0, -paintRect.height(), paintRect.width(), paintRect.height()), 1.0, largestCornerRadius, toPKPaymentButtonType(style.applePayButtonType()), toPKPaymentButtonStyle(style.applePayButtonStyle()), style.computedLocale());
+
+    destinationContext.drawConsumingImageBuffer(WTFMove(imageBuffer), paintRect);
     return false;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to