Title: [293968] trunk/Source
Revision
293968
Author
[email protected]
Date
2022-05-08 23:28:36 -0700 (Sun, 08 May 2022)

Log Message

[macOS] REGRESSION (r293825): Find highlight snapshots are incorrectly scaled
https://bugs.webkit.org/show_bug.cgi?id=240203
rdar://92892014

Reviewed by Tim Horton.

Source/WebCore:

takeSnapshots() depends on the snapshot ImageBuffer::resolutionScale() to
set the size of the TextIndicatorData image. r293825 scaled the size of
the ImageBuffer before creation and moved the scaling to the GraphicsContext.
So we have correct scaled pixels but the resolutionScale is 1. So we get
enlarged incorrect image.

The fix is to revert r293825 and fix the iOS snapshot without having to
change snapshotFrameRectWithClip().

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

Source/WebKit:

In getShareableBitmapForImageBufferWithQualifiedIdentifier(), we used to
pass the backendSize as the srcRect and the backendSize as the destRect
to GraphicsContext::drawImageBuffer(). The backendSize is the logicalSize
scaled by the resolutionScale. But in ImageBufferCGBackend::draw() we
scale the srcRect by the resolutionScale one more time. This double-
scaled srcRect draws a srcRect whose size = backendSize * resolutionScale
to a destRect whose size = backendSize. And this results in shrinking the
desired snapshot image by 1 / resolutionScale.

* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::getShareableBitmapForImageBufferWithQualifiedIdentifier):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (293967 => 293968)


--- trunk/Source/WebCore/ChangeLog	2022-05-09 06:14:33 UTC (rev 293967)
+++ trunk/Source/WebCore/ChangeLog	2022-05-09 06:28:36 UTC (rev 293968)
@@ -1,3 +1,23 @@
+2022-05-08  Said Abou-Hallawa  <[email protected]>
+
+        [macOS] REGRESSION (r293825): Find highlight snapshots are incorrectly scaled
+        https://bugs.webkit.org/show_bug.cgi?id=240203
+        rdar://92892014
+
+        Reviewed by Tim Horton.
+
+        takeSnapshots() depends on the snapshot ImageBuffer::resolutionScale() to
+        set the size of the TextIndicatorData image. r293825 scaled the size of 
+        the ImageBuffer before creation and moved the scaling to the GraphicsContext.
+        So we have correct scaled pixels but the resolutionScale is 1. So we get
+        enlarged incorrect image.
+
+        The fix is to revert r293825 and fix the iOS snapshot without having to
+        change snapshotFrameRectWithClip().
+
+        * page/FrameSnapshotting.cpp:
+        (WebCore::snapshotFrameRectWithClip):
+
 2022-05-07  Yusuke Suzuki  <[email protected]>
 
         Introduce EventTrackingRegions::Event enum

Modified: trunk/Source/WebCore/page/FrameSnapshotting.cpp (293967 => 293968)


--- trunk/Source/WebCore/page/FrameSnapshotting.cpp	2022-05-09 06:14:33 UTC (rev 293967)
+++ trunk/Source/WebCore/page/FrameSnapshotting.cpp	2022-05-09 06:28:36 UTC (rev 293968)
@@ -115,23 +115,19 @@
     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(scaledImageRect.size(), purpose, 1, options.colorSpace, options.pixelFormat, { }, { hostWindow });
+    auto buffer = ImageBuffer::create(imageRect.size(), purpose, scaleFactor, options.colorSpace, options.pixelFormat, { }, { hostWindow });
     if (!buffer)
         return nullptr;
 
-    buffer->context().translate(-scaledImageRect.location());
-    buffer->context().scale(scaleFactor);
+    buffer->context().translate(-imageRect.location());
 
     if (!clipRects.isEmpty()) {
         Path clipPath;
         for (auto& rect : clipRects)
-            clipPath.addRect(rect);
+            clipPath.addRect(encloseRectToDevicePixels(rect, scaleFactor));
         buffer->context().clipPath(clipPath);
     }
 

Modified: trunk/Source/WebKit/ChangeLog (293967 => 293968)


--- trunk/Source/WebKit/ChangeLog	2022-05-09 06:14:33 UTC (rev 293967)
+++ trunk/Source/WebKit/ChangeLog	2022-05-09 06:28:36 UTC (rev 293968)
@@ -1,3 +1,23 @@
+2022-05-08  Said Abou-Hallawa  <[email protected]>
+
+        [macOS] REGRESSION (r293825): Find highlight snapshots are incorrectly scaled
+        https://bugs.webkit.org/show_bug.cgi?id=240203
+        rdar://92892014
+
+        Reviewed by Tim Horton.
+
+        In getShareableBitmapForImageBufferWithQualifiedIdentifier(), we used to
+        pass the backendSize as the srcRect and the backendSize as the destRect 
+        to GraphicsContext::drawImageBuffer(). The backendSize is the logicalSize
+        scaled by the resolutionScale. But in ImageBufferCGBackend::draw() we
+        scale the srcRect by the resolutionScale one more time. This double-
+        scaled srcRect draws a srcRect whose size = backendSize * resolutionScale
+        to a destRect whose size = backendSize. And this results in shrinking the 
+        desired snapshot image by 1 / resolutionScale.
+
+        * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+        (WebKit::RemoteRenderingBackend::getShareableBitmapForImageBufferWithQualifiedIdentifier):
+
 2022-05-07  Yusuke Suzuki  <[email protected]>
 
         Introduce EventTrackingRegions::Event enum

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (293967 => 293968)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2022-05-09 06:14:33 UTC (rev 293967)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2022-05-09 06:28:36 UTC (rev 293968)
@@ -292,6 +292,7 @@
         if (!imageBuffer)
             return;
         auto backendSize = imageBuffer->backendSize();
+        auto logicalSize = imageBuffer->logicalSize();
         auto resultSize = preserveResolution == PreserveResolution::Yes ? backendSize : imageBuffer->truncatedLogicalSize();
         auto bitmap = ShareableBitmap::create(resultSize, { imageBuffer->colorSpace() });
         if (!bitmap)
@@ -299,7 +300,7 @@
         auto context = bitmap->createGraphicsContext();
         if (!context)
             return;
-        context->drawImageBuffer(*imageBuffer, FloatRect { { }, resultSize }, FloatRect { { }, backendSize }, { CompositeOperator::Copy });
+        context->drawImageBuffer(*imageBuffer, FloatRect { { }, resultSize }, FloatRect { { }, logicalSize }, { CompositeOperator::Copy });
         bitmap->createHandle(handle);
     }();
     completionHandler(WTFMove(handle));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to