Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3dc88e02d3ffa980bc418fa28c6a144b512ea058
https://github.com/WebKit/WebKit/commit/3dc88e02d3ffa980bc418fa28c6a144b512ea058
Author: Ahmad Saleem <[email protected]>
Date: 2026-09-21 (Mon, 21 Sep 2026)
Changed paths:
M Source/WebCore/platform/graphics/GraphicsContext.cpp
M Tools/TestWebKitAPI/Tests/WebCore/ImageBufferTests.cpp
Log Message:
-----------
GraphicsContext::drawPattern(ImageBuffer&) ignores resolutionScale, sampling
the wrong tile rect for HiDPI pattern buffers
https://bugs.webkit.org/show_bug.cgi?id=324071
rdar://187300627
Reviewed by Kimmo Kinnunen.
GraphicsContext::drawPattern(ImageBuffer&) computed a scaledSource rect
(source scaled by the buffer's resolutionScale) but then forwarded the
unscaled source to the NativeImage overload. That overload's tile rect is
in native (device) image pixels — logicalSize * resolutionScale — so for a
resolutionScale != 1 pattern buffer it sampled a too-small tile rect: at
resolutionScale 2, only the top-left quadrant of the tile. This matches the
sibling drawImageBuffer() / drawConsumingImageBuffer() overloads, which
already forward the scaled source rect.
The defect is latent today because every caller builds its pattern buffer
at resolutionScale 1 (createScaledImageBuffer/createAlignedImageBuffer bake
the device scale into the buffer's pixel dimensions and pre-scale the source
rect), so it is not reachable from web content and is covered by an API test
rather than a layout test.
Test: Tools/TestWebKitAPI/Tests/WebCore/ImageBufferTests.cpp
* Source/WebCore/platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::drawPattern): Forward scaledSource instead of
source to the NativeImage overload.
* Tools/TestWebKitAPI/Tests/WebCore/ImageBufferTests.cpp:
(TestWebKitAPI::TEST(ImageBufferTests,
DrawPatternScalesSourceRectByResolutionScale)):
Add DrawPatternScalesSourceRectByResolutionScale, which tiles a resolutionScale
2 buffer into a scale 1 destination and verifies the whole tile is reproduced
(fails without the fix: the top-right quadrant is magenta instead of yellow).
Canonical link: https://commits.webkit.org/321506@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications