Changeset 247466 in webkit


Ignore:
Timestamp:
Jul 15, 2019 7:32:43 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

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

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r247461 r247466  
     12019-07-15  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        [ Mojave WK1 ] Some Image tests are flakey failures and are failing in tandem with zoomed in or blank image results
     4        https://bugs.webkit.org/show_bug.cgi?id=193108
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add a workaround for <rdar://problem/17084993> in createBitmapContextFromWebView().
     9        Re-request the snapshot at kCGWindowImageNominalResolution if it was captured
     10        at the wrong scale.
     11
     12        * DumpRenderTree/mac/PixelDumpSupportMac.mm:
     13        (takeWindowSnapshot):
     14        (createBitmapContextFromWebView):
     15
    1162019-07-15  Brady Eidson  <beidson@apple.com>
    217
  • trunk/Tools/DumpRenderTree/mac/PixelDumpSupportMac.mm

    r234115 r247466  
    3737#import <CoreGraphics/CGBitmapContext.h>
    3838#import <QuartzCore/QuartzCore.h>
     39#import <pal/spi/cg/CoreGraphicsSPI.h>
    3940#import <wtf/Assertions.h>
    4041#import <wtf/RefPtr.h>
     
    8182    CGContextEndTransparencyLayer(context);
    8283    CGContextRestoreGState(context);
     84}
     85
     86static CGImageRef takeWindowSnapshot(CGSWindowID windowID, CGWindowImageOption imageOptions)
     87{
     88    imageOptions |= kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque;
     89    return CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, imageOptions);
    8390}
    8491
     
    129136            // Ask the window server to provide us a composited version of the *real* window content including surfaces (i.e. OpenGL content)
    130137            // Note that the returned image might differ very slightly from the window backing because of dithering artifacts in the window server compositor.
    131             CGImageRef image = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, [[view window] windowNumber], kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque);
     138            NSWindow *window = [view window];
     139            CGImageRef image = takeWindowSnapshot([window windowNumber], kCGWindowImageDefault);
     140
     141            if (image) {
     142                // Work around <rdar://problem/17084993>; re-request the snapshot at kCGWindowImageNominalResolution if it was captured at the wrong scale.
     143                CGFloat desiredSnapshotWidth = window.frame.size.width * deviceScaleFactor;
     144                if (CGImageGetWidth(image) != desiredSnapshotWidth)
     145                    image = takeWindowSnapshot([window windowNumber], kCGWindowImageNominalResolution);
     146            }
     147
     148            if (!image)
     149                return nullptr;
     150
    132151            CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image)), image);
    133152            CGImageRelease(image);
Note: See TracChangeset for help on using the changeset viewer.