Changeset 216462 in webkit


Ignore:
Timestamp:
May 8, 2017 4:15:00 PM (7 years ago)
Author:
Jonathan Bedard
Message:

Implement PlatformWebView::windowSnapshotImage and createBitmapContextFromWebView for iOS devices
https://bugs.webkit.org/show_bug.cgi?id=169421
<rdar://problem/30950171>

Reviewed by Tim Horton.

Tools:

  • DumpRenderTree/ios/PixelDumpSupportIOS.mm:

(createBitmapContextFromWebView): Implement for IOSurface.

  • WebKitTestRunner/ios/PlatformWebViewIOS.mm:

(WTR::PlatformWebView::windowSnapshotImage): Use snapshot API for device.

LayoutTests:

  • platform/ios-device/TestExpectations: Mark compositing tests as failures, this

is due to a bug tracked in https://bugs.webkit.org/show_bug.cgi?id=170772.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r216458 r216462  
     12017-05-08  Jonathan Bedard  <jbedard@apple.com>
     2
     3        Implement PlatformWebView::windowSnapshotImage and createBitmapContextFromWebView for iOS devices
     4        https://bugs.webkit.org/show_bug.cgi?id=169421
     5        <rdar://problem/30950171>
     6
     7        Reviewed by Tim Horton.
     8
     9        * platform/ios-device/TestExpectations: Mark compositing tests as failures, this
     10        is due to a bug tracked in https://bugs.webkit.org/show_bug.cgi?id=170772.
     11
    1122017-05-08  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/LayoutTests/platform/ios-device/TestExpectations

    r214474 r216462  
    44#
    55
     6# https://bugs.webkit.org/show_bug.cgi?id=170772
     7compositing/geometry/clipped-out-perspective.html [ ImageOnlyFailure ]
     8compositing/hidpi-subpixel-transform-origin.html [ ImageOnlyFailure ]
     9compositing/regions/position-layer-inside-region-overflow-hidden.html [ ImageOnlyFailure ]
     10compositing/regions/position-layers-inside-region-overflow-hidden.html [ ImageOnlyFailure ]
     11compositing/regions/position-layers-inside-regions-overflow-hidden.html [ ImageOnlyFailure ]
     12
  • trunk/Tools/ChangeLog

    r216447 r216462  
     12017-05-08  Jonathan Bedard  <jbedard@apple.com>
     2
     3        Implement PlatformWebView::windowSnapshotImage and createBitmapContextFromWebView for iOS devices
     4        https://bugs.webkit.org/show_bug.cgi?id=169421
     5        <rdar://problem/30950171>
     6
     7        Reviewed by Tim Horton.
     8
     9        * DumpRenderTree/ios/PixelDumpSupportIOS.mm:
     10        (createBitmapContextFromWebView): Implement for IOSurface.
     11        * WebKitTestRunner/ios/PlatformWebViewIOS.mm:
     12        (WTR::PlatformWebView::windowSnapshotImage): Use snapshot API for device.
     13
    1142017-05-08  Jonathan Bedard  <jbedard@apple.com>
    215
  • trunk/Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm

    r208289 r216462  
    3939#import <MobileCoreServices/UTCoreTypes.h>
    4040#import <QuartzCore/QuartzCore.h>
     41#import <WebCore/CoreGraphicsSPI.h>
     42#import <WebCore/GraphicsContextCG.h>
     43#import <WebCore/IOSurface.h>
     44#import <WebCore/PlatformScreen.h>
    4145#import <WebCore/QuartzCoreSPI.h>
    4246#import <WebKit/WebCoreThread.h>
     
    5761    [CATransaction flush];
    5862
    59 #if USE(IOSURFACE)
    60     return nullptr;
    61 #else
    6263    CGFloat deviceScaleFactor = 2; // FIXME: hardcode 2x for now. In future we could respect 1x and 3x as we do on Mac.
    63     CATransform3D transform = CATransform3DMakeScale(deviceScaleFactor, deviceScaleFactor, 1);
    6464   
    6565    CGSize viewSize = [[mainFrame webView] frame].size;
    6666    int bufferWidth = ceil(viewSize.width * deviceScaleFactor);
    6767    int bufferHeight = ceil(viewSize.height * deviceScaleFactor);
     68
     69#if USE(IOSURFACE)
     70    WebCore::FloatSize snapshotSize(viewSize);
     71    snapshotSize.scale(deviceScaleFactor);
     72
     73    WebCore::IOSurface::Format snapshotFormat = WebCore::screenSupportsExtendedColor() ? WebCore::IOSurface::Format::RGB10 : WebCore::IOSurface::Format::RGBA;
     74    auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(snapshotSize), WebCore::sRGBColorSpaceRef(), snapshotFormat);
     75    RetainPtr<CGImageRef> cgImage = surface->createImage();
     76
     77    void* bitmapBuffer = nullptr;
     78    size_t bitmapRowBytes = 0;
     79    auto bitmapContext = createBitmapContext(bufferWidth, bufferHeight, bitmapRowBytes, bitmapBuffer);
     80    if (!bitmapContext)
     81        return nullptr;
     82
     83    CGContextDrawImage(bitmapContext->cgContext(), CGRectMake(0, 0, bufferWidth, bufferHeight), cgImage.get());
     84    return bitmapContext;
     85#else
     86    CATransform3D transform = CATransform3DMakeScale(deviceScaleFactor, deviceScaleFactor, 1);
     87    static CGColorSpaceRef sRGBSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
    6888
    6989    CARenderServerBufferRef buffer = CARenderServerCreateBuffer(bufferWidth, bufferHeight);
     
    7898    size_t rowBytes = CARenderServerGetBufferRowBytes(buffer);
    7999
    80     static CGColorSpaceRef sRGBSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
    81100    RetainPtr<CGDataProviderRef> provider = adoptCF(CGDataProviderCreateWithData(0, data, CARenderServerGetBufferDataSize(buffer), nullptr));
    82101   
  • trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm

    r216335 r216462  
    3333#import <WebKit/WKImageCG.h>
    3434#import <WebKit/WKPreferencesPrivate.h>
     35#import <WebKit/WKSnapshotConfiguration.h>
    3536#import <WebKit/WKWebViewConfiguration.h>
    3637#import <WebKit/WKWebViewPrivate.h>
     
    305306    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    306307#if USE(IOSURFACE)
    307     return nullptr;
     308    __block bool isDone = false;
     309    __block RetainPtr<CGImageRef> result;
     310   
     311    RetainPtr<WKSnapshotConfiguration> snapshotConfiguration = adoptNS([[WKSnapshotConfiguration alloc] init]);
     312    [snapshotConfiguration setRect:CGRectMake(0, 0, m_view.frame.size.width, m_view.frame.size.height)];
     313    [snapshotConfiguration setSnapshotWidth:@(m_view.frame.size.width)];
     314   
     315    [m_view takeSnapshotWithConfiguration:snapshotConfiguration.get() completionHandler:^(UIImage *snapshotImage, NSError *error) {
     316        if (!error)
     317            result = [snapshotImage CGImage];
     318        isDone = true;
     319    }];
     320    while (!isDone)
     321        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]];
     322    return result;
     323
    308324#else
    309325    CGFloat deviceScaleFactor = 2; // FIXME: hardcode 2x for now. In future we could respect 1x and 3x as we do on Mac.
Note: See TracChangeset for help on using the changeset viewer.