Changeset 180882 in webkit
- Timestamp:
- Mar 1, 2015 10:35:20 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r180879 r180882 1 2015-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 1 20 2015-03-01 Gyuyoung Kim <gyuyoung.kim@samsung.com> 2 21 -
trunk/Source/WebCore/ChangeLog
r180881 r180882 1 2015-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 1 140 2015-03-01 Hunseop Jeong <hs85.jeong@samsung.com> 2 141 -
trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp
r179604 r180882 72 72 } 73 73 74 GraphicsLayer::GraphicsLayer(Type, GraphicsLayerClient& client) 74 #if !USE(CA) 75 bool 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 89 bool 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) 100 bool GraphicsLayer::supportsContentsTiling() 101 { 102 // FIXME: Enable the feature on different ports. 103 return false; 104 } 105 #endif 106 107 GraphicsLayer::GraphicsLayer(Type type, GraphicsLayerClient& client) 75 108 : m_client(client) 76 109 , m_anchorPoint(0.5f, 0.5f, 0) … … 80 113 , m_blendMode(BlendModeNormal) 81 114 #endif 115 , m_type(type) 82 116 , m_contentsOpaque(false) 83 117 , m_preserves3D(false) … … 273 307 274 308 m_maskLayer = layer; 309 } 310 311 Path GraphicsLayer::shapeLayerPath() const 312 { 313 #if USE(CA) 314 return m_shapeLayerPath; 315 #else 316 return Path(); 317 #endif 318 } 319 320 void GraphicsLayer::setShapeLayerPath(const Path& path) 321 { 322 #if USE(CA) 323 m_shapeLayerPath = path; 324 #else 325 UNUSED_PARAM(path); 326 #endif 327 } 328 329 WindRule GraphicsLayer::shapeLayerWindRule() const 330 { 331 #if USE(CA) 332 return m_shapeLayerWindRule; 333 #else 334 return RULE_NONZERO; 335 #endif 336 } 337 338 void GraphicsLayer::setShapeLayerWindRule(WindRule windRule) 339 { 340 #if USE(CA) 341 m_shapeLayerWindRule = windRule; 342 #else 343 UNUSED_PARAM(windRule); 344 #endif 275 345 } 276 346 -
trunk/Source/WebCore/platform/graphics/GraphicsLayer.h
r180580 r180882 36 36 #include "GraphicsLayerClient.h" 37 37 #include "IntRect.h" 38 #include "Path.h" 38 39 #include "PlatformLayer.h" 39 40 #include "TransformOperations.h" 41 #include "WindRule.h" 40 42 #include <wtf/TypeCasts.h> 41 43 … … 199 201 Normal, 200 202 PageTiledBacking, 201 Scrolling 203 Scrolling, 204 Shape 202 205 }; 203 206 … … 205 208 206 209 WEBCORE_EXPORT virtual ~GraphicsLayer(); 210 211 Type type() const { return m_type; } 207 212 208 213 virtual void initialize(Type) { } … … 381 386 FloatRoundedRect maskToBoundsRect() const { return m_masksToBoundsRect; }; 382 387 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); 383 394 384 395 // Transitions are identified by a special animation name that cannot clash with a keyframe identifier. … … 481 492 void addRepaintRect(const FloatRect&); 482 493 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); 493 496 static bool supportsContentsTiling(); 494 #else495 static bool supportsContentsTiling()496 {497 // FIXME: Enable the feature on different ports.498 return false;499 }500 #endif501 497 502 498 void updateDebugIndicators(); … … 507 503 virtual bool isGraphicsLayerCARemote() const { return false; } 508 504 virtual bool isGraphicsLayerTextureMapper() const { return false; } 509 510 virtual bool needsClippingMaskLayer() { return true; };511 505 512 506 protected: … … 570 564 BlendMode m_blendMode; 571 565 #endif 566 567 const Type m_type; 572 568 573 569 bool m_contentsOpaque : 1; … … 605 601 int m_repaintCount; 606 602 CustomAppearance m_customAppearance; 603 604 #if USE(CA) 605 Path m_shapeLayerPath; 606 WindRule m_shapeLayerWindRule { RULE_NONZERO }; 607 #endif 607 608 }; 608 609 -
trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h
r179604 r180882 40 40 41 41 enum 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 49 50 }; 50 51 typedef unsigned GraphicsLayerPaintingPhase; … … 59 60 60 61 enum 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, 69 70 }; 70 71 typedef unsigned LayerTreeAsTextBehavior; -
trunk/Source/WebCore/platform/graphics/Path.h
r180790 r180882 91 91 WEBCORE_EXPORT ~Path(); 92 92 93 Path(const Path&);94 Path& operator=(const Path&);93 WEBCORE_EXPORT Path(const Path&); 94 WEBCORE_EXPORT Path& operator=(const Path&); 95 95 96 96 bool contains(const FloatPoint&, WindRule rule = RULE_NONZERO) const; … … 106 106 float normalAngleAtLength(float length, bool& ok) const; 107 107 108 void clear();108 WEBCORE_EXPORT void clear(); 109 109 bool isNull() const { return !m_path; } 110 110 bool isEmpty() const; … … 114 114 FloatPoint currentPoint() const; 115 115 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); 120 120 void addArcTo(const FloatPoint&, const FloatPoint&, float radius); 121 void closeSubpath();121 WEBCORE_EXPORT void closeSubpath(); 122 122 123 123 void addArc(const FloatPoint&, float radius, float startAngle, float endAngle, bool anticlockwise); … … 145 145 PlatformPathPtr ensurePlatformPath(); 146 146 147 void apply(void* info, PathApplierFunction) const;147 WEBCORE_EXPORT void apply(void* info, PathApplierFunction) const; 148 148 void transform(const AffineTransform&); 149 149 -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
r179784 r180882 277 277 } 278 278 279 bool 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 298 bool GraphicsLayer::supportsBackgroundColorContent() 299 { 300 return true; 301 } 302 279 303 std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType) 280 304 { … … 352 376 platformLayerType = PlatformCALayer::LayerType::LayerTypeScrollingLayer; 353 377 break; 378 case Type::Shape: 379 platformLayerType = PlatformCALayer::LayerType::LayerTypeShapeLayer; 380 break; 354 381 } 355 382 m_layer = createPlatformCALayer(platformLayerType, this); … … 806 833 noteLayerPropertyChanged(MasksToBoundsRectChanged); 807 834 return true; 835 } 836 837 void 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 844 void GraphicsLayerCA::setShapeLayerWindRule(WindRule windRule) 845 { 846 if (windRule == m_shapeLayerWindRule) 847 return; 848 849 GraphicsLayer::setShapeLayerWindRule(windRule); 850 noteLayerPropertyChanged(WindRuleChanged); 808 851 } 809 852 … … 1372 1415 #endif 1373 1416 1417 if (m_uncommittedChanges & ShapeChanged) 1418 updateShape(); 1419 1420 if (m_uncommittedChanges & WindRuleChanged) 1421 updateWindRule(); 1422 1374 1423 if (m_uncommittedChanges & AnimationChanged) 1375 1424 updateAnimations(); … … 1730 1779 } 1731 1780 #endif 1781 1782 void GraphicsLayerCA::updateShape() 1783 { 1784 m_layer->setShapePath(m_shapeLayerPath); 1785 } 1786 1787 void GraphicsLayerCA::updateWindRule() 1788 { 1789 m_layer->setShapeWindRule(m_shapeLayerWindRule); 1790 } 1732 1791 1733 1792 void GraphicsLayerCA::updateStructuralLayer() -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
r179604 r180882 121 121 WEBCORE_EXPORT virtual bool setMasksToBoundsRect(const FloatRoundedRect&) override; 122 122 123 WEBCORE_EXPORT virtual void setShapeLayerPath(const Path&); 124 WEBCORE_EXPORT virtual void setShapeLayerWindRule(WindRule); 125 123 126 WEBCORE_EXPORT virtual void suspendAnimations(double time) override; 124 127 WEBCORE_EXPORT virtual void resumeAnimations() override; … … 204 207 205 208 WEBCORE_EXPORT void layerDidDisplay(PlatformCALayer*); 206 void updateOpacityOnLayer();207 void updateFilters();208 void updateBackdropFilters();209 210 #if ENABLE(CSS_COMPOSITING)211 void updateBlendMode();212 #endif213 209 214 210 virtual PassRefPtr<PlatformCALayer> createPlatformCALayer(PlatformCALayer::LayerType, PlatformCALayerClient* owner); … … 384 380 void updateContentsScale(float pageScaleFactor); 385 381 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(); 386 393 387 394 enum StructuralLayerPurpose { … … 449 456 CustomAppearanceChanged = 1LLU << 32, 450 457 BlendModeChanged = 1LLU << 33, 458 ShapeChanged = 1LLU << 34, 459 WindRuleChanged = 1LLU << 35, 451 460 }; 452 461 typedef uint64_t LayerChangeFlags; -
trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h
r180301 r180882 211 211 virtual FloatRoundedRect shapeRoundedRect() const = 0; 212 212 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; 213 220 214 221 virtual GraphicsLayer::CustomAppearance customAppearance() const = 0; -
trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h
r179604 r180882 143 143 virtual void setShapeRoundedRect(const FloatRoundedRect&) override; 144 144 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 145 151 virtual GraphicsLayer::CustomAppearance customAppearance() const override { return m_customAppearance; } 146 152 virtual void updateCustomAppearance(GraphicsLayer::CustomAppearance) override; -
trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
r179604 r180882 350 350 PlatformCALayerMac::~PlatformCALayerMac() 351 351 { 352 [m_layer .get()setValue:nil forKey:platformCALayerPointer];352 [m_layer setValue:nil forKey:platformCALayerPointer]; 353 353 354 354 // Remove the owner pointer from the delegate in case there is a pending animationStarted event. … … 374 374 { 375 375 BEGIN_BLOCK_OBJC_EXCEPTIONS 376 [m_layer .get()setNeedsDisplay];376 [m_layer setNeedsDisplay]; 377 377 END_BLOCK_OBJC_EXCEPTIONS 378 378 } … … 381 381 { 382 382 BEGIN_BLOCK_OBJC_EXCEPTIONS 383 [m_layer .get()setNeedsDisplayInRect:dirtyRect];383 [m_layer setNeedsDisplayInRect:dirtyRect]; 384 384 END_BLOCK_OBJC_EXCEPTIONS 385 385 } … … 404 404 { 405 405 BEGIN_BLOCK_OBJC_EXCEPTIONS 406 [m_layer .get()removeFromSuperlayer];406 [m_layer removeFromSuperlayer]; 407 407 END_BLOCK_OBJC_EXCEPTIONS 408 408 } … … 421 421 [sublayers addObject:list[i]->m_layer.get()]; 422 422 423 [m_layer .get()setSublayers:sublayers];423 [m_layer setSublayers:sublayers]; 424 424 [sublayers release]; 425 425 END_BLOCK_OBJC_EXCEPTIONS … … 429 429 { 430 430 BEGIN_BLOCK_OBJC_EXCEPTIONS 431 [m_layer .get()setSublayers:nil];431 [m_layer setSublayers:nil]; 432 432 END_BLOCK_OBJC_EXCEPTIONS 433 433 } … … 437 437 BEGIN_BLOCK_OBJC_EXCEPTIONS 438 438 ASSERT(m_layer != layer.m_layer); 439 [m_layer .get()addSublayer:layer.m_layer.get()];439 [m_layer addSublayer:layer.m_layer.get()]; 440 440 END_BLOCK_OBJC_EXCEPTIONS 441 441 } … … 445 445 BEGIN_BLOCK_OBJC_EXCEPTIONS 446 446 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]; 448 448 END_BLOCK_OBJC_EXCEPTIONS 449 449 } … … 453 453 BEGIN_BLOCK_OBJC_EXCEPTIONS 454 454 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()]; 456 456 END_BLOCK_OBJC_EXCEPTIONS 457 457 } … … 460 460 { 461 461 BEGIN_BLOCK_OBJC_EXCEPTIONS 462 [m_layer .get()setSublayers:[source.m_layer.get() sublayers]];462 [m_layer setSublayers:[source.m_layer.get() sublayers]]; 463 463 END_BLOCK_OBJC_EXCEPTIONS 464 464 } … … 478 478 479 479 BEGIN_BLOCK_OBJC_EXCEPTIONS 480 [m_layer .get()addAnimation:propertyAnimation forKey:key];480 [m_layer addAnimation:propertyAnimation forKey:key]; 481 481 END_BLOCK_OBJC_EXCEPTIONS 482 482 } … … 485 485 { 486 486 BEGIN_BLOCK_OBJC_EXCEPTIONS 487 [m_layer .get()removeAnimationForKey:key];487 [m_layer removeAnimationForKey:key]; 488 488 END_BLOCK_OBJC_EXCEPTIONS 489 489 } … … 491 491 PassRefPtr<PlatformCAAnimation> PlatformCALayerMac::animationForKey(const String& key) 492 492 { 493 CAPropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>([m_layer .get()animationForKey:key]);493 CAPropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>([m_layer animationForKey:key]); 494 494 if (!propertyAnimation) 495 495 return 0; … … 500 500 { 501 501 BEGIN_BLOCK_OBJC_EXCEPTIONS 502 [m_layer .get()setMask:layer ? layer->platformLayer() : nil];502 [m_layer setMask:layer ? layer->platformLayer() : nil]; 503 503 END_BLOCK_OBJC_EXCEPTIONS 504 504 } … … 506 506 bool PlatformCALayerMac::isOpaque() const 507 507 { 508 return [m_layer .get()isOpaque];508 return [m_layer isOpaque]; 509 509 } 510 510 … … 512 512 { 513 513 BEGIN_BLOCK_OBJC_EXCEPTIONS 514 [m_layer .get()setOpaque:value];514 [m_layer setOpaque:value]; 515 515 END_BLOCK_OBJC_EXCEPTIONS 516 516 } … … 518 518 FloatRect PlatformCALayerMac::bounds() const 519 519 { 520 return [m_layer .get()bounds];520 return [m_layer bounds]; 521 521 } 522 522 … … 524 524 { 525 525 BEGIN_BLOCK_OBJC_EXCEPTIONS 526 [m_layer .get()setBounds:value];526 [m_layer setBounds:value]; 527 527 528 528 if (requiresCustomAppearanceUpdateOnBoundsChange()) … … 534 534 FloatPoint3D PlatformCALayerMac::position() const 535 535 { 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]); 538 538 } 539 539 … … 541 541 { 542 542 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()]; 545 545 END_BLOCK_OBJC_EXCEPTIONS 546 546 } … … 548 548 FloatPoint3D PlatformCALayerMac::anchorPoint() const 549 549 { 550 CGPoint point = [m_layer .get()anchorPoint];550 CGPoint point = [m_layer anchorPoint]; 551 551 float z = 0; 552 z = [m_layer .get()anchorPointZ];552 z = [m_layer anchorPointZ]; 553 553 return FloatPoint3D(point.x, point.y, z); 554 554 } … … 557 557 { 558 558 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()]; 561 561 END_BLOCK_OBJC_EXCEPTIONS 562 562 } … … 564 564 TransformationMatrix PlatformCALayerMac::transform() const 565 565 { 566 return [m_layer .get()transform];566 return [m_layer transform]; 567 567 } 568 568 … … 570 570 { 571 571 BEGIN_BLOCK_OBJC_EXCEPTIONS 572 [m_layer .get()setTransform:value];572 [m_layer setTransform:value]; 573 573 END_BLOCK_OBJC_EXCEPTIONS 574 574 } … … 576 576 TransformationMatrix PlatformCALayerMac::sublayerTransform() const 577 577 { 578 return [m_layer .get()sublayerTransform];578 return [m_layer sublayerTransform]; 579 579 } 580 580 … … 582 582 { 583 583 BEGIN_BLOCK_OBJC_EXCEPTIONS 584 [m_layer .get()setSublayerTransform:value];584 [m_layer setSublayerTransform:value]; 585 585 END_BLOCK_OBJC_EXCEPTIONS 586 586 } … … 589 589 { 590 590 BEGIN_BLOCK_OBJC_EXCEPTIONS 591 [m_layer .get()setHidden:value];591 [m_layer setHidden:value]; 592 592 END_BLOCK_OBJC_EXCEPTIONS 593 593 } … … 596 596 { 597 597 BEGIN_BLOCK_OBJC_EXCEPTIONS 598 [m_layer .get()setGeometryFlipped:value];598 [m_layer setGeometryFlipped:value]; 599 599 END_BLOCK_OBJC_EXCEPTIONS 600 600 } … … 602 602 bool PlatformCALayerMac::isDoubleSided() const 603 603 { 604 return [m_layer .get()isDoubleSided];604 return [m_layer isDoubleSided]; 605 605 } 606 606 … … 608 608 { 609 609 BEGIN_BLOCK_OBJC_EXCEPTIONS 610 [m_layer .get()setDoubleSided:value];610 [m_layer setDoubleSided:value]; 611 611 END_BLOCK_OBJC_EXCEPTIONS 612 612 } … … 614 614 bool PlatformCALayerMac::masksToBounds() const 615 615 { 616 return [m_layer .get()masksToBounds];616 return [m_layer masksToBounds]; 617 617 } 618 618 … … 620 620 { 621 621 BEGIN_BLOCK_OBJC_EXCEPTIONS 622 [m_layer .get()setMasksToBounds:value];622 [m_layer setMasksToBounds:value]; 623 623 END_BLOCK_OBJC_EXCEPTIONS 624 624 } … … 626 626 bool PlatformCALayerMac::acceleratesDrawing() const 627 627 { 628 return [m_layer .get()acceleratesDrawing];628 return [m_layer acceleratesDrawing]; 629 629 } 630 630 … … 632 632 { 633 633 BEGIN_BLOCK_OBJC_EXCEPTIONS 634 [m_layer .get()setAcceleratesDrawing:acceleratesDrawing];634 [m_layer setAcceleratesDrawing:acceleratesDrawing]; 635 635 END_BLOCK_OBJC_EXCEPTIONS 636 636 } … … 638 638 CFTypeRef PlatformCALayerMac::contents() const 639 639 { 640 return [m_layer .get()contents];640 return [m_layer contents]; 641 641 } 642 642 … … 644 644 { 645 645 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))]; 647 647 END_BLOCK_OBJC_EXCEPTIONS 648 648 } … … 651 651 { 652 652 BEGIN_BLOCK_OBJC_EXCEPTIONS 653 [m_layer .get()setContentsRect:value];653 [m_layer setContentsRect:value]; 654 654 END_BLOCK_OBJC_EXCEPTIONS 655 655 } … … 658 658 { 659 659 BEGIN_BLOCK_OBJC_EXCEPTIONS 660 [m_layer .get()setMinificationFilter:toCAFilterType(value)];660 [m_layer setMinificationFilter:toCAFilterType(value)]; 661 661 END_BLOCK_OBJC_EXCEPTIONS 662 662 } … … 665 665 { 666 666 BEGIN_BLOCK_OBJC_EXCEPTIONS 667 [m_layer .get()setMagnificationFilter:toCAFilterType(value)];667 [m_layer setMagnificationFilter:toCAFilterType(value)]; 668 668 END_BLOCK_OBJC_EXCEPTIONS 669 669 } … … 671 671 Color PlatformCALayerMac::backgroundColor() const 672 672 { 673 return [m_layer .get()backgroundColor];673 return [m_layer backgroundColor]; 674 674 } 675 675 … … 683 683 684 684 BEGIN_BLOCK_OBJC_EXCEPTIONS 685 [m_layer .get()setBackgroundColor:color.get()];685 [m_layer setBackgroundColor:color.get()]; 686 686 END_BLOCK_OBJC_EXCEPTIONS 687 687 } … … 690 690 { 691 691 BEGIN_BLOCK_OBJC_EXCEPTIONS 692 [m_layer .get()setBorderWidth:value];692 [m_layer setBorderWidth:value]; 693 693 END_BLOCK_OBJC_EXCEPTIONS 694 694 } … … 704 704 705 705 BEGIN_BLOCK_OBJC_EXCEPTIONS 706 [m_layer .get()setBorderColor:color.get()];706 [m_layer setBorderColor:color.get()]; 707 707 END_BLOCK_OBJC_EXCEPTIONS 708 708 } else { 709 709 BEGIN_BLOCK_OBJC_EXCEPTIONS 710 [m_layer .get()setBorderColor:nil];710 [m_layer setBorderColor:nil]; 711 711 END_BLOCK_OBJC_EXCEPTIONS 712 712 } … … 715 715 float PlatformCALayerMac::opacity() const 716 716 { 717 return [m_layer .get()opacity];717 return [m_layer opacity]; 718 718 } 719 719 … … 721 721 { 722 722 BEGIN_BLOCK_OBJC_EXCEPTIONS 723 [m_layer .get()setOpacity:value];723 [m_layer setOpacity:value]; 724 724 END_BLOCK_OBJC_EXCEPTIONS 725 725 } … … 733 733 { 734 734 BEGIN_BLOCK_OBJC_EXCEPTIONS 735 [m_layer .get()setFilters:[sourceLayer.platformLayer() filters]];735 [m_layer setFilters:[sourceLayer.platformLayer() filters]]; 736 736 END_BLOCK_OBJC_EXCEPTIONS 737 737 } … … 771 771 { 772 772 BEGIN_BLOCK_OBJC_EXCEPTIONS 773 [m_layer .get()setName:value];773 [m_layer setName:value]; 774 774 END_BLOCK_OBJC_EXCEPTIONS 775 775 } … … 778 778 { 779 779 BEGIN_BLOCK_OBJC_EXCEPTIONS 780 [m_layer .get()setSpeed:value];780 [m_layer setSpeed:value]; 781 781 END_BLOCK_OBJC_EXCEPTIONS 782 782 } … … 785 785 { 786 786 BEGIN_BLOCK_OBJC_EXCEPTIONS 787 [m_layer .get()setTimeOffset:value];787 [m_layer setTimeOffset:value]; 788 788 END_BLOCK_OBJC_EXCEPTIONS 789 789 } … … 791 791 float PlatformCALayerMac::contentsScale() const 792 792 { 793 return [m_layer .get()contentsScale];793 return [m_layer contentsScale]; 794 794 } 795 795 … … 797 797 { 798 798 BEGIN_BLOCK_OBJC_EXCEPTIONS 799 [m_layer .get()setContentsScale:value];799 [m_layer setContentsScale:value]; 800 800 #if PLATFORM(IOS) 801 [m_layer .get()setRasterizationScale:value];801 [m_layer setRasterizationScale:value]; 802 802 803 803 if (m_layerType == LayerTypeWebTiledLayer) { … … 805 805 // see <rdar://problem/9434765> for more information. 806 806 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]; 808 808 } 809 809 #endif … … 813 813 float PlatformCALayerMac::cornerRadius() const 814 814 { 815 return [m_layer .get()cornerRadius];815 return [m_layer cornerRadius]; 816 816 } 817 817 … … 819 819 { 820 820 BEGIN_BLOCK_OBJC_EXCEPTIONS 821 [m_layer .get()setCornerRadius:value];821 [m_layer setCornerRadius:value]; 822 822 END_BLOCK_OBJC_EXCEPTIONS 823 823 } … … 826 826 { 827 827 BEGIN_BLOCK_OBJC_EXCEPTIONS 828 [m_layer .get()setEdgeAntialiasingMask:mask];828 [m_layer setEdgeAntialiasingMask:mask]; 829 829 END_BLOCK_OBJC_EXCEPTIONS 830 830 } … … 848 848 shapePath.addRoundedRect(roundedRect); 849 849 [(CAShapeLayer *)m_layer setPath:shapePath.platformPath()]; 850 END_BLOCK_OBJC_EXCEPTIONS 851 } 852 853 WindRule 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 864 void 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 878 Path 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 887 void PlatformCALayerMac::setShapePath(const Path& path) 888 { 889 ASSERT(m_layerType == LayerTypeShapeLayer); 890 891 BEGIN_BLOCK_OBJC_EXCEPTIONS 892 [(CAShapeLayer *)m_layer setPath:path.platformPath()]; 850 893 END_BLOCK_OBJC_EXCEPTIONS 851 894 } … … 893 936 BOOL result = NO; 894 937 BEGIN_BLOCK_OBJC_EXCEPTIONS 895 result = [m_layer .get()isKindOfClass:[WebLayer self]];938 result = [m_layer isKindOfClass:[WebLayer self]]; 896 939 END_BLOCK_OBJC_EXCEPTIONS 897 940 return result; -
trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
r179604 r180882 602 602 } 603 603 604 WindRule PlatformCALayerWin::shapeWindRule() const 605 { 606 // FIXME: implement. 607 return RULE_NONZERO; 608 } 609 610 void PlatformCALayerWin::setShapeWindRule(WindRule) 611 { 612 // FIXME: implement. 613 } 614 615 Path PlatformCALayerWin::shapePath() const 616 { 617 // FIXME: implement. 618 return Path(); 619 } 620 621 void PlatformCALayerWin::setShapePath(const Path&) 622 { 623 // FIXME: implement. 624 } 625 604 626 #ifndef NDEBUG 605 627 static void printIndent(int indent) -
trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h
r179604 r180882 129 129 virtual void setShapeRoundedRect(const FloatRoundedRect&) override; 130 130 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 131 137 virtual void setEdgeAntialiasingMask(unsigned) override; 132 138 -
trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp
r180790 r180882 75 75 76 76 Path::Path() 77 : m_path( 0)77 : m_path(nullptr) 78 78 { 79 79 } -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r180474 r180882 4024 4024 } 4025 4025 4026 bool RenderLayer::paintsWithClipPath() const 4027 { 4028 return renderer().style().clipPath() && !isComposited(); 4029 } 4030 4031 Path 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 4026 4057 bool RenderLayer::setupClipPath(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed) 4027 4058 { … … 4036 4067 RenderStyle& style = renderer().style(); 4037 4068 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); 4042 4072 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); 4055 4074 return true; 4056 4075 } … … 4219 4238 if (renderer().flowThreadContainingBlock() && (renderer().hasClipPath() || hasFilterThatIsPainting(context, paintFlags))) 4220 4239 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); 4222 4244 4223 4245 LayerPaintingInfo localPaintingInfo(paintingInfo); … … 4320 4342 } 4321 4343 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 4322 4349 if ((localPaintFlags & PaintLayerPaintingChildClippingMaskPhase) && shouldPaintContent && !selectionOnly) { 4323 4350 // Paint the border radius mask for the fragments. -
trunk/Source/WebCore/rendering/RenderLayer.h
r178533 r180882 429 429 430 430 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 445 446 }; 446 447 … … 753 754 754 755 bool setupFontSubpixelQuantization(GraphicsContext*, bool& didQuantizeFonts); 756 757 bool paintsWithClipPath() const; 758 759 Path computeClipPath(const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, WindRule&) const; 760 755 761 bool setupClipPath(GraphicsContext*, const LayerPaintingInfo&, const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed); 756 762 -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r180580 r180882 150 150 updateForegroundLayer(false); 151 151 updateBackgroundLayer(false); 152 updateMask Layer(false);152 updateMaskingLayer(false, false); 153 153 updateScrollingLayers(false); 154 154 detachFromScrollingCoordinator(); … … 571 571 } 572 572 573 updateMask Layer(renderer().hasMask());573 updateMaskingLayer(renderer().hasMask(), renderer().hasClipPath()); 574 574 575 575 updateChildClippingStrategy(needsDescendantsClippingLayer); … … 828 828 } 829 829 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(); 835 832 836 833 if (m_owningLayer.renderer().hasTransformRelatedProperty()) { … … 1006 1003 } 1007 1004 1005 // FIXME: Avoid repaints when clip path changes. 1006 void 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 1008 1027 void RenderLayerBacking::adjustAncestorCompositingBoundsForFlowThread(LayoutRect& ancestorCompositingBounds, const RenderLayer* compositingAncestor) const 1009 1028 { … … 1410 1429 } 1411 1430 1412 void RenderLayerBacking::updateMaskLayer(bool needsMaskLayer) 1431 // Masking layer is used for masks or clip-path. 1432 void RenderLayerBacking::updateMaskingLayer(bool hasMask, bool hasClipPath) 1413 1433 { 1414 1434 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 1416 1454 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); 1420 1458 layerChanged = true; 1421 1459 m_graphicsLayer->setMaskLayer(m_maskLayer.get()); … … 1528 1566 if (!m_foregroundLayer) 1529 1567 phase |= GraphicsLayerPaintForeground; 1530 if (!m_maskLayer)1531 phase |= GraphicsLayerPaintMask;1532 1568 1533 1569 if (m_scrollingContentsLayer) { … … 2193 2229 if (paintingPhase & GraphicsLayerPaintMask) 2194 2230 paintFlags |= RenderLayer::PaintLayerPaintingCompositingMaskPhase; 2231 if (paintingPhase & GraphicsLayerPaintClipPath) 2232 paintFlags |= RenderLayer::PaintLayerPaintingCompositingClipPathPhase; 2195 2233 if (paintingPhase & GraphicsLayerPaintChildClippingMask) 2196 2234 paintFlags |= RenderLayer::PaintLayerPaintingChildClippingMaskPhase; -
trunk/Source/WebCore/rendering/RenderLayerBacking.h
r179604 r180882 267 267 bool updateForegroundLayer(bool needsForegroundLayer); 268 268 bool updateBackgroundLayer(bool needsBackgroundLayer); 269 void updateMask Layer(bool needsMaskLayer);269 void updateMaskingLayer(bool hasMask, bool hasClipPath); 270 270 bool requiresHorizontalScrollbarLayer() const; 271 271 bool requiresVerticalScrollbarLayer() const; … … 274 274 void updateDrawsContent(bool isSimpleContainer); 275 275 void updateChildClippingStrategy(bool needsDescendantsClippingLayer); 276 277 void updateMaskingLayerGeometry(); 276 278 277 279 void updateRootLayerConfiguration(); … … 340 342 std::unique_ptr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need to draw the background separately. 341 343 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. 343 345 std::unique_ptr<GraphicsLayer> m_childClippingMaskLayer; // Only used if we have to clip child layers or accelerated contents with border radius or clip-path. 344 346 -
trunk/Source/WebKit2/ChangeLog
r180871 r180882 1 2015-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 1 31 2015-03-01 Chris Dumez <cdumez@apple.com> 2 32 -
trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
r178820 r180882 50 50 #include <WebCore/Image.h> 51 51 #include <WebCore/Length.h> 52 #include <WebCore/Path.h> 52 53 #include <WebCore/PluginData.h> 53 54 #include <WebCore/ProtectionSpace.h> … … 365 366 } 366 367 368 static void pathPointCountApplierFunction(void* info, const PathElement* element) 369 { 370 uint64_t* pointCount = static_cast<uint64_t*>(info); 371 ++*pointCount; 372 } 373 374 static 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 401 void 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 411 bool 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 367 477 template<> struct ArgumentCoder<Region::Span> { 368 478 static void encode(ArgumentEncoder&, const Region::Span&); -
trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h
r177593 r180882 55 55 class LinearTimingFunction; 56 56 class Notification; 57 class Path; 57 58 class ProtectionSpace; 58 59 class Region; … … 199 200 }; 200 201 202 template<> struct ArgumentCoder<WebCore::Path> { 203 static void encode(ArgumentEncoder&, const WebCore::Path&); 204 static bool decode(ArgumentDecoder&, WebCore::Path&); 205 }; 206 201 207 template<> struct ArgumentCoder<WebCore::Region> { 202 208 static void encode(ArgumentEncoder&, const WebCore::Region&); -
trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm
r177214 r180882 198 198 } 199 199 200 if (properties.changedProperties & RemoteLayerTreeTransaction::ShapePathChanged) { 201 ASSERT([layer isKindOfClass:[CAShapeLayer class]]); 202 [(CAShapeLayer *)layer setPath:properties.shapePath.platformPath()]; 203 } 204 200 205 if (properties.changedProperties & RemoteLayerTreeTransaction::MinificationFilterChanged) 201 206 layer.minificationFilter = toCAFilterType(properties.minificationFilter); … … 206 211 if (properties.changedProperties & RemoteLayerTreeTransaction::BlendModeChanged) 207 212 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 } 208 226 209 227 if (properties.changedProperties & RemoteLayerTreeTransaction::SpeedChanged) -
trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h
r179604 r180882 74 74 CornerRadiusChanged = 1LLU << 21, 75 75 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 86 88 }; 87 89 typedef uint64_t LayerChange; … … 137 139 std::unique_ptr<RemoteLayerBackingStore> backingStore; 138 140 std::unique_ptr<WebCore::FilterOperations> filters; 141 WebCore::Path shapePath; 139 142 WebCore::GraphicsLayer::PlatformLayerID maskLayerID; 140 143 WebCore::GraphicsLayer::PlatformLayerID clonedLayerID; … … 152 155 WebCore::PlatformCALayer::FilterType magnificationFilter; 153 156 WebCore::BlendMode blendMode; 157 WebCore::WindRule windRule; 154 158 bool hidden; 155 159 bool geometryFlipped; -
trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
r179604 r180882 97 97 , magnificationFilter(PlatformCALayer::FilterType::Linear) 98 98 , blendMode(BlendModeNormal) 99 , windRule(RULE_NONZERO) 99 100 , hidden(false) 100 101 , geometryFlipped(false) … … 116 117 , bounds(other.bounds) 117 118 , contentsRect(other.contentsRect) 119 , shapePath(other.shapePath) 118 120 , maskLayerID(other.maskLayerID) 119 121 , clonedLayerID(other.clonedLayerID) … … 131 133 , magnificationFilter(other.magnificationFilter) 132 134 , blendMode(other.blendMode) 135 , windRule(other.windRule) 133 136 , hidden(other.hidden) 134 137 , geometryFlipped(other.geometryFlipped) … … 225 228 encoder << *shapeRoundedRect; 226 229 230 if (changedProperties & ShapePathChanged) 231 encoder << shapePath; 232 227 233 if (changedProperties & MinificationFilterChanged) 228 234 encoder.encodeEnum(minificationFilter); … … 233 239 if (changedProperties & BlendModeChanged) 234 240 encoder.encodeEnum(blendMode); 241 242 if (changedProperties & WindRuleChanged) 243 encoder.encodeEnum(windRule); 235 244 236 245 if (changedProperties & SpeedChanged) … … 394 403 } 395 404 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 396 413 if (result.changedProperties & MinificationFilterChanged) { 397 414 if (!decoder.decodeEnum(result.minificationFilter)) … … 406 423 if (result.changedProperties & BlendModeChanged) { 407 424 if (!decoder.decodeEnum(result.blendMode)) 425 return false; 426 } 427 428 if (result.changedProperties & WindRuleChanged) { 429 if (!decoder.decodeEnum(result.windRule)) 408 430 return false; 409 431 } -
trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp
r179791 r180882 706 706 } 707 707 708 Path PlatformCALayerRemote::shapePath() const 709 { 710 ASSERT(m_layerType == LayerTypeShapeLayer); 711 return m_properties.shapePath; 712 } 713 714 void PlatformCALayerRemote::setShapePath(const Path& path) 715 { 716 ASSERT(m_layerType == LayerTypeShapeLayer); 717 m_properties.shapePath = path; 718 m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ShapePathChanged); 719 } 720 721 WindRule PlatformCALayerRemote::shapeWindRule() const 722 { 723 ASSERT(m_layerType == LayerTypeShapeLayer); 724 return m_properties.windRule; 725 } 726 727 void PlatformCALayerRemote::setShapeWindRule(WindRule windRule) 728 { 729 ASSERT(m_layerType == LayerTypeShapeLayer); 730 m_properties.windRule = windRule; 731 m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::WindRuleChanged); 732 } 733 708 734 bool PlatformCALayerRemote::requiresCustomAppearanceUpdateOnBoundsChange() const 709 735 { -
trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h
r179604 r180882 145 145 virtual void setEdgeAntialiasingMask(unsigned) override; 146 146 147 // FIXME: Having both shapeRoundedRect and shapePath is redundant. We could use shapePath for everything. 147 148 virtual WebCore::FloatRoundedRect shapeRoundedRect() const override; 148 149 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; 149 156 150 157 virtual WebCore::GraphicsLayer::CustomAppearance customAppearance() const override;
Note: See TracChangeset
for help on using the changeset viewer.