Changeset 180882 in webkit


Ignore:
Timestamp:
Mar 1, 2015 10:35:20 PM (9 years ago)
Author:
Simon Fraser
Message:

Make clip-path work on <video>, <canvas> etc.
https://bugs.webkit.org/show_bug.cgi?id=138684

Reviewed by Darin Adler.

Source/WebCore:

clip-path only worked in compositing layers on the painted contents of the layer,
and failed to clip children. Fix this by translating the clip path into a Path
which is set on a CA shape layer (for Mac and iOS), or painted into the
RenderLayerBacking's mask layer. There are two code paths:

  1. clip-path which is a <basic-shape> or <geometry-box>, and no mask.

Here we can use the optimal code path of converting the clip into a path
that is put onto a CAShapeLayer, which is then used as a mask. There is no
additional backing store.

  1. clip-path with an SVG reference, or clip-path combined with -webkit-mask:

Here we have to allocate backing store for the mask layer, and paint the
clip path (possibly with the mask).

We add GraphicsLayer::Type::Shape, and add a getter for the layer type.

Tests: compositing/masks/compositing-clip-path-and-mask.html

compositing/masks/compositing-clip-path-mask-change.html
compositing/masks/compositing-clip-path.html
compositing/masks/reference-clip-path-on-composited.html

  • platform/graphics/GraphicsLayer.cpp:

(WebCore::GraphicsLayer::GraphicsLayer): Store the type in the layer so the getter can return it.
(WebCore::GraphicsLayer::shapeLayerPath): Get and set the shape layer path.
(WebCore::GraphicsLayer::setShapeLayerPath): Ditto.
(WebCore::GraphicsLayer::shapeLayerWindRule): Get and set the shape layer wind rule.
(WebCore::GraphicsLayer::setShapeLayerWindRule): Ditto.

  • platform/graphics/GraphicsLayer.h:

(WebCore::GraphicsLayer::type): Expose the type.
(WebCore::GraphicsLayer::supportsLayerType): Allow the cross-platform code to use
shape layers when it knows they are available.
(WebCore::GraphicsLayer::needsClippingMaskLayer): Deleted. This was never used.

  • platform/graphics/GraphicsLayerClient.h: Align the bits (helps avoid typos). Add a

GraphicsLayerPaintClipPath phase.

  • platform/graphics/Path.h: Some exports since WK2 needs to encode Paths now.
  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::GraphicsLayerCA::initialize): Make shape layers.
(WebCore::GraphicsLayerCA::setShapeLayerPath): Setter for the shape path. Sadly we
can't early return on unchanged paths yet.
(WebCore::GraphicsLayerCA::setShapeLayerWindRule):
(WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers): Updates for shape path
and wind rule.
(WebCore::GraphicsLayerCA::updateShape):
(WebCore::GraphicsLayerCA::updateWindRule):

  • platform/graphics/ca/GraphicsLayerCA.h: Some new dirty bits for shape path and wind rule.
  • platform/graphics/ca/PlatformCALayer.h:
  • platform/graphics/ca/mac/PlatformCALayerMac.h:
  • platform/graphics/ca/mac/PlatformCALayerMac.mm: Got rid of lots of m_layer.get().

(PlatformCALayerMac::~PlatformCALayerMac):
(PlatformCALayerMac::setNeedsDisplay):
(PlatformCALayerMac::setNeedsDisplayInRect):
(PlatformCALayerMac::removeFromSuperlayer):
(PlatformCALayerMac::setSublayers):
(PlatformCALayerMac::removeAllSublayers):
(PlatformCALayerMac::appendSublayer):
(PlatformCALayerMac::insertSublayer):
(PlatformCALayerMac::replaceSublayer):
(PlatformCALayerMac::adoptSublayers):
(PlatformCALayerMac::addAnimationForKey):
(PlatformCALayerMac::removeAnimationForKey):
(PlatformCALayerMac::animationForKey):
(PlatformCALayerMac::setMask):
(PlatformCALayerMac::isOpaque):
(PlatformCALayerMac::setOpaque):
(PlatformCALayerMac::bounds):
(PlatformCALayerMac::setBounds):
(PlatformCALayerMac::position):
(PlatformCALayerMac::setPosition):
(PlatformCALayerMac::anchorPoint):
(PlatformCALayerMac::setAnchorPoint):
(PlatformCALayerMac::transform):
(PlatformCALayerMac::setTransform):
(PlatformCALayerMac::sublayerTransform):
(PlatformCALayerMac::setSublayerTransform):
(PlatformCALayerMac::setHidden):
(PlatformCALayerMac::setGeometryFlipped):
(PlatformCALayerMac::isDoubleSided):
(PlatformCALayerMac::setDoubleSided):
(PlatformCALayerMac::masksToBounds):
(PlatformCALayerMac::setMasksToBounds):
(PlatformCALayerMac::acceleratesDrawing):
(PlatformCALayerMac::setAcceleratesDrawing):
(PlatformCALayerMac::contents):
(PlatformCALayerMac::setContents):
(PlatformCALayerMac::setContentsRect):
(PlatformCALayerMac::setMinificationFilter):
(PlatformCALayerMac::setMagnificationFilter):
(PlatformCALayerMac::backgroundColor):
(PlatformCALayerMac::setBackgroundColor):
(PlatformCALayerMac::setBorderWidth):
(PlatformCALayerMac::setBorderColor):
(PlatformCALayerMac::opacity):
(PlatformCALayerMac::setOpacity):
(PlatformCALayerMac::copyFiltersFrom):
(PlatformCALayerMac::setName):
(PlatformCALayerMac::setSpeed):
(PlatformCALayerMac::setTimeOffset):
(PlatformCALayerMac::contentsScale):
(PlatformCALayerMac::setContentsScale):
(PlatformCALayerMac::cornerRadius):
(PlatformCALayerMac::setCornerRadius):
(PlatformCALayerMac::setEdgeAntialiasingMask):
(PlatformCALayerMac::shapeWindRule): New function.
(PlatformCALayerMac::setShapeWindRule): Ditto.
(PlatformCALayerMac::shapePath): Ditto.
(PlatformCALayerMac::setShapePath): Ditto.
(PlatformCALayer::isWebLayer):

  • platform/graphics/cg/PathCG.cpp:

(WebCore::Path::Path): nullptr.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::paintsWithClipPath): Return true if the clip path is painted.
(WebCore::RenderLayer::computeClipPath): Factor code that computes the clip path into this
function, so we can call it from RenderLayerBacking too.
(WebCore::RenderLayer::setupClipPath):
(WebCore::RenderLayer::paintLayerContents): We only want to apply the clip path
for painting when we're either painting a non-composited layer, or we're painting the
mask layer of a composited layer. We in the latter case, we just want to fill the clip
path with black, so re-use the paintChildClippingMaskForFragments() which does this.

  • rendering/RenderLayer.h: Align the bits, add PaintLayerPaintingCompositingClipPathPhase.
  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::~RenderLayerBacking):
(WebCore::RenderLayerBacking::updateConfiguration):
(WebCore::RenderLayerBacking::updateGeometry): Move mask updating into its own function.
(WebCore::RenderLayerBacking::updateMaskingLayerGeometry): If we're using the shape layer
code path, compute the Path and set it and the wind rule on the mask layer.
(WebCore::RenderLayerBacking::updateMaskingLayer): This is now more complex, as it has
to deal with combinations of clip-path and mask, some of which allow for the shape layer
mask, and we handle dynamic changes between these and painted masks.
(WebCore::RenderLayerBacking::paintingPhaseForPrimaryLayer): Include the GraphicsLayerPaintClipPath phase.
(WebCore::RenderLayerBacking::paintIntoLayer): Map GraphicsLayerPaintClipPath to PaintLayerPaintingCompositingClipPathPhase.
(WebCore::RenderLayerBacking::updateMaskLayer): Deleted.

  • rendering/RenderLayerBacking.h:

Source/WebKit2:

Support encode/decode for WebCore Path objects, which is done by traversing
the path.

  • Shared/WebCoreArgumentCoders.cpp:

(IPC::pathPointCountApplierFunction):
(IPC::pathEncodeApplierFunction):
(IPC::ArgumentCoder<Path>::encode):
(IPC::ArgumentCoder<Path>::decode):

  • Shared/WebCoreArgumentCoders.h:
  • Shared/mac/RemoteLayerTreePropertyApplier.mm:

(WebKit::applyPropertiesToLayer): Actually apply the path and wind rule to the shape layer.

  • Shared/mac/RemoteLayerTreeTransaction.h: Include path and wind rule in the layer properties.
  • Shared/mac/RemoteLayerTreeTransaction.mm:

(WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::encode): Encode shape and wind rule.
(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode): Decode shape and wind rule.

  • WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:

(WebKit::PlatformCALayerRemote::shapePath):
(WebKit::PlatformCALayerRemote::setShapePath):
(WebKit::PlatformCALayerRemote::shapeWindRule):
(WebKit::PlatformCALayerRemote::setShapeWindRule):

  • WebProcess/WebPage/mac/PlatformCALayerRemote.h:

LayoutTests:

Tests for various combinations of clip-path and mask, and dynamic changes
thereof.

  • compositing/masks/compositing-clip-path-and-mask-expected.html: Added.
  • compositing/masks/compositing-clip-path-and-mask.html: Added.
  • compositing/masks/compositing-clip-path-expected.html: Added.
  • compositing/masks/compositing-clip-path-mask-change-expected.html: Added.
  • compositing/masks/compositing-clip-path-mask-change.html: Added.
  • compositing/masks/compositing-clip-path.html: Added.
  • compositing/masks/reference-clip-path-on-composited-expected.html: Added.
  • compositing/masks/reference-clip-path-on-composited.html: Added.
Location:
trunk
Files:
8 added
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r180879 r180882  
     12015-03-01  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make clip-path work on <video>, <canvas> etc.
     4        https://bugs.webkit.org/show_bug.cgi?id=138684
     5
     6        Reviewed by Darin Adler.
     7       
     8        Tests for various combinations of clip-path and mask, and dynamic changes
     9        thereof.
     10
     11        * compositing/masks/compositing-clip-path-and-mask-expected.html: Added.
     12        * compositing/masks/compositing-clip-path-and-mask.html: Added.
     13        * compositing/masks/compositing-clip-path-expected.html: Added.
     14        * compositing/masks/compositing-clip-path-mask-change-expected.html: Added.
     15        * compositing/masks/compositing-clip-path-mask-change.html: Added.
     16        * compositing/masks/compositing-clip-path.html: Added.
     17        * compositing/masks/reference-clip-path-on-composited-expected.html: Added.
     18        * compositing/masks/reference-clip-path-on-composited.html: Added.
     19
    1202015-03-01  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    221
  • trunk/Source/WebCore/ChangeLog

    r180881 r180882  
     12015-03-01  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make clip-path work on <video>, <canvas> etc.
     4        https://bugs.webkit.org/show_bug.cgi?id=138684
     5
     6        Reviewed by Darin Adler.
     7       
     8        clip-path only worked in compositing layers on the painted contents of the layer,
     9        and failed to clip children. Fix this by translating the clip path into a Path
     10        which is set on a CA shape layer (for Mac and iOS), or painted into the
     11        RenderLayerBacking's mask layer. There are two code paths:
     12
     13        1. clip-path which is a <basic-shape> or <geometry-box>, and no mask.
     14            Here we can use the optimal code path of converting the clip into a path
     15            that is put onto a CAShapeLayer, which is then used as a mask. There is no
     16            additional backing store.
     17        2. clip-path with an SVG reference, or clip-path combined with -webkit-mask:
     18            Here we have to allocate backing store for the mask layer, and paint the
     19            clip path (possibly with the mask).
     20       
     21        We add GraphicsLayer::Type::Shape, and add a getter for the layer type.
     22
     23        Tests: compositing/masks/compositing-clip-path-and-mask.html
     24               compositing/masks/compositing-clip-path-mask-change.html
     25               compositing/masks/compositing-clip-path.html
     26               compositing/masks/reference-clip-path-on-composited.html
     27
     28        * platform/graphics/GraphicsLayer.cpp:
     29        (WebCore::GraphicsLayer::GraphicsLayer): Store the type in the layer so the getter can return it.
     30        (WebCore::GraphicsLayer::shapeLayerPath): Get and set the shape layer path.
     31        (WebCore::GraphicsLayer::setShapeLayerPath): Ditto.
     32        (WebCore::GraphicsLayer::shapeLayerWindRule): Get and set the shape layer wind rule.
     33        (WebCore::GraphicsLayer::setShapeLayerWindRule): Ditto.
     34        * platform/graphics/GraphicsLayer.h:
     35        (WebCore::GraphicsLayer::type): Expose the type.
     36        (WebCore::GraphicsLayer::supportsLayerType): Allow the cross-platform code to use
     37        shape layers when it knows they are available.
     38        (WebCore::GraphicsLayer::needsClippingMaskLayer): Deleted. This was never used.
     39        * platform/graphics/GraphicsLayerClient.h: Align the bits (helps avoid typos). Add a
     40        GraphicsLayerPaintClipPath phase.
     41        * platform/graphics/Path.h: Some exports since WK2 needs to encode Paths now.
     42        * platform/graphics/ca/GraphicsLayerCA.cpp:
     43        (WebCore::GraphicsLayerCA::initialize): Make shape layers.
     44        (WebCore::GraphicsLayerCA::setShapeLayerPath): Setter for the shape path. Sadly we
     45        can't early return on unchanged paths yet.
     46        (WebCore::GraphicsLayerCA::setShapeLayerWindRule):
     47        (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers): Updates for shape path
     48        and wind rule.
     49        (WebCore::GraphicsLayerCA::updateShape):
     50        (WebCore::GraphicsLayerCA::updateWindRule):
     51        * platform/graphics/ca/GraphicsLayerCA.h: Some new dirty bits for shape path and wind rule.
     52        * platform/graphics/ca/PlatformCALayer.h:
     53        * platform/graphics/ca/mac/PlatformCALayerMac.h:
     54        * platform/graphics/ca/mac/PlatformCALayerMac.mm: Got rid of lots of m_layer.get().
     55        (PlatformCALayerMac::~PlatformCALayerMac):
     56        (PlatformCALayerMac::setNeedsDisplay):
     57        (PlatformCALayerMac::setNeedsDisplayInRect):
     58        (PlatformCALayerMac::removeFromSuperlayer):
     59        (PlatformCALayerMac::setSublayers):
     60        (PlatformCALayerMac::removeAllSublayers):
     61        (PlatformCALayerMac::appendSublayer):
     62        (PlatformCALayerMac::insertSublayer):
     63        (PlatformCALayerMac::replaceSublayer):
     64        (PlatformCALayerMac::adoptSublayers):
     65        (PlatformCALayerMac::addAnimationForKey):
     66        (PlatformCALayerMac::removeAnimationForKey):
     67        (PlatformCALayerMac::animationForKey):
     68        (PlatformCALayerMac::setMask):
     69        (PlatformCALayerMac::isOpaque):
     70        (PlatformCALayerMac::setOpaque):
     71        (PlatformCALayerMac::bounds):
     72        (PlatformCALayerMac::setBounds):
     73        (PlatformCALayerMac::position):
     74        (PlatformCALayerMac::setPosition):
     75        (PlatformCALayerMac::anchorPoint):
     76        (PlatformCALayerMac::setAnchorPoint):
     77        (PlatformCALayerMac::transform):
     78        (PlatformCALayerMac::setTransform):
     79        (PlatformCALayerMac::sublayerTransform):
     80        (PlatformCALayerMac::setSublayerTransform):
     81        (PlatformCALayerMac::setHidden):
     82        (PlatformCALayerMac::setGeometryFlipped):
     83        (PlatformCALayerMac::isDoubleSided):
     84        (PlatformCALayerMac::setDoubleSided):
     85        (PlatformCALayerMac::masksToBounds):
     86        (PlatformCALayerMac::setMasksToBounds):
     87        (PlatformCALayerMac::acceleratesDrawing):
     88        (PlatformCALayerMac::setAcceleratesDrawing):
     89        (PlatformCALayerMac::contents):
     90        (PlatformCALayerMac::setContents):
     91        (PlatformCALayerMac::setContentsRect):
     92        (PlatformCALayerMac::setMinificationFilter):
     93        (PlatformCALayerMac::setMagnificationFilter):
     94        (PlatformCALayerMac::backgroundColor):
     95        (PlatformCALayerMac::setBackgroundColor):
     96        (PlatformCALayerMac::setBorderWidth):
     97        (PlatformCALayerMac::setBorderColor):
     98        (PlatformCALayerMac::opacity):
     99        (PlatformCALayerMac::setOpacity):
     100        (PlatformCALayerMac::copyFiltersFrom):
     101        (PlatformCALayerMac::setName):
     102        (PlatformCALayerMac::setSpeed):
     103        (PlatformCALayerMac::setTimeOffset):
     104        (PlatformCALayerMac::contentsScale):
     105        (PlatformCALayerMac::setContentsScale):
     106        (PlatformCALayerMac::cornerRadius):
     107        (PlatformCALayerMac::setCornerRadius):
     108        (PlatformCALayerMac::setEdgeAntialiasingMask):
     109        (PlatformCALayerMac::shapeWindRule): New function.
     110        (PlatformCALayerMac::setShapeWindRule): Ditto.
     111        (PlatformCALayerMac::shapePath): Ditto.
     112        (PlatformCALayerMac::setShapePath): Ditto.
     113        (PlatformCALayer::isWebLayer):
     114        * platform/graphics/cg/PathCG.cpp:
     115        (WebCore::Path::Path): nullptr.
     116        * rendering/RenderLayer.cpp:
     117        (WebCore::RenderLayer::paintsWithClipPath): Return true if the clip path is painted.
     118        (WebCore::RenderLayer::computeClipPath): Factor code that computes the clip path into this
     119        function, so we can call it from RenderLayerBacking too.
     120        (WebCore::RenderLayer::setupClipPath):
     121        (WebCore::RenderLayer::paintLayerContents): We only want to apply the clip path
     122        for painting when we're either painting a non-composited layer, or we're painting the
     123        mask layer of a composited layer. We in the latter case, we just want to fill the clip
     124        path with black, so re-use the paintChildClippingMaskForFragments() which does this.
     125        * rendering/RenderLayer.h: Align the bits, add PaintLayerPaintingCompositingClipPathPhase.
     126        * rendering/RenderLayerBacking.cpp:
     127        (WebCore::RenderLayerBacking::~RenderLayerBacking):
     128        (WebCore::RenderLayerBacking::updateConfiguration):
     129        (WebCore::RenderLayerBacking::updateGeometry): Move mask updating into its own function.
     130        (WebCore::RenderLayerBacking::updateMaskingLayerGeometry): If we're using the shape layer
     131        code path, compute the Path and set it and the wind rule on the mask layer.
     132        (WebCore::RenderLayerBacking::updateMaskingLayer): This is now more complex, as it has
     133        to deal with combinations of clip-path and mask, some of which allow for the shape layer
     134        mask, and we handle dynamic changes between these and painted masks.
     135        (WebCore::RenderLayerBacking::paintingPhaseForPrimaryLayer): Include the GraphicsLayerPaintClipPath phase.
     136        (WebCore::RenderLayerBacking::paintIntoLayer): Map GraphicsLayerPaintClipPath to PaintLayerPaintingCompositingClipPathPhase.
     137        (WebCore::RenderLayerBacking::updateMaskLayer): Deleted.
     138        * rendering/RenderLayerBacking.h:
     139
    11402015-03-01  Hunseop Jeong  <hs85.jeong@samsung.com>
    2141
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp

    r179604 r180882  
    7272}
    7373
    74 GraphicsLayer::GraphicsLayer(Type, GraphicsLayerClient& client)
     74#if !USE(CA)
     75bool GraphicsLayer::supportsLayerType(Type type)
     76{
     77    switch (type) {
     78    case Type::Normal:
     79    case Type::PageTiledBacking:
     80    case Type::Scrolling:
     81        return true;
     82    case Type::Shape:
     83        return false;
     84    }
     85    ASSERT_NOT_REACHED();
     86    return false;
     87}
     88
     89bool GraphicsLayer::supportsBackgroundColorContent()
     90{
     91#if USE(TEXTURE_MAPPER)
     92    return true;
     93#else
     94    return false;
     95#endif
     96}
     97#endif
     98
     99#if !USE(COORDINATED_GRAPHICS)
     100bool GraphicsLayer::supportsContentsTiling()
     101{
     102    // FIXME: Enable the feature on different ports.
     103    return false;
     104}
     105#endif
     106
     107GraphicsLayer::GraphicsLayer(Type type, GraphicsLayerClient& client)
    75108    : m_client(client)
    76109    , m_anchorPoint(0.5f, 0.5f, 0)
     
    80113    , m_blendMode(BlendModeNormal)
    81114#endif
     115    , m_type(type)
    82116    , m_contentsOpaque(false)
    83117    , m_preserves3D(false)
     
    273307   
    274308    m_maskLayer = layer;
     309}
     310
     311Path GraphicsLayer::shapeLayerPath() const
     312{
     313#if USE(CA)
     314    return m_shapeLayerPath;
     315#else
     316    return Path();
     317#endif
     318}
     319
     320void GraphicsLayer::setShapeLayerPath(const Path& path)
     321{
     322#if USE(CA)
     323    m_shapeLayerPath = path;
     324#else
     325    UNUSED_PARAM(path);
     326#endif
     327}
     328
     329WindRule GraphicsLayer::shapeLayerWindRule() const
     330{
     331#if USE(CA)
     332    return m_shapeLayerWindRule;
     333#else
     334    return RULE_NONZERO;
     335#endif
     336}
     337
     338void GraphicsLayer::setShapeLayerWindRule(WindRule windRule)
     339{
     340#if USE(CA)
     341    m_shapeLayerWindRule = windRule;
     342#else
     343    UNUSED_PARAM(windRule);
     344#endif
    275345}
    276346
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r180580 r180882  
    3636#include "GraphicsLayerClient.h"
    3737#include "IntRect.h"
     38#include "Path.h"
    3839#include "PlatformLayer.h"
    3940#include "TransformOperations.h"
     41#include "WindRule.h"
    4042#include <wtf/TypeCasts.h>
    4143
     
    199201        Normal,
    200202        PageTiledBacking,
    201         Scrolling
     203        Scrolling,
     204        Shape
    202205    };
    203206   
     
    205208   
    206209    WEBCORE_EXPORT virtual ~GraphicsLayer();
     210   
     211    Type type() const { return m_type; }
    207212
    208213    virtual void initialize(Type) { }
     
    381386    FloatRoundedRect maskToBoundsRect() const { return m_masksToBoundsRect; };
    382387    virtual bool setMasksToBoundsRect(const FloatRoundedRect& roundedRect) { m_masksToBoundsRect = roundedRect; return false; }
     388
     389    Path shapeLayerPath() const;
     390    virtual void setShapeLayerPath(const Path&);
     391
     392    WindRule shapeLayerWindRule() const;
     393    virtual void setShapeLayerWindRule(WindRule);
    383394
    384395    // Transitions are identified by a special animation name that cannot clash with a keyframe identifier.
     
    481492    void addRepaintRect(const FloatRect&);
    482493
    483     static bool supportsBackgroundColorContent()
    484     {
    485 #if USE(CA) || USE(TEXTURE_MAPPER)
    486         return true;
    487 #else
    488         return false;
    489 #endif
    490     }
    491 
    492 #if USE(COORDINATED_GRAPHICS)
     494    static bool supportsBackgroundColorContent();
     495    static bool supportsLayerType(Type);
    493496    static bool supportsContentsTiling();
    494 #else
    495     static bool supportsContentsTiling()
    496     {
    497         // FIXME: Enable the feature on different ports.
    498         return false;
    499     }
    500 #endif
    501497
    502498    void updateDebugIndicators();
     
    507503    virtual bool isGraphicsLayerCARemote() const { return false; }
    508504    virtual bool isGraphicsLayerTextureMapper() const { return false; }
    509 
    510     virtual bool needsClippingMaskLayer() { return true; };
    511505
    512506protected:
     
    570564    BlendMode m_blendMode;
    571565#endif
     566
     567    const Type m_type;
    572568
    573569    bool m_contentsOpaque : 1;
     
    605601    int m_repaintCount;
    606602    CustomAppearance m_customAppearance;
     603
     604#if USE(CA)
     605    Path m_shapeLayerPath;
     606    WindRule m_shapeLayerWindRule { RULE_NONZERO };
     607#endif
    607608};
    608609
  • trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h

    r179604 r180882  
    4040
    4141enum GraphicsLayerPaintingPhaseFlags {
    42     GraphicsLayerPaintBackground = (1 << 0),
    43     GraphicsLayerPaintForeground = (1 << 1),
    44     GraphicsLayerPaintMask = (1 << 2),
    45     GraphicsLayerPaintOverflowContents = (1 << 3),
    46     GraphicsLayerPaintCompositedScroll = (1 << 4),
    47     GraphicsLayerPaintChildClippingMask = (1 << 5),
    48     GraphicsLayerPaintAllWithOverflowClip = (GraphicsLayerPaintBackground | GraphicsLayerPaintForeground | GraphicsLayerPaintMask)
     42    GraphicsLayerPaintBackground            = 1 << 0,
     43    GraphicsLayerPaintForeground            = 1 << 1,
     44    GraphicsLayerPaintMask                  = 1 << 2,
     45    GraphicsLayerPaintClipPath              = 1 << 3,
     46    GraphicsLayerPaintOverflowContents      = 1 << 4,
     47    GraphicsLayerPaintCompositedScroll      = 1 << 5,
     48    GraphicsLayerPaintChildClippingMask     = 1 << 6,
     49    GraphicsLayerPaintAllWithOverflowClip   = GraphicsLayerPaintBackground | GraphicsLayerPaintForeground
    4950};
    5051typedef unsigned GraphicsLayerPaintingPhase;
     
    5960
    6061enum LayerTreeAsTextBehaviorFlags {
    61     LayerTreeAsTextBehaviorNormal = 0,
    62     LayerTreeAsTextDebug = 1 << 0, // Dump extra debugging info like layer addresses.
    63     LayerTreeAsTextIncludeVisibleRects = 1 << 1,
    64     LayerTreeAsTextIncludeTileCaches = 1 << 2,
    65     LayerTreeAsTextIncludeRepaintRects = 1 << 3,
    66     LayerTreeAsTextIncludePaintingPhases = 1 << 4,
    67     LayerTreeAsTextIncludeContentLayers = 1 << 5,
    68     LayerTreeAsTextIncludePageOverlayLayers = 1 << 6,
     62    LayerTreeAsTextBehaviorNormal               = 0,
     63    LayerTreeAsTextDebug                        = 1 << 0, // Dump extra debugging info like layer addresses.
     64    LayerTreeAsTextIncludeVisibleRects          = 1 << 1,
     65    LayerTreeAsTextIncludeTileCaches            = 1 << 2,
     66    LayerTreeAsTextIncludeRepaintRects          = 1 << 3,
     67    LayerTreeAsTextIncludePaintingPhases        = 1 << 4,
     68    LayerTreeAsTextIncludeContentLayers         = 1 << 5,
     69    LayerTreeAsTextIncludePageOverlayLayers     = 1 << 6,
    6970};
    7071typedef unsigned LayerTreeAsTextBehavior;
  • trunk/Source/WebCore/platform/graphics/Path.h

    r180790 r180882  
    9191        WEBCORE_EXPORT ~Path();
    9292
    93         Path(const Path&);
    94         Path& operator=(const Path&);
     93        WEBCORE_EXPORT Path(const Path&);
     94        WEBCORE_EXPORT Path& operator=(const Path&);
    9595
    9696        bool contains(const FloatPoint&, WindRule rule = RULE_NONZERO) const;
     
    106106        float normalAngleAtLength(float length, bool& ok) const;
    107107
    108         void clear();
     108        WEBCORE_EXPORT void clear();
    109109        bool isNull() const { return !m_path; }
    110110        bool isEmpty() const;
     
    114114        FloatPoint currentPoint() const;
    115115
    116         void moveTo(const FloatPoint&);
    117         void addLineTo(const FloatPoint&);
    118         void addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& endPoint);
    119         void addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& endPoint);
     116        WEBCORE_EXPORT void moveTo(const FloatPoint&);
     117        WEBCORE_EXPORT void addLineTo(const FloatPoint&);
     118        WEBCORE_EXPORT void addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& endPoint);
     119        WEBCORE_EXPORT void addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& endPoint);
    120120        void addArcTo(const FloatPoint&, const FloatPoint&, float radius);
    121         void closeSubpath();
     121        WEBCORE_EXPORT void closeSubpath();
    122122
    123123        void addArc(const FloatPoint&, float radius, float startAngle, float endAngle, bool anticlockwise);
     
    145145        PlatformPathPtr ensurePlatformPath();
    146146
    147         void apply(void* info, PathApplierFunction) const;
     147        WEBCORE_EXPORT void apply(void* info, PathApplierFunction) const;
    148148        void transform(const AffineTransform&);
    149149
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r179784 r180882  
    277277}
    278278
     279bool GraphicsLayer::supportsLayerType(Type type)
     280{
     281    switch (type) {
     282    case Type::Normal:
     283    case Type::PageTiledBacking:
     284    case Type::Scrolling:
     285        return true;
     286    case Type::Shape:
     287#if PLATFORM(COCOA)
     288        // FIXME: we can use shaper layers on Windows when PlatformCALayerMac::setShapePath() etc are implemented.
     289        return true;
     290#else
     291        return false;
     292#endif
     293    }
     294    ASSERT_NOT_REACHED();
     295    return false;
     296}
     297
     298bool GraphicsLayer::supportsBackgroundColorContent()
     299{
     300    return true;
     301}
     302
    279303std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
    280304{
     
    352376        platformLayerType = PlatformCALayer::LayerType::LayerTypeScrollingLayer;
    353377        break;
     378    case Type::Shape:
     379        platformLayerType = PlatformCALayer::LayerType::LayerTypeShapeLayer;
     380        break;
    354381    }
    355382    m_layer = createPlatformCALayer(platformLayerType, this);
     
    806833    noteLayerPropertyChanged(MasksToBoundsRectChanged);
    807834    return true;
     835}
     836
     837void GraphicsLayerCA::setShapeLayerPath(const Path& path)
     838{
     839    // FIXME: need to check for path equality. No bool Path::operator==(const Path&)!.
     840    GraphicsLayer::setShapeLayerPath(path);
     841    noteLayerPropertyChanged(ShapeChanged);
     842}
     843
     844void GraphicsLayerCA::setShapeLayerWindRule(WindRule windRule)
     845{
     846    if (windRule == m_shapeLayerWindRule)
     847        return;
     848
     849    GraphicsLayer::setShapeLayerWindRule(windRule);
     850    noteLayerPropertyChanged(WindRuleChanged);
    808851}
    809852
     
    13721415#endif
    13731416
     1417    if (m_uncommittedChanges & ShapeChanged)
     1418        updateShape();
     1419
     1420    if (m_uncommittedChanges & WindRuleChanged)
     1421        updateWindRule();
     1422
    13741423    if (m_uncommittedChanges & AnimationChanged)
    13751424        updateAnimations();
     
    17301779}
    17311780#endif
     1781
     1782void GraphicsLayerCA::updateShape()
     1783{
     1784    m_layer->setShapePath(m_shapeLayerPath);
     1785}
     1786
     1787void GraphicsLayerCA::updateWindRule()
     1788{
     1789    m_layer->setShapeWindRule(m_shapeLayerWindRule);
     1790}
    17321791
    17331792void GraphicsLayerCA::updateStructuralLayer()
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r179604 r180882  
    121121    WEBCORE_EXPORT virtual bool setMasksToBoundsRect(const FloatRoundedRect&) override;
    122122
     123    WEBCORE_EXPORT virtual void setShapeLayerPath(const Path&);
     124    WEBCORE_EXPORT virtual void setShapeLayerWindRule(WindRule);
     125
    123126    WEBCORE_EXPORT virtual void suspendAnimations(double time) override;
    124127    WEBCORE_EXPORT virtual void resumeAnimations() override;
     
    204207
    205208    WEBCORE_EXPORT void layerDidDisplay(PlatformCALayer*);
    206     void updateOpacityOnLayer();
    207     void updateFilters();
    208     void updateBackdropFilters();
    209 
    210 #if ENABLE(CSS_COMPOSITING)
    211     void updateBlendMode();
    212 #endif
    213209
    214210    virtual PassRefPtr<PlatformCALayer> createPlatformCALayer(PlatformCALayer::LayerType, PlatformCALayerClient* owner);
     
    384380    void updateContentsScale(float pageScaleFactor);
    385381    void updateCustomAppearance();
     382
     383    void updateOpacityOnLayer();
     384    void updateFilters();
     385    void updateBackdropFilters();
     386
     387#if ENABLE(CSS_COMPOSITING)
     388    void updateBlendMode();
     389#endif
     390
     391    void updateShape();
     392    void updateWindRule();
    386393
    387394    enum StructuralLayerPurpose {
     
    449456        CustomAppearanceChanged =       1LLU << 32,
    450457        BlendModeChanged =              1LLU << 33,
     458        ShapeChanged =                  1LLU << 34,
     459        WindRuleChanged =               1LLU << 35,
    451460    };
    452461    typedef uint64_t LayerChangeFlags;
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h

    r180301 r180882  
    211211    virtual FloatRoundedRect shapeRoundedRect() const = 0;
    212212    virtual void setShapeRoundedRect(const FloatRoundedRect&) = 0;
     213
     214    // Only used by LayerTypeShapeLayer.
     215    virtual Path shapePath() const = 0;
     216    virtual void setShapePath(const Path&) = 0;
     217
     218    virtual WindRule shapeWindRule() const = 0;
     219    virtual void setShapeWindRule(WindRule) = 0;
    213220   
    214221    virtual GraphicsLayer::CustomAppearance customAppearance() const = 0;
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h

    r179604 r180882  
    143143    virtual void setShapeRoundedRect(const FloatRoundedRect&) override;
    144144
     145    virtual Path shapePath() const override;
     146    virtual void setShapePath(const Path&) override;
     147
     148    virtual WindRule shapeWindRule() const override;
     149    virtual void setShapeWindRule(WindRule) override;
     150
    145151    virtual GraphicsLayer::CustomAppearance customAppearance() const override { return m_customAppearance; }
    146152    virtual void updateCustomAppearance(GraphicsLayer::CustomAppearance) override;
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm

    r179604 r180882  
    350350PlatformCALayerMac::~PlatformCALayerMac()
    351351{
    352     [m_layer.get() setValue:nil forKey:platformCALayerPointer];
     352    [m_layer setValue:nil forKey:platformCALayerPointer];
    353353   
    354354    // Remove the owner pointer from the delegate in case there is a pending animationStarted event.
     
    374374{
    375375    BEGIN_BLOCK_OBJC_EXCEPTIONS
    376     [m_layer.get() setNeedsDisplay];
     376    [m_layer setNeedsDisplay];
    377377    END_BLOCK_OBJC_EXCEPTIONS
    378378}
     
    381381{
    382382    BEGIN_BLOCK_OBJC_EXCEPTIONS
    383     [m_layer.get() setNeedsDisplayInRect:dirtyRect];
     383    [m_layer setNeedsDisplayInRect:dirtyRect];
    384384    END_BLOCK_OBJC_EXCEPTIONS
    385385}
     
    404404{
    405405    BEGIN_BLOCK_OBJC_EXCEPTIONS
    406     [m_layer.get() removeFromSuperlayer];
     406    [m_layer removeFromSuperlayer];
    407407    END_BLOCK_OBJC_EXCEPTIONS
    408408}
     
    421421        [sublayers addObject:list[i]->m_layer.get()];
    422422
    423     [m_layer.get() setSublayers:sublayers];
     423    [m_layer setSublayers:sublayers];
    424424    [sublayers release];
    425425    END_BLOCK_OBJC_EXCEPTIONS
     
    429429{
    430430    BEGIN_BLOCK_OBJC_EXCEPTIONS
    431     [m_layer.get() setSublayers:nil];
     431    [m_layer setSublayers:nil];
    432432    END_BLOCK_OBJC_EXCEPTIONS
    433433}
     
    437437    BEGIN_BLOCK_OBJC_EXCEPTIONS
    438438    ASSERT(m_layer != layer.m_layer);
    439     [m_layer.get() addSublayer:layer.m_layer.get()];
     439    [m_layer addSublayer:layer.m_layer.get()];
    440440    END_BLOCK_OBJC_EXCEPTIONS
    441441}
     
    445445    BEGIN_BLOCK_OBJC_EXCEPTIONS
    446446    ASSERT(m_layer != layer.m_layer);
    447     [m_layer.get() insertSublayer:layer.m_layer.get() atIndex:index];
     447    [m_layer insertSublayer:layer.m_layer.get() atIndex:index];
    448448    END_BLOCK_OBJC_EXCEPTIONS
    449449}
     
    453453    BEGIN_BLOCK_OBJC_EXCEPTIONS
    454454    ASSERT(m_layer != layer.m_layer);
    455     [m_layer.get() replaceSublayer:reference.m_layer.get() with:layer.m_layer.get()];
     455    [m_layer replaceSublayer:reference.m_layer.get() with:layer.m_layer.get()];
    456456    END_BLOCK_OBJC_EXCEPTIONS
    457457}
     
    460460{
    461461    BEGIN_BLOCK_OBJC_EXCEPTIONS
    462     [m_layer.get() setSublayers:[source.m_layer.get() sublayers]];
     462    [m_layer setSublayers:[source.m_layer.get() sublayers]];
    463463    END_BLOCK_OBJC_EXCEPTIONS
    464464}
     
    478478     
    479479    BEGIN_BLOCK_OBJC_EXCEPTIONS
    480     [m_layer.get() addAnimation:propertyAnimation forKey:key];
     480    [m_layer addAnimation:propertyAnimation forKey:key];
    481481    END_BLOCK_OBJC_EXCEPTIONS
    482482}
     
    485485{
    486486    BEGIN_BLOCK_OBJC_EXCEPTIONS
    487     [m_layer.get() removeAnimationForKey:key];
     487    [m_layer removeAnimationForKey:key];
    488488    END_BLOCK_OBJC_EXCEPTIONS
    489489}
     
    491491PassRefPtr<PlatformCAAnimation> PlatformCALayerMac::animationForKey(const String& key)
    492492{
    493     CAPropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>([m_layer.get() animationForKey:key]);
     493    CAPropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>([m_layer animationForKey:key]);
    494494    if (!propertyAnimation)
    495495        return 0;
     
    500500{
    501501    BEGIN_BLOCK_OBJC_EXCEPTIONS
    502     [m_layer.get() setMask:layer ? layer->platformLayer() : nil];
     502    [m_layer setMask:layer ? layer->platformLayer() : nil];
    503503    END_BLOCK_OBJC_EXCEPTIONS
    504504}
     
    506506bool PlatformCALayerMac::isOpaque() const
    507507{
    508     return [m_layer.get() isOpaque];
     508    return [m_layer isOpaque];
    509509}
    510510
     
    512512{
    513513    BEGIN_BLOCK_OBJC_EXCEPTIONS
    514     [m_layer.get() setOpaque:value];
     514    [m_layer setOpaque:value];
    515515    END_BLOCK_OBJC_EXCEPTIONS
    516516}
     
    518518FloatRect PlatformCALayerMac::bounds() const
    519519{
    520     return [m_layer.get() bounds];
     520    return [m_layer bounds];
    521521}
    522522
     
    524524{
    525525    BEGIN_BLOCK_OBJC_EXCEPTIONS
    526     [m_layer.get() setBounds:value];
     526    [m_layer setBounds:value];
    527527   
    528528    if (requiresCustomAppearanceUpdateOnBoundsChange())
     
    534534FloatPoint3D PlatformCALayerMac::position() const
    535535{
    536     CGPoint point = [m_layer.get() position];
    537     return FloatPoint3D(point.x, point.y, [m_layer.get() zPosition]);
     536    CGPoint point = [m_layer position];
     537    return FloatPoint3D(point.x, point.y, [m_layer zPosition]);
    538538}
    539539
     
    541541{
    542542    BEGIN_BLOCK_OBJC_EXCEPTIONS
    543     [m_layer.get() setPosition:CGPointMake(value.x(), value.y())];
    544     [m_layer.get() setZPosition:value.z()];
     543    [m_layer setPosition:CGPointMake(value.x(), value.y())];
     544    [m_layer setZPosition:value.z()];
    545545    END_BLOCK_OBJC_EXCEPTIONS
    546546}
     
    548548FloatPoint3D PlatformCALayerMac::anchorPoint() const
    549549{
    550     CGPoint point = [m_layer.get() anchorPoint];
     550    CGPoint point = [m_layer anchorPoint];
    551551    float z = 0;
    552     z = [m_layer.get() anchorPointZ];
     552    z = [m_layer anchorPointZ];
    553553    return FloatPoint3D(point.x, point.y, z);
    554554}
     
    557557{
    558558    BEGIN_BLOCK_OBJC_EXCEPTIONS
    559     [m_layer.get() setAnchorPoint:CGPointMake(value.x(), value.y())];
    560     [m_layer.get() setAnchorPointZ:value.z()];
     559    [m_layer setAnchorPoint:CGPointMake(value.x(), value.y())];
     560    [m_layer setAnchorPointZ:value.z()];
    561561    END_BLOCK_OBJC_EXCEPTIONS
    562562}
     
    564564TransformationMatrix PlatformCALayerMac::transform() const
    565565{
    566     return [m_layer.get() transform];
     566    return [m_layer transform];
    567567}
    568568
     
    570570{
    571571    BEGIN_BLOCK_OBJC_EXCEPTIONS
    572     [m_layer.get() setTransform:value];
     572    [m_layer setTransform:value];
    573573    END_BLOCK_OBJC_EXCEPTIONS
    574574}
     
    576576TransformationMatrix PlatformCALayerMac::sublayerTransform() const
    577577{
    578     return [m_layer.get() sublayerTransform];
     578    return [m_layer sublayerTransform];
    579579}
    580580
     
    582582{
    583583    BEGIN_BLOCK_OBJC_EXCEPTIONS
    584     [m_layer.get() setSublayerTransform:value];
     584    [m_layer setSublayerTransform:value];
    585585    END_BLOCK_OBJC_EXCEPTIONS
    586586}
     
    589589{
    590590    BEGIN_BLOCK_OBJC_EXCEPTIONS
    591     [m_layer.get() setHidden:value];
     591    [m_layer setHidden:value];
    592592    END_BLOCK_OBJC_EXCEPTIONS
    593593}
     
    596596{
    597597    BEGIN_BLOCK_OBJC_EXCEPTIONS
    598     [m_layer.get() setGeometryFlipped:value];
     598    [m_layer setGeometryFlipped:value];
    599599    END_BLOCK_OBJC_EXCEPTIONS
    600600}
     
    602602bool PlatformCALayerMac::isDoubleSided() const
    603603{
    604     return [m_layer.get() isDoubleSided];
     604    return [m_layer isDoubleSided];
    605605}
    606606
     
    608608{
    609609    BEGIN_BLOCK_OBJC_EXCEPTIONS
    610     [m_layer.get() setDoubleSided:value];
     610    [m_layer setDoubleSided:value];
    611611    END_BLOCK_OBJC_EXCEPTIONS
    612612}
     
    614614bool PlatformCALayerMac::masksToBounds() const
    615615{
    616     return [m_layer.get() masksToBounds];
     616    return [m_layer masksToBounds];
    617617}
    618618
     
    620620{
    621621    BEGIN_BLOCK_OBJC_EXCEPTIONS
    622     [m_layer.get() setMasksToBounds:value];
     622    [m_layer setMasksToBounds:value];
    623623    END_BLOCK_OBJC_EXCEPTIONS
    624624}
     
    626626bool PlatformCALayerMac::acceleratesDrawing() const
    627627{
    628     return [m_layer.get() acceleratesDrawing];
     628    return [m_layer acceleratesDrawing];
    629629}
    630630
     
    632632{
    633633    BEGIN_BLOCK_OBJC_EXCEPTIONS
    634     [m_layer.get() setAcceleratesDrawing:acceleratesDrawing];
     634    [m_layer setAcceleratesDrawing:acceleratesDrawing];
    635635    END_BLOCK_OBJC_EXCEPTIONS
    636636}
     
    638638CFTypeRef PlatformCALayerMac::contents() const
    639639{
    640     return [m_layer.get() contents];
     640    return [m_layer contents];
    641641}
    642642
     
    644644{
    645645    BEGIN_BLOCK_OBJC_EXCEPTIONS
    646     [m_layer.get() setContents:static_cast<id>(const_cast<void*>(value))];
     646    [m_layer setContents:static_cast<id>(const_cast<void*>(value))];
    647647    END_BLOCK_OBJC_EXCEPTIONS
    648648}
     
    651651{
    652652    BEGIN_BLOCK_OBJC_EXCEPTIONS
    653     [m_layer.get() setContentsRect:value];
     653    [m_layer setContentsRect:value];
    654654    END_BLOCK_OBJC_EXCEPTIONS
    655655}
     
    658658{
    659659    BEGIN_BLOCK_OBJC_EXCEPTIONS
    660     [m_layer.get() setMinificationFilter:toCAFilterType(value)];
     660    [m_layer setMinificationFilter:toCAFilterType(value)];
    661661    END_BLOCK_OBJC_EXCEPTIONS
    662662}
     
    665665{
    666666    BEGIN_BLOCK_OBJC_EXCEPTIONS
    667     [m_layer.get() setMagnificationFilter:toCAFilterType(value)];
     667    [m_layer setMagnificationFilter:toCAFilterType(value)];
    668668    END_BLOCK_OBJC_EXCEPTIONS
    669669}
     
    671671Color PlatformCALayerMac::backgroundColor() const
    672672{
    673     return [m_layer.get() backgroundColor];
     673    return [m_layer backgroundColor];
    674674}
    675675
     
    683683
    684684    BEGIN_BLOCK_OBJC_EXCEPTIONS
    685     [m_layer.get() setBackgroundColor:color.get()];
     685    [m_layer setBackgroundColor:color.get()];
    686686    END_BLOCK_OBJC_EXCEPTIONS
    687687}
     
    690690{
    691691    BEGIN_BLOCK_OBJC_EXCEPTIONS
    692     [m_layer.get() setBorderWidth:value];
     692    [m_layer setBorderWidth:value];
    693693    END_BLOCK_OBJC_EXCEPTIONS
    694694}
     
    704704
    705705        BEGIN_BLOCK_OBJC_EXCEPTIONS
    706         [m_layer.get() setBorderColor:color.get()];
     706        [m_layer setBorderColor:color.get()];
    707707        END_BLOCK_OBJC_EXCEPTIONS
    708708    } else {
    709709        BEGIN_BLOCK_OBJC_EXCEPTIONS
    710         [m_layer.get() setBorderColor:nil];
     710        [m_layer setBorderColor:nil];
    711711        END_BLOCK_OBJC_EXCEPTIONS
    712712    }
     
    715715float PlatformCALayerMac::opacity() const
    716716{
    717     return [m_layer.get() opacity];
     717    return [m_layer opacity];
    718718}
    719719
     
    721721{
    722722    BEGIN_BLOCK_OBJC_EXCEPTIONS
    723     [m_layer.get() setOpacity:value];
     723    [m_layer setOpacity:value];
    724724    END_BLOCK_OBJC_EXCEPTIONS
    725725}
     
    733733{
    734734    BEGIN_BLOCK_OBJC_EXCEPTIONS
    735     [m_layer.get() setFilters:[sourceLayer.platformLayer() filters]];
     735    [m_layer setFilters:[sourceLayer.platformLayer() filters]];
    736736    END_BLOCK_OBJC_EXCEPTIONS
    737737}
     
    771771{
    772772    BEGIN_BLOCK_OBJC_EXCEPTIONS
    773     [m_layer.get() setName:value];
     773    [m_layer setName:value];
    774774    END_BLOCK_OBJC_EXCEPTIONS
    775775}
     
    778778{
    779779    BEGIN_BLOCK_OBJC_EXCEPTIONS
    780     [m_layer.get() setSpeed:value];
     780    [m_layer setSpeed:value];
    781781    END_BLOCK_OBJC_EXCEPTIONS
    782782}
     
    785785{
    786786    BEGIN_BLOCK_OBJC_EXCEPTIONS
    787     [m_layer.get() setTimeOffset:value];
     787    [m_layer setTimeOffset:value];
    788788    END_BLOCK_OBJC_EXCEPTIONS
    789789}
     
    791791float PlatformCALayerMac::contentsScale() const
    792792{
    793     return [m_layer.get() contentsScale];
     793    return [m_layer contentsScale];
    794794}
    795795
     
    797797{
    798798    BEGIN_BLOCK_OBJC_EXCEPTIONS
    799     [m_layer.get() setContentsScale:value];
     799    [m_layer setContentsScale:value];
    800800#if PLATFORM(IOS)
    801     [m_layer.get() setRasterizationScale:value];
     801    [m_layer setRasterizationScale:value];
    802802
    803803    if (m_layerType == LayerTypeWebTiledLayer) {
     
    805805        // see <rdar://problem/9434765> for more information.
    806806        static NSDictionary *optionsDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithBool:YES], kCATiledLayerRemoveImmediately, nil];
    807         [(CATiledLayer *)m_layer.get() setNeedsDisplayInRect:[m_layer.get() bounds] levelOfDetail:0 options:optionsDictionary];
     807        [(CATiledLayer *)m_layer.get() setNeedsDisplayInRect:[m_layer bounds] levelOfDetail:0 options:optionsDictionary];
    808808    }
    809809#endif
     
    813813float PlatformCALayerMac::cornerRadius() const
    814814{
    815     return [m_layer.get() cornerRadius];
     815    return [m_layer cornerRadius];
    816816}
    817817
     
    819819{
    820820    BEGIN_BLOCK_OBJC_EXCEPTIONS
    821     [m_layer.get() setCornerRadius:value];
     821    [m_layer setCornerRadius:value];
    822822    END_BLOCK_OBJC_EXCEPTIONS
    823823}
     
    826826{
    827827    BEGIN_BLOCK_OBJC_EXCEPTIONS
    828     [m_layer.get() setEdgeAntialiasingMask:mask];
     828    [m_layer setEdgeAntialiasingMask:mask];
    829829    END_BLOCK_OBJC_EXCEPTIONS
    830830}
     
    848848    shapePath.addRoundedRect(roundedRect);
    849849    [(CAShapeLayer *)m_layer setPath:shapePath.platformPath()];
     850    END_BLOCK_OBJC_EXCEPTIONS
     851}
     852
     853WindRule PlatformCALayerMac::shapeWindRule() const
     854{
     855    ASSERT(m_layerType == LayerTypeShapeLayer);
     856
     857    NSString *fillRule = [(CAShapeLayer *)m_layer fillRule];
     858    if ([fillRule isEqualToString:@"even-odd"])
     859        return RULE_EVENODD;
     860
     861    return RULE_NONZERO;
     862}
     863
     864void PlatformCALayerMac::setShapeWindRule(WindRule windRule)
     865{
     866    ASSERT(m_layerType == LayerTypeShapeLayer);
     867
     868    switch (windRule) {
     869    case RULE_NONZERO:
     870        [(CAShapeLayer *)m_layer setFillRule:@"non-zero"];
     871        break;
     872    case RULE_EVENODD:
     873        [(CAShapeLayer *)m_layer setFillRule:@"even-odd"];
     874        break;
     875    }
     876}
     877
     878Path PlatformCALayerMac::shapePath() const
     879{
     880    ASSERT(m_layerType == LayerTypeShapeLayer);
     881
     882    BEGIN_BLOCK_OBJC_EXCEPTIONS
     883    return Path(CGPathCreateMutableCopy([(CAShapeLayer *)m_layer path]));
     884    END_BLOCK_OBJC_EXCEPTIONS
     885}
     886
     887void PlatformCALayerMac::setShapePath(const Path& path)
     888{
     889    ASSERT(m_layerType == LayerTypeShapeLayer);
     890
     891    BEGIN_BLOCK_OBJC_EXCEPTIONS
     892    [(CAShapeLayer *)m_layer setPath:path.platformPath()];
    850893    END_BLOCK_OBJC_EXCEPTIONS
    851894}
     
    893936    BOOL result = NO;
    894937    BEGIN_BLOCK_OBJC_EXCEPTIONS
    895     result = [m_layer.get() isKindOfClass:[WebLayer self]];
     938    result = [m_layer isKindOfClass:[WebLayer self]];
    896939    END_BLOCK_OBJC_EXCEPTIONS
    897940    return result;
  • trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp

    r179604 r180882  
    602602}
    603603
     604WindRule PlatformCALayerWin::shapeWindRule() const
     605{
     606    // FIXME: implement.
     607    return RULE_NONZERO;
     608}
     609
     610void PlatformCALayerWin::setShapeWindRule(WindRule)
     611{
     612    // FIXME: implement.
     613}
     614
     615Path PlatformCALayerWin::shapePath() const
     616{
     617    // FIXME: implement.
     618    return Path();
     619}
     620
     621void PlatformCALayerWin::setShapePath(const Path&)
     622{
     623    // FIXME: implement.
     624}
     625
    604626#ifndef NDEBUG
    605627static void printIndent(int indent)
  • trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h

    r179604 r180882  
    129129    virtual void setShapeRoundedRect(const FloatRoundedRect&) override;
    130130
     131    virtual Path shapePath() const override;
     132    virtual void setShapePath(const Path&) override;
     133
     134    virtual WindRule shapeWindRule() const override;
     135    virtual void setShapeWindRule(WindRule) override;
     136
    131137    virtual void setEdgeAntialiasingMask(unsigned) override;
    132138
  • trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp

    r180790 r180882  
    7575
    7676Path::Path()
    77     : m_path(0)
     77    : m_path(nullptr)
    7878{
    7979}
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r180474 r180882  
    40244024}
    40254025
     4026bool RenderLayer::paintsWithClipPath() const
     4027{
     4028    return renderer().style().clipPath() && !isComposited();
     4029}
     4030
     4031Path RenderLayer::computeClipPath(const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, WindRule& windRule) const
     4032{
     4033    const RenderStyle& style = renderer().style();
     4034
     4035    if (is<ShapeClipPathOperation>(*style.clipPath())) {
     4036        auto& clipPath = downcast<ShapeClipPathOperation>(*style.clipPath());
     4037        LayoutRect referenceBox = computeReferenceBox(renderer(), clipPath, offsetFromRoot, rootRelativeBounds);
     4038
     4039        windRule = clipPath.windRule();
     4040        return clipPath.pathForReferenceRect(referenceBox);
     4041    }
     4042   
     4043    if (is<BoxClipPathOperation>(*style.clipPath()) && is<RenderBox>(renderer())) {
     4044
     4045        auto& clipPath = downcast<BoxClipPathOperation>(*style.clipPath());
     4046
     4047        RoundedRect shapeRect = computeRoundedRectForBoxShape(clipPath.referenceBox(), downcast<RenderBox>(renderer()));
     4048        shapeRect.move(offsetFromRoot);
     4049
     4050        windRule = RULE_NONZERO;
     4051        return clipPath.pathForReferenceRect(shapeRect);
     4052    }
     4053   
     4054    return Path();
     4055}
     4056
    40264057bool RenderLayer::setupClipPath(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed)
    40274058{
     
    40364067    RenderStyle& style = renderer().style();
    40374068    ASSERT(style.clipPath());
    4038     if (is<ShapeClipPathOperation>(*style.clipPath())) {
    4039         auto& clipPath = downcast<ShapeClipPathOperation>(*style.clipPath());
    4040 
    4041         LayoutRect referenceBox = computeReferenceBox(renderer(), clipPath, offsetFromRoot, rootRelativeBounds);
     4069    if (is<ShapeClipPathOperation>(*style.clipPath()) || (is<BoxClipPathOperation>(*style.clipPath()) && is<RenderBox>(renderer()))) {
     4070        WindRule windRule;
     4071        Path path = computeClipPath(offsetFromRoot, rootRelativeBounds, windRule);
    40424072        context->save();
    4043         context->clipPath(clipPath.pathForReferenceRect(referenceBox), clipPath.windRule());
    4044         return true;
    4045     }
    4046 
    4047     if (is<BoxClipPathOperation>(*style.clipPath()) && is<RenderBox>(renderer())) {
    4048         auto& clipPath = downcast<BoxClipPathOperation>(*style.clipPath());
    4049 
    4050         RoundedRect shapeRect = computeRoundedRectForBoxShape(clipPath.referenceBox(), downcast<RenderBox>(renderer()));
    4051         shapeRect.move(offsetFromRoot);
    4052 
    4053         context->save();
    4054         context->clipPath(clipPath.pathForReferenceRect(shapeRect), RULE_NONZERO);
     4073        context->clipPath(path, windRule);
    40554074        return true;
    40564075    }
     
    42194238    if (renderer().flowThreadContainingBlock() && (renderer().hasClipPath() || hasFilterThatIsPainting(context, paintFlags)))
    42204239        columnAwareOffsetFromRoot = toLayoutSize(convertToLayerCoords(paintingInfo.rootLayer, LayoutPoint(), AdjustForColumns));
    4221     bool hasClipPath = setupClipPath(context, paintingInfo, columnAwareOffsetFromRoot, rootRelativeBounds, rootRelativeBoundsComputed);
     4240
     4241    bool hasClipPath = false;
     4242    if (paintsWithClipPath() || (localPaintFlags & PaintLayerPaintingCompositingClipPathPhase) || (localPaintFlags & PaintLayerPaintingCompositingMaskPhase))
     4243        hasClipPath = setupClipPath(context, paintingInfo, columnAwareOffsetFromRoot, rootRelativeBounds, rootRelativeBoundsComputed);
    42224244
    42234245    LayerPaintingInfo localPaintingInfo(paintingInfo);
     
    43204342    }
    43214343
     4344    if ((localPaintFlags & PaintLayerPaintingCompositingClipPathPhase) && shouldPaintContent && !selectionOnly) {
     4345        // Re-use paintChildClippingMaskForFragments to paint black for the compositing clipping mask.
     4346        paintChildClippingMaskForFragments(layerFragments, context, localPaintingInfo, subtreePaintRootForRenderer);
     4347    }
     4348   
    43224349    if ((localPaintFlags & PaintLayerPaintingChildClippingMaskPhase) && shouldPaintContent && !selectionOnly) {
    43234350        // Paint the border radius mask for the fragments.
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r178533 r180882  
    429429
    430430    enum PaintLayerFlag {
    431         PaintLayerHaveTransparency = 1,
    432         PaintLayerAppliedTransform = 1 << 1,
    433         PaintLayerTemporaryClipRects = 1 << 2,
    434         PaintLayerPaintingReflection = 1 << 3,
    435         PaintLayerPaintingOverlayScrollbars = 1 << 4,
    436         PaintLayerPaintingCompositingBackgroundPhase = 1 << 5,
    437         PaintLayerPaintingCompositingForegroundPhase = 1 << 6,
    438         PaintLayerPaintingCompositingMaskPhase = 1 << 7,
    439         PaintLayerPaintingCompositingScrollingPhase = 1 << 8,
    440         PaintLayerPaintingOverflowContents = 1 << 9,
    441         PaintLayerPaintingRootBackgroundOnly = 1 << 10,
    442         PaintLayerPaintingSkipRootBackground = 1 << 11,
    443         PaintLayerPaintingChildClippingMaskPhase = 1 << 12,
    444         PaintLayerPaintingCompositingAllPhases = (PaintLayerPaintingCompositingBackgroundPhase | PaintLayerPaintingCompositingForegroundPhase | PaintLayerPaintingCompositingMaskPhase)
     431        PaintLayerHaveTransparency                      = 1 << 0,
     432        PaintLayerAppliedTransform                      = 1 << 1,
     433        PaintLayerTemporaryClipRects                    = 1 << 2,
     434        PaintLayerPaintingReflection                    = 1 << 3,
     435        PaintLayerPaintingOverlayScrollbars             = 1 << 4,
     436        PaintLayerPaintingCompositingBackgroundPhase    = 1 << 5,
     437        PaintLayerPaintingCompositingForegroundPhase    = 1 << 6,
     438        PaintLayerPaintingCompositingMaskPhase          = 1 << 7,
     439        PaintLayerPaintingCompositingClipPathPhase      = 1 << 8,
     440        PaintLayerPaintingCompositingScrollingPhase     = 1 << 9,
     441        PaintLayerPaintingOverflowContents              = 1 << 10,
     442        PaintLayerPaintingRootBackgroundOnly            = 1 << 11,
     443        PaintLayerPaintingSkipRootBackground            = 1 << 12,
     444        PaintLayerPaintingChildClippingMaskPhase        = 1 << 13,
     445        PaintLayerPaintingCompositingAllPhases          = PaintLayerPaintingCompositingBackgroundPhase | PaintLayerPaintingCompositingForegroundPhase | PaintLayerPaintingCompositingMaskPhase
    445446    };
    446447   
     
    753754
    754755    bool setupFontSubpixelQuantization(GraphicsContext*, bool& didQuantizeFonts);
     756
     757    bool paintsWithClipPath() const;
     758
     759    Path computeClipPath(const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, WindRule&) const;
     760
    755761    bool setupClipPath(GraphicsContext*, const LayerPaintingInfo&, const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed);
    756762
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r180580 r180882  
    150150    updateForegroundLayer(false);
    151151    updateBackgroundLayer(false);
    152     updateMaskLayer(false);
     152    updateMaskingLayer(false, false);
    153153    updateScrollingLayers(false);
    154154    detachFromScrollingCoordinator();
     
    571571    }
    572572
    573     updateMaskLayer(renderer().hasMask());
     573    updateMaskingLayer(renderer().hasMask(), renderer().hasClipPath());
    574574
    575575    updateChildClippingStrategy(needsDescendantsClippingLayer);
     
    828828    }
    829829   
    830     if (m_maskLayer) {
    831         m_maskLayer->setSize(m_graphicsLayer->size());
    832         m_maskLayer->setPosition(FloatPoint());
    833         m_maskLayer->setOffsetFromRenderer(m_graphicsLayer->offsetFromRenderer());
    834     }
     830    if (m_maskLayer)
     831        updateMaskingLayerGeometry();
    835832   
    836833    if (m_owningLayer.renderer().hasTransformRelatedProperty()) {
     
    10061003}
    10071004
     1005// FIXME: Avoid repaints when clip path changes.
     1006void RenderLayerBacking::updateMaskingLayerGeometry()
     1007{
     1008    m_maskLayer->setSize(m_graphicsLayer->size());
     1009    m_maskLayer->setPosition(FloatPoint());
     1010    m_maskLayer->setOffsetFromRenderer(m_graphicsLayer->offsetFromRenderer());
     1011   
     1012    if (!m_maskLayer->drawsContent()) {
     1013        if (renderer().hasClipPath()) {
     1014            ASSERT(renderer().style().clipPath()->type() != ClipPathOperation::Reference);
     1015
     1016            WindRule windRule;
     1017            // FIXME: Use correct reference box for inlines: https://bugs.webkit.org/show_bug.cgi?id=129047
     1018            LayoutRect referenceBoxForClippedInline = m_owningLayer.boundingBox(&m_owningLayer);
     1019            Path clipPath = m_owningLayer.computeClipPath(LayoutSize(), referenceBoxForClippedInline, windRule);
     1020
     1021            m_maskLayer->setShapeLayerPath(clipPath);
     1022            m_maskLayer->setShapeLayerWindRule(windRule);
     1023        }
     1024    }
     1025}
     1026
    10081027void RenderLayerBacking::adjustAncestorCompositingBoundsForFlowThread(LayoutRect& ancestorCompositingBounds, const RenderLayer* compositingAncestor) const
    10091028{
     
    14101429}
    14111430
    1412 void RenderLayerBacking::updateMaskLayer(bool needsMaskLayer)
     1431// Masking layer is used for masks or clip-path.
     1432void RenderLayerBacking::updateMaskingLayer(bool hasMask, bool hasClipPath)
    14131433{
    14141434    bool layerChanged = false;
    1415     if (needsMaskLayer) {
     1435    if (hasMask || hasClipPath) {
     1436        GraphicsLayerPaintingPhase maskPhases = 0;
     1437        if (hasMask)
     1438            maskPhases = GraphicsLayerPaintMask;
     1439       
     1440        if (hasClipPath) {
     1441            bool clipNeedsPainting = renderer().style().clipPath()->type() == ClipPathOperation::Reference;
     1442            if (clipNeedsPainting || !GraphicsLayer::supportsLayerType(GraphicsLayer::Type::Shape))
     1443                maskPhases |= GraphicsLayerPaintClipPath;
     1444        }
     1445
     1446        bool paintsContent = maskPhases;
     1447        GraphicsLayer::Type requiredLayerType = paintsContent ? GraphicsLayer::Type::Normal : GraphicsLayer::Type::Shape;
     1448        if (m_maskLayer && m_maskLayer->type() != requiredLayerType) {
     1449            m_graphicsLayer->setMaskLayer(nullptr);
     1450            willDestroyLayer(m_maskLayer.get());
     1451            m_maskLayer = nullptr;
     1452        }
     1453
    14161454        if (!m_maskLayer) {
    1417             m_maskLayer = createGraphicsLayer("Mask");
    1418             m_maskLayer->setDrawsContent(true);
    1419             m_maskLayer->setPaintingPhase(GraphicsLayerPaintMask);
     1455            m_maskLayer = createGraphicsLayer("Mask", requiredLayerType);
     1456            m_maskLayer->setDrawsContent(paintsContent);
     1457            m_maskLayer->setPaintingPhase(maskPhases);
    14201458            layerChanged = true;
    14211459            m_graphicsLayer->setMaskLayer(m_maskLayer.get());
     
    15281566    if (!m_foregroundLayer)
    15291567        phase |= GraphicsLayerPaintForeground;
    1530     if (!m_maskLayer)
    1531         phase |= GraphicsLayerPaintMask;
    15321568
    15331569    if (m_scrollingContentsLayer) {
     
    21932229    if (paintingPhase & GraphicsLayerPaintMask)
    21942230        paintFlags |= RenderLayer::PaintLayerPaintingCompositingMaskPhase;
     2231    if (paintingPhase & GraphicsLayerPaintClipPath)
     2232        paintFlags |= RenderLayer::PaintLayerPaintingCompositingClipPathPhase;
    21952233    if (paintingPhase & GraphicsLayerPaintChildClippingMask)
    21962234        paintFlags |= RenderLayer::PaintLayerPaintingChildClippingMaskPhase;
  • trunk/Source/WebCore/rendering/RenderLayerBacking.h

    r179604 r180882  
    267267    bool updateForegroundLayer(bool needsForegroundLayer);
    268268    bool updateBackgroundLayer(bool needsBackgroundLayer);
    269     void updateMaskLayer(bool needsMaskLayer);
     269    void updateMaskingLayer(bool hasMask, bool hasClipPath);
    270270    bool requiresHorizontalScrollbarLayer() const;
    271271    bool requiresVerticalScrollbarLayer() const;
     
    274274    void updateDrawsContent(bool isSimpleContainer);
    275275    void updateChildClippingStrategy(bool needsDescendantsClippingLayer);
     276
     277    void updateMaskingLayerGeometry();
    276278   
    277279    void updateRootLayerConfiguration();
     
    340342    std::unique_ptr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need to draw the background separately.
    341343    std::unique_ptr<GraphicsLayer> m_childContainmentLayer; // Only used if we have clipping on a stacking context with compositing children, or if the layer has a tile cache.
    342     std::unique_ptr<GraphicsLayer> m_maskLayer; // Only used if we have a mask.
     344    std::unique_ptr<GraphicsLayer> m_maskLayer; // Only used if we have a mask and/or clip-path.
    343345    std::unique_ptr<GraphicsLayer> m_childClippingMaskLayer; // Only used if we have to clip child layers or accelerated contents with border radius or clip-path.
    344346
  • trunk/Source/WebKit2/ChangeLog

    r180871 r180882  
     12015-03-01  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make clip-path work on <video>, <canvas> etc.
     4        https://bugs.webkit.org/show_bug.cgi?id=138684
     5
     6        Reviewed by Darin Adler.
     7       
     8        Support encode/decode for WebCore Path objects, which is done by traversing
     9        the path.
     10
     11        * Shared/WebCoreArgumentCoders.cpp:
     12        (IPC::pathPointCountApplierFunction):
     13        (IPC::pathEncodeApplierFunction):
     14        (IPC::ArgumentCoder<Path>::encode):
     15        (IPC::ArgumentCoder<Path>::decode):
     16        * Shared/WebCoreArgumentCoders.h:
     17        * Shared/mac/RemoteLayerTreePropertyApplier.mm:
     18        (WebKit::applyPropertiesToLayer): Actually apply the path and wind rule to the shape layer.
     19        * Shared/mac/RemoteLayerTreeTransaction.h: Include path and wind rule in the layer properties.
     20        * Shared/mac/RemoteLayerTreeTransaction.mm:
     21        (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
     22        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode): Encode shape and wind rule.
     23        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode): Decode shape and wind rule.
     24        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
     25        (WebKit::PlatformCALayerRemote::shapePath):
     26        (WebKit::PlatformCALayerRemote::setShapePath):
     27        (WebKit::PlatformCALayerRemote::shapeWindRule):
     28        (WebKit::PlatformCALayerRemote::setShapeWindRule):
     29        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
     30
    1312015-03-01  Chris Dumez  <cdumez@apple.com>
    232
  • trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp

    r178820 r180882  
    5050#include <WebCore/Image.h>
    5151#include <WebCore/Length.h>
     52#include <WebCore/Path.h>
    5253#include <WebCore/PluginData.h>
    5354#include <WebCore/ProtectionSpace.h>
     
    365366}
    366367
     368static void pathPointCountApplierFunction(void* info, const PathElement* element)
     369{
     370    uint64_t* pointCount = static_cast<uint64_t*>(info);
     371    ++*pointCount;
     372}
     373
     374static void pathEncodeApplierFunction(void* info, const PathElement* element)
     375{
     376    ArgumentEncoder& encoder = *static_cast<ArgumentEncoder*>(info);
     377
     378    encoder.encodeEnum(element->type);
     379
     380    switch (element->type) {
     381    case PathElementMoveToPoint: // The points member will contain 1 value.
     382        encoder << element->points[0];
     383        break;
     384    case PathElementAddLineToPoint: // The points member will contain 1 value.
     385        encoder << element->points[0];
     386        break;
     387    case PathElementAddQuadCurveToPoint: // The points member will contain 2 values.
     388        encoder << element->points[0];
     389        encoder << element->points[1];
     390        break;
     391    case PathElementAddCurveToPoint: // The points member will contain 3 values.
     392        encoder << element->points[0];
     393        encoder << element->points[1];
     394        encoder << element->points[2];
     395        break;
     396    case PathElementCloseSubpath: // The points member will contain no values.
     397        break;
     398    }
     399}
     400
     401void ArgumentCoder<Path>::encode(ArgumentEncoder& encoder, const Path& path)
     402{
     403    uint64_t numPoints = 0;
     404    path.apply(&numPoints, pathPointCountApplierFunction);
     405
     406    encoder << numPoints;
     407
     408    path.apply(&encoder, pathEncodeApplierFunction);
     409}
     410
     411bool ArgumentCoder<Path>::decode(ArgumentDecoder& decoder, Path& path)
     412{
     413    uint64_t numPoints;
     414    if (!decoder.decode(numPoints))
     415        return false;
     416   
     417    path.clear();
     418
     419    for (uint64_t i = 0; i < numPoints; ++i) {
     420   
     421        PathElementType elementType;
     422        if (!decoder.decodeEnum(elementType))
     423            return false;
     424       
     425        switch (elementType) {
     426        case PathElementMoveToPoint: { // The points member will contain 1 value.
     427            FloatPoint point;
     428            if (!decoder.decode(point))
     429                return false;
     430            path.moveTo(point);
     431            break;
     432        }
     433        case PathElementAddLineToPoint: { // The points member will contain 1 value.
     434            FloatPoint point;
     435            if (!decoder.decode(point))
     436                return false;
     437            path.addLineTo(point);
     438            break;
     439        }
     440        case PathElementAddQuadCurveToPoint: { // The points member will contain 2 values.
     441            FloatPoint controlPoint;
     442            if (!decoder.decode(controlPoint))
     443                return false;
     444
     445            FloatPoint endPoint;
     446            if (!decoder.decode(endPoint))
     447                return false;
     448
     449            path.addQuadCurveTo(controlPoint, endPoint);
     450            break;
     451        }
     452        case PathElementAddCurveToPoint: { // The points member will contain 3 values.
     453            FloatPoint controlPoint1;
     454            if (!decoder.decode(controlPoint1))
     455                return false;
     456
     457            FloatPoint controlPoint2;
     458            if (!decoder.decode(controlPoint2))
     459                return false;
     460
     461            FloatPoint endPoint;
     462            if (!decoder.decode(endPoint))
     463                return false;
     464
     465            path.addBezierCurveTo(controlPoint1, controlPoint2, endPoint);
     466            break;
     467        }
     468        case PathElementCloseSubpath: // The points member will contain no values.
     469            path.closeSubpath();
     470            break;
     471        }
     472    }
     473
     474    return true;
     475}
     476
    367477template<> struct ArgumentCoder<Region::Span> {
    368478    static void encode(ArgumentEncoder&, const Region::Span&);
  • trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h

    r177593 r180882  
    5555class LinearTimingFunction;
    5656class Notification;
     57class Path;
    5758class ProtectionSpace;
    5859class Region;
     
    199200};
    200201
     202template<> struct ArgumentCoder<WebCore::Path> {
     203    static void encode(ArgumentEncoder&, const WebCore::Path&);
     204    static bool decode(ArgumentDecoder&, WebCore::Path&);
     205};
     206
    201207template<> struct ArgumentCoder<WebCore::Region> {
    202208    static void encode(ArgumentEncoder&, const WebCore::Region&);
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm

    r177214 r180882  
    198198    }
    199199
     200    if (properties.changedProperties & RemoteLayerTreeTransaction::ShapePathChanged) {
     201        ASSERT([layer isKindOfClass:[CAShapeLayer class]]);
     202        [(CAShapeLayer *)layer setPath:properties.shapePath.platformPath()];
     203    }
     204
    200205    if (properties.changedProperties & RemoteLayerTreeTransaction::MinificationFilterChanged)
    201206        layer.minificationFilter = toCAFilterType(properties.minificationFilter);
     
    206211    if (properties.changedProperties & RemoteLayerTreeTransaction::BlendModeChanged)
    207212        PlatformCAFilters::setBlendingFiltersOnLayer(layer, properties.blendMode);
     213
     214    if (properties.changedProperties & RemoteLayerTreeTransaction::WindRuleChanged) {
     215        ASSERT([layer isKindOfClass:[CAShapeLayer class]]);
     216        CAShapeLayer *shapeLayer = (CAShapeLayer *)layer;
     217        switch (properties.windRule) {
     218        case RULE_NONZERO:
     219            shapeLayer.fillRule = @"non-zero";
     220            break;
     221        case RULE_EVENODD:
     222            shapeLayer.fillRule = @"even-odd";
     223            break;
     224        }
     225    }
    208226
    209227    if (properties.changedProperties & RemoteLayerTreeTransaction::SpeedChanged)
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h

    r179604 r180882  
    7474        CornerRadiusChanged             = 1LLU << 21,
    7575        ShapeRoundedRectChanged         = 1LLU << 22,
    76         MinificationFilterChanged       = 1LLU << 23,
    77         MagnificationFilterChanged      = 1LLU << 24,
    78         BlendModeChanged                = 1LLU << 25,
    79         SpeedChanged                    = 1LLU << 26,
    80         TimeOffsetChanged               = 1LLU << 27,
    81         BackingStoreChanged             = 1LLU << 28,
    82         FiltersChanged                  = 1LLU << 29,
    83         AnimationsChanged               = 1LLU << 30,
    84         EdgeAntialiasingMaskChanged     = 1LLU << 31,
    85         CustomAppearanceChanged         = 1LLU << 32
     76        ShapePathChanged                = 1LLU << 23,
     77        MinificationFilterChanged       = 1LLU << 24,
     78        MagnificationFilterChanged      = 1LLU << 25,
     79        BlendModeChanged                = 1LLU << 26,
     80        WindRuleChanged                 = 1LLU << 27,
     81        SpeedChanged                    = 1LLU << 28,
     82        TimeOffsetChanged               = 1LLU << 29,
     83        BackingStoreChanged             = 1LLU << 30,
     84        FiltersChanged                  = 1LLU << 31,
     85        AnimationsChanged               = 1LLU << 32,
     86        EdgeAntialiasingMaskChanged     = 1LLU << 33,
     87        CustomAppearanceChanged         = 1LLU << 34
    8688    };
    8789    typedef uint64_t LayerChange;
     
    137139        std::unique_ptr<RemoteLayerBackingStore> backingStore;
    138140        std::unique_ptr<WebCore::FilterOperations> filters;
     141        WebCore::Path shapePath;
    139142        WebCore::GraphicsLayer::PlatformLayerID maskLayerID;
    140143        WebCore::GraphicsLayer::PlatformLayerID clonedLayerID;
     
    152155        WebCore::PlatformCALayer::FilterType magnificationFilter;
    153156        WebCore::BlendMode blendMode;
     157        WebCore::WindRule windRule;
    154158        bool hidden;
    155159        bool geometryFlipped;
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm

    r179604 r180882  
    9797    , magnificationFilter(PlatformCALayer::FilterType::Linear)
    9898    , blendMode(BlendModeNormal)
     99    , windRule(RULE_NONZERO)
    99100    , hidden(false)
    100101    , geometryFlipped(false)
     
    116117    , bounds(other.bounds)
    117118    , contentsRect(other.contentsRect)
     119    , shapePath(other.shapePath)
    118120    , maskLayerID(other.maskLayerID)
    119121    , clonedLayerID(other.clonedLayerID)
     
    131133    , magnificationFilter(other.magnificationFilter)
    132134    , blendMode(other.blendMode)
     135    , windRule(other.windRule)
    133136    , hidden(other.hidden)
    134137    , geometryFlipped(other.geometryFlipped)
     
    225228        encoder << *shapeRoundedRect;
    226229
     230    if (changedProperties & ShapePathChanged)
     231        encoder << shapePath;
     232
    227233    if (changedProperties & MinificationFilterChanged)
    228234        encoder.encodeEnum(minificationFilter);
     
    233239    if (changedProperties & BlendModeChanged)
    234240        encoder.encodeEnum(blendMode);
     241
     242    if (changedProperties & WindRuleChanged)
     243        encoder.encodeEnum(windRule);
    235244
    236245    if (changedProperties & SpeedChanged)
     
    394403    }
    395404
     405    if (result.changedProperties & ShapePathChanged) {
     406        Path path;
     407        if (!decoder.decode(path))
     408            return false;
     409       
     410        result.shapePath = WTF::move(path);
     411    }
     412
    396413    if (result.changedProperties & MinificationFilterChanged) {
    397414        if (!decoder.decodeEnum(result.minificationFilter))
     
    406423    if (result.changedProperties & BlendModeChanged) {
    407424        if (!decoder.decodeEnum(result.blendMode))
     425            return false;
     426    }
     427
     428    if (result.changedProperties & WindRuleChanged) {
     429        if (!decoder.decodeEnum(result.windRule))
    408430            return false;
    409431    }
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp

    r179791 r180882  
    706706}
    707707
     708Path PlatformCALayerRemote::shapePath() const
     709{
     710    ASSERT(m_layerType == LayerTypeShapeLayer);
     711    return m_properties.shapePath;
     712}
     713
     714void PlatformCALayerRemote::setShapePath(const Path& path)
     715{
     716    ASSERT(m_layerType == LayerTypeShapeLayer);
     717    m_properties.shapePath = path;
     718    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ShapePathChanged);
     719}
     720
     721WindRule PlatformCALayerRemote::shapeWindRule() const
     722{
     723    ASSERT(m_layerType == LayerTypeShapeLayer);
     724    return m_properties.windRule;
     725}
     726
     727void PlatformCALayerRemote::setShapeWindRule(WindRule windRule)
     728{
     729    ASSERT(m_layerType == LayerTypeShapeLayer);
     730    m_properties.windRule = windRule;
     731    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::WindRuleChanged);
     732}
     733
    708734bool PlatformCALayerRemote::requiresCustomAppearanceUpdateOnBoundsChange() const
    709735{
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h

    r179604 r180882  
    145145    virtual void setEdgeAntialiasingMask(unsigned) override;
    146146
     147    // FIXME: Having both shapeRoundedRect and shapePath is redundant. We could use shapePath for everything.
    147148    virtual WebCore::FloatRoundedRect shapeRoundedRect() const override;
    148149    virtual void setShapeRoundedRect(const WebCore::FloatRoundedRect&) override;
     150
     151    virtual WebCore::Path shapePath() const override;
     152    virtual void setShapePath(const WebCore::Path&) override;
     153
     154    virtual WebCore::WindRule shapeWindRule() const override;
     155    virtual void setShapeWindRule(WebCore::WindRule) override;
    149156
    150157    virtual WebCore::GraphicsLayer::CustomAppearance customAppearance() const override;
Note: See TracChangeset for help on using the changeset viewer.