⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 283331 in webkit


Ignore:
Timestamp:
Sep 30, 2021, 1:21:45 PM (5 years ago)
Author:
Devin Rousso
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.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r283322 r283331  
     12021-09-30  Devin Rousso  <drousso@apple.com>
     2
     3        [GPU Process] support rendering Apple Pay buttons
     4        https://bugs.webkit.org/show_bug.cgi?id=230648
     5        <rdar://problem/72061985>
     6
     7        Reviewed by Tim Horton.
     8
     9        * rendering/RenderThemeCocoa.mm:
     10        (WebCore::RenderThemeCocoa::paintApplePayButton):
     11        Instead of drawing directly into the `GraphicsContext::platformContext` (which will not be
     12        valid in the WebProcess when DOM rendering happens in the GPUProcess), first draw into a
     13        temporary `ImageBuffer` and then consume it to draw into the actual/used `GraphicsContext`.
     14        While it is possible to create a dedicated display list item for this, we don't want to do
     15        that because `PKDrawApplePayButtonWithCornerRadius` involves dealing with PDFs, which are
     16        not as secure as we'd like for use in the GPUProcess.
     17
    1182021-09-30  Chris Dumez  <cdumez@apple.com>
    219
  • trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp

    r283273 r283331  
    278278AffineTransform Recorder::getCTM(GraphicsContext::IncludeDeviceScale) const
    279279{
    280     // FIXME: Respect the given value of IncludeDeviceScale.
     280    // FIXME: <https://webkit.org/b/230647> ([GPU Process] add support for `IncludeDeviceScale` inside `DisplayList::Recorder::getCTM`)
    281281    return currentState().ctm;
    282282}
  • trunk/Source/WebCore/rendering/RenderThemeCocoa.mm

    r278618 r283331  
    2929#import "GraphicsContextCG.h"
    3030#import "HTMLInputElement.h"
     31#import "ImageBuffer.h"
    3132#import "RenderText.h"
    3233#import "UserAgentScripts.h"
     
    152153bool RenderThemeCocoa::paintApplePayButton(const RenderObject& renderer, const PaintInfo& paintInfo, const IntRect& paintRect)
    153154{
    154     GraphicsContextStateSaver stateSaver(paintInfo.context());
    155 
    156     paintInfo.context().setShouldSmoothFonts(true);
    157     paintInfo.context().scale(FloatSize(1, -1));
     155    auto& destinationContext = paintInfo.context();
     156
     157    auto imageBuffer = ImageBuffer::createCompatibleBuffer(paintRect.size(), destinationContext);
     158    if (!imageBuffer)
     159        return false;
    158160
    159161    auto& style = renderer.style();
     
    169171    });
    170172
    171     PKDrawApplePayButtonWithCornerRadius(paintInfo.context().platformContext(), CGRectMake(paintRect.x(), -paintRect.maxY(), paintRect.width(), paintRect.height()), 1.0, largestCornerRadius, toPKPaymentButtonType(style.applePayButtonType()), toPKPaymentButtonStyle(style.applePayButtonStyle()), style.computedLocale());
     173    auto& imageContext = imageBuffer->context();
     174    imageContext.setShouldSmoothFonts(true);
     175    imageContext.setShouldSubpixelQuantizeFonts(false);
     176    imageContext.scale(FloatSize(1, -1));
     177    PKDrawApplePayButtonWithCornerRadius(imageContext.platformContext(), CGRectMake(0, -paintRect.height(), paintRect.width(), paintRect.height()), 1.0, largestCornerRadius, toPKPaymentButtonType(style.applePayButtonType()), toPKPaymentButtonStyle(style.applePayButtonStyle()), style.computedLocale());
     178
     179    destinationContext.drawConsumingImageBuffer(WTFMove(imageBuffer), paintRect);
    172180    return false;
    173181}
Note: See TracChangeset for help on using the changeset viewer.