Title: [202404] trunk
Revision
202404
Author
[email protected]
Date
2016-06-23 17:08:00 -0700 (Thu, 23 Jun 2016)

Log Message

[iOS] Make DumpRenderTree and WebKitTestRunner in the simulator use render server snapshotting
https://bugs.webkit.org/show_bug.cgi?id=159077

Reviewed by Tim Horton.

Source/WebCore:

Add CARenderServer SPIs.

Test: fast/harness/snapshot-captures-compositing.html

* platform/spi/cocoa/QuartzCoreSPI.h:

Tools:

Fix both DRT and WTR for iOS to use CARenderServerRenderLayerWithTransform() on the view's layer.
This allows them to capture compositing layers in snapshots, rather than doing a software paint,
thus enabling testing of more things.

* DumpRenderTree/cg/PixelDumpSupportCG.cpp:
(createBitmapContext): Moved to this file to share it.
* DumpRenderTree/cg/PixelDumpSupportCG.h:
* DumpRenderTree/ios/PixelDumpSupportIOS.mm:
(createBitmapContextFromWebView):
(BitmapContext::createFromUIImage): Deleted.
(BitmapContext::pixelData): Deleted.
(BitmapContext::BitmapContext): Deleted.
(computeMD5HashStringForBitmapContext): Deleted.
(dumpBitmap): Deleted.
* DumpRenderTree/mac/Configurations/DumpRenderTreeLibrary.xcconfig: Don't exclude PixelDumpSupportCG.cpp.
* DumpRenderTree/mac/PixelDumpSupportMac.mm:
(createPagedBitmapContext):
(createBitmapContext): Deleted.
* WebKitTestRunner/Configurations/WebKitTestRunnerApp.xcconfig: link with QuartzCore.
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::dump): Deleted.
* WebKitTestRunner/ios/PlatformWebViewIOS.mm:
(WTR::PlatformWebView::windowSnapshotImage):

LayoutTests:

Test that fails if snapshotting doesn't correctly snapshot 3D transforms.

* fast/harness/snapshot-captures-compositing-expected.html: Added.
* fast/harness/snapshot-captures-compositing.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202403 => 202404)


--- trunk/LayoutTests/ChangeLog	2016-06-24 00:00:28 UTC (rev 202403)
+++ trunk/LayoutTests/ChangeLog	2016-06-24 00:08:00 UTC (rev 202404)
@@ -1,3 +1,15 @@
+2016-06-23  Simon Fraser  <[email protected]>
+
+        [iOS] Make DumpRenderTree and WebKitTestRunner in the simulator use render server snapshotting
+        https://bugs.webkit.org/show_bug.cgi?id=159077
+
+        Reviewed by Tim Horton.
+
+        Test that fails if snapshotting doesn't correctly snapshot 3D transforms.
+
+        * fast/harness/snapshot-captures-compositing-expected.html: Added.
+        * fast/harness/snapshot-captures-compositing.html: Added.
+
 2016-06-23  Said Abou-Hallawa  <[email protected]>
 
         requestFrameAnimation() callback timestamp should be very close to Performance.now() 

Added: trunk/LayoutTests/fast/harness/snapshot-captures-compositing-expected.html (0 => 202404)


--- trunk/LayoutTests/fast/harness/snapshot-captures-compositing-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/harness/snapshot-captures-compositing-expected.html	2016-06-24 00:08:00 UTC (rev 202404)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        .container {
+            position: absolute;
+            top: 200px;
+            left: 100px;
+        }
+        .box {
+            position: relative;
+            left: 110px;
+            height: 400px;
+            width: 300px;
+            background-color: green;
+            transform: translateZ(0);
+        }
+        .clipper {
+            position: absolute;
+            top: 30px;
+            left: 200px;
+            height: 270px;
+            width: 220px;
+            border: 50px solid gray;
+            border-top-width: 230px;
+            border-bottom-width: 260px;
+        }
+    </style>
+</head>
+<body>
+    <div class="container">
+        <div class="box"></div>
+    </div>
+    <div class="clipper"></div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/harness/snapshot-captures-compositing.html (0 => 202404)


--- trunk/LayoutTests/fast/harness/snapshot-captures-compositing.html	                        (rev 0)
+++ trunk/LayoutTests/fast/harness/snapshot-captures-compositing.html	2016-06-24 00:08:00 UTC (rev 202404)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        .container {
+            position: absolute;
+            top: 200px;
+            left: 100px;
+            perspective: 400px;
+        }
+        .box {
+            height: 400px;
+            width: 400px;
+            background-color: green;
+            transform: rotateY(120deg);
+        }
+        .clipper {
+            position: absolute;
+            top: 30px;
+            left: 200px;
+            height: 270px;
+            width: 220px;
+            border: 50px solid gray;
+            border-top-width: 230px;
+            border-bottom-width: 260px;
+        }
+    </style>
+</head>
+<body>
+    <div class="container">
+        <div class="box"></div>
+    </div>
+    <div class="clipper"></div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (202403 => 202404)


--- trunk/Source/WebCore/ChangeLog	2016-06-24 00:00:28 UTC (rev 202403)
+++ trunk/Source/WebCore/ChangeLog	2016-06-24 00:08:00 UTC (rev 202404)
@@ -1,3 +1,16 @@
+2016-06-23  Simon Fraser  <[email protected]>
+
+        [iOS] Make DumpRenderTree and WebKitTestRunner in the simulator use render server snapshotting
+        https://bugs.webkit.org/show_bug.cgi?id=159077
+
+        Reviewed by Tim Horton.
+
+        Add CARenderServer SPIs.
+
+        Test: fast/harness/snapshot-captures-compositing.html
+
+        * platform/spi/cocoa/QuartzCoreSPI.h:
+
 2016-06-23  Brian Burg  <[email protected]>
 
         Web Inspector: add assertions to catch dangling frontends that persist between tests

Modified: trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h (202403 => 202404)


--- trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h	2016-06-24 00:00:28 UTC (rev 202403)
+++ trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h	2016-06-24 00:08:00 UTC (rev 202404)
@@ -172,6 +172,15 @@
 #if !USE(APPLE_INTERNAL_SDK)
 EXTERN_C void CARenderServerCaptureLayerWithTransform(mach_port_t serverPort, uint32_t clientId, uint64_t layerId,
                                                       uint32_t slotId, int32_t ox, int32_t oy, const CATransform3D *);
+
+EXTERN_C CARenderServerBufferRef CARenderServerCreateBuffer(size_t, size_t);
+EXTERN_C void CARenderServerDestroyBuffer(CARenderServerBufferRef);
+EXTERN_C size_t CARenderServerGetBufferWidth(CARenderServerBufferRef);
+EXTERN_C size_t CARenderServerGetBufferHeight(CARenderServerBufferRef);
+EXTERN_C size_t CARenderServerGetBufferRowBytes(CARenderServerBufferRef);
+EXTERN_C uint8_t* CARenderServerGetBufferData(CARenderServerBufferRef);
+EXTERN_C size_t CARenderServerGetBufferDataSize(CARenderServerBufferRef);
+
 #if USE(IOSURFACE)
 EXTERN_C void CARenderServerRenderLayerWithTransform(mach_port_t server_port, uint32_t client_id, uint64_t layer_id, IOSurfaceRef iosurface, int32_t ox, int32_t oy, const CATransform3D *matrix);
 EXTERN_C void CARenderServerRenderDisplayLayerWithTransformAndTimeOffset(mach_port_t server_port, CFStringRef display_name, uint32_t client_id, uint64_t layer_id, IOSurfaceRef iosurface, int32_t ox, int32_t oy, const CATransform3D *matrix, CFTimeInterval offset);

Modified: trunk/Tools/ChangeLog (202403 => 202404)


--- trunk/Tools/ChangeLog	2016-06-24 00:00:28 UTC (rev 202403)
+++ trunk/Tools/ChangeLog	2016-06-24 00:08:00 UTC (rev 202404)
@@ -1,3 +1,34 @@
+2016-06-23  Simon Fraser  <[email protected]>
+
+        [iOS] Make DumpRenderTree and WebKitTestRunner in the simulator use render server snapshotting
+        https://bugs.webkit.org/show_bug.cgi?id=159077
+
+        Reviewed by Tim Horton.
+
+        Fix both DRT and WTR for iOS to use CARenderServerRenderLayerWithTransform() on the view's layer.
+        This allows them to capture compositing layers in snapshots, rather than doing a software paint,
+        thus enabling testing of more things.
+
+        * DumpRenderTree/cg/PixelDumpSupportCG.cpp:
+        (createBitmapContext): Moved to this file to share it.
+        * DumpRenderTree/cg/PixelDumpSupportCG.h:
+        * DumpRenderTree/ios/PixelDumpSupportIOS.mm:
+        (createBitmapContextFromWebView):
+        (BitmapContext::createFromUIImage): Deleted.
+        (BitmapContext::pixelData): Deleted.
+        (BitmapContext::BitmapContext): Deleted.
+        (computeMD5HashStringForBitmapContext): Deleted.
+        (dumpBitmap): Deleted.
+        * DumpRenderTree/mac/Configurations/DumpRenderTreeLibrary.xcconfig: Don't exclude PixelDumpSupportCG.cpp.
+        * DumpRenderTree/mac/PixelDumpSupportMac.mm:
+        (createPagedBitmapContext):
+        (createBitmapContext): Deleted.
+        * WebKitTestRunner/Configurations/WebKitTestRunnerApp.xcconfig: link with QuartzCore.
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::dump): Deleted.
+        * WebKitTestRunner/ios/PlatformWebViewIOS.mm:
+        (WTR::PlatformWebView::windowSnapshotImage):
+
 2016-06-23  Konstantin Tokarev  <[email protected]>
 
         [jhbuild] Added libxslt module.

Modified: trunk/Tools/DumpRenderTree/cg/PixelDumpSupportCG.cpp (202403 => 202404)


--- trunk/Tools/DumpRenderTree/cg/PixelDumpSupportCG.cpp	2016-06-24 00:00:28 UTC (rev 202403)
+++ trunk/Tools/DumpRenderTree/cg/PixelDumpSupportCG.cpp	2016-06-24 00:08:00 UTC (rev 202404)
@@ -115,3 +115,27 @@
     RetainPtr<CGImageRef> image = adoptCF(CGBitmapContextCreateImage(context->cgContext()));
     printPNG(image.get(), checksum);
 }
+
+PassRefPtr<BitmapContext> createBitmapContext(size_t pixelsWide, size_t pixelsHigh, size_t& rowBytes, void*& buffer)
+{
+    rowBytes = (4 * pixelsWide + 63) & ~63; // Use a multiple of 64 bytes to improve CG performance
+
+    buffer = calloc(pixelsHigh, rowBytes);
+    if (!buffer) {
+        WTFLogAlways("DumpRenderTree: calloc(%zu, %zu) failed\n", pixelsHigh, rowBytes);
+        return nullptr;
+    }
+    
+    // Creating this bitmap in the device color space prevents any color conversion when the image of the web view is drawn into it.
+    RetainPtr<CGColorSpaceRef> colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
+    CGContextRef context = CGBitmapContextCreate(buffer, pixelsWide, pixelsHigh, 8, rowBytes, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
+    if (!context) {
+        WTFLogAlways("DumpRenderTree: CGBitmapContextCreate(%p, %zu, %zu, 8, %zu, %p, 0x%x) failed\n", buffer, pixelsHigh, pixelsWide, rowBytes, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
+        free(buffer);
+        buffer = nullptr;
+        return nullptr;
+    }
+
+    return BitmapContext::createByAdoptingBitmapAndContext(buffer, context);
+}
+

Modified: trunk/Tools/DumpRenderTree/cg/PixelDumpSupportCG.h (202403 => 202404)


--- trunk/Tools/DumpRenderTree/cg/PixelDumpSupportCG.h	2016-06-24 00:00:28 UTC (rev 202403)
+++ trunk/Tools/DumpRenderTree/cg/PixelDumpSupportCG.h	2016-06-24 00:08:00 UTC (rev 202404)
@@ -79,6 +79,7 @@
 
 };
 
+PassRefPtr<BitmapContext> createBitmapContext(size_t pixelsWide, size_t pixelsHigh, size_t& rowBytes, void*& buffer);
 PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect);
 
 #endif // PixelDumpSupportCG_h

Modified: trunk/Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm (202403 => 202404)


--- trunk/Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm	2016-06-24 00:00:28 UTC (rev 202403)
+++ trunk/Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm	2016-06-24 00:08:00 UTC (rev 202404)
@@ -31,6 +31,7 @@
 
 #import "DumpRenderTree.h"
 #import "DumpRenderTreeWindow.h"
+#import "PixelDumpSupportCG.h"
 #import "UIKitSPI.h"
 
 #define COMMON_DIGEST_FOR_OPENSSL
@@ -37,7 +38,9 @@
 #import <CommonCrypto/CommonDigest.h>
 #import <MobileCoreServices/UTCoreTypes.h>
 #import <QuartzCore/QuartzCore.h>
+#import <WebCore/QuartzCoreSPI.h>
 #import <WebKit/WebCoreThread.h>
+#import <wtf/BlockObjCExceptions.h>
 #import <wtf/RefCounted.h>
 #import <wtf/RefPtr.h>
 #import <wtf/RetainPtr.h>
@@ -45,49 +48,49 @@
 extern DumpRenderTreeWindow *gDrtWindow;
 extern UIWebBrowserView *gWebBrowserView;
 
-class BitmapContext : public RefCounted<BitmapContext> {
-public:
-    static PassRefPtr<BitmapContext> createFromUIImage(UIImage *image)
-    {
-        return adoptRef(new BitmapContext(image));
-    }
+PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect)
+{
+    // TODO: <rdar://problem/6558366> DumpRenderTree: Investigate testRepaintSweepHorizontally and dumpSelectionRect
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    NSData *pixelData() const { return m_pixelData.get(); }
+    WebThreadLock();
+    [CATransaction flush];
 
-private:
-    BitmapContext(UIImage *image)
-        : m_pixelData(UIImagePNGRepresentation(image))
-    {
+    CGFloat deviceScaleFactor = 2; // FIXME: hardcode 2x for now. In future we could respect 1x and 3x as we do on Mac.
+    CATransform3D transform = CATransform3DMakeScale(deviceScaleFactor, deviceScaleFactor, 1);
+    
+    CGSize viewSize = [[mainFrame webView] frame].size;
+    int bufferWidth = ceil(viewSize.width * deviceScaleFactor);
+    int bufferHeight = ceil(viewSize.height * deviceScaleFactor);
+
+    CARenderServerBufferRef buffer = CARenderServerCreateBuffer(bufferWidth, bufferHeight);
+    if (!buffer) {
+        WTFLogAlways("CARenderServerCreateBuffer failed for buffer with width %d height %d\n", bufferWidth, bufferHeight);
+        return nullptr;
     }
 
-    RetainPtr<NSData> m_pixelData;
-};
+    CARenderServerRenderLayerWithTransform(MACH_PORT_NULL, [gWebBrowserView layer].context.contextId, reinterpret_cast<uint64_t>([gWebBrowserView layer]), buffer, 0, 0, &transform);
 
-void computeMD5HashStringForBitmapContext(BitmapContext* context, char hashString[33])
-{
-    unsigned char result[CC_MD5_DIGEST_LENGTH];
-    CC_MD5([context->pixelData() bytes], [context->pixelData() length], result);
-    hashString[0] = '\0';
-    for (int i = 0; i < 16; ++i)
-        snprintf(hashString, 33, "%s%02x", hashString, result[i]);
-}
+    uint8_t* data = ""
+    size_t rowBytes = CARenderServerGetBufferRowBytes(buffer);
 
-void dumpBitmap(BitmapContext* context, const char* checksum)
-{
-    printPNG(static_cast<const unsigned char*>([context->pixelData() bytes]), [context->pixelData() length], checksum);
-}
+    static CGColorSpaceRef sRGBSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
+    RetainPtr<CGDataProviderRef> provider = adoptCF(CGDataProviderCreateWithData(0, data, CARenderServerGetBufferDataSize(buffer), nullptr));
+    
+    RetainPtr<CGImageRef> cgImage = adoptCF(CGImageCreate(bufferWidth, bufferHeight, 8, 32, rowBytes, sRGBSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, provider.get(), 0, false, kCGRenderingIntentDefault));
 
-PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect)
-{
-    // TODO: <rdar://problem/6558366> DumpRenderTree: Investigate testRepaintSweepHorizontally and dumpSelectionRect
+    void* bitmapBuffer = nullptr;
+    size_t bitmapRowBytes = 0;
+    auto bitmapContext = createBitmapContext(bufferWidth, bufferHeight, bitmapRowBytes, bitmapBuffer);
+    if (!bitmapContext) {
+        CARenderServerDestroyBuffer(buffer);
+        return nullptr;
+    }
 
-    WebThreadLock();
-    [CATransaction flush];
+    CGContextDrawImage(bitmapContext->cgContext(), CGRectMake(0, 0, bufferWidth, bufferHeight), cgImage.get());
+    CARenderServerDestroyBuffer(buffer);
 
-    UIGraphicsBeginImageContextWithOptions([[mainFrame webView] frame].size, YES /* opaque */, [gDrtWindow screenScale]);
-    [[gWebBrowserView layer] renderInContext:UIGraphicsGetCurrentContext()];
-    RefPtr<BitmapContext> context = BitmapContext::createFromUIImage(UIGraphicsGetImageFromCurrentImageContext());
-    UIGraphicsEndImageContext();
+    return bitmapContext;
 
-    return context.release();
+    END_BLOCK_OBJC_EXCEPTIONS;
 }

Modified: trunk/Tools/DumpRenderTree/mac/Configurations/DumpRenderTreeLibrary.xcconfig (202403 => 202404)


--- trunk/Tools/DumpRenderTree/mac/Configurations/DumpRenderTreeLibrary.xcconfig	2016-06-24 00:00:28 UTC (rev 202403)
+++ trunk/Tools/DumpRenderTree/mac/Configurations/DumpRenderTreeLibrary.xcconfig	2016-06-24 00:08:00 UTC (rev 202404)
@@ -30,5 +30,5 @@
 
 OTHER_LDFLAGS = ;
 
-EXCLUDED_SOURCE_FILE_NAMES[sdk=iphone*] = AccessibilityControllerMac.mm AccessibilityUIElementMac.mm DumpRenderTreeFileDraggingSource.m PixelDumpSupportMac.mm PixelDumpSupportCG.cpp;
+EXCLUDED_SOURCE_FILE_NAMES[sdk=iphone*] = AccessibilityControllerMac.mm AccessibilityUIElementMac.mm DumpRenderTreeFileDraggingSource.m PixelDumpSupportMac.mm;
 EXCLUDED_SOURCE_FILE_NAMES[sdk=macosx*] = AccessibilityUIElementIOS.mm AccessibilityControllerIOS.mm PixelDumpSupportIOS.mm DumpRenderTreeBrowserView.mm;

Modified: trunk/Tools/DumpRenderTree/mac/PixelDumpSupportMac.mm (202403 => 202404)


--- trunk/Tools/DumpRenderTree/mac/PixelDumpSupportMac.mm	2016-06-24 00:00:28 UTC (rev 202403)
+++ trunk/Tools/DumpRenderTree/mac/PixelDumpSupportMac.mm	2016-06-24 00:08:00 UTC (rev 202404)
@@ -49,29 +49,6 @@
 + (void)synchronize;
 @end
 
-static PassRefPtr<BitmapContext> createBitmapContext(size_t pixelsWide, size_t pixelsHigh, size_t& rowBytes, void*& buffer)
-{
-    rowBytes = (4 * pixelsWide + 63) & ~63; // Use a multiple of 64 bytes to improve CG performance
-
-    buffer = calloc(pixelsHigh, rowBytes);
-    if (!buffer) {
-        WTFLogAlways("DumpRenderTree: calloc(%llu, %llu) failed\n", pixelsHigh, rowBytes);
-        return nullptr;
-    }
-    
-    // Creating this bitmap in the device color space prevents any color conversion when the image of the web view is drawn into it.
-    RetainPtr<CGColorSpaceRef> colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
-    CGContextRef context = CGBitmapContextCreate(buffer, pixelsWide, pixelsHigh, 8, rowBytes, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host); // Use ARGB8 on PPC or BGRA8 on X86 to improve CG performance
-    if (!context) {
-        WTFLogAlways("DumpRenderTree: CGBitmapContextCreate(%p, %llu, %llu, 8, %llu, %p, 0x%x) failed\n", buffer, pixelsHigh, pixelsWide, rowBytes, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
-        free(buffer);
-        buffer = nullptr;
-        return nullptr;
-    }
-
-    return BitmapContext::createByAdoptingBitmapAndContext(buffer, context);
-}
-
 static void paintRepaintRectOverlay(WebView* webView, CGContextRef context)
 {
     CGRect viewRect = NSRectToCGRect([webView bounds]);
@@ -203,7 +180,7 @@
     int pageHeightInPixels = TestRunner::viewHeight;
     int numberOfPages = [mainFrame numberOfPagesWithPageWidth:pageWidthInPixels pageHeight:pageHeightInPixels];
     size_t rowBytes = 0;
-    void* buffer = 0;
+    void* buffer = nullptr;
 
     int totalHeight = numberOfPages * (pageHeightInPixels + 1) - 1;
 

Modified: trunk/Tools/WebKitTestRunner/Configurations/WebKitTestRunnerApp.xcconfig (202403 => 202404)


--- trunk/Tools/WebKitTestRunner/Configurations/WebKitTestRunnerApp.xcconfig	2016-06-24 00:00:28 UTC (rev 202403)
+++ trunk/Tools/WebKitTestRunner/Configurations/WebKitTestRunnerApp.xcconfig	2016-06-24 00:08:00 UTC (rev 202404)
@@ -27,7 +27,7 @@
 
 PRODUCT_NAME = WebKitTestRunner;
 GCC_ENABLE_OBJC_EXCEPTIONS = YES;
-OTHER_LDFLAGS = $(inherited) -l$(WEBKIT_SYSTEM_INTERFACE_LIBRARY) -lWebKitTestRunner -framework _javascript_Core -framework CoreGraphics -framework ImageIO -framework IOKit -framework UIKit -framework WebKit -framework Foundation;
+OTHER_LDFLAGS = $(inherited) -l$(WEBKIT_SYSTEM_INTERFACE_LIBRARY) -lWebKitTestRunner -framework _javascript_Core -framework CoreGraphics -framework QuartzCore -framework ImageIO -framework IOKit -framework UIKit -framework WebKit -framework Foundation;
 SKIP_INSTALL[sdk=macosx*] = YES;
 EXCLUDED_SOURCE_FILE_NAMES[sdk=macosx*] = ios/* AppDelegate.m;
 EXCLUDED_SOURCE_FILE_NAMES[sdk=appletv*] = ios/Launch.storyboard;

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (202403 => 202404)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2016-06-24 00:00:28 UTC (rev 202403)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2016-06-24 00:08:00 UTC (rev 202404)
@@ -895,12 +895,7 @@
         injectedBundle.dumpBackForwardListsForAllPages(stringBuilder);
 
     if (injectedBundle.shouldDumpPixels() && injectedBundle.testRunner()->shouldDumpPixels()) {
-#if PLATFORM(IOS)
-        // IOS doesn't implement PlatformWebView::windowSnapshotImage() yet, so we need to generate the snapshot in the web process.
-        bool shouldCreateSnapshot = true;
-#else
         bool shouldCreateSnapshot = injectedBundle.testRunner()->isPrinting();
-#endif
         if (shouldCreateSnapshot) {
             WKSnapshotOptions options = kWKSnapshotOptionsShareable;
             WKRect snapshotRect = WKBundleFrameGetVisibleContentBounds(WKBundlePageGetMainFrame(m_page));

Modified: trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm (202403 => 202404)


--- trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm	2016-06-24 00:00:28 UTC (rev 202403)
+++ trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm	2016-06-24 00:08:00 UTC (rev 202404)
@@ -28,10 +28,12 @@
 
 #import "TestController.h"
 #import "TestRunnerWKWebView.h"
+#import <WebCore/QuartzCoreSPI.h>
 #import <WebKit/WKImageCG.h>
 #import <WebKit/WKPreferencesPrivate.h>
 #import <WebKit/WKWebViewConfiguration.h>
 #import <WebKit/WKWebViewPrivate.h>
+#import <wtf/BlockObjCExceptions.h>
 #import <wtf/RetainPtr.h>
 
 @interface WKWebView (Details)
@@ -94,12 +96,6 @@
 
 @end
 
-@interface UIWindow ()
-
-- (void)_setWindowResolution:(CGFloat)resolution displayIfChanged:(BOOL)displayIfChanged;
-
-@end
-
 namespace WTR {
 
 PlatformWebView::PlatformWebView(WKWebViewConfiguration* configuration, const TestOptions& options)
@@ -206,8 +202,36 @@
 
 WKRetainPtr<WKImageRef> PlatformWebView::windowSnapshotImage()
 {
-    // FIXME: Need an implementation of this, or we're depending on software paints!
-    return nullptr;
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
+    CGFloat deviceScaleFactor = 2; // FIXME: hardcode 2x for now. In future we could respect 1x and 3x as we do on Mac.
+    CATransform3D transform = CATransform3DMakeScale(deviceScaleFactor, deviceScaleFactor, 1);
+    
+    CGSize viewSize = m_view.bounds.size;
+    int bufferWidth = ceil(viewSize.width * deviceScaleFactor);
+    int bufferHeight = ceil(viewSize.height * deviceScaleFactor);
+
+    CARenderServerBufferRef buffer = CARenderServerCreateBuffer(bufferWidth, bufferHeight);
+    if (!buffer) {
+        WTFLogAlways("CARenderServerCreateBuffer failed for buffer with width %d height %d\n", bufferWidth, bufferHeight);
+        return nullptr;
+    }
+
+    CARenderServerRenderLayerWithTransform(MACH_PORT_NULL, m_view.layer.context.contextId, reinterpret_cast<uint64_t>(m_view.layer), buffer, 0, 0, &transform);
+
+    uint8_t* data = ""
+    size_t rowBytes = CARenderServerGetBufferRowBytes(buffer);
+
+    static CGColorSpaceRef sRGBSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
+    RetainPtr<CGDataProviderRef> provider = adoptCF(CGDataProviderCreateWithData(0, data, CARenderServerGetBufferDataSize(buffer), nullptr));
+    
+    RetainPtr<CGImageRef> cgImage = adoptCF(CGImageCreate(bufferWidth, bufferHeight, 8, 32, rowBytes, sRGBSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, provider.get(), 0, false, kCGRenderingIntentDefault));
+    WKRetainPtr<WKImageRef> result = adoptWK(WKImageCreateFromCGImage(cgImage.get(), 0));
+
+    CARenderServerDestroyBuffer(buffer);
+
+    return result;
+    END_BLOCK_OBJC_EXCEPTIONS;
 }
 
 bool PlatformWebView::viewSupportsOptions(const TestOptions& options) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to