Changeset 181910 in webkit


Ignore:
Timestamp:
Mar 24, 2015 3:47:53 PM (9 years ago)
Author:
mitz@apple.com
Message:

Source/WebCore:
WebCore part of <rdar://problem/20282863> Transforms are flattened in snapshots of on-screen WKWebViews
https://bugs.webkit.org/show_bug.cgi?id=143023

Reviewed by Tim Horton.

  • platform/spi/cocoa/QuartzCoreSPI.h: Added the declaration of

CARenderServerRenderLayerWithTransform.

Source/WebKit2:
WebKit2 part of <rdar://problem/20282863> Transforms are flattened in snapshots of on-screen WKWebViews
https://bugs.webkit.org/show_bug.cgi?id=143023

Reviewed by Tim Horton.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]): If the view is in a
window, use CARenderServerRenderLayerWithTransform to synchronously capture a snapshot of
its layer tree into an IOSurfcae, then call the completion handler with an image created
from the IOSurface.

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r181909 r181910  
     12015-03-24  Dan Bernstein  <mitz@apple.com>
     2
     3        WebCore part of <rdar://problem/20282863> Transforms are flattened in snapshots of on-screen WKWebViews
     4        https://bugs.webkit.org/show_bug.cgi?id=143023
     5
     6        Reviewed by Tim Horton.
     7
     8        * platform/spi/cocoa/QuartzCoreSPI.h: Added the declaration of
     9        CARenderServerRenderLayerWithTransform.
     10
    1112015-03-24  David Hyatt  <hyatt@apple.com>
    212
  • trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h

    r181193 r181910  
    116116                                                      uint32_t slotId, int32_t ox, int32_t oy, const CATransform3D *);
    117117
     118EXTERN_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);
     119
    118120EXTERN_C NSString * const kCATiledLayerRemoveImmediately;
    119121
  • trunk/Source/WebKit2/ChangeLog

    r181907 r181910  
     12015-03-24  Dan Bernstein  <mitz@apple.com>
     2
     3        WebKit2 part of <rdar://problem/20282863> Transforms are flattened in snapshots of on-screen WKWebViews
     4        https://bugs.webkit.org/show_bug.cgi?id=143023
     5
     6        Reviewed by Tim Horton.
     7
     8        * UIProcess/API/Cocoa/WKWebView.mm:
     9        (-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]): If the view is in a
     10        window, use CARenderServerRenderLayerWithTransform to synchronously capture a snapshot of
     11        its layer tree into an IOSurfcae, then call the completion handler with an image created
     12        from the IOSurface.
     13
    1142015-03-24  Beth Dakin  <bdakin@apple.com>
    215
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r181836 r181910  
    7878#import <JavaScriptCore/JSContext.h>
    7979#import <JavaScriptCore/JSValue.h>
     80#import <WebCore/IOSurface.h>
    8081#import <wtf/HashMap.h>
    8182#import <wtf/MathExtras.h>
     
    25032504        return;
    25042505    }
    2505    
     2506
     2507#if USE(IOSURFACE)
     2508    // If we are parented and thus won't incur a significant penalty from paging in tiles, snapshot the view hierarchy directly.
     2509    if (self.window) {
     2510        float deviceScaleFactor = _page->deviceScaleFactor();
     2511
     2512        CGRect imageRectInPoints;
     2513        imageRectInPoints.size.width = imageWidth / deviceScaleFactor;
     2514        imageRectInPoints.size.height = imageRectInPoints.size.width / rectInViewCoordinates.size.width * rectInViewCoordinates.size.height;
     2515        imageRectInPoints.origin.x = rectInViewCoordinates.origin.x / deviceScaleFactor;
     2516        imageRectInPoints.origin.y = rectInViewCoordinates.origin.y / deviceScaleFactor;
     2517
     2518        auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebCore::ColorSpaceDeviceRGB);
     2519        CATransform3D transform = CATransform3DMakeScale(deviceScaleFactor, deviceScaleFactor, 1);
     2520        CARenderServerRenderLayerWithTransform(MACH_PORT_NULL, self.layer.context.contextId, reinterpret_cast<uint64_t>(self.layer), surface->surface(), 0, 0, &transform);
     2521        completionHandler(surface->createImage().get());
     2522
     2523        return;
     2524    }
     2525#endif
     2526
    25062527    void(^copiedCompletionHandler)(CGImageRef) = [completionHandler copy];
    25072528    _page->takeSnapshot(WebCore::enclosingIntRect(snapshotRectInContentCoordinates), WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebKit::SnapshotOptionsExcludeDeviceScaleFactor, [=](const WebKit::ShareableBitmap::Handle& imageHandle, WebKit::CallbackBase::Error) {
Note: See TracChangeset for help on using the changeset viewer.