Title: [247586] branches/safari-608-branch/Tools
Revision
247586
Author
kocsen_ch...@apple.com
Date
2019-07-18 13:23:29 -0700 (Thu, 18 Jul 2019)

Log Message

Cherry-pick r247466. rdar://problem/53228860

    [ Mojave WK1 ] Some Image tests are flakey failures and are failing in tandem with zoomed in or blank image results
    https://bugs.webkit.org/show_bug.cgi?id=193108

    Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2019-07-15
    Reviewed by Simon Fraser.

    Add a workaround for <rdar://problem/17084993> in createBitmapContextFromWebView().
    Re-request the snapshot at kCGWindowImageNominalResolution if it was captured
    at the wrong scale.

    * DumpRenderTree/mac/PixelDumpSupportMac.mm:
    (takeWindowSnapshot):
    (createBitmapContextFromWebView):

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

Modified Paths

Diff

Modified: branches/safari-608-branch/Tools/ChangeLog (247585 => 247586)


--- branches/safari-608-branch/Tools/ChangeLog	2019-07-18 20:23:27 UTC (rev 247585)
+++ branches/safari-608-branch/Tools/ChangeLog	2019-07-18 20:23:29 UTC (rev 247586)
@@ -1,5 +1,40 @@
 2019-07-17  Kocsen Chung  <kocsen_ch...@apple.com>
 
+        Cherry-pick r247466. rdar://problem/53228860
+
+    [ Mojave WK1 ] Some Image tests are flakey failures and are failing in tandem with zoomed in or blank image results
+    https://bugs.webkit.org/show_bug.cgi?id=193108
+    
+    Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2019-07-15
+    Reviewed by Simon Fraser.
+    
+    Add a workaround for <rdar://problem/17084993> in createBitmapContextFromWebView().
+    Re-request the snapshot at kCGWindowImageNominalResolution if it was captured
+    at the wrong scale.
+    
+    * DumpRenderTree/mac/PixelDumpSupportMac.mm:
+    (takeWindowSnapshot):
+    (createBitmapContextFromWebView):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247466 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-07-15  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+            [ Mojave WK1 ] Some Image tests are flakey failures and are failing in tandem with zoomed in or blank image results
+            https://bugs.webkit.org/show_bug.cgi?id=193108
+
+            Reviewed by Simon Fraser.
+
+            Add a workaround for <rdar://problem/17084993> in createBitmapContextFromWebView().
+            Re-request the snapshot at kCGWindowImageNominalResolution if it was captured
+            at the wrong scale.
+
+            * DumpRenderTree/mac/PixelDumpSupportMac.mm:
+            (takeWindowSnapshot):
+            (createBitmapContextFromWebView):
+
+2019-07-17  Kocsen Chung  <kocsen_ch...@apple.com>
+
         Cherry-pick r247461. rdar://problem/53229637
 
     Make WKURLSchemeTask thread safe.

Modified: branches/safari-608-branch/Tools/DumpRenderTree/mac/PixelDumpSupportMac.mm (247585 => 247586)


--- branches/safari-608-branch/Tools/DumpRenderTree/mac/PixelDumpSupportMac.mm	2019-07-18 20:23:27 UTC (rev 247585)
+++ branches/safari-608-branch/Tools/DumpRenderTree/mac/PixelDumpSupportMac.mm	2019-07-18 20:23:29 UTC (rev 247586)
@@ -36,6 +36,7 @@
 #import "TestRunner.h"
 #import <CoreGraphics/CGBitmapContext.h>
 #import <QuartzCore/QuartzCore.h>
+#import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <wtf/Assertions.h>
 #import <wtf/RefPtr.h>
 
@@ -82,6 +83,12 @@
     CGContextRestoreGState(context);
 }
 
+static CGImageRef takeWindowSnapshot(CGSWindowID windowID, CGWindowImageOption imageOptions)
+{
+    imageOptions |= kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque;
+    return CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, imageOptions);
+}
+
 RefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect)
 {
     WebView* view = [mainFrame webView];
@@ -128,7 +135,19 @@
 
             // Ask the window server to provide us a composited version of the *real* window content including surfaces (i.e. OpenGL content)
             // Note that the returned image might differ very slightly from the window backing because of dithering artifacts in the window server compositor.
-            CGImageRef image = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, [[view window] windowNumber], kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque);
+            NSWindow *window = [view window];
+            CGImageRef image = takeWindowSnapshot([window windowNumber], kCGWindowImageDefault);
+
+            if (image) {
+                // Work around <rdar://problem/17084993>; re-request the snapshot at kCGWindowImageNominalResolution if it was captured at the wrong scale.
+                CGFloat desiredSnapshotWidth = window.frame.size.width * deviceScaleFactor;
+                if (CGImageGetWidth(image) != desiredSnapshotWidth)
+                    image = takeWindowSnapshot([window windowNumber], kCGWindowImageNominalResolution);
+            }
+
+            if (!image)
+                return nullptr;
+
             CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image)), image);
             CGImageRelease(image);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to