⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 238550 in webkit


Ignore:
Timestamp:
Nov 27, 2018, 5:34:17 AM (8 years ago)
Author:
Antti Koivisto
Message:

Factor mask layer applying in RemoteLayerTreePropertyApplier into a shared function
https://bugs.webkit.org/show_bug.cgi?id=192001

Reviewed by Tim Horton.

  • Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h:
  • Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:

(WebKit::RemoteLayerTreePropertyApplier::applyProperties):
(WebKit::RemoteLayerTreePropertyApplier::updateMask):

Shared function, with some special tricks for iOS backdrop layers.

(WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToUIView):

Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r238549 r238550  
     12018-11-27  Antti Koivisto  <antti@apple.com>
     2
     3        Factor mask layer applying in RemoteLayerTreePropertyApplier into a shared function
     4        https://bugs.webkit.org/show_bug.cgi?id=192001
     5
     6        Reviewed by Tim Horton.
     7
     8        * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h:
     9        * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
     10        (WebKit::RemoteLayerTreePropertyApplier::applyProperties):
     11        (WebKit::RemoteLayerTreePropertyApplier::updateMask):
     12
     13        Shared function, with some special tricks for iOS backdrop layers.
     14
     15        (WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToUIView):
     16
    1172018-11-27  Antti Koivisto  <antti@apple.com>
    218
  • trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h

    r238549 r238550  
    4242private:
    4343    static void updateChildren(RemoteLayerTreeNode&, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
     44    static void updateMask(RemoteLayerTreeNode&, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
    4445#if PLATFORM(IOS_FAMILY)
    4546    static void applyPropertiesToUIView(UIView *, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
  • trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm

    r238547 r238550  
    259259    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    260260
    261     CALayer *layer = node.layer();
    262 
    263     applyPropertiesToLayer(layer, layerTreeHost, properties, layerContentsType);
     261    applyPropertiesToLayer(node.layer(), layerTreeHost, properties, layerContentsType);
    264262    updateChildren(node, properties, relatedLayers);
     263    updateMask(node, properties, relatedLayers);
    265264
    266265#if PLATFORM(IOS_FAMILY)
    267266    applyPropertiesToUIView(node.uiView(), properties, relatedLayers);
    268 #else
    269     if (properties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged) {
    270         if (!properties.maskLayerID)
    271             layer.mask = nullptr;
    272         else {
    273             CALayer *maskLayer = relatedLayers.get(properties.maskLayerID)->layer();
    274             ASSERT(!maskLayer.superlayer);
    275             if (!maskLayer.superlayer)
    276                 layer.mask = maskLayer;
    277         }
    278     }
    279 #endif
     267#endif
     268
    280269    END_BLOCK_OBJC_EXCEPTIONS;
    281270}
     
    329318}
    330319
    331 #if PLATFORM(IOS_FAMILY)
    332 void RemoteLayerTreePropertyApplier::applyPropertiesToUIView(UIView *view, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
    333 {
    334     if (properties.changedProperties.contains(RemoteLayerTreeTransaction::MaskLayerChanged)) {
    335         CALayer *maskOwnerLayer = view.layer;
    336 
     320void RemoteLayerTreePropertyApplier::updateMask(RemoteLayerTreeNode& node, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
     321{
     322    if (!properties.changedProperties.contains(RemoteLayerTreeTransaction::MaskLayerChanged))
     323        return;
     324
     325    auto maskOwnerLayer = [&] {
     326        CALayer *layer = node.layer();
     327#if PLATFORM(IOS_FAMILY)
    337328        if (properties.customAppearance == GraphicsLayer::CustomAppearance::LightBackdrop || properties.customAppearance == GraphicsLayer::CustomAppearance::DarkBackdrop) {
    338329            // This is a UIBackdropView, which means any mask must be applied to the CABackdropLayer rather
    339330            // that the view's layer. The backdrop is the first layer child.
    340             if (view.layer.sublayers.count && [view.layer.sublayers[0] isKindOfClass:[CABackdropLayer class]])
    341                 maskOwnerLayer = view.layer.sublayers[0];
    342         }
    343 
    344         if (!properties.maskLayerID)
    345             maskOwnerLayer.mask = nullptr;
    346         else {
    347             UIView *maskView = relatedLayers.get(properties.maskLayerID)->uiView();
    348             // FIXME: need to check that the mask view is kept alive.
    349             ASSERT(!maskView.layer.superlayer);
    350             if (!maskView.layer.superlayer)
    351                 maskOwnerLayer.mask = maskView.layer;
    352         }
    353     }
    354 
     331            if (layer.sublayers.count && [layer.sublayers[0] isKindOfClass:[CABackdropLayer class]])
     332                layer = layer.sublayers[0];
     333        }
     334#endif
     335        return layer;
     336    };
     337
     338    if (!properties.maskLayerID) {
     339        maskOwnerLayer().mask = nullptr;
     340        return;
     341    }
     342
     343    CALayer *maskLayer = relatedLayers.get(properties.maskLayerID)->layer();
     344    ASSERT(!maskLayer.superlayer);
     345    if (maskLayer.superlayer)
     346        return;
     347    maskOwnerLayer().mask = maskLayer;
     348}
     349
     350#if PLATFORM(IOS_FAMILY)
     351void RemoteLayerTreePropertyApplier::applyPropertiesToUIView(UIView *view, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
     352{
    355353    if (properties.changedProperties.containsAny({ RemoteLayerTreeTransaction::ContentsHiddenChanged, RemoteLayerTreeTransaction::UserInteractionEnabledChanged }))
    356354        view.userInteractionEnabled = !properties.contentsHidden && properties.userInteractionEnabled;
Note: See TracChangeset for help on using the changeset viewer.