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

Changeset 290679 in webkit


Ignore:
Timestamp:
Mar 1, 2022, 3:16:43 PM (5 years ago)
Author:
Said Abou-Hallawa
Message:

Source/WebCore:
[macOS][REGRESSION] (r289518): Form controls are scaled twice on Retina display
​https://bugs.webkit.org/show_bug.cgi?id=237128
rdar://89064642

Reviewed by Darin Adler.

Using the name GraphicsContext::createImageBuffer() for different behaviors
was a mistake in r289518. To clean this up, the createImageBuffer() version
which scales the GraphicsContext of the ImageBuffer will be renamed
createScaledImageBuffer(). and the existing createCompatibleImageBuffer()
will be renamed createAlignedImageBuffer(). So we will have these three
methods in GraphicsContext:

1) createImageBuffer(): The default behavior of this method is to create

an ImageBuffer similar to the underlying ImageBuffer of GraphicsContext.
But it gives ability to change the renderingMode and the renderingMethod.
It can be forced to create a non-accelerated local ImageBuffer for example.

The caller of this method usually uses a framework to draw some custom
drawing and it just needs a scratch buffer to be drawn in the place of
a render object. The caller does not require any transformation to be
applied to the GraphicsContext of the ImageBuffer before starting its
custom drawing. Drawing the form controls using AppKit is an example
of such case.

2) createScaledImageBuffer(): This is similar to createImageBuffer() but

it always creates the ImageBuffer with resolutionScale = 1 so it has
to scale the size by the scaleFactor before calling createImageBuffer().
It also scales the GraphicsContext of the created ImageBuffer with the
scaleFactor and it translates its coordinates origin for the FloatRect
version. It also handles the clamping if needed.

This method is suitable for cases when the overall scaleFatcor
(device ScaleFactor + clamping ScaleFactor) has be known to the caller
in advance. No clamping will be required in this case. SVG filter,
masker, clipper and gradient are the callers to this function.

3) createAlignedImageBuffer(): This is similar to createScaledImageBuffer()

but it does not take a scaling factor argument. It inherits it from
the GraphicsContext.

Usually the purpose of this method is to transfer the drawing from a
layer to a scratch ImageBuffer temporarily then draw the scratch
ImageBuffer in the place of the original drawing. Drawing a PDFDocument
image, for example, requires using this method.

To fix this bug:

Form controls have to use the first version of createImageBuffer() which
still has the same name instead of using the second version which will
be renamed createScaledImageBuffer().

Another cleaning is to pass RenderingMethod as an std::optional argument
the three methods. This means we do not need the value "Default" since
passing std::nullopt will have the same meaning.

Test: fast/hidpi/hidpi-form-controls-drawing-size.html

  • html/CustomPaintCanvas.cpp:

(WebCore::CustomPaintCanvas::replayDisplayList const):

  • html/CustomPaintImage.cpp:

(WebCore::CustomPaintImage::drawPattern):

  • html/canvas/CanvasRenderingContext2DBase.cpp:

(WebCore::CanvasRenderingContext2DBase::drawImage):
(WebCore::CanvasRenderingContext2DBase::drawTextUnchecked):

  • platform/cocoa/ThemeCocoa.mm:

(WebCore::drawApplePayButton):

  • platform/graphics/BitmapImage.cpp:

(WebCore::BitmapImage::drawPattern):

  • platform/graphics/GradientImage.cpp:

(WebCore::GradientImage::drawPattern):

  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContext::createImageBuffer const):
(WebCore::GraphicsContext::createScaledImageBuffer const):
(WebCore::GraphicsContext::createAlignedImageBuffer const):
(WebCore::GraphicsContext::createCompatibleImageBuffer const): Deleted.

  • platform/graphics/GraphicsContext.h:

(WebCore::GraphicsContext::createScaledImageBuffer):
(WebCore::GraphicsContext::createImageBuffer): Deleted.

  • platform/graphics/ImageBuffer.cpp:

(WebCore::ImageBuffer::clone const):

  • platform/graphics/NamedImageGeneratedImage.cpp:

(WebCore::NamedImageGeneratedImage::drawPattern):

  • platform/graphics/cg/PDFDocumentImage.cpp:

(WebCore::PDFDocumentImage::updateCachedImageIfNeeded):
(WebCore::PDFDocumentImage::draw):

  • platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp:

(WebCore::DrawGlyphsRecorder::drawOTSVGRun):

  • platform/graphics/displaylists/DisplayListRecorder.cpp:

(WebCore::DisplayList::Recorder::createImageBuffer const):

  • platform/graphics/displaylists/DisplayListRecorder.h:
  • platform/mac/ThemeMac.mm:

(WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext):

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::paintFillLayerExtended):

  • rendering/RenderLayerBacking.cpp:

(WebCore::patternForDescription):

  • rendering/RenderLayerFilters.cpp:

(WebCore::RenderLayerFilters::allocateBackingStoreIfNeeded):

  • rendering/RenderThemeCocoa.mm:

(WebCore::RenderThemeCocoa::paintApplePayButton):

  • rendering/RenderThemeMac.mm:

(WebCore::RenderThemeMac::paintListButtonForInput):
(WebCore::RenderThemeMac::paintProgressBar):

  • rendering/svg/RenderSVGResourceClipper.cpp:

(WebCore::RenderSVGResourceClipper::applyClippingToContext):

  • rendering/svg/RenderSVGResourceFilter.cpp:

(WebCore::RenderSVGResourceFilter::applyResource):

  • rendering/svg/RenderSVGResourceGradient.cpp:

(WebCore::createMaskAndSwapContextForTextGradient):

  • rendering/svg/RenderSVGResourceMasker.cpp:

(WebCore::RenderSVGResourceMasker::applyResource):

  • rendering/svg/RenderSVGResourcePattern.cpp:

(WebCore::RenderSVGResourcePattern::createTileImage const):

  • rendering/svg/SVGRenderingContext.cpp:

(WebCore::SVGRenderingContext::bufferForeground):

Source/WebKit:
[macOS][REGRESSION] (rr289518): Form controls are scaled twice on Retina display
​https://bugs.webkit.org/show_bug.cgi?id=237128
rdar://89064642

Reviewed by Darin Adler.

  • WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp:

(WebKit::RemoteDisplayListRecorderProxy::createImageBuffer const):
(WebKit::RemoteDisplayListRecorderProxy::createAlignedImageBuffer const):
(WebKit::RemoteDisplayListRecorderProxy::createCompatibleImageBuffer const): Deleted.

  • WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h:

LayoutTests:
[macOS][REGRESSION] (rr289518): Form controls are scaled twice on Retina display
​https://bugs.webkit.org/show_bug.cgi?id=237128
rdar://89064642

Reviewed by Darin Adler.

  • fast/hidpi/hidpi-form-controls-drawing-size-expected.html: Added.
  • fast/hidpi/hidpi-form-controls-drawing-size.html: Added.
Location:
trunk
Files:
2 added
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r290678 r290679  
     12022-03-01  Said Abou-Hallawa  <said@apple.com>
     2
     3        [macOS][REGRESSION] (rr289518): Form controls are scaled twice on Retina display
     4        https://bugs.webkit.org/show_bug.cgi?id=237128
     5        rdar://89064642
     6
     7        Reviewed by Darin Adler.
     8
     9        * fast/hidpi/hidpi-form-controls-drawing-size-expected.html: Added.
     10        * fast/hidpi/hidpi-form-controls-drawing-size.html: Added.
     11
    1122022-03-01  Robert Jenner  <Jenner@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r290676 r290679  
     12022-03-01  Said Abou-Hallawa  <said@apple.com>
     2
     3        [macOS][REGRESSION] (r289518): Form controls are scaled twice on Retina display
     4        https://bugs.webkit.org/show_bug.cgi?id=237128
     5        rdar://89064642
     6
     7        Reviewed by Darin Adler.
     8
     9        Using the name GraphicsContext::createImageBuffer() for different behaviors
     10        was a mistake in r289518. To clean this up, the createImageBuffer() version
     11        which scales the GraphicsContext of the ImageBuffer will be renamed
     12        createScaledImageBuffer(). and the existing createCompatibleImageBuffer()
     13        will be renamed createAlignedImageBuffer(). So we will have these three
     14        methods in GraphicsContext:
     15
     16        1) createImageBuffer(): The default behavior of this method is to create
     17           an ImageBuffer similar to the underlying ImageBuffer of GraphicsContext.
     18           But it gives ability to change the renderingMode and the renderingMethod.
     19           It can be forced to create a non-accelerated local ImageBuffer for example.
     20           
     21           The caller of this method usually uses a framework to draw some custom
     22           drawing and it just needs a scratch buffer to be drawn in the place of
     23           a render object. The caller does not require any transformation to be
     24           applied to the GraphicsContext of the ImageBuffer before starting its
     25           custom drawing. Drawing the form controls using AppKit is an example
     26           of such case.
     27
     28        2) createScaledImageBuffer(): This is similar to createImageBuffer() but
     29           it always creates the ImageBuffer with resolutionScale = 1 so it has
     30           to scale the size by the scaleFactor before calling createImageBuffer().
     31           It also scales the GraphicsContext of the created ImageBuffer with the
     32           scaleFactor and it translates its coordinates origin for the FloatRect
     33           version. It also handles the clamping if needed.
     34
     35           This method is suitable for cases when the overall scaleFatcor
     36           (device ScaleFactor + clamping ScaleFactor) has be known to the caller
     37           in advance. No clamping will be required in this case. SVG filter,
     38           masker, clipper and gradient are the callers to this function.
     39
     40        3) createAlignedImageBuffer(): This is similar to createScaledImageBuffer()
     41           but it does not take a scaling factor argument. It inherits it from
     42           the GraphicsContext.
     43
     44           Usually the purpose of this method is to transfer the drawing from a
     45           layer to a scratch ImageBuffer temporarily then draw the scratch
     46           ImageBuffer in the place of the original drawing. Drawing a PDFDocument
     47           image, for example, requires using this method.
     48
     49        To fix this bug:
     50
     51        Form controls have to use the first version of createImageBuffer() which
     52        still has the same name instead of using the second version which will
     53        be renamed createScaledImageBuffer().
     54
     55        Another cleaning is to pass RenderingMethod as an std::optional argument
     56        the three methods. This means we do not need the value "Default" since
     57        passing std::nullopt will have the same meaning.
     58
     59        Test: fast/hidpi/hidpi-form-controls-drawing-size.html
     60
     61        * html/CustomPaintCanvas.cpp:
     62        (WebCore::CustomPaintCanvas::replayDisplayList const):
     63        * html/CustomPaintImage.cpp:
     64        (WebCore::CustomPaintImage::drawPattern):
     65        * html/canvas/CanvasRenderingContext2DBase.cpp:
     66        (WebCore::CanvasRenderingContext2DBase::drawImage):
     67        (WebCore::CanvasRenderingContext2DBase::drawTextUnchecked):
     68        * platform/cocoa/ThemeCocoa.mm:
     69        (WebCore::drawApplePayButton):
     70        * platform/graphics/BitmapImage.cpp:
     71        (WebCore::BitmapImage::drawPattern):
     72        * platform/graphics/GradientImage.cpp:
     73        (WebCore::GradientImage::drawPattern):
     74        * platform/graphics/GraphicsContext.cpp:
     75        (WebCore::GraphicsContext::createImageBuffer const):
     76        (WebCore::GraphicsContext::createScaledImageBuffer const):
     77        (WebCore::GraphicsContext::createAlignedImageBuffer const):
     78        (WebCore::GraphicsContext::createCompatibleImageBuffer const): Deleted.
     79        * platform/graphics/GraphicsContext.h:
     80        (WebCore::GraphicsContext::createScaledImageBuffer):
     81        (WebCore::GraphicsContext::createImageBuffer): Deleted.
     82        * platform/graphics/ImageBuffer.cpp:
     83        (WebCore::ImageBuffer::clone const):
     84        * platform/graphics/NamedImageGeneratedImage.cpp:
     85        (WebCore::NamedImageGeneratedImage::drawPattern):
     86        * platform/graphics/cg/PDFDocumentImage.cpp:
     87        (WebCore::PDFDocumentImage::updateCachedImageIfNeeded):
     88        (WebCore::PDFDocumentImage::draw):
     89        * platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp:
     90        (WebCore::DrawGlyphsRecorder::drawOTSVGRun):
     91        * platform/graphics/displaylists/DisplayListRecorder.cpp:
     92        (WebCore::DisplayList::Recorder::createImageBuffer const):
     93        * platform/graphics/displaylists/DisplayListRecorder.h:
     94        * platform/mac/ThemeMac.mm:
     95        (WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext):
     96        * rendering/RenderBoxModelObject.cpp:
     97        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
     98        * rendering/RenderLayerBacking.cpp:
     99        (WebCore::patternForDescription):
     100        * rendering/RenderLayerFilters.cpp:
     101        (WebCore::RenderLayerFilters::allocateBackingStoreIfNeeded):
     102        * rendering/RenderThemeCocoa.mm:
     103        (WebCore::RenderThemeCocoa::paintApplePayButton):
     104        * rendering/RenderThemeMac.mm:
     105        (WebCore::RenderThemeMac::paintListButtonForInput):
     106        (WebCore::RenderThemeMac::paintProgressBar):
     107        * rendering/svg/RenderSVGResourceClipper.cpp:
     108        (WebCore::RenderSVGResourceClipper::applyClippingToContext):
     109        * rendering/svg/RenderSVGResourceFilter.cpp:
     110        (WebCore::RenderSVGResourceFilter::applyResource):
     111        * rendering/svg/RenderSVGResourceGradient.cpp:
     112        (WebCore::createMaskAndSwapContextForTextGradient):
     113        * rendering/svg/RenderSVGResourceMasker.cpp:
     114        (WebCore::RenderSVGResourceMasker::applyResource):
     115        * rendering/svg/RenderSVGResourcePattern.cpp:
     116        (WebCore::RenderSVGResourcePattern::createTileImage const):
     117        * rendering/svg/SVGRenderingContext.cpp:
     118        (WebCore::SVGRenderingContext::bufferForeground):
     119
    11202022-03-01  Eric Carlson  <eric.carlson@apple.com>
    2121
  • trunk/Source/WebCore/html/CustomPaintCanvas.cpp

    r289518 r290679  
    7474    auto clipBounds = ctx->clipBounds();
    7575
    76     auto image = ctx->createCompatibleImageBuffer(clipBounds.size());
     76    auto image = ctx->createAlignedImageBuffer(clipBounds.size());
    7777    if (!image)
    7878        return;
  • trunk/Source/WebCore/html/CustomPaintImage.cpp

    r289976 r290679  
    200200    adjustedSrcRect.scale(xScale, yScale);
    201201
    202     auto buffer = destContext.createCompatibleImageBuffer(adjustedSize);
     202    auto buffer = destContext.createAlignedImageBuffer(adjustedSize);
    203203    if (!buffer)
    204204        return;
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp

    r289981 r290679  
    16121612    } else if (state().globalComposite == CompositeOperator::Copy) {
    16131613        if (&sourceCanvas == &canvasBase()) {
    1614             if (auto copy = c->createCompatibleImageBuffer(srcRect.size(), colorSpace())) {
     1614            if (auto copy = c->createAlignedImageBuffer(srcRect.size(), colorSpace())) {
    16151615                copy->context().drawImageBuffer(*buffer, -srcRect.location());
    16161616                clearCanvas();
    … …  
    24602460        }
    24612461
    2462         auto maskImage = c->createCompatibleImageBuffer(maskRect.size());
     2462        auto maskImage = c->createAlignedImageBuffer(maskRect.size());
    24632463        if (!maskImage)
    24642464            return;
  • trunk/Source/WebCore/platform/cocoa/ThemeCocoa.mm

    r289518 r290679  
    112112{
    113113    // Create a local ImageBuffer because decoding the PDF images has to happen in WebProcess.
    114     auto imageBuffer = context.createCompatibleImageBuffer(size, DestinationColorSpace::SRGB(), RenderingMethod::Local);
     114    auto imageBuffer = context.createAlignedImageBuffer(size, DestinationColorSpace::SRGB(), RenderingMethod::Local);
    115115    if (!imageBuffer)
    116116        return;
  • trunk/Source/WebCore/platform/graphics/BitmapImage.cpp

    r289981 r290679  
    349349
    350350    if (!m_cachedImage) {
    351         auto buffer = ctxt.createCompatibleImageBuffer(expandedIntSize(tileRect.size()));
     351        auto buffer = ctxt.createAlignedImageBuffer(expandedIntSize(tileRect.size()));
    352352        if (!buffer)
    353353            return;
  • trunk/Source/WebCore/platform/graphics/GradientImage.cpp

    r289518 r290679  
    7373
    7474    if (!m_cachedImage || m_cachedGeneratorHash != generatorHash || m_cachedAdjustedSize != adjustedSize || !areEssentiallyEqual(destContext.scaleFactor(), m_cachedScaleFactor)) {
    75         auto imageBuffer = destContext.createCompatibleImageBuffer(adjustedSize);
     75        auto imageBuffer = destContext.createAlignedImageBuffer(adjustedSize);
    7676        if (!imageBuffer)
    7777            return;
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r289981 r290679  
    578578}
    579579
    580 RefPtr<ImageBuffer> GraphicsContext::createImageBuffer(const FloatSize& size, const DestinationColorSpace& colorSpace, RenderingMode renderingMode, RenderingMethod renderingMethod) const
    581 {
    582     if (renderingMethod == RenderingMethod::DisplayList)
    583         return ImageBuffer::create(size, renderingMode, ShouldUseDisplayList::Yes, RenderingPurpose::Unspecified, 1, colorSpace, PixelFormat::BGRA8);
    584 
    585     return ImageBuffer::create(size, renderingMode, 1, colorSpace, PixelFormat::BGRA8);
    586 }
    587 
    588 RefPtr<ImageBuffer> GraphicsContext::createImageBuffer(const FloatSize& size, const FloatSize& scale, const DestinationColorSpace& colorSpace, std::optional<RenderingMode> renderingMode, RenderingMethod renderingMethod) const
     580RefPtr<ImageBuffer> GraphicsContext::createImageBuffer(const FloatSize& size, float resolutionScale, const DestinationColorSpace& colorSpace, std::optional<RenderingMode> renderingMode, std::optional<RenderingMethod> renderingMethod) const
     581{
     582    if (!renderingMethod || *renderingMethod == RenderingMethod::Local)
     583        return ImageBuffer::create(size, renderingMode.value_or(this->renderingMode()), resolutionScale, colorSpace, PixelFormat::BGRA8);
     584
     585    return ImageBuffer::create(size, renderingMode.value_or(this->renderingMode()), ShouldUseDisplayList::Yes, RenderingPurpose::Unspecified, resolutionScale, colorSpace, PixelFormat::BGRA8);
     586}
     587
     588RefPtr<ImageBuffer> GraphicsContext::createScaledImageBuffer(const FloatSize& size, const FloatSize& scale, const DestinationColorSpace& colorSpace, std::optional<RenderingMode> renderingMode, std::optional<RenderingMethod> renderingMethod) const
    589589{
    590590    auto expandedScaledSize = scaledImageBufferSize(size, scale);
    … …  
    594594    auto clampingScale = clampingScaleForImageBufferSize(expandedScaledSize);
    595595
    596     auto imageBuffer = createImageBuffer(expandedScaledSize * clampingScale, colorSpace, renderingMode.value_or(this->renderingMode()), renderingMethod);
     596    auto imageBuffer = createImageBuffer(expandedScaledSize * clampingScale, 1, colorSpace, renderingMode, renderingMethod);
    597597    if (!imageBuffer)
    598598        return nullptr;
    … …  
    606606}
    607607
    608 RefPtr<ImageBuffer> GraphicsContext::createImageBuffer(const FloatRect& rect, const FloatSize& scale, const DestinationColorSpace& colorSpace, std::optional<RenderingMode> renderingMode, RenderingMethod renderingMethod) const
     608RefPtr<ImageBuffer> GraphicsContext::createScaledImageBuffer(const FloatRect& rect, const FloatSize& scale, const DestinationColorSpace& colorSpace, std::optional<RenderingMode> renderingMode, std::optional<RenderingMethod> renderingMethod) const
    609609{
    610610    auto expandedScaledRect = scaledImageBufferRect(rect, scale);
    … …  
    614614    auto clampingScale = clampingScaleForImageBufferSize(expandedScaledRect.size());
    615615
    616     auto imageBuffer = createImageBuffer(expandedScaledRect.size() * clampingScale, colorSpace, renderingMode.value_or(this->renderingMode()), renderingMethod);
     616    auto imageBuffer = createImageBuffer(expandedScaledRect.size() * clampingScale, 1, colorSpace, renderingMode, renderingMethod);
    617617    if (!imageBuffer)
    618618        return nullptr;
    … …  
    629629}
    630630
    631 RefPtr<ImageBuffer> GraphicsContext::createCompatibleImageBuffer(const FloatSize& size, const DestinationColorSpace& colorSpace, RenderingMethod renderingMethod) const
    632 {
    633     return createImageBuffer(size, scaleFactor(), colorSpace, renderingMode(), renderingMethod);
    634 }
    635 
    636 RefPtr<ImageBuffer> GraphicsContext::createCompatibleImageBuffer(const FloatRect& rect, const DestinationColorSpace& colorSpace, RenderingMethod renderingMethod) const
    637 {
    638     return createImageBuffer(rect, scaleFactor(), colorSpace, renderingMode(), renderingMethod);
     631RefPtr<ImageBuffer> GraphicsContext::createAlignedImageBuffer(const FloatSize& size, const DestinationColorSpace& colorSpace, std::optional<RenderingMethod> renderingMethod) const
     632{
     633    return createScaledImageBuffer(size, scaleFactor(), colorSpace, renderingMode(), renderingMethod);
     634}
     635
     636RefPtr<ImageBuffer> GraphicsContext::createAlignedImageBuffer(const FloatRect& rect, const DestinationColorSpace& colorSpace, std::optional<RenderingMethod> renderingMethod) const
     637{
     638    return createScaledImageBuffer(rect, scaleFactor(), colorSpace, renderingMode(), renderingMethod);
    639639}
    640640
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r289981 r290679  
    419419    IntSize compatibleImageBufferSize(const FloatSize&) const;
    420420
    421     WEBCORE_EXPORT RefPtr<ImageBuffer> createImageBuffer(const FloatSize&, const FloatSize& scale = { 1, 1 }, const DestinationColorSpace& = DestinationColorSpace::SRGB(), std::optional<RenderingMode> = std::nullopt, RenderingMethod = RenderingMethod::Default) const;
    422     WEBCORE_EXPORT RefPtr<ImageBuffer> createImageBuffer(const FloatRect&, const FloatSize& scale = { 1, 1 }, const DestinationColorSpace& = DestinationColorSpace::SRGB(), std::optional<RenderingMode> = std::nullopt, RenderingMethod = RenderingMethod::Default) const;
    423 
    424     WEBCORE_EXPORT virtual RefPtr<ImageBuffer> createCompatibleImageBuffer(const FloatSize&, const DestinationColorSpace& = DestinationColorSpace::SRGB(), RenderingMethod = RenderingMethod::Default) const;
    425     WEBCORE_EXPORT virtual RefPtr<ImageBuffer> createCompatibleImageBuffer(const FloatRect&, const DestinationColorSpace& = DestinationColorSpace::SRGB(), RenderingMethod = RenderingMethod::Default) const;
     421    WEBCORE_EXPORT virtual RefPtr<ImageBuffer> createImageBuffer(const FloatSize&, float resolutionScale = 1, const DestinationColorSpace& = DestinationColorSpace::SRGB(), std::optional<RenderingMode> = std::nullopt, std::optional<RenderingMethod> = std::nullopt) const;
     422
     423    WEBCORE_EXPORT RefPtr<ImageBuffer> createScaledImageBuffer(const FloatSize&, const FloatSize& scale = { 1, 1 }, const DestinationColorSpace& = DestinationColorSpace::SRGB(), std::optional<RenderingMode> = std::nullopt, std::optional<RenderingMethod> = std::nullopt) const;
     424    WEBCORE_EXPORT RefPtr<ImageBuffer> createScaledImageBuffer(const FloatRect&, const FloatSize& scale = { 1, 1 }, const DestinationColorSpace& = DestinationColorSpace::SRGB(), std::optional<RenderingMode> = std::nullopt, std::optional<RenderingMethod> = std::nullopt) const;
     425
     426    WEBCORE_EXPORT virtual RefPtr<ImageBuffer> createAlignedImageBuffer(const FloatSize&, const DestinationColorSpace& = DestinationColorSpace::SRGB(), std::optional<RenderingMethod> = std::nullopt) const;
     427    WEBCORE_EXPORT virtual RefPtr<ImageBuffer> createAlignedImageBuffer(const FloatRect&, const DestinationColorSpace& = DestinationColorSpace::SRGB(), std::optional<RenderingMethod> = std::nullopt) const;
    426428
    427429    virtual void drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& = { }) = 0;
    … …  
    549551    void fillEllipseAsPath(const FloatRect&);
    550552    void strokeEllipseAsPath(const FloatRect&);
    551 
    552     WEBCORE_EXPORT virtual RefPtr<ImageBuffer> createImageBuffer(const FloatSize&, const DestinationColorSpace&, RenderingMode, RenderingMethod) const;
    553553
    554554    FloatRect computeLineBoundsAndAntialiasingModeForText(const FloatRect&, bool printing, Color&);
  • trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp

    r289518 r290679  
    7575RefPtr<ImageBuffer> ImageBuffer::clone() const
    7676{
    77     auto clone = context().createCompatibleImageBuffer(logicalSize(), colorSpace());
     77    auto clone = context().createAlignedImageBuffer(logicalSize(), colorSpace());
    7878    if (!clone)
    7979        return nullptr;
  • trunk/Source/WebCore/platform/graphics/NamedImageGeneratedImage.cpp

    r289976 r290679  
    6666{
    6767#if USE(NEW_THEME)
    68     auto imageBuffer = context.createCompatibleImageBuffer(size());
     68    auto imageBuffer = context.createAlignedImageBuffer(size());
    6969    if (!imageBuffer)
    7070        return;
  • trunk/Source/WebCore/platform/graphics/RenderingMode.h

    r289518 r290679  
    3737enum class ShouldUseDisplayList : bool { No, Yes };
    3838enum class RenderingMode : bool { Unaccelerated, Accelerated };
    39 
    40 enum class RenderingMethod : uint8_t {
    41     Default,
    42     Local,
    43     DisplayList
    44 };
     39enum class RenderingMethod : bool { Local, DisplayList };
    4540
    4641} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp

    r289518 r290679  
    241241
    242242    // Create a local ImageBuffer because decoding the PDF images has to happen in WebProcess.
    243     m_cachedImageBuffer = context.createCompatibleImageBuffer(cachedImageSize, DestinationColorSpace::SRGB(), RenderingMethod::Local);
     243    m_cachedImageBuffer = context.createAlignedImageBuffer(cachedImageSize, DestinationColorSpace::SRGB(), RenderingMethod::Local);
    244244    if (!m_cachedImageBuffer) {
    245245        destroyDecodedData();
    … …  
    294294            auto scalar = std::min(1.f, std::sqrt(static_cast<float>(s_maxCachedImageArea) / (dstRect.width() * dstRect.height())));
    295295            FloatRect localDestinationRect(FloatPoint(), dstRect.size() * scalar);
    296             if (auto imageBuffer = context.createCompatibleImageBuffer(localDestinationRect.size(), DestinationColorSpace::SRGB(), RenderingMethod::Local)) {
     296            if (auto imageBuffer = context.createAlignedImageBuffer(localDestinationRect.size(), DestinationColorSpace::SRGB(), RenderingMethod::Local)) {
    297297                auto& bufferContext = imageBuffer->context();
    298298                transformContextForPainting(bufferContext, localDestinationRect, srcRect);
  • trunk/Source/WebCore/platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp

    r289518 r290679  
    380380
    381381        // Create a local ImageBuffer because decoding the SVG fonts has to happen in WebProcess.
    382         if (auto imageBuffer = m_owner.createCompatibleImageBuffer(bounds, DestinationColorSpace::SRGB(), RenderingMethod::Local)) {
     382        if (auto imageBuffer = m_owner.createAlignedImageBuffer(bounds, DestinationColorSpace::SRGB(), RenderingMethod::Local)) {
    383383            FontCascade::drawGlyphs(imageBuffer->context(), font, glyphs + i, advances + i, 1, FloatPoint(), smoothingMode);
    384384
  • trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp

    r290581 r290679  
    493493}
    494494
    495 RefPtr<ImageBuffer> Recorder::createImageBuffer(const FloatSize& size, const DestinationColorSpace& colorSpace, RenderingMode renderingMode, RenderingMethod renderingMethod) const
    496 {
    497     if (renderingMethod == RenderingMethod::Default)
    498         renderingMethod = RenderingMethod::DisplayList;
    499 
    500     return GraphicsContext::createImageBuffer(size, colorSpace, renderingMode, renderingMethod);
     495RefPtr<ImageBuffer> Recorder::createImageBuffer(const FloatSize& size, float resolutionScale, const DestinationColorSpace& colorSpace, std::optional<RenderingMode> renderingMode, std::optional<RenderingMethod> renderingMethod) const
     496{
     497    return GraphicsContext::createImageBuffer(size, resolutionScale, colorSpace, renderingMode, renderingMethod.value_or(RenderingMethod::DisplayList));
    501498}
    502499
  • trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h

    r290581 r290679  
    173173    ContextState& currentState();
    174174
    175     WEBCORE_EXPORT RefPtr<ImageBuffer> createImageBuffer(const FloatSize&, const DestinationColorSpace&, RenderingMode, RenderingMethod) const override;
     175    WEBCORE_EXPORT RefPtr<ImageBuffer> createImageBuffer(const FloatSize&, float resolutionScale, const DestinationColorSpace&, std::optional<RenderingMode>, std::optional<RenderingMethod>) const override;
    176176
    177177private:
  • trunk/Source/WebCore/platform/mac/ThemeMac.mm

    r289518 r290679  
    735735    if (useImageBuffer) {
    736736        NSRect imageBufferDrawRect = NSRect(FloatRect(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth, rect.width(), rect.height()));
    737         auto imageBuffer = context.createImageBuffer(rect.size() + 2 * FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth), { deviceScaleFactor, deviceScaleFactor });
     737        auto imageBuffer = context.createImageBuffer(rect.size() + 2 * FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth), deviceScaleFactor);
    738738        if (!imageBuffer)
    739739            return needsRepaint;
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r290649 r290679  
    895895
    896896        // Now create the mask.
    897         maskImage = context.createCompatibleImageBuffer(maskRect.size());
     897        maskImage = context.createAlignedImageBuffer(maskRect.size());
    898898        if (!maskImage)
    899899            return;
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r290545 r290679  
    33253325    const FloatSize tileSize { 32, 18 };
    33263326
    3327     auto imageBuffer = destContext.createCompatibleImageBuffer(tileSize);
     3327    auto imageBuffer = destContext.createAlignedImageBuffer(tileSize);
    33283328    if (!imageBuffer)
    33293329        return nullptr;
  • trunk/Source/WebCore/rendering/RenderLayerFilters.cpp

    r289518 r290679  
    136136
    137137    if (!m_sourceImage || m_sourceImage->logicalSize() != logicalSize)
    138         m_sourceImage = context.createImageBuffer(m_filterRegion.size(), filter.filterScale(), DestinationColorSpace::SRGB(), filter.renderingMode());
     138        m_sourceImage = context.createScaledImageBuffer(m_filterRegion.size(), filter.filterScale(), DestinationColorSpace::SRGB(), filter.renderingMode());
    139139}
    140140
  • trunk/Source/WebCore/rendering/RenderThemeCocoa.mm

    r290456 r290679  
    155155    auto& destinationContext = paintInfo.context();
    156156
    157     auto imageBuffer = destinationContext.createCompatibleImageBuffer(paintRect.size());
     157    auto imageBuffer = destinationContext.createAlignedImageBuffer(paintRect.size());
    158158    if (!imageBuffer)
    159159        return false;
  • trunk/Source/WebCore/rendering/RenderThemeMac.mm

    r290329 r290679  
    995995    float deviceScaleFactor = o.document().deviceScaleFactor();
    996996
    997     auto comboBoxImageBuffer = context.createImageBuffer(comboBoxSize, { deviceScaleFactor, deviceScaleFactor });
     997    auto comboBoxImageBuffer = context.createImageBuffer(comboBoxSize, deviceScaleFactor);
    998998    if (!comboBoxImageBuffer)
    999999        return;
    … …  
    10191019    }];
    10201020
    1021     auto comboBoxButtonImageBuffer = context.createImageBuffer(desiredComboBoxButtonSize, { deviceScaleFactor, deviceScaleFactor });
     1021    auto comboBoxButtonImageBuffer = context.createImageBuffer(desiredComboBoxButtonSize, deviceScaleFactor);
    10221022    if (!comboBoxButtonImageBuffer)
    10231023        return;
    … …  
    14031403    float deviceScaleFactor = renderObject.document().deviceScaleFactor();
    14041404    bool isIndeterminate = renderProgress.position() < 0;
    1405     auto imageBuffer = paintInfo.context().createImageBuffer(inflatedRect.size(), { deviceScaleFactor, deviceScaleFactor });
     1405    auto imageBuffer = paintInfo.context().createImageBuffer(inflatedRect.size(), deviceScaleFactor);
    14061406    if (!imageBuffer)
    14071407        return true;
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp

    r289518 r290679  
    163163    if (!clipperData.isValidForGeometry(objectBoundingBox, clippedContentBounds, absoluteTransform)) {
    164164        // FIXME (149469): This image buffer should not be unconditionally unaccelerated. Making it match the context breaks nested clipping, though.
    165         auto maskImage = context.createImageBuffer(clippedContentBounds, scale, DestinationColorSpace::SRGB(), RenderingMode::Unaccelerated);
     165        auto maskImage = context.createScaledImageBuffer(clippedContentBounds, scale, DestinationColorSpace::SRGB(), RenderingMode::Unaccelerated);
    166166        if (!maskImage)
    167167            return false;
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp

    r289518 r290679  
    154154#endif
    155155
    156     auto sourceGraphic = context->createImageBuffer(filterData->drawingRegion, filterScale, colorSpace, filterData->filter->renderingMode());
     156    auto sourceGraphic = context->createScaledImageBuffer(filterData->drawingRegion, filterScale, colorSpace, filterData->filter->renderingMode());
    157157    if (!sourceGraphic) {
    158158        ASSERT(m_rendererFilterDataMap.contains(&renderer));
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp

    r289518 r290679  
    6868    ImageBuffer::sizeNeedsClamping(repaintRect.size(), scale);
    6969
    70     auto maskImage = context->createImageBuffer(repaintRect, scale);
     70    auto maskImage = context->createScaledImageBuffer(repaintRect, scale);
    7171    if (!maskImage)
    7272        return false;
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp

    r289518 r290679  
    9191#endif
    9292        // FIXME (149470): This image buffer should not be unconditionally unaccelerated. Making it match the context breaks alpha masking, though.
    93         maskerData->maskImage = context->createImageBuffer(repaintRect, scale, maskColorSpace, RenderingMode::Unaccelerated);
     93        maskerData->maskImage = context->createScaledImageBuffer(repaintRect, scale, maskColorSpace, RenderingMode::Unaccelerated);
    9494        if (!maskerData->maskImage)
    9595            return false;
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp

    r289518 r290679  
    244244
    245245    // FIXME: Use createImageBuffer(rect, scale), delete the above calculations and fix 'tileImageTransform'
    246     auto tileImage = context.createImageBuffer(tileSize, scale);
     246    auto tileImage = context.createScaledImageBuffer(tileSize, scale);
    247247    if (!tileImage)
    248248        return nullptr;
  • trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp

    r289518 r290679  
    283283    // Create a new buffer and paint the foreground into it.
    284284    if (!imageBuffer) {
    285         imageBuffer = m_paintInfo->context().createCompatibleImageBuffer(expandedIntSize(boundingBox.size()));
     285        imageBuffer = m_paintInfo->context().createAlignedImageBuffer(expandedIntSize(boundingBox.size()));
    286286        if (!imageBuffer)
    287287            return false;
  • trunk/Source/WebKit/ChangeLog

    r290676 r290679  
     12022-03-01  Said Abou-Hallawa  <said@apple.com>
     2
     3        [macOS][REGRESSION] (rr289518): Form controls are scaled twice on Retina display
     4        https://bugs.webkit.org/show_bug.cgi?id=237128
     5        rdar://89064642
     6
     7        Reviewed by Darin Adler.
     8
     9        * WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp:
     10        (WebKit::RemoteDisplayListRecorderProxy::createImageBuffer const):
     11        (WebKit::RemoteDisplayListRecorderProxy::createAlignedImageBuffer const):
     12        (WebKit::RemoteDisplayListRecorderProxy::createCompatibleImageBuffer const): Deleted.
     13        * WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h:
     14
    1152022-03-01  Eric Carlson  <eric.carlson@apple.com>
    216
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp

    r290581 r290679  
    435435}
    436436
    437 RefPtr<ImageBuffer> RemoteDisplayListRecorderProxy::createImageBuffer(const FloatSize& size, const DestinationColorSpace& colorSpace, RenderingMode renderingMode, RenderingMethod renderingMethod) const
     437RefPtr<ImageBuffer> RemoteDisplayListRecorderProxy::createImageBuffer(const FloatSize& size, float resolutionScale, const DestinationColorSpace& colorSpace, std::optional<RenderingMode> renderingMode, std::optional<RenderingMethod> renderingMethod) const
    438438{
    439439    if (UNLIKELY(!m_renderingBackend)) {
    … …  
    442442    }
    443443
    444     if (renderingMethod != RenderingMethod::Default)
    445         return Recorder::createImageBuffer(size, colorSpace, renderingMode, renderingMethod);
    446 
    447     return m_renderingBackend->createImageBuffer(size, renderingMode, 1, colorSpace, PixelFormat::BGRA8);
    448 }
    449 
    450 RefPtr<ImageBuffer> RemoteDisplayListRecorderProxy::createCompatibleImageBuffer(const FloatSize& size, const DestinationColorSpace& colorSpace, RenderingMethod renderingMethod) const
    451 {
    452     auto renderingMode = renderingMethod == RenderingMethod::Default ? this->renderingMode() : RenderingMode::Unaccelerated;
    453     return GraphicsContext::createImageBuffer(size, scaleFactor(), colorSpace, renderingMode, renderingMethod);
    454 }
    455 
    456 RefPtr<ImageBuffer> RemoteDisplayListRecorderProxy::createCompatibleImageBuffer(const FloatRect& rect, const DestinationColorSpace& colorSpace, RenderingMethod renderingMethod) const
    457 {
    458     auto renderingMode = renderingMethod == RenderingMethod::Default ? this->renderingMode() : RenderingMode::Unaccelerated;
    459     return GraphicsContext::createImageBuffer(rect, scaleFactor(), colorSpace, renderingMode, renderingMethod);
     444    if (renderingMethod)
     445        return Recorder::createImageBuffer(size, resolutionScale, colorSpace, renderingMode, renderingMethod);
     446
     447    return m_renderingBackend->createImageBuffer(size, renderingMode.value_or(this->renderingMode()), resolutionScale, colorSpace, PixelFormat::BGRA8);
     448}
     449
     450RefPtr<ImageBuffer> RemoteDisplayListRecorderProxy::createAlignedImageBuffer(const FloatSize& size, const DestinationColorSpace& colorSpace, std::optional<RenderingMethod> renderingMethod) const
     451{
     452    auto renderingMode = !renderingMethod ? this->renderingMode() : RenderingMode::Unaccelerated;
     453    return GraphicsContext::createScaledImageBuffer(size, scaleFactor(), colorSpace, renderingMode, renderingMethod);
     454}
     455
     456RefPtr<ImageBuffer> RemoteDisplayListRecorderProxy::createAlignedImageBuffer(const FloatRect& rect, const DestinationColorSpace& colorSpace, std::optional<RenderingMethod> renderingMethod) const
     457{
     458    auto renderingMode = !renderingMethod ? this->renderingMode() : RenderingMode::Unaccelerated;
     459    return GraphicsContext::createScaledImageBuffer(rect, scaleFactor(), colorSpace, renderingMode, renderingMethod);
    460460}
    461461
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h

    r290581 r290679  
    137137    bool recordResourceUse(WebCore::Font&) final;
    138138
    139     RefPtr<WebCore::ImageBuffer> createImageBuffer(const WebCore::FloatSize&, const WebCore::DestinationColorSpace&, WebCore::RenderingMode, WebCore::RenderingMethod) const final;
    140     RefPtr<WebCore::ImageBuffer> createCompatibleImageBuffer(const WebCore::FloatSize&, const WebCore::DestinationColorSpace& = WebCore::DestinationColorSpace::SRGB(), WebCore::RenderingMethod = WebCore::RenderingMethod::Default) const final;
    141     RefPtr<WebCore::ImageBuffer> createCompatibleImageBuffer(const WebCore::FloatRect&, const WebCore::DestinationColorSpace& = WebCore::DestinationColorSpace::SRGB(), WebCore::RenderingMethod = WebCore::RenderingMethod::Default) const final;
     139    RefPtr<WebCore::ImageBuffer> createImageBuffer(const WebCore::FloatSize&, float resolutionScale, const WebCore::DestinationColorSpace&, std::optional<WebCore::RenderingMode>, std::optional<WebCore::RenderingMethod>) const final;
     140    RefPtr<WebCore::ImageBuffer> createAlignedImageBuffer(const WebCore::FloatSize&, const WebCore::DestinationColorSpace&, std::optional<WebCore::RenderingMethod>) const final;
     141    RefPtr<WebCore::ImageBuffer> createAlignedImageBuffer(const WebCore::FloatRect&, const WebCore::DestinationColorSpace&, std::optional<WebCore::RenderingMethod>) const final;
    142142
    143143    WebCore::RenderingResourceIdentifier m_destinationBufferIdentifier;
Note: See TracChangeset for help on using the changeset viewer.