Skip to content

Commit

Permalink
[GPU Process] [iOS] REGRESSION(r293570): Snapshot rendering is not sc…
Browse files Browse the repository at this point in the history
…aled with the device scale factor

https://bugs.webkit.org/show_bug.cgi?id=240100
rdar://92635752

Reviewed by Simon Fraser.

The scaling factor is not set in the GraphicsContext of the
ImageBufferShareableBitmapBackend.

To fix this bug is to make snapshotFrameRectWithClip() handle the scaling
outside the ImageBuffer creation. This is similar to what we do in
GraphicsContext::createAlignedImageBuffer() where we scale the size and
create the ImageBuffer with scaleFactor = 1.

* page/FrameSnapshotting.cpp:
(WebCore::snapshotFrameRectWithClip):

Canonical link: https://commits.webkit.org/250298@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@293825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
shallawa committed May 5, 2022
1 parent 5cf83d8 commit 29fdbe1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
19 changes: 19 additions & 0 deletions Source/WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
2022-05-05 Said Abou-Hallawa <said@apple.com>

[GPU Process] [iOS] REGRESSION(r293570): Snapshot rendering is not scaled with the device scale factor
https://bugs.webkit.org/show_bug.cgi?id=240100
rdar://92635752

Reviewed by Simon Fraser.

The scaling factor is not set in the GraphicsContext of the
ImageBufferShareableBitmapBackend.

To fix this bug is to make snapshotFrameRectWithClip() handle the scaling
outside the ImageBuffer creation. This is similar to what we do in
GraphicsContext::createAlignedImageBuffer() where we scale the size and
create the ImageBuffer with scaleFactor = 1.

* page/FrameSnapshotting.cpp:
(WebCore::snapshotFrameRectWithClip):

2022-05-05 Youenn Fablet <youenn@apple.com>

SWOriginStore is no longer needed
Expand Down
10 changes: 7 additions & 3 deletions Source/WebCore/page/FrameSnapshotting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,23 @@ RefPtr<ImageBuffer> snapshotFrameRectWithClip(Frame& frame, const IntRect& image
if (options.flags.contains(SnapshotFlags::PaintWithIntegralScaleFactor))
scaleFactor = ceilf(scaleFactor);

auto scaledImageRect = imageRect;
scaledImageRect.scale(scaleFactor);

auto purpose = options.flags.contains(SnapshotFlags::Shareable) ? RenderingPurpose::ShareableSnapshot : RenderingPurpose::Snapshot;
auto hostWindow = (document->view() && document->view()->root()) ? document->view()->root()->hostWindow() : nullptr;

auto buffer = ImageBuffer::create(imageRect.size(), purpose, scaleFactor, options.colorSpace, options.pixelFormat, { }, { hostWindow });
auto buffer = ImageBuffer::create(scaledImageRect.size(), purpose, 1, options.colorSpace, options.pixelFormat, { }, { hostWindow });
if (!buffer)
return nullptr;

buffer->context().translate(-imageRect.x(), -imageRect.y());
buffer->context().translate(-scaledImageRect.location());
buffer->context().scale(scaleFactor);

if (!clipRects.isEmpty()) {
Path clipPath;
for (auto& rect : clipRects)
clipPath.addRect(encloseRectToDevicePixels(rect, scaleFactor));
clipPath.addRect(rect);
buffer->context().clipPath(clipPath);
}

Expand Down

0 comments on commit 29fdbe1

Please sign in to comment.