Noticeable delay taking an HTML5 trailer fullscreen.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 May 2012 06:33:40 +0000 (06:33 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 May 2012 06:33:40 +0000 (06:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=87794

Reviewed by Darin Adler.

Work around a not-entirely understood delay when using the results of a CGWindowListCreateImage()
call as the contents of a placeholder view.  The backing of the resulting CGImageRef resides on
the WindowServer, and drawing that image requires synchronous calls to the WindowServer process.
By copying the image data, up front, into our own process, we can avoid those synchronous calls
later and avoid the delay-causing drawing behavior.

* UIProcess/mac/WKFullScreenWindowController.mm:
(CGImageDeepCopy): Added a helper function which copies the image data into a new CGImage.
(-[WKFullScreenWindowController enterFullScreen:]): Use the above.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm

index 662b490..873a79e 100644 (file)
@@ -1,3 +1,20 @@
+2012-05-29  Jer Noble  <jer.noble@apple.com>
+
+        Noticeable delay taking an HTML5 trailer fullscreen.
+        https://bugs.webkit.org/show_bug.cgi?id=87794
+
+        Reviewed by Darin Adler.
+
+        Work around a not-entirely understood delay when using the results of a CGWindowListCreateImage()
+        call as the contents of a placeholder view.  The backing of the resulting CGImageRef resides on
+        the WindowServer, and drawing that image requires synchronous calls to the WindowServer process.
+        By copying the image data, up front, into our own process, we can avoid those synchronous calls
+        later and avoid the delay-causing drawing behavior.
+
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (CGImageDeepCopy): Added a helper function which copies the image data into a new CGImage.
+        (-[WKFullScreenWindowController enterFullScreen:]): Use the above.
+
 2012-05-29  Sudarsana Nagineni  <sudarsana.nagineni@linux.intel.com>
 
         [GTK] [WK2] Reproducible crash in performDragControllerAction
index 6491762..68e2cd3 100644 (file)
@@ -183,6 +183,28 @@ static const NSTimeInterval DefaultWatchdogTimerInterval = 1;
 #pragma mark -
 #pragma mark Exposed Interface
 
+static RetainPtr<CGDataProviderRef> createImageProviderWithCopiedData(CGDataProviderRef sourceProvider)
+{
+    RetainPtr<CFDataRef> data = adoptCF(CGDataProviderCopyData(sourceProvider));
+    return adoptCF(CGDataProviderCreateWithCFData(data.get()));
+}
+
+static RetainPtr<CGImageRef> createImageWithCopiedData(CGImageRef sourceImage)
+{
+    size_t width = CGImageGetWidth(sourceImage);
+    size_t height = CGImageGetHeight(sourceImage);
+    size_t bitsPerComponent = CGImageGetBitsPerComponent(sourceImage);
+    size_t bitsPerPixel = CGImageGetBitsPerPixel(sourceImage);
+    size_t bytesPerRow = CGImageGetBytesPerRow(sourceImage);
+    CGColorSpaceRef colorSpace = CGImageGetColorSpace(sourceImage);
+    CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(sourceImage);
+    RetainPtr<CGDataProviderRef> provider = createImageProviderWithCopiedData(CGImageGetDataProvider(sourceImage));
+    bool shouldInterpolate = CGImageGetShouldInterpolate(sourceImage);
+    CGColorRenderingIntent intent = CGImageGetRenderingIntent(sourceImage);
+
+    return adoptCF(CGImageCreate(width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpace, bitmapInfo, provider.get(), 0, shouldInterpolate, intent));
+}
+
 - (void)enterFullScreen:(NSScreen *)screen
 {
     if (_isFullScreen)
@@ -204,6 +226,11 @@ static const NSTimeInterval DefaultWatchdogTimerInterval = 1;
     CGWindowID windowID = [[_webView window] windowNumber];
     RetainPtr<CGImageRef> webViewContents(AdoptCF, CGWindowListCreateImage(NSRectToCGRect(webViewFrame), kCGWindowListOptionIncludingWindow, windowID, kCGWindowImageShouldBeOpaque));
 
+    // Using the returned CGImage directly would result in calls to the WindowServer every time
+    // the image was painted. Instead, copy the image data into our own process to eliminate that
+    // future overhead.
+    webViewContents = createImageWithCopiedData(webViewContents.get());
+
     // Screen updates to be re-enabled in beganEnterFullScreenWithInitialFrame:finalFrame:
     NSDisableScreenUpdates();
     [[self window] setAutodisplay:NO];