+2014-05-31 Timothy Horton <timothy_horton@apple.com>
+
+ View snapshots are sometimes taken at the wrong scale
+ https://bugs.webkit.org/show_bug.cgi?id=133419
+ <rdar://problem/17087497>
+
+ Reviewed by Sam Weinig.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView _takeViewSnapshot]):
+ Work around <rdar://problem/17084993> by re-requesting the snapshot at
+ kCGWindowImageNominalResolution if it was captured at the wrong scale.
+
2014-05-31 Dan Bernstein <mitz@apple.com>
[iOS] WebKit2.framework is unused
#if defined(__has_include) && __has_include(<CoreGraphics/CoreGraphicsPrivate.h>)
#import <CoreGraphics/CoreGraphicsPrivate.h>
-#import <CoreGraphics/CGSCapture.h>
#endif
extern "C" {
typedef uint32_t CGSWindowID;
CGSConnectionID CGSMainConnectionID(void);
CGError CGSGetScreenRectForWindow(CGSConnectionID cid, CGSWindowID wid, CGRect *rect);
-CGError CGSCaptureWindowsContentsToRect(CGSConnectionID cid, const CGSWindowID windows[], uint32_t windowCount, CGRect rect, CGImageRef *outImage);
};
using namespace WebKit;
ViewSnapshot snapshot;
- if (![window windowNumber])
+ CGSWindowID windowID = (CGSWindowID)[window windowNumber];
+ if (!windowID)
return snapshot;
- // FIXME: This should use CGWindowListCreateImage once <rdar://problem/15709646> is resolved.
- CGSWindowID windowID = [window windowNumber];
- CGImageRef cgWindowImage = nullptr;
- CGSCaptureWindowsContentsToRect(CGSMainConnectionID(), &windowID, 1, CGRectNull, &cgWindowImage);
- RetainPtr<CGImageRef> windowSnapshotImage = adoptCF(cgWindowImage);
+ RetainPtr<CGImageRef> windowSnapshotImage = adoptCF(CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque));
+
+ // 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 * window.screen.backingScaleFactor;
+ if (CGImageGetWidth(windowSnapshotImage.get()) != desiredSnapshotWidth)
+ windowSnapshotImage = adoptCF(CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque | kCGWindowImageNominalResolution));
[self _ensureGestureController];