Title: [183083] trunk/Source
Revision
183083
Author
[email protected]
Date
2015-04-21 16:25:00 -0700 (Tue, 21 Apr 2015)

Log Message

Long pause under _takeViewSnapshot when screen updates are disabled
https://bugs.webkit.org/show_bug.cgi?id=144017
<rdar://problem/20548397>

Reviewed by Simon Fraser.

* UIProcess/API/mac/WKView.mm:
(-[WKView _takeViewSnapshot]):
Use CGSHWCaptureWindowList, for snapshotting that doesn't block on
the next commit, and can succeed while screen updates are disabled
without blocking.

* platform/spi/cg/CoreGraphicsSPI.h:
Add some SPI.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (183082 => 183083)


--- trunk/Source/WebCore/ChangeLog	2015-04-21 23:23:55 UTC (rev 183082)
+++ trunk/Source/WebCore/ChangeLog	2015-04-21 23:25:00 UTC (rev 183083)
@@ -1,3 +1,14 @@
+2015-04-21  Tim Horton  <[email protected]>
+
+        Long pause under _takeViewSnapshot when screen updates are disabled
+        https://bugs.webkit.org/show_bug.cgi?id=144017
+        <rdar://problem/20548397>
+
+        Reviewed by Simon Fraser.
+
+        * platform/spi/cg/CoreGraphicsSPI.h:
+        Add some SPI.
+
 2015-04-21  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r183077.

Modified: trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h (183082 => 183083)


--- trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h	2015-04-21 23:23:55 UTC (rev 183082)
+++ trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h	2015-04-21 23:25:00 UTC (rev 183083)
@@ -113,6 +113,17 @@
 
 typedef struct CGFontCache CGFontCache;
 
+typedef uint32_t CGSConnectionID;
+typedef uint32_t CGSWindowID;
+typedef uint32_t CGSWindowCount;
+typedef CGSWindowID *CGSWindowIDList;
+
+enum {
+    kCGSWindowCaptureNominalResolution = 0x0200,
+    kCGSCaptureIgnoreGlobalClipShape = 0x0800,
+};
+typedef uint32_t CGSWindowCaptureOptions;
+
 #endif // USE(APPLE_INTERNAL_SDK)
 
 WTF_EXTERN_C_BEGIN
@@ -162,6 +173,9 @@
 void CGFontCacheSetMaxSize(CGFontCache*, size_t);
 #endif
 
+CGSConnectionID CGSMainConnectionID(void);
+CFArrayRef CGSHWCaptureWindowList(CGSConnectionID cid, CGSWindowIDList windowList, CGSWindowCount windowCount, CGSWindowCaptureOptions options);
+
 WTF_EXTERN_C_END
 
 #endif // CoreGraphicsSPI_h

Modified: trunk/Source/WebKit2/ChangeLog (183082 => 183083)


--- trunk/Source/WebKit2/ChangeLog	2015-04-21 23:23:55 UTC (rev 183082)
+++ trunk/Source/WebKit2/ChangeLog	2015-04-21 23:25:00 UTC (rev 183083)
@@ -1,3 +1,17 @@
+2015-04-21  Tim Horton  <[email protected]>
+
+        Long pause under _takeViewSnapshot when screen updates are disabled
+        https://bugs.webkit.org/show_bug.cgi?id=144017
+        <rdar://problem/20548397>
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _takeViewSnapshot]):
+        Use CGSHWCaptureWindowList, for snapshotting that doesn't block on
+        the next commit, and can succeed while screen updates are disabled
+        without blocking.
+
 2015-04-21  Chris Dumez  <[email protected]>
 
         [WK2][NetworkCache] Better account of resource revalidations in efficacy logging

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (183082 => 183083)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2015-04-21 23:23:55 UTC (rev 183082)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2015-04-21 23:25:00 UTC (rev 183083)
@@ -3370,12 +3370,22 @@
     if (!windowID || ![window isVisible])
         return nullptr;
 
-    RetainPtr<CGImageRef> windowSnapshotImage = adoptCF(CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque));
+    CGSWindowCaptureOptions options = kCGSCaptureIgnoreGlobalClipShape;
+    RetainPtr<CFArrayRef> windowSnapshotImages = adoptCF(CGSHWCaptureWindowList(CGSMainConnectionID(), &windowID, 1, options));
+    if (!CFArrayGetCount(windowSnapshotImages.get()))
+        return nullptr;
 
+    RetainPtr<CGImageRef> windowSnapshotImage = (CGImageRef)CFArrayGetValueAtIndex(windowSnapshotImages.get(), 0);
+
     // 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));
+    if (CGImageGetWidth(windowSnapshotImage.get()) != desiredSnapshotWidth) {
+        options |= kCGSWindowCaptureNominalResolution;
+        windowSnapshotImages = adoptCF(CGSHWCaptureWindowList(CGSMainConnectionID(), &windowID, 1, options));
+        if (!CFArrayGetCount(windowSnapshotImages.get()))
+            return nullptr;
+        windowSnapshotImage = (CGImageRef)CFArrayGetValueAtIndex(windowSnapshotImages.get(), 0);
+    }
 
     [self _ensureGestureController];
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to