Changeset 201727 in webkit


Ignore:
Timestamp:
Jun 6, 2016 1:58:19 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Position of WebGL <canvas> on iOS is incorrect with CSS borders
https://bugs.webkit.org/show_bug.cgi?id=156790

Patch by Antoine Quint <Antoine Quint> on 2016-06-06
Reviewed by Simon Fraser.

Source/WebKit2:

WebGL layers on iOS are hosted by a WKRemoteView, which applies a transform scaling
its content by the inverse of the device pixel ratio, which affects how positions are
applied to the WebGL layer. The container layer of the layer hosted by a WKRemoteView
then has an inverse transform applied to it in the PlatformCALayerRemoteCustom
constructor. However, the position of a CALayer is not affected by its transform.

The fix for <rdar://problem/18316542> should be specific to video, so we only apply the
scaling in the case of a LayerTypeAVPlayerLayer.

  • UIProcess/ios/RemoteLayerTreeHostIOS.mm:

(-[WKRemoteView initWithFrame:contextID:]):
(WebKit::RemoteLayerTreeHost::createLayer):
(-[WKRemoteView initWithFrame:contextID:hostingDeviceScaleFactor:]): Deleted.

  • WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:

(WebKit::PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):

LayoutTests:

Adding new tests checking that CSS border, box-shadow and padding properties used on a
WebGL <canvas> element correctly affect the position of the WebGL content.

  • webgl/webgl-border-expected.html: Added.
  • webgl/webgl-border.html: Added.
  • webgl/webgl-box-shadow-expected.html: Added.
  • webgl/webgl-box-shadow.html: Added.
  • webgl/webgl-padding-expected.html: Added.
  • webgl/webgl-padding.html: Added.
Location:
trunk
Files:
6 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r201725 r201727  
     12016-06-06  Antoine Quint  <graouts@apple.com>
     2
     3        Position of WebGL <canvas> on iOS is incorrect with CSS borders
     4        https://bugs.webkit.org/show_bug.cgi?id=156790
     5
     6        Reviewed by Simon Fraser.
     7
     8        Adding new tests checking that CSS border, box-shadow and padding properties used on a
     9        WebGL <canvas> element correctly affect the position of the WebGL content.
     10
     11        * webgl/webgl-border-expected.html: Added.
     12        * webgl/webgl-border.html: Added.
     13        * webgl/webgl-box-shadow-expected.html: Added.
     14        * webgl/webgl-box-shadow.html: Added.
     15        * webgl/webgl-padding-expected.html: Added.
     16        * webgl/webgl-padding.html: Added.
     17
    1182016-06-06  Skachkov Oleksandr  <gskachkov@gmail.com>
    219
  • trunk/Source/WebKit2/ChangeLog

    r201722 r201727  
     12016-06-06  Antoine Quint  <graouts@apple.com>
     2
     3        Position of WebGL <canvas> on iOS is incorrect with CSS borders
     4        https://bugs.webkit.org/show_bug.cgi?id=156790
     5
     6        Reviewed by Simon Fraser.
     7
     8        WebGL layers on iOS are hosted by a WKRemoteView, which applies a transform scaling
     9        its content by the inverse of the device pixel ratio, which affects how positions are
     10        applied to the WebGL layer. The container layer of the layer hosted by a WKRemoteView
     11        then has an inverse transform applied to it in the PlatformCALayerRemoteCustom
     12        constructor. However, the position of a CALayer is not affected by its transform.
     13
     14        The fix for <rdar://problem/18316542> should be specific to video, so we only apply the
     15        scaling in the case of a LayerTypeAVPlayerLayer.
     16
     17        * UIProcess/ios/RemoteLayerTreeHostIOS.mm:
     18        (-[WKRemoteView initWithFrame:contextID:]):
     19        (WebKit::RemoteLayerTreeHost::createLayer):
     20        (-[WKRemoteView initWithFrame:contextID:hostingDeviceScaleFactor:]): Deleted.
     21        * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
     22        (WebKit::PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
     23
    1242016-06-06  Brady Eidson  <beidson@apple.com>
    225
  • trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm

    r200602 r201727  
    141141@implementation WKRemoteView
    142142
    143 - (instancetype)initWithFrame:(CGRect)frame contextID:(uint32_t)contextID hostingDeviceScaleFactor:(float)scaleFactor
    144 {
    145     if ((self = [super initWithFrame:frame])) {
     143- (instancetype)initWithFrame:(CGRect)frame contextID:(uint32_t)contextID
     144{
     145    if ((self = [super initWithFrame:frame]))
    146146        [[self layer] setContextId:contextID];
    147         // Invert the scale transform added in the WebProcess to fix <rdar://problem/18316542>.
    148         float inverseScale = 1 / scaleFactor;
    149         [[self layer] setTransform:CATransform3DMakeScale(inverseScale, inverseScale, 1)];
    150     }
    151147   
    152148    return self;
     
    212208    case PlatformCALayer::LayerTypeAVPlayerLayer:
    213209    case PlatformCALayer::LayerTypeWebGLLayer:
    214         if (!m_isDebugLayerTreeHost)
    215             view = adoptNS([[WKRemoteView alloc] initWithFrame:CGRectZero contextID:properties.hostingContextID hostingDeviceScaleFactor:properties.hostingDeviceScaleFactor]);
    216         else
     210        if (!m_isDebugLayerTreeHost) {
     211            view = adoptNS([[WKRemoteView alloc] initWithFrame:CGRectZero contextID:properties.hostingContextID]);
     212            if (properties.type == PlatformCALayer::LayerTypeAVPlayerLayer) {
     213                // Invert the scale transform added in the WebProcess to fix <rdar://problem/18316542>.
     214                float inverseScale = 1 / properties.hostingDeviceScaleFactor;
     215                [[view layer] setTransform:CATransform3DMakeScale(inverseScale, inverseScale, 1)];
     216            }
     217        } else
    217218            view = adoptNS([[WKCompositingView alloc] init]);
    218219        break;
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm

    r185856 r201727  
    6666        m_layerHostingContext = LayerHostingContext::createForExternalHostingProcess();
    6767#if PLATFORM(IOS)
    68         float scaleFactor = context.deviceScaleFactor();
    69         // Set a scale factor here to make convertRect:toLayer:nil take scale factor into account. <rdar://problem/18316542>.
    70         // This scale factor is inverted in the hosting process.
    71         [customLayer setTransform:CATransform3DMakeScale(scaleFactor, scaleFactor, 1)];
     68        if (layerType == LayerTypeAVPlayerLayer) {
     69            float scaleFactor = context.deviceScaleFactor();
     70            // Set a scale factor here to make convertRect:toLayer:nil take scale factor into account. <rdar://problem/18316542>.
     71            // This scale factor is inverted in the hosting process.
     72            [customLayer setTransform:CATransform3DMakeScale(scaleFactor, scaleFactor, 1)];
     73        }
    7274#endif
    7375        break;
Note: See TracChangeset for help on using the changeset viewer.