Subpixel fringes around TextIndicator snapshots at non-integral scale factors
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jul 2019 00:40:26 +0000 (00:40 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jul 2019 00:40:26 +0000 (00:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200145

Reviewed by Simon Fraser.

* page/FrameSnapshotting.cpp:
(WebCore::snapshotFrameRectWithClip):
* page/FrameSnapshotting.h:
* page/TextIndicator.cpp:
(WebCore::snapshotOptionsForTextIndicatorOptions):
Round the scale factor up, and snappily enclose the clip rects.

TextIndicator doesn't require the use of the precise scale factor that
the page is painted at, but we want it to be sharp, so we overshoot!

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247846 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/FrameSnapshotting.cpp
Source/WebCore/page/FrameSnapshotting.h
Source/WebCore/page/TextIndicator.cpp

index 18829fe..b441b5a 100644 (file)
@@ -1,3 +1,20 @@
+2019-07-25  Tim Horton  <timothy_horton@apple.com>
+
+        Subpixel fringes around TextIndicator snapshots at non-integral scale factors
+        https://bugs.webkit.org/show_bug.cgi?id=200145
+
+        Reviewed by Simon Fraser.
+
+        * page/FrameSnapshotting.cpp:
+        (WebCore::snapshotFrameRectWithClip):
+        * page/FrameSnapshotting.h:
+        * page/TextIndicator.cpp:
+        (WebCore::snapshotOptionsForTextIndicatorOptions):
+        Round the scale factor up, and snappily enclose the clip rects.
+
+        TextIndicator doesn't require the use of the precise scale factor that
+        the page is painted at, but we want it to be sharp, so we overshoot!
+
 2019-07-25  Brent Fulgham  <bfulgham@apple.com>
 
         Use IWICBitmap (rather than ID2D1Bitmap) for NativeImagePtr on FTW
index 787bd48..e27c41a 100644 (file)
@@ -108,6 +108,9 @@ std::unique_ptr<ImageBuffer> snapshotFrameRectWithClip(Frame& frame, const IntRe
     if (frame.settings().delegatesPageScaling())
         scaleFactor *= frame.page()->pageScaleFactor();
 
+    if (options & SnapshotOptionsPaintWithIntegralScaleFactor)
+        scaleFactor = ceilf(scaleFactor);
+
     std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(imageRect.size(), Unaccelerated, scaleFactor);
     if (!buffer)
         return nullptr;
@@ -116,7 +119,7 @@ std::unique_ptr<ImageBuffer> snapshotFrameRectWithClip(Frame& frame, const IntRe
     if (!clipRects.isEmpty()) {
         Path clipPath;
         for (auto& rect : clipRects)
-            clipPath.addRect(rect);
+            clipPath.addRect(encloseRectToDevicePixels(rect, scaleFactor));
         buffer->context().clipPath(clipPath);
     }
 
index bdbc7ea..3603bcb 100644 (file)
@@ -47,7 +47,8 @@ enum {
     SnapshotOptionsInViewCoordinates = 1 << 2,
     SnapshotOptionsForceBlackText = 1 << 3,
     SnapshotOptionsPaintSelectionAndBackgroundsOnly = 1 << 4,
-    SnapshotOptionsPaintEverythingExcludingSelection = 1 << 5
+    SnapshotOptionsPaintEverythingExcludingSelection = 1 << 5,
+    SnapshotOptionsPaintWithIntegralScaleFactor = 1 << 6,
 };
 typedef unsigned SnapshotOptions;
 
index 4608d55..7e0503e 100644 (file)
@@ -132,7 +132,7 @@ static bool hasNonInlineOrReplacedElements(const Range& range)
 
 static SnapshotOptions snapshotOptionsForTextIndicatorOptions(TextIndicatorOptions options)
 {
-    SnapshotOptions snapshotOptions = SnapshotOptionsNone;
+    SnapshotOptions snapshotOptions = SnapshotOptionsPaintWithIntegralScaleFactor;
 
     if (!(options & TextIndicatorOptionPaintAllContent)) {
         if (options & TextIndicatorOptionPaintBackgrounds)