Title: [293825] trunk/Source/WebCore
Revision
293825
Author
s...@apple.com
Date
2022-05-05 01:19:13 -0700 (Thu, 05 May 2022)

Log Message

[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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (293824 => 293825)


--- trunk/Source/WebCore/ChangeLog	2022-05-05 07:38:15 UTC (rev 293824)
+++ trunk/Source/WebCore/ChangeLog	2022-05-05 08:19:13 UTC (rev 293825)
@@ -1,3 +1,22 @@
+2022-05-05  Said Abou-Hallawa  <s...@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  <you...@apple.com>
 
         SWOriginStore is no longer needed

Modified: trunk/Source/WebCore/page/FrameSnapshotting.cpp (293824 => 293825)


--- trunk/Source/WebCore/page/FrameSnapshotting.cpp	2022-05-05 07:38:15 UTC (rev 293824)
+++ trunk/Source/WebCore/page/FrameSnapshotting.cpp	2022-05-05 08:19:13 UTC (rev 293825)
@@ -115,19 +115,23 @@
     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);
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to