Skip to content
Permalink
Browse files
Use device pixel scaled backing store for <canvas> with image-renderi…
…ng: pixelated.

https://bugs.webkit.org/show_bug.cgi?id=247251
<rdar://99895407>

Reviewed by Simon Fraser.

We need to do scaling during painting to apply the image-rendering effect. An alternative fix would
be to set the image-rendering value on the GraphicsLayer, but its complicated to make that change
dependent on having computed isUnscaledBitmapOnly.

* LayoutTests/platform/ios-wk2/TestExpectations:
* Source/WebCore/rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::isUnscaledBitmapOnly const):
* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::layerStyleChanged):

Canonical link: https://commits.webkit.org/256299@main
  • Loading branch information
mattwoodrow committed Nov 3, 2022
1 parent 0310eb3 commit 8ed3d524525aa6fa2ee34d47e744f36947536bfb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
@@ -2372,8 +2372,6 @@ imported/w3c/web-platform-tests/html/canvas/element/manual/imagebitmap/createIma
webkit.org/b/245588 mathml/presentation/mathvariant-inheritance.html [ ImageOnlyFailure ]
webkit.org/b/245588 mathml/presentation/fenced-mi.html [ ImageOnlyFailure ]

webkit.org/b/245590 svg/canvas/canvas-global-alpha-svg.html [ ImageOnlyFailure ]

webkit.org/b/245592 imported/w3c/web-platform-tests/css/css-counter-styles/mongolian/css3-counter-styles-138.html [ ImageOnlyFailure ]

webkit.org/b/245595 imported/blink/svg/canvas/canvas-draw-pattern-size.html [ ImageOnlyFailure ]
@@ -2970,6 +2970,9 @@ bool RenderLayerBacking::isUnscaledBitmapOnly() const
return false;
}

if (renderer().style().imageRendering() == ImageRendering::CrispEdges || renderer().style().imageRendering() == ImageRendering::Pixelated)
return false;

auto& canvasRenderer = downcast<RenderHTMLCanvas>(renderer());
if (snappedIntRect(contents).size() == canvasRenderer.canvasElement().size())
return true;
@@ -1769,6 +1769,10 @@ void RenderLayerCompositor::layerStyleChanged(StyleDifference diff, RenderLayer&
if (styleAffectsLayerGeometry(*oldStyle) || styleAffectsLayerGeometry(newStyle))
layer.setNeedsCompositingGeometryUpdate();
}

// image rendering mode can determine whether we use device pixel ratio for the backing store.
if (oldStyle && oldStyle->imageRendering() != newStyle.imageRendering())
layer.setNeedsCompositingConfigurationUpdate();
}

if (diff >= StyleDifference::RecompositeLayer) {

0 comments on commit 8ed3d52

Please sign in to comment.