Diff
Modified: trunk/LayoutTests/ChangeLog (175793 => 175794)
--- trunk/LayoutTests/ChangeLog 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/LayoutTests/ChangeLog 2014-11-09 19:42:17 UTC (rev 175794)
@@ -1,3 +1,18 @@
+2014-11-08 Simon Fraser <[email protected]>
+
+ Implement round-rect clipping on video elements
+ https://bugs.webkit.org/show_bug.cgi?id=138537
+ rdar://problem/9534399
+
+ Reviewed by Darin Adler.
+
+ Test that uses clip() to compare a bit of rounded-rect video in the corner.
+ Rebaselined test that dumped contents layers.
+
+ * compositing/video/video-border-radius-expected.html: Added.
+ * compositing/video/video-border-radius.html: Added.
+ * platform/mac/compositing/reflections/direct-image-object-fit-reflected-expected.txt:
+
2014-11-08 Alexey Proskuryakov <[email protected]>
http/tests/xmlhttprequest/cross-origin-cookie-storage.html fails with PPT.
Added: trunk/LayoutTests/compositing/video/video-border-radius-expected.html (0 => 175794)
--- trunk/LayoutTests/compositing/video/video-border-radius-expected.html (rev 0)
+++ trunk/LayoutTests/compositing/video/video-border-radius-expected.html 2014-11-09 19:42:17 UTC (rev 175794)
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+ .wrapper {
+ position: absolute;
+ clip: rect(0, 20px, 50px, 0);
+ background-color: gray;
+ width: 300px;
+ height: 250px;
+ margin: 5px;
+ border: 1px solid black;
+ -webkit-box-reflect: right 10px;
+ }
+
+ .wrapper.non-uniform {
+ clip: rect(0, 50px, 20px, 0);
+ }
+
+ .wrapper > .obscurer {
+ border-radius: 50%;
+ }
+ .non-uniform.wrapper > .obscurer {
+ border-top-left-radius: 300px 100px;
+ border-bottom-right-radius: 250px 10px;
+ }
+
+ .obscurer {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ background-color: green;
+ }
+
+ .composited {
+ -webkit-transform: translateZ(0);
+ }
+
+ .box {
+ position: absolute;
+ top: 100px;
+ left: 100px;
+ width: 100px;
+ height: 100px;
+ background-color: blue;
+ }
+</style>
+</head>
+<body>
+
+ <div class="wrapper">
+ <div class="composited box"></div>
+ <div class="obscurer"></div>
+ </div>
+
+ <div class="wrapper non-uniform" style="top: 100px;">
+ <div class="composited box"></div>
+ <div class="obscurer"></div>
+ </div>
+</body>
+</html>
Added: trunk/LayoutTests/compositing/video/video-border-radius.html (0 => 175794)
--- trunk/LayoutTests/compositing/video/video-border-radius.html (rev 0)
+++ trunk/LayoutTests/compositing/video/video-border-radius.html 2014-11-09 19:42:17 UTC (rev 175794)
@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+ .wrapper {
+ position: absolute;
+ clip: rect(0, 20px, 50px, 0);
+ background-color: gray;
+ width: 300px;
+ height: 250px;
+ margin: 5px;
+ border: 1px solid black;
+ -webkit-box-reflect: right 10px;
+ }
+
+ .wrapper.non-uniform {
+ clip: rect(0, 50px, 20px, 0);
+ }
+
+ video {
+ position: absolute;
+ top: 1px; /* inset slightly to avoid antialiasing diffs */
+ left: 1px;
+ width: 298px;
+ height: 248px;
+ border-radius: 50%;
+ box-sizing: border-box;
+ }
+
+ .wrapper > * {
+ border-radius: 50%;
+ }
+
+ .non-uniform.wrapper > * {
+ border-radius: 50%;
+ border-top-left-radius: 300px 100px;
+ border-bottom-right-radius: 250px 10px;
+ }
+
+ .obscurer { /* This should cover the video */
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ background-color: green;
+ }
+</style>
+<script src=""
+<script>
+ if (window.testRunner)
+ testRunner.waitUntilDone();
+
+ function init()
+ {
+ setSrcByTagName("video", findMediaFile("video", "../../media/content/counting"));
+
+ var totalCount = document.getElementsByTagName('video').length;
+ var count = totalCount;
+ window.console.log('loading videos')
+ document.addEventListener("canplaythrough", function () {
+ window.console.log('loaded videos ' + count)
+ if (!--count) {
+ if (window.testRunner)
+ setTimeout(function() {
+ testRunner.notifyDone();
+ }, totalCount * 150);
+ }
+ }, true);
+ }
+</script>
+
+</head>
+<body _onload_="init();">
+
+ <div class="wrapper">
+ <video></video>
+ <div class="obscurer"></div>
+ </div>
+
+ <div class="wrapper non-uniform" style="top: 100px;">
+ <video></video>
+ <div class="obscurer"></div>
+ </div>
+</body>
+</html>
Modified: trunk/LayoutTests/platform/mac/compositing/reflections/direct-image-object-fit-reflected-expected.txt (175793 => 175794)
--- trunk/LayoutTests/platform/mac/compositing/reflections/direct-image-object-fit-reflected-expected.txt 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/LayoutTests/platform/mac/compositing/reflections/direct-image-object-fit-reflected-expected.txt 2014-11-09 19:42:17 UTC (rev 175794)
@@ -16,6 +16,7 @@
(transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 140.00 0.00 1.00])
(replicated layer)
)
+ (structural layer 128.00, 88.00 200.00 x 120.00)
(contents clipping layer 0.00, 0.00 200.00 x 120.00)
(contents layer -20.00, 0.00 240.00 x 120.00)
)
@@ -28,6 +29,7 @@
(transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 140.00 0.00 1.00])
(replicated layer)
)
+ (structural layer 372.00, 88.00 200.00 x 120.00)
(contents layer 0.00, 10.00 200.00 x 100.00)
)
(GraphicsLayer
@@ -39,6 +41,7 @@
(transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 140.00 0.00 1.00])
(replicated layer)
)
+ (structural layer 616.00, 88.00 200.00 x 120.00)
(contents clipping layer 0.00, 0.00 200.00 x 120.00)
(contents layer -44.00, -12.00 288.00 x 144.00)
)
Modified: trunk/Source/WebCore/ChangeLog (175793 => 175794)
--- trunk/Source/WebCore/ChangeLog 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/ChangeLog 2014-11-09 19:42:17 UTC (rev 175794)
@@ -1,3 +1,71 @@
+2014-11-08 Simon Fraser <[email protected]>
+
+ Implement round-rect clipping on video elements
+ https://bugs.webkit.org/show_bug.cgi?id=138537
+ rdar://problem/9534399
+
+ Reviewed by Darin Adler.
+
+ Support border-radius on video and other layers with composited contents,
+ by pushing a FloatRoundedRect onto the GraphicsLayer as the contentsClippingRect,
+ and, on Mac, using layer corner-radius or a CAShapeLayer mask.
+
+ Test: compositing/video/video-border-radius.html
+
+ * WebCore.exp.in:
+ * platform/graphics/FloatRoundedRect.cpp:
+ (WebCore::FloatRoundedRect::Radii::isUniformCornerRadius): Returns true if all
+ corner radii are the same, and have equal widths and heights.
+ * platform/graphics/FloatRoundedRect.h: Allow construction without an explicit
+ rect.
+ * platform/graphics/GraphicsLayer.cpp:
+ (WebCore::GraphicsLayer::GraphicsLayer): nullptr goodness.
+ (showGraphicsLayerTree): Print contents layers when debugging.
+ * platform/graphics/GraphicsLayer.h:
+ (WebCore::GraphicsLayer::contentsClippingRect): Make this take a FloatRoundedRect.
+ (WebCore::GraphicsLayer::setContentsClippingRect):
+ * platform/graphics/ca/GraphicsLayerCA.cpp:
+ (WebCore::GraphicsLayerCA::setContentsClippingRect):
+ (WebCore::GraphicsLayerCA::setContentsToSolidColor):
+ (WebCore::GraphicsLayerCA::setContentsToImage):
+ (WebCore::GraphicsLayerCA::setContentsToPlatformLayer):
+ (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
+ (WebCore::GraphicsLayerCA::updateClippingStrategy): Determines whether we can simply
+ use corner-radius on the existing contentsClippingLayer, or whether we have to
+ create a shape layer to use as a mask.
+ (WebCore::GraphicsLayerCA::updateContentsRects): We have to add/remove the shape layer
+ based on the rounded rect radii. Calls updateClippingStrategy() on the clipping layer,
+ and also updates clones accordingly.
+ (WebCore::dumpInnerLayer):
+ (WebCore::GraphicsLayerCA::dumpAdditionalProperties): Dump all the inner layers
+ (requiring on test rebaseline), including the new shape and backdrop layers.
+ * platform/graphics/ca/GraphicsLayerCA.h:
+ * platform/graphics/ca/PlatformCALayer.h: Add a new shape layer type.
+ * platform/graphics/ca/mac/PlatformCALayerMac.h: Support for corner radius and
+ a rounded rect shape mask.
+ * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+ (PlatformCALayerMac::PlatformCALayerMac):
+ (PlatformCALayerMac::clone):
+ (PlatformCALayerMac::setMask):
+ (PlatformCALayerMac::cornerRadius):
+ (PlatformCALayerMac::setCornerRadius):
+ (PlatformCALayerMac::shapeRoundedRect):
+ (PlatformCALayerMac::setShapeRoundedRect):
+ * platform/graphics/ca/win/PlatformCALayerWin.cpp:
+ (PlatformCALayerWin::cornerRadius):
+ (PlatformCALayerWin::setCornerRadius):
+ (PlatformCALayerWin::shapeRoundedRect):
+ (PlatformCALayerWin::setShapeRoundedRect):
+ * platform/graphics/ca/win/PlatformCALayerWin.h:
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::RenderLayerBacking::resetContentsRect): Use getRoundedInnerBorderFor() to get
+ the rounded rect used to clip contents.
+ (WebCore::RenderLayerBacking::positionOverflowControlsLayers): Push a FloatRoundedRect for the contents clip,
+ (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundColor): Ditto.
+ (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage): Ditto.
+ (WebCore::RenderLayerBacking::updateImageContents): Get the rounded rect clip.
+ * rendering/RenderLayerBacking.h: nullptr.
+
2014-11-09 Darin Adler <[email protected]>
Fix various cases of incorrect cross-thread capture of non-thread-safe RefCounted
Modified: trunk/Source/WebCore/WebCore.exp.in (175793 => 175794)
--- trunk/Source/WebCore/WebCore.exp.in 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/WebCore.exp.in 2014-11-09 19:42:17 UTC (rev 175794)
@@ -594,7 +594,7 @@
__ZN7WebCore15GraphicsLayerCA21setBackfaceVisibilityEb
__ZN7WebCore15GraphicsLayerCA21setNeedsDisplayInRectERKNS_9FloatRectENS_13GraphicsLayer17ShouldClipToLayerE
__ZN7WebCore15GraphicsLayerCA21setShowRepaintCounterEb
-__ZN7WebCore15GraphicsLayerCA23setContentsClippingRectERKNS_9FloatRectE
+__ZN7WebCore15GraphicsLayerCA23setContentsClippingRectERKNS_16FloatRoundedRectE
__ZN7WebCore15GraphicsLayerCA23setContentsNeedsDisplayEv
__ZN7WebCore15GraphicsLayerCA23setContentsToSolidColorERKNS_5ColorE
__ZN7WebCore15GraphicsLayerCA23setDebugBackgroundColorERKNS_5ColorE
@@ -687,6 +687,7 @@
__ZN7WebCore16DeviceMotionData6createEN3WTF10PassRefPtrINS0_12AccelerationEEES4_NS2_INS0_12RotationRateEEEbd
__ZN7WebCore16FilterOperationsC1Ev
__ZN7WebCore16FilterOperationsaSERKS0_
+__ZN7WebCore16FloatRoundedRectC1ERKNS_9FloatRectERKNS0_5RadiiE
__ZN7WebCore16FontPlatformDataD1Ev
__ZN7WebCore16FrameLoadRequestC1EPNS_5FrameERKNS_15ResourceRequestERKNS_14SubstituteDataE
__ZN7WebCore16HTMLInputElement13setAutofilledEb
@@ -1179,6 +1180,7 @@
__ZN7WebCore4Page9initGroupEv
__ZN7WebCore4PageC1ERNS0_11PageClientsE
__ZN7WebCore4PageD1Ev
+__ZN7WebCore4Path14addRoundedRectERKNS_16FloatRoundedRectENS0_19RoundedRectStrategyE
__ZN7WebCore4Path14addRoundedRectERKNS_9FloatRectERKNS_9FloatSizeENS0_19RoundedRectStrategyE
__ZN7WebCore4PathC1Ev
__ZN7WebCore4PathD1Ev
Modified: trunk/Source/WebCore/platform/graphics/FloatRoundedRect.cpp (175793 => 175794)
--- trunk/Source/WebCore/platform/graphics/FloatRoundedRect.cpp 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/platform/graphics/FloatRoundedRect.cpp 2014-11-09 19:42:17 UTC (rev 175794)
@@ -62,6 +62,14 @@
return m_topLeft.isZero() && m_topRight.isZero() && m_bottomLeft.isZero() && m_bottomRight.isZero();
}
+bool FloatRoundedRect::Radii::isUniformCornerRadius() const
+{
+ return WTF::withinEpsilon(m_topLeft.width(), m_topLeft.height())
+ && withinEpsilon(m_topLeft, m_topRight)
+ && withinEpsilon(m_topLeft, m_bottomLeft)
+ && withinEpsilon(m_topLeft, m_bottomRight);
+}
+
void FloatRoundedRect::Radii::scale(float factor)
{
scale(factor, factor);
Modified: trunk/Source/WebCore/platform/graphics/FloatRoundedRect.h (175793 => 175794)
--- trunk/Source/WebCore/platform/graphics/FloatRoundedRect.h 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/platform/graphics/FloatRoundedRect.h 2014-11-09 19:42:17 UTC (rev 175794)
@@ -67,6 +67,7 @@
const FloatSize& bottomRight() const { return m_bottomRight; }
bool isZero() const;
+ bool isUniformCornerRadius() const; // Including no radius.
void scale(float factor);
void scale(float horizontalFactor, float verticalFactor);
@@ -82,7 +83,7 @@
FloatSize m_bottomRight;
};
- explicit FloatRoundedRect(const FloatRect&, const Radii& = Radii());
+ explicit FloatRoundedRect(const FloatRect& = FloatRect(), const Radii& = Radii());
explicit FloatRoundedRect(const RoundedRect&);
FloatRoundedRect(float x, float y, float width, float height);
FloatRoundedRect(const FloatRect&, const FloatSize& topLeft, const FloatSize& topRight, const FloatSize& bottomLeft, const FloatSize& bottomRight);
Modified: trunk/Source/WebCore/platform/graphics/FloatSize.h (175793 => 175794)
--- trunk/Source/WebCore/platform/graphics/FloatSize.h 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/platform/graphics/FloatSize.h 2014-11-09 19:42:17 UTC (rev 175794)
@@ -168,6 +168,11 @@
return a.width() == b.width() && a.height() == b.height();
}
+inline bool withinEpsilon(const FloatSize& a, const FloatSize& b)
+{
+ return WTF::withinEpsilon(a.width(), b.width()) && WTF::withinEpsilon(a.height(), b.height());
+}
+
inline bool operator!=(const FloatSize& a, const FloatSize& b)
{
return a.width() != b.width() || a.height() != b.height();
Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (175793 => 175794)
--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp 2014-11-09 19:42:17 UTC (rev 175794)
@@ -93,10 +93,10 @@
, m_isMaskLayer(false)
, m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip)
, m_contentsOrientation(CompositingCoordinatesTopDown)
- , m_parent(0)
- , m_maskLayer(0)
- , m_replicaLayer(0)
- , m_replicatedLayer(0)
+ , m_parent(nullptr)
+ , m_maskLayer(nullptr)
+ , m_replicaLayer(nullptr)
+ , m_replicatedLayer(nullptr)
, m_repaintCount(0)
, m_customAppearance(NoCustomAppearance)
, m_customBehavior(NoCustomBehavior)
@@ -808,7 +808,7 @@
if (!layer)
return;
- String output = layer->layerTreeAsText(WebCore::LayerTreeAsTextDebug | WebCore::LayerTreeAsTextIncludeVisibleRects | WebCore::LayerTreeAsTextIncludeTileCaches);
+ String output = layer->layerTreeAsText(WebCore::LayerTreeAsTextDebug | WebCore::LayerTreeAsTextIncludeVisibleRects | WebCore::LayerTreeAsTextIncludeTileCaches | WebCore::LayerTreeAsTextIncludeContentLayers);
fprintf(stderr, "%s\n", output.utf8().data());
}
#endif
Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (175793 => 175794)
--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h 2014-11-09 19:42:17 UTC (rev 175794)
@@ -31,7 +31,7 @@
#include "FilterOperations.h"
#include "FloatPoint.h"
#include "FloatPoint3D.h"
-#include "FloatRect.h"
+#include "FloatRoundedRect.h"
#include "FloatSize.h"
#include "GraphicsLayerClient.h"
#include "IntRect.h"
@@ -382,8 +382,8 @@
FloatRect contentsRect() const { return m_contentsRect; }
virtual void setContentsRect(const FloatRect& r) { m_contentsRect = r; }
- FloatRect contentsClippingRect() const { return m_contentsClippingRect; }
- virtual void setContentsClippingRect(const FloatRect& r) { m_contentsClippingRect = r; }
+ FloatRoundedRect contentsClippingRect() const { return m_contentsClippingRect; }
+ virtual void setContentsClippingRect(const FloatRoundedRect& roundedRect) { m_contentsClippingRect = roundedRect; }
// Transitions are identified by a special animation name that cannot clash with a keyframe identifier.
static String animationNameForTransition(AnimatedPropertyID);
@@ -602,7 +602,7 @@
FloatPoint m_replicatedLayerPosition; // For a replica layer, the position of the replica.
FloatRect m_contentsRect;
- FloatRect m_contentsClippingRect;
+ FloatRoundedRect m_contentsClippingRect;
FloatPoint m_contentsTilePhase;
FloatSize m_contentsTileSize;
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (175793 => 175794)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2014-11-09 19:42:17 UTC (rev 175794)
@@ -778,7 +778,7 @@
noteLayerPropertyChanged(ContentsRectsChanged);
}
-void GraphicsLayerCA::setContentsClippingRect(const FloatRect& rect)
+void GraphicsLayerCA::setContentsClippingRect(const FloatRoundedRect& rect)
{
if (rect == m_contentsClippingRect)
return;
@@ -883,7 +883,7 @@
} else {
contentsLayerChanged = m_contentsLayer;
m_contentsLayerPurpose = NoContentsLayer;
- m_contentsLayer = 0;
+ m_contentsLayer = nullptr;
}
if (contentsLayerChanged)
@@ -922,8 +922,8 @@
if (!m_contentsLayer)
noteSublayersChanged();
} else {
- m_uncorrectedContentsImage = 0;
- m_pendingContentsImage = 0;
+ m_uncorrectedContentsImage = nullptr;
+ m_pendingContentsImage = nullptr;
m_contentsLayerPurpose = NoContentsLayer;
if (m_contentsLayer)
noteSublayersChanged();
@@ -945,7 +945,7 @@
// the creator of the raw layer is using it for some other purpose.
// For now we don't support such a case.
PlatformCALayer* platformCALayer = PlatformCALayer::platformCALayer(platformLayer);
- m_contentsLayer = platformLayer ? (platformCALayer ? platformCALayer : createPlatformCALayer(platformLayer, this)) : 0;
+ m_contentsLayer = platformLayer ? (platformCALayer ? platformCALayer : createPlatformCALayer(platformLayer, this)) : nullptr;
m_contentsLayerPurpose = platformLayer ? purpose : NoContentsLayer;
noteSublayersChanged();
@@ -1355,7 +1355,7 @@
if (m_uncommittedChanges & VisibleRectChanged)
updateVisibleRect(oldVisibleRect);
-
+
if (m_uncommittedChanges & TilingAreaChanged) // Needs to happen after VisibleRectChanged, ContentsScaleChanged
updateTiles();
@@ -1512,20 +1512,19 @@
m_structuralLayer->setAnchorPoint(m_anchorPoint);
if (LayerMap* layerCloneMap = m_structuralLayerClones.get()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
- PlatformCALayer* clone = it->value.get();
+ for (auto& clone : *layerCloneMap) {
+ PlatformCALayer* cloneLayer = clone.value.get();
FloatPoint clonePosition = layerPosition;
- if (m_replicaLayer && isReplicatedRootClone(it->key)) {
+ if (m_replicaLayer && isReplicatedRootClone(clone.key)) {
// Maintain the special-case position for the root of a clone subtree,
// which we set up in replicatedLayerRoot().
clonePosition = positionForCloneRootLayer();
}
- clone->setPosition(clonePosition);
- clone->setBounds(layerBounds);
- clone->setAnchorPoint(m_anchorPoint);
+ cloneLayer->setPosition(clonePosition);
+ cloneLayer->setBounds(layerBounds);
+ cloneLayer->setAnchorPoint(m_anchorPoint);
}
}
@@ -1549,20 +1548,19 @@
}
if (LayerMap* layerCloneMap = m_layerClones.get()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
- PlatformCALayer* clone = it->value.get();
+ for (auto& clone : *layerCloneMap) {
+ PlatformCALayer* cloneLayer = clone.value.get();
FloatPoint clonePosition = adjustedPosition;
- if (!m_structuralLayer && m_replicaLayer && isReplicatedRootClone(it->key)) {
+ if (!m_structuralLayer && m_replicaLayer && isReplicatedRootClone(clone.key)) {
// Maintain the special-case position for the root of a clone subtree,
// which we set up in replicatedLayerRoot().
clonePosition = positionForCloneRootLayer();
}
- clone->setPosition(clonePosition);
- clone->setBounds(adjustedBounds);
- clone->setAnchorPoint(scaledAnchorPoint);
+ cloneLayer->setPosition(clonePosition);
+ cloneLayer->setBounds(adjustedBounds);
+ cloneLayer->setAnchorPoint(scaledAnchorPoint);
}
}
}
@@ -1572,10 +1570,9 @@
primaryLayer()->setTransform(m_transform);
if (LayerMap* layerCloneMap = primaryLayerClones()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
- PlatformCALayer* currLayer = it->value.get();
- if (m_replicaLayer && isReplicatedRootClone(it->key)) {
+ for (auto& clone : *layerCloneMap) {
+ PlatformCALayer* currLayer = clone.value.get();
+ if (m_replicaLayer && isReplicatedRootClone(clone.key)) {
// Maintain the special-case transform for the root of a clone subtree,
// which we set up in replicatedLayerRoot().
currLayer->setTransform(TransformationMatrix());
@@ -1590,9 +1587,8 @@
primaryLayer()->setSublayerTransform(m_childrenTransform);
if (LayerMap* layerCloneMap = primaryLayerClones()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it)
- it->value->setSublayerTransform(m_childrenTransform);
+ for (auto & layer : layerCloneMap->values())
+ layer->setSublayerTransform(m_childrenTransform);
}
}
@@ -1601,9 +1597,8 @@
m_layer->setMasksToBounds(m_masksToBounds);
if (LayerMap* layerCloneMap = m_layerClones.get()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it)
- it->value->setMasksToBounds(m_masksToBounds);
+ for (auto & layer : layerCloneMap->values())
+ layer->setMasksToBounds(m_masksToBounds);
}
}
@@ -1614,12 +1609,11 @@
if (m_drawsContent)
m_layer->setNeedsDisplay();
} else {
- m_layer->setContents(0);
+ m_layer->setContents(nullptr);
if (LayerMap* layerCloneMap = m_layerClones.get()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it)
- it->value->setContents(0);
+ for (auto & layer : layerCloneMap->values())
+ layer->setContents(nullptr);
}
}
}
@@ -1636,9 +1630,8 @@
m_layer->setOpaque(contentsOpaque);
if (LayerMap* layerCloneMap = m_layerClones.get()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it)
- it->value->setOpaque(contentsOpaque);
+ for (auto & layer : layerCloneMap->values())
+ layer->setOpaque(contentsOpaque);
}
}
@@ -1648,18 +1641,16 @@
m_structuralLayer->setDoubleSided(m_backfaceVisibility);
if (LayerMap* layerCloneMap = m_structuralLayerClones.get()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it)
- it->value->setDoubleSided(m_backfaceVisibility);
+ for (auto& layer : layerCloneMap->values())
+ layer->setDoubleSided(m_backfaceVisibility);
}
}
m_layer->setDoubleSided(m_backfaceVisibility);
if (LayerMap* layerCloneMap = m_layerClones.get()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it)
- it->value->setDoubleSided(m_backfaceVisibility);
+ for (auto& layer : layerCloneMap->values())
+ layer->setDoubleSided(m_backfaceVisibility);
}
}
@@ -1668,12 +1659,11 @@
m_layer->setFilters(m_filters);
if (LayerMap* layerCloneMap = m_layerClones.get()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
- if (m_replicaLayer && isReplicatedRootClone(it->key))
+ for (auto& clone : *layerCloneMap) {
+ if (m_replicaLayer && isReplicatedRootClone(clone.key))
continue;
- it->value->setFilters(m_filters);
+ clone.value->setFilters(m_filters);
}
}
}
@@ -1705,11 +1695,10 @@
primaryLayer()->setBlendMode(m_blendMode);
if (LayerMap* layerCloneMap = primaryLayerClones()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
- if (m_replicaLayer && isReplicatedRootClone(it->key))
+ for (auto& clone : *layerCloneMap) {
+ if (m_replicaLayer && isReplicatedRootClone(clone.key))
continue;
- it->value->setBlendMode(m_blendMode);
+ clone.value->setBlendMode(m_blendMode);
}
}
}
@@ -1995,6 +1984,36 @@
}
}
+// The clipping strategy depends on whether the rounded rect has equal corner radii.
+void GraphicsLayerCA::updateClippingStrategy(PlatformCALayer& clippingLayer, RefPtr<PlatformCALayer>& shapeMaskLayer, const FloatRoundedRect& roundedRect)
+{
+ if (roundedRect.radii().isUniformCornerRadius()) {
+ clippingLayer.setMask(nullptr);
+ if (shapeMaskLayer) {
+ shapeMaskLayer->setOwner(nullptr);
+ shapeMaskLayer = nullptr;
+ }
+
+ clippingLayer.setMasksToBounds(true);
+ clippingLayer.setCornerRadius(roundedRect.radii().topLeft().width());
+ return;
+ }
+
+ if (!shapeMaskLayer) {
+ shapeMaskLayer = createPlatformCALayer(PlatformCALayer::LayerTypeShapeLayer, this);
+ shapeMaskLayer->setAnchorPoint(FloatPoint3D());
+ }
+
+ shapeMaskLayer->setPosition(FloatPoint());
+ shapeMaskLayer->setBounds(clippingLayer.bounds());
+
+ clippingLayer.setCornerRadius(0);
+ clippingLayer.setMask(shapeMaskLayer.get());
+
+ FloatRoundedRect offsetRoundedRect(clippingLayer.bounds(), roundedRect.radii());
+ shapeMaskLayer->setShapeRoundedRect(offsetRoundedRect);
+}
+
void GraphicsLayerCA::updateContentsRects()
{
if (!m_contentsLayer)
@@ -2003,44 +2022,47 @@
FloatPoint contentOrigin;
FloatRect contentBounds(0, 0, m_contentsRect.width(), m_contentsRect.height());
- FloatPoint clippingOrigin;
- FloatRect clippingBounds;
+ FloatPoint clippingOrigin(m_contentsClippingRect.rect().location());
+ FloatRect clippingBounds(FloatPoint(), m_contentsClippingRect.rect().size());
bool gainedOrLostClippingLayer = false;
- if (!m_contentsClippingRect.contains(m_contentsRect)) {
+ if (m_contentsClippingRect.isRounded() || !m_contentsClippingRect.rect().contains(m_contentsRect)) {
if (!m_contentsClippingLayer) {
m_contentsClippingLayer = createPlatformCALayer(PlatformCALayer::LayerTypeLayer, this);
- m_contentsClippingLayer->setMasksToBounds(true);
m_contentsClippingLayer->setAnchorPoint(FloatPoint());
#ifndef NDEBUG
m_contentsClippingLayer->setName("Contents Clipping");
#endif
- m_contentsLayer->removeFromSuperlayer();
- m_contentsClippingLayer->appendSublayer(*m_contentsLayer);
gainedOrLostClippingLayer = true;
}
-
- clippingOrigin = m_contentsClippingRect.location();
- clippingBounds.setSize(m_contentsClippingRect.size());
- contentOrigin = FloatPoint(m_contentsRect.location() - m_contentsClippingRect.location());
-
m_contentsClippingLayer->setPosition(clippingOrigin);
m_contentsClippingLayer->setBounds(clippingBounds);
- m_contentsLayer->setPosition(contentOrigin);
- m_contentsLayer->setBounds(contentBounds);
+ updateClippingStrategy(*m_contentsClippingLayer, m_shapeMaskLayer, m_contentsClippingRect);
+
+ if (gainedOrLostClippingLayer) {
+ m_contentsLayer->removeFromSuperlayer();
+ m_contentsClippingLayer->appendSublayer(*m_contentsLayer);
+ }
+ contentOrigin = FloatPoint(m_contentsRect.location() - m_contentsClippingRect.rect().location());
} else {
if (m_contentsClippingLayer) {
m_contentsLayer->removeFromSuperlayer();
m_contentsClippingLayer->removeFromSuperlayer();
- m_contentsClippingLayer->setOwner(0);
+ m_contentsClippingLayer->setOwner(nullptr);
+ m_contentsClippingLayer->setMask(nullptr);
m_contentsClippingLayer = nullptr;
gainedOrLostClippingLayer = true;
}
+ if (m_shapeMaskLayer) {
+ m_shapeMaskLayer->setOwner(nullptr);
+ m_shapeMaskLayer = nullptr;
+ }
+
contentOrigin = m_contentsRect.location();
}
@@ -2051,18 +2073,29 @@
m_contentsLayer->setBounds(contentBounds);
if (m_contentsLayerClones) {
- LayerMap::const_iterator end = m_contentsLayerClones->end();
- for (LayerMap::const_iterator it = m_contentsLayerClones->begin(); it != end; ++it) {
- it->value->setPosition(contentOrigin);
- it->value->setBounds(contentBounds);
+ for (auto& layer : m_contentsLayerClones->values()) {
+ layer->setPosition(contentOrigin);
+ layer->setBounds(contentBounds);
}
}
if (m_contentsClippingLayerClones) {
- LayerMap::const_iterator end = m_contentsClippingLayerClones->end();
- for (LayerMap::const_iterator it = m_contentsClippingLayerClones->begin(); it != end; ++it) {
- it->value->setPosition(clippingOrigin);
- it->value->setBounds(clippingBounds);
+ if (!m_shapeMaskLayerClones && m_shapeMaskLayer)
+ m_shapeMaskLayerClones = std::make_unique<LayerMap>();
+
+ for (auto& clone : *m_contentsClippingLayerClones) {
+ CloneID cloneID = clone.key;
+ RefPtr<PlatformCALayer> shapeMaskLayerClone;
+ if (m_shapeMaskLayerClones)
+ shapeMaskLayerClone = m_shapeMaskLayerClones->get(cloneID);
+
+ bool hadShapeMask = shapeMaskLayerClone;
+ updateClippingStrategy(*clone.value, shapeMaskLayerClone, m_contentsClippingRect);
+
+ if (!shapeMaskLayerClone && m_shapeMaskLayerClones)
+ m_shapeMaskLayerClones->remove(cloneID);
+ else if (shapeMaskLayerClone && !hadShapeMask)
+ m_shapeMaskLayerClones->add(cloneID, shapeMaskLayerClone);
}
}
}
@@ -2075,10 +2108,9 @@
LayerMap* maskLayerCloneMap = m_maskLayer ? downcast<GraphicsLayerCA>(*m_maskLayer).primaryLayerClones() : nullptr;
if (LayerMap* layerCloneMap = m_layerClones.get()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
- PlatformCALayer* maskClone = maskLayerCloneMap ? maskLayerCloneMap->get(it->key) : nullptr;
- it->value->setMask(maskClone);
+ for (auto& clone : *layerCloneMap) {
+ PlatformCALayer* maskClone = maskLayerCloneMap ? maskLayerCloneMap->get(clone.key) : nullptr;
+ clone.value->setMask(maskClone);
}
}
}
@@ -2217,14 +2249,13 @@
layer->addAnimationForKey(animationID, caAnim);
if (LayerMap* layerCloneMap = animatedLayerClones(property)) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
+ for (auto& clone : *layerCloneMap) {
// Skip immediate replicas, since they move with the original.
- if (m_replicaLayer && isReplicatedRootClone(it->key))
+ if (m_replicaLayer && isReplicatedRootClone(clone.key))
continue;
- it->value->removeAnimationForKey(animationID);
- it->value->addAnimationForKey(animationID, caAnim);
+ clone.value->removeAnimationForKey(animationID);
+ clone.value->addAnimationForKey(animationID, caAnim);
}
}
}
@@ -2256,13 +2287,12 @@
bug7311367Workaround(m_structuralLayer.get(), m_transform);
if (LayerMap* layerCloneMap = animatedLayerClones(property)) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
+ for (auto& clone : *layerCloneMap) {
// Skip immediate replicas, since they move with the original.
- if (m_replicaLayer && isReplicatedRootClone(it->key))
+ if (m_replicaLayer && isReplicatedRootClone(clone.key))
continue;
- it->value->removeAnimationForKey(animationID);
+ clone.value->removeAnimationForKey(animationID);
}
}
return true;
@@ -2288,12 +2318,11 @@
// Pause the animations on the clones too.
if (LayerMap* layerCloneMap = animatedLayerClones(property)) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
+ for (auto& clone : *layerCloneMap) {
// Skip immediate replicas, since they move with the original.
- if (m_replicaLayer && isReplicatedRootClone(it->key))
+ if (m_replicaLayer && isReplicatedRootClone(clone.key))
continue;
- it->value->addAnimationForKey(animationID, *newAnim);
+ clone.value->addAnimationForKey(animationID, *newAnim);
}
}
}
@@ -2817,10 +2846,9 @@
// Suspend the animations on the clones too.
if (LayerMap* layerCloneMap = primaryLayerClones()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
- it->value->setSpeed(0);
- it->value->setTimeOffset(t);
+ for (auto& layer : layerCloneMap->values()) {
+ layer->setSpeed(0);
+ layer->setTimeOffset(t);
}
}
}
@@ -2832,10 +2860,9 @@
// Resume the animations on the clones too.
if (LayerMap* layerCloneMap = primaryLayerClones()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
- it->value->setSpeed(1);
- it->value->setTimeOffset(0);
+ for (auto& layer : layerCloneMap->values()) {
+ layer->setSpeed(1);
+ layer->setTimeOffset(0);
}
}
}
@@ -2933,6 +2960,20 @@
GraphicsLayer::getDebugBorderInfo(color, width);
}
+
+static void dumpInnerLayer(TextStream& textStream, String label, PlatformCALayer* layer, int indent, LayerTreeAsTextBehavior behavior)
+{
+ if (!layer)
+ return;
+
+ writeIndent(textStream, indent + 1);
+ textStream << "(" << label << " ";
+ if (behavior & LayerTreeAsTextDebug)
+ textStream << "id=" << layer->layerID() << " ";
+ textStream << layer->position().x() << ", " << layer->position().y()
+ << " " << layer->bounds().width() << " x " << layer->bounds().height() << ")\n";
+}
+
void GraphicsLayerCA::dumpAdditionalProperties(TextStream& textStream, int indent, LayerTreeAsTextBehavior behavior) const
{
if (behavior & LayerTreeAsTextIncludeVisibleRects) {
@@ -2963,17 +3004,11 @@
}
if (behavior & LayerTreeAsTextIncludeContentLayers) {
- if (m_contentsClippingLayer) {
- writeIndent(textStream, indent + 1);
- textStream << "(contents clipping layer " << m_contentsClippingLayer->position().x() << ", " << m_contentsClippingLayer->position().y()
- << " " << m_contentsClippingLayer->bounds().width() << " x " << m_contentsClippingLayer->bounds().height() << ")\n";
- }
-
- if (m_contentsLayer) {
- writeIndent(textStream, indent + 1);
- textStream << "(contents layer " << m_contentsLayer->position().x() << ", " << m_contentsLayer->position().y()
- << " " << m_contentsLayer->bounds().width() << " x " << m_contentsLayer->bounds().height() << ")\n";
- }
+ dumpInnerLayer(textStream, "structural layer", m_structuralLayer.get(), indent, behavior);
+ dumpInnerLayer(textStream, "contents clipping layer", m_contentsClippingLayer.get(), indent, behavior);
+ dumpInnerLayer(textStream, "shape mask layer", m_shapeMaskLayer.get(), indent, behavior);
+ dumpInnerLayer(textStream, "contents layer", m_contentsLayer.get(), indent, behavior);
+ dumpInnerLayer(textStream, "backdrop layer", m_backdropLayer.get(), indent, behavior);
}
}
@@ -3139,27 +3174,31 @@
}
void GraphicsLayerCA::ensureCloneLayers(CloneID cloneID, RefPtr<PlatformCALayer>& primaryLayer, RefPtr<PlatformCALayer>& structuralLayer,
- RefPtr<PlatformCALayer>& contentsLayer, RefPtr<PlatformCALayer>& contentsClippingLayer, CloneLevel cloneLevel)
+ RefPtr<PlatformCALayer>& contentsLayer, RefPtr<PlatformCALayer>& contentsClippingLayer, RefPtr<PlatformCALayer>& shapeMaskLayer, CloneLevel cloneLevel)
{
- structuralLayer = 0;
- contentsLayer = 0;
+ structuralLayer = nullptr;
+ contentsLayer = nullptr;
if (!m_layerClones)
- m_layerClones = adoptPtr(new LayerMap);
+ m_layerClones = std::make_unique<LayerMap>();
if (!m_structuralLayerClones && m_structuralLayer)
- m_structuralLayerClones = adoptPtr(new LayerMap);
+ m_structuralLayerClones = std::make_unique<LayerMap>();
if (!m_contentsLayerClones && m_contentsLayer)
- m_contentsLayerClones = adoptPtr(new LayerMap);
+ m_contentsLayerClones = std::make_unique<LayerMap>();
if (!m_contentsClippingLayerClones && m_contentsClippingLayer)
- m_contentsClippingLayerClones = adoptPtr(new LayerMap);
+ m_contentsClippingLayerClones = std::make_unique<LayerMap>();
+ if (!m_shapeMaskLayerClones && m_shapeMaskLayer)
+ m_shapeMaskLayerClones = std::make_unique<LayerMap>();
+
primaryLayer = findOrMakeClone(cloneID, m_layer.get(), m_layerClones.get(), cloneLevel);
structuralLayer = findOrMakeClone(cloneID, m_structuralLayer.get(), m_structuralLayerClones.get(), cloneLevel);
contentsLayer = findOrMakeClone(cloneID, m_contentsLayer.get(), m_contentsLayerClones.get(), cloneLevel);
contentsClippingLayer = findOrMakeClone(cloneID, m_contentsClippingLayer.get(), m_contentsClippingLayerClones.get(), cloneLevel);
+ shapeMaskLayer = findOrMakeClone(cloneID, m_shapeMaskLayer.get(), m_shapeMaskLayerClones.get(), cloneLevel);
}
void GraphicsLayerCA::removeCloneLayers()
@@ -3199,7 +3238,8 @@
RefPtr<PlatformCALayer> structuralLayer;
RefPtr<PlatformCALayer> contentsLayer;
RefPtr<PlatformCALayer> contentsClippingLayer;
- ensureCloneLayers(replicaState.cloneID(), primaryLayer, structuralLayer, contentsLayer, contentsClippingLayer, cloneLevel);
+ RefPtr<PlatformCALayer> shapeMaskLayer;
+ ensureCloneLayers(replicaState.cloneID(), primaryLayer, structuralLayer, contentsLayer, contentsClippingLayer, shapeMaskLayer, cloneLevel);
if (m_maskLayer) {
RefPtr<PlatformCALayer> maskClone = downcast<GraphicsLayerCA>(*m_maskLayer).fetchCloneLayers(replicaRoot, replicaState, IntermediateCloneLevel);
@@ -3237,6 +3277,9 @@
ASSERT(contentsLayer);
contentsClippingLayer->appendSublayer(*contentsLayer);
}
+
+ if (shapeMaskLayer)
+ contentsClippingLayer->setMask(shapeMaskLayer.get());
if (replicaLayer || structuralLayer || contentsLayer || contentsClippingLayer || childLayers.size() > 0) {
if (structuralLayer) {
@@ -3311,7 +3354,7 @@
void GraphicsLayerCA::setOpacityInternal(float accumulatedOpacity)
{
- LayerMap* layerCloneMap = 0;
+ LayerMap* layerCloneMap = nullptr;
if (preserves3D()) {
m_layer->setOpacity(accumulatedOpacity);
@@ -3322,11 +3365,10 @@
}
if (layerCloneMap) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
- if (m_replicaLayer && isReplicatedRootClone(it->key))
+ for (auto& clone : *layerCloneMap) {
+ if (m_replicaLayer && isReplicatedRootClone(clone.key))
continue;
- it->value->setOpacity(m_opacity);
+ clone.value->setOpacity(m_opacity);
}
}
}
@@ -3336,14 +3378,12 @@
primaryLayer()->setOpacity(m_opacity);
if (LayerMap* layerCloneMap = primaryLayerClones()) {
- LayerMap::const_iterator end = layerCloneMap->end();
- for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
- if (m_replicaLayer && isReplicatedRootClone(it->key))
+ for (auto& clone : *layerCloneMap) {
+ if (m_replicaLayer && isReplicatedRootClone(clone.key))
continue;
- it->value->setOpacity(m_opacity);
+ clone.value->setOpacity(m_opacity);
}
-
}
}
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (175793 => 175794)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2014-11-09 19:42:17 UTC (rev 175794)
@@ -45,6 +45,7 @@
namespace WebCore {
+class FloatRoundedRect;
class Image;
class TransformState;
@@ -116,7 +117,7 @@
WEBCORE_EXPORT virtual void setContentsNeedsDisplay() override;
WEBCORE_EXPORT virtual void setContentsRect(const FloatRect&) override;
- WEBCORE_EXPORT virtual void setContentsClippingRect(const FloatRect&) override;
+ WEBCORE_EXPORT virtual void setContentsClippingRect(const FloatRoundedRect&) override;
WEBCORE_EXPORT virtual void suspendAnimations(double time) override;
WEBCORE_EXPORT virtual void resumeAnimations() override;
@@ -266,6 +267,8 @@
void setupContentsLayer(PlatformCALayer*);
PlatformCALayer* contentsLayer() const { return m_contentsLayer.get(); }
+ void updateClippingStrategy(PlatformCALayer&, RefPtr<PlatformCALayer>& shapeMaskLayer, const FloatRoundedRect&);
+
WEBCORE_EXPORT virtual void setReplicatedByLayer(GraphicsLayer*) override;
WEBCORE_EXPORT virtual void getDebugBorderInfo(Color&, float& width) const override;
@@ -344,12 +347,12 @@
PassRefPtr<PlatformCALayer> findOrMakeClone(CloneID, PlatformCALayer *, LayerMap*, CloneLevel);
void ensureCloneLayers(CloneID, RefPtr<PlatformCALayer>& primaryLayer, RefPtr<PlatformCALayer>& structuralLayer,
- RefPtr<PlatformCALayer>& contentsLayer, RefPtr<PlatformCALayer>& contentsClippingLayer, CloneLevel);
+ RefPtr<PlatformCALayer>& contentsLayer, RefPtr<PlatformCALayer>& contentsClippingLayer, RefPtr<PlatformCALayer>& shapeMaskLayer, CloneLevel);
- bool hasCloneLayers() const { return m_layerClones; }
+ bool hasCloneLayers() const { return !!m_layerClones; }
void removeCloneLayers();
FloatPoint positionForCloneRootLayer() const;
-
+
// All these "update" methods will be called inside a BEGIN_BLOCK_OBJC_EXCEPTIONS/END_BLOCK_OBJC_EXCEPTIONS block.
void updateLayerNames();
void updateSublayerList(bool maxLayerDepthReached = false);
@@ -450,14 +453,16 @@
RefPtr<PlatformCALayer> m_layer; // The main layer
RefPtr<PlatformCALayer> m_structuralLayer; // A layer used for structural reasons, like preserves-3d or replica-flattening. Is the parent of m_layer.
RefPtr<PlatformCALayer> m_contentsClippingLayer; // A layer used to clip inner content
+ RefPtr<PlatformCALayer> m_shapeMaskLayer; // Used to clip with non-trivial corner radii.
RefPtr<PlatformCALayer> m_contentsLayer; // A layer used for inner content, like image and video
RefPtr<PlatformCALayer> m_backdropLayer; // The layer used for backdrop rendering, if necessary.
// References to clones of our layers, for replicated layers.
- OwnPtr<LayerMap> m_layerClones;
- OwnPtr<LayerMap> m_structuralLayerClones;
- OwnPtr<LayerMap> m_contentsLayerClones;
- OwnPtr<LayerMap> m_contentsClippingLayerClones;
+ std::unique_ptr<LayerMap> m_layerClones;
+ std::unique_ptr<LayerMap> m_structuralLayerClones;
+ std::unique_ptr<LayerMap> m_contentsLayerClones;
+ std::unique_ptr<LayerMap> m_contentsClippingLayerClones;
+ std::unique_ptr<LayerMap> m_shapeMaskLayerClones;
#ifdef VISIBLE_TILE_WASH
RefPtr<PlatformCALayer> m_visibleTileWashLayer;
Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h (175793 => 175794)
--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h 2014-11-09 19:42:17 UTC (rev 175794)
@@ -26,6 +26,7 @@
#ifndef PlatformCALayer_h
#define PlatformCALayer_h
+#include "FloatRoundedRect.h"
#include "GraphicsLayer.h"
#include "PlatformCALayerClient.h"
#include <QuartzCore/CABase.h>
@@ -78,6 +79,7 @@
LayerTypeAVPlayerLayer,
LayerTypeWebGLLayer,
LayerTypeBackdropLayer,
+ LayerTypeShapeLayer,
LayerTypeCustom
};
enum FilterType { Linear, Nearest, Trilinear };
@@ -199,8 +201,15 @@
virtual float contentsScale() const = 0;
virtual void setContentsScale(float) = 0;
+ virtual float cornerRadius() const = 0;
+ virtual void setCornerRadius(float) = 0;
+
virtual void setEdgeAntialiasingMask(unsigned) = 0;
+ // Only used by LayerTypeShapeLayer.
+ virtual FloatRoundedRect shapeRoundedRect() const = 0;
+ virtual void setShapeRoundedRect(const FloatRoundedRect&) = 0;
+
virtual GraphicsLayer::CustomAppearance customAppearance() const = 0;
virtual void updateCustomAppearance(GraphicsLayer::CustomAppearance) = 0;
Modified: trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h (175793 => 175794)
--- trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h 2014-11-09 19:42:17 UTC (rev 175794)
@@ -134,8 +134,14 @@
virtual float contentsScale() const override;
virtual void setContentsScale(float) override;
+ virtual float cornerRadius() const override;
+ virtual void setCornerRadius(float) override;
+
virtual void setEdgeAntialiasingMask(unsigned) override;
+ virtual FloatRoundedRect shapeRoundedRect() const override;
+ virtual void setShapeRoundedRect(const FloatRoundedRect&) override;
+
virtual GraphicsLayer::CustomAppearance customAppearance() const override { return m_customAppearance; }
virtual void updateCustomAppearance(GraphicsLayer::CustomAppearance) override;
@@ -164,6 +170,7 @@
std::unique_ptr<PlatformCALayerList> m_customSublayers;
GraphicsLayer::CustomAppearance m_customAppearance;
GraphicsLayer::CustomBehavior m_customBehavior;
+ std::unique_ptr<FloatRoundedRect> m_shapeRoundedRect;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm (175793 => 175794)
--- trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm 2014-11-09 19:42:17 UTC (rev 175794)
@@ -259,13 +259,17 @@
// We don't create PlatformCALayerMacs wrapped around WebGLLayers.
ASSERT_NOT_REACHED();
break;
+ case LayerTypeShapeLayer:
+ layerClass = [CAShapeLayer class];
+ // fillColor defaults to opaque black.
+ break;
case LayerTypeCustom:
break;
}
if (layerClass)
m_layer = adoptNS([[layerClass alloc] init]);
-
+
commonInit();
}
@@ -314,6 +318,9 @@
case LayerTypeAVPlayerLayer:
type = LayerTypeAVPlayerLayer;
break;
+ case LayerTypeShapeLayer:
+ type = LayerTypeShapeLayer;
+ break;
case LayerTypeLayer:
default:
type = LayerTypeLayer;
@@ -332,6 +339,7 @@
newLayer->setOpaque(isOpaque());
newLayer->setBackgroundColor(backgroundColor());
newLayer->setContentsScale(contentsScale());
+ newLayer->setCornerRadius(cornerRadius());
newLayer->copyFiltersFrom(*this);
newLayer->updateCustomAppearance(customAppearance());
@@ -345,6 +353,9 @@
[destinationPlayerLayer setPlayer:[sourcePlayerLayer player]];
});
}
+
+ if (type == LayerTypeShapeLayer)
+ newLayer->setShapeRoundedRect(shapeRoundedRect());
return newLayer;
}
@@ -501,7 +512,7 @@
void PlatformCALayerMac::setMask(PlatformCALayer* layer)
{
BEGIN_BLOCK_OBJC_EXCEPTIONS
- [m_layer.get() setMask:layer ? layer->platformLayer() : 0];
+ [m_layer.get() setMask:layer ? layer->platformLayer() : nil];
END_BLOCK_OBJC_EXCEPTIONS
}
@@ -806,6 +817,18 @@
END_BLOCK_OBJC_EXCEPTIONS
}
+float PlatformCALayerMac::cornerRadius() const
+{
+ return [m_layer.get() cornerRadius];
+}
+
+void PlatformCALayerMac::setCornerRadius(float value)
+{
+ BEGIN_BLOCK_OBJC_EXCEPTIONS
+ [m_layer.get() setCornerRadius:value];
+ END_BLOCK_OBJC_EXCEPTIONS
+}
+
void PlatformCALayerMac::setEdgeAntialiasingMask(unsigned mask)
{
BEGIN_BLOCK_OBJC_EXCEPTIONS
@@ -813,6 +836,27 @@
END_BLOCK_OBJC_EXCEPTIONS
}
+FloatRoundedRect PlatformCALayerMac::shapeRoundedRect() const
+{
+ ASSERT(m_layerType == LayerTypeShapeLayer);
+ if (m_shapeRoundedRect)
+ return *m_shapeRoundedRect;
+
+ return FloatRoundedRect();
+}
+
+void PlatformCALayerMac::setShapeRoundedRect(const FloatRoundedRect& roundedRect)
+{
+ ASSERT(m_layerType == LayerTypeShapeLayer);
+ m_shapeRoundedRect = std::make_unique<FloatRoundedRect>(roundedRect);
+
+ BEGIN_BLOCK_OBJC_EXCEPTIONS
+ Path shapePath;
+ shapePath.addRoundedRect(roundedRect);
+ [(CAShapeLayer *)m_layer setPath:shapePath.platformPath()];
+ END_BLOCK_OBJC_EXCEPTIONS
+}
+
bool PlatformCALayerMac::requiresCustomAppearanceUpdateOnBoundsChange() const
{
return m_customAppearance == GraphicsLayer::ScrollingShadow;
Modified: trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp (175793 => 175794)
--- trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp 2014-11-09 19:42:17 UTC (rev 175794)
@@ -581,6 +581,27 @@
{
}
+float PlatformCALayerWin::cornerRadius() const
+{
+ return 0; // FIXME: implement.
+}
+
+void PlatformCALayerWin::setCornerRadius(float value)
+{
+ // FIXME: implement.
+}
+
+FloatRoundedRect PlatformCALayerWin::shapeRoundedRect() const
+{
+ // FIXME: implement.
+ return FloatRoundedRect();
+}
+
+void PlatformCALayerWin::setShapeRoundedRect(const FloatRoundedRect&)
+{
+ // FIXME: implement.
+}
+
#ifndef NDEBUG
static void printIndent(int indent)
{
Modified: trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h (175793 => 175794)
--- trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h 2014-11-09 19:42:17 UTC (rev 175794)
@@ -122,6 +122,12 @@
virtual float contentsScale() const override;
virtual void setContentsScale(float) override;
+ virtual float cornerRadius() const override;
+ virtual void setCornerRadius(float) override;
+
+ virtual FloatRoundedRect shapeRoundedRect() const override;
+ virtual void setShapeRoundedRect(const FloatRoundedRect&) override;
+
virtual void setEdgeAntialiasingMask(unsigned) override;
virtual GraphicsLayer::CustomAppearance customAppearance() const override { return m_customAppearance; }
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (175793 => 175794)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2014-11-09 19:42:17 UTC (rev 175794)
@@ -1097,13 +1097,13 @@
{
m_graphicsLayer->setContentsRect(snappedIntRect(contentsBox()));
- LayoutRect contentsClippingRect;
- if (is<RenderBox>(renderer()))
- contentsClippingRect = downcast<RenderBox>(renderer()).contentBoxRect();
+ if (is<RenderBox>(renderer())) {
+ LayoutRect boxRect(LayoutPoint(), downcast<RenderBox>(renderer()).size());
+ FloatRoundedRect contentsClippingRect = renderer().style().getRoundedInnerBorderFor(boxRect).pixelSnappedRoundedRectForPainting(deviceScaleFactor());
+ contentsClippingRect.move(contentOffsetInCompostingLayer());
+ m_graphicsLayer->setContentsClippingRect(contentsClippingRect);
+ }
- contentsClippingRect.move(contentOffsetInCompostingLayer());
- m_graphicsLayer->setContentsClippingRect(snappedIntRect(contentsClippingRect));
-
m_graphicsLayer->setContentsTileSize(IntSize());
m_graphicsLayer->setContentsTilePhase(IntPoint());
}
@@ -1270,7 +1270,7 @@
if (layer->usesContentsLayer()) {
IntRect barRect = IntRect(IntPoint(), hBarRect.size());
layer->setContentsRect(barRect);
- layer->setContentsClippingRect(barRect);
+ layer->setContentsClippingRect(FloatRoundedRect(barRect));
}
layer->setDrawsContent(m_owningLayer.horizontalScrollbar() && !layer->usesContentsLayer());
}
@@ -1282,7 +1282,7 @@
if (layer->usesContentsLayer()) {
IntRect barRect = IntRect(IntPoint(), vBarRect.size());
layer->setContentsRect(barRect);
- layer->setContentsClippingRect(barRect);
+ layer->setContentsClippingRect(FloatRoundedRect(barRect));
}
layer->setDrawsContent(m_owningLayer.verticalScrollbar() && !layer->usesContentsLayer());
}
@@ -1587,7 +1587,7 @@
m_graphicsLayer->setContentsToSolidColor(backgroundColor);
FloatRect contentsRect = backgroundBoxForPainting();
m_graphicsLayer->setContentsRect(contentsRect);
- m_graphicsLayer->setContentsClippingRect(contentsRect);
+ m_graphicsLayer->setContentsClippingRect(FloatRoundedRect(contentsRect));
didUpdateContentsRect = true;
}
@@ -1615,7 +1615,7 @@
m_graphicsLayer->setContentsTileSize(tileSize);
m_graphicsLayer->setContentsTilePhase(phase);
m_graphicsLayer->setContentsRect(destRect);
- m_graphicsLayer->setContentsClippingRect(destRect);
+ m_graphicsLayer->setContentsClippingRect(FloatRoundedRect(destRect));
m_graphicsLayer->setContentsToImage(image.get());
didUpdateContentsRect = true;
}
@@ -1905,9 +1905,10 @@
// This is a no-op if the layer doesn't have an inner layer for the image.
m_graphicsLayer->setContentsRect(snappedIntRect(contentsBox()));
- LayoutRect contentsClippingRect = imageRenderer.contentBoxRect();
+ LayoutRect boxRect(LayoutPoint(), imageRenderer.size());
+ FloatRoundedRect contentsClippingRect = renderer().style().getRoundedInnerBorderFor(boxRect).pixelSnappedRoundedRectForPainting(deviceScaleFactor());
contentsClippingRect.move(contentOffsetInCompostingLayer());
- m_graphicsLayer->setContentsClippingRect(snappedIntRect(contentsClippingRect));
+ m_graphicsLayer->setContentsClippingRect(contentsClippingRect);
m_graphicsLayer->setContentsToImage(image);
bool isSimpleContainer = false;
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (175793 => 175794)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.h 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h 2014-11-09 19:42:17 UTC (rev 175794)
@@ -316,7 +316,7 @@
bool shouldClipCompositedBounds() const;
bool hasTiledBackingFlatteningLayer() const { return (m_childContainmentLayer && m_usingTiledCacheLayer); }
- GraphicsLayer* tileCacheFlatteningLayer() const { return m_usingTiledCacheLayer ? m_childContainmentLayer.get() : 0; }
+ GraphicsLayer* tileCacheFlatteningLayer() const { return m_usingTiledCacheLayer ? m_childContainmentLayer.get() : nullptr; }
void paintIntoLayer(const GraphicsLayer*, GraphicsContext*, const IntRect& paintDirtyRect, PaintBehavior, GraphicsLayerPaintingPhase);
Modified: trunk/Source/WebKit2/ChangeLog (175793 => 175794)
--- trunk/Source/WebKit2/ChangeLog 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebKit2/ChangeLog 2014-11-09 19:42:17 UTC (rev 175794)
@@ -1,3 +1,47 @@
+2014-11-08 Simon Fraser <[email protected]>
+
+ Implement round-rect clipping on video elements
+ https://bugs.webkit.org/show_bug.cgi?id=138537
+ rdar://problem/9534399
+
+ Reviewed by Darin Adler.
+
+ Support border-radius on video and other layers with composited contents,
+ by pushing a FloatRoundedRect onto the GraphicsLayer as the contentsClippingRect,
+ and, on Mac, using layer corner-radius or a CAShapeLayer mask.
+
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<FloatRoundedRect>::encode):
+ (IPC::ArgumentCoder<FloatRoundedRect>::decode):
+ * Shared/WebCoreArgumentCoders.h:
+ * Shared/mac/RemoteLayerBackingStore.mm: New shape layer type.
+ (WebKit::RemoteLayerBackingStore::drawInContext):
+ * Shared/mac/RemoteLayerTreePropertyApplier.mm:
+ (WebKit::applyPropertiesToLayer): Apply corner-radius and shape path.
+ * Shared/mac/RemoteLayerTreeTransaction.h: Prettify the flags. Yes, I prefer this style.
+ * Shared/mac/RemoteLayerTreeTransaction.mm:
+ (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
+ (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
+ (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
+ (WebKit::RemoteLayerTreeTextStream::operator<<):
+ (WebKit::dumpChangedLayers):
+ (WebKit::RemoteLayerTreeTransaction::description):
+ * UIProcess/ios/RemoteLayerTreeHostIOS.mm:
+ (+[WKShapeView layerClass]): Make UIViews with a CAShapeLayer layer class.
+ (WebKit::RemoteLayerTreeHost::createLayer):
+ * UIProcess/mac/RemoteLayerTreeHost.mm:
+ (WebKit::RemoteLayerTreeHost::createLayer):
+ * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+ (WebKit::PlatformCALayerRemote::updateClonedLayerProperties):
+ (WebKit::isEquivalentLayer):
+ (WebKit::PlatformCALayerRemote::setMask):
+ (WebKit::PlatformCALayerRemote::setClonedLayer):
+ (WebKit::PlatformCALayerRemote::cornerRadius):
+ (WebKit::PlatformCALayerRemote::setCornerRadius):
+ (WebKit::PlatformCALayerRemote::shapeRoundedRect):
+ (WebKit::PlatformCALayerRemote::setShapeRoundedRect):
+ * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
+
2014-11-09 Conrad Shultz <[email protected]>
Move _ignoresNonWheelMouseEvents implementation to WKView(Private)
Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp (175793 => 175794)
--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2014-11-09 19:42:17 UTC (rev 175794)
@@ -298,6 +298,16 @@
}
+void ArgumentCoder<FloatRoundedRect>::encode(ArgumentEncoder& encoder, const FloatRoundedRect& roundedRect)
+{
+ SimpleArgumentCoder<FloatRoundedRect>::encode(encoder, roundedRect);
+}
+
+bool ArgumentCoder<FloatRoundedRect>::decode(ArgumentDecoder& decoder, FloatRoundedRect& roundedRect)
+{
+ return SimpleArgumentCoder<FloatRoundedRect>::decode(decoder, roundedRect);
+}
+
#if PLATFORM(IOS)
void ArgumentCoder<FloatQuad>::encode(ArgumentEncoder& encoder, const FloatQuad& floatQuad)
{
Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h (175793 => 175794)
--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h 2014-11-09 19:42:17 UTC (rev 175794)
@@ -43,6 +43,7 @@
class FloatPoint;
class FloatPoint3D;
class FloatRect;
+class FloatRoundedRect;
class FloatSize;
class FixedPositionViewportConstraints;
class HTTPHeaderMap;
@@ -163,6 +164,11 @@
static bool decode(ArgumentDecoder&, WebCore::FloatSize&);
};
+template<> struct ArgumentCoder<WebCore::FloatRoundedRect> {
+ static void encode(ArgumentEncoder&, const WebCore::FloatRoundedRect&);
+ static bool decode(ArgumentDecoder&, WebCore::FloatRoundedRect&);
+};
+
#if PLATFORM(IOS)
template<> struct ArgumentCoder<WebCore::FloatQuad> {
static void encode(ArgumentEncoder&, const WebCore::FloatQuad&);
Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm (175793 => 175794)
--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm 2014-11-09 19:42:17 UTC (rev 175794)
@@ -349,6 +349,7 @@
case PlatformCALayer::LayerTypeAVPlayerLayer:
case PlatformCALayer::LayerTypeWebGLLayer:
case PlatformCALayer::LayerTypeBackdropLayer:
+ case PlatformCALayer::LayerTypeShapeLayer:
case PlatformCALayer::LayerTypeCustom:
ASSERT_NOT_REACHED();
break;
Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm (175793 => 175794)
--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm 2014-11-09 19:42:17 UTC (rev 175794)
@@ -29,7 +29,7 @@
#import "PlatformCAAnimationRemote.h"
#import "PlatformCALayerRemote.h"
#import "RemoteLayerTreeHost.h"
-#import <QuartzCore/CALayer.h>
+#import <QuartzCore/QuartzCore.h>
#import <WebCore/BlockExceptions.h>
#import <WebCore/PlatformCAFilters.h>
#import <WebCore/ScrollbarThemeMac.h>
@@ -190,6 +190,17 @@
layer.rasterizationScale = properties.contentsScale;
}
+ if (properties.changedProperties & RemoteLayerTreeTransaction::CornerRadiusChanged)
+ layer.cornerRadius = properties.cornerRadius;
+
+ if (properties.changedProperties & RemoteLayerTreeTransaction::ShapeRoundedRectChanged) {
+ Path path;
+ if (properties.shapeRoundedRect)
+ path.addRoundedRect(*properties.shapeRoundedRect);
+ ASSERT([layer isKindOfClass:[CAShapeLayer class]]);
+ [(CAShapeLayer *)layer setPath:path.platformPath()];
+ }
+
if (properties.changedProperties & RemoteLayerTreeTransaction::MinificationFilterChanged)
layer.minificationFilter = toCAFilterType(properties.minificationFilter);
Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h (175793 => 175794)
--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h 2014-11-09 19:42:17 UTC (rev 175794)
@@ -50,40 +50,42 @@
class RemoteLayerTreeTransaction {
public:
enum LayerChanges {
- NoChange = 0,
- NameChanged = 1 << 1,
- ChildrenChanged = 1 << 2,
- PositionChanged = 1 << 3,
- BoundsChanged = 1 << 4,
- BackgroundColorChanged = 1 << 5,
- AnchorPointChanged = 1 << 6,
- BorderWidthChanged = 1 << 7,
- BorderColorChanged = 1 << 8,
- OpacityChanged = 1 << 9,
- TransformChanged = 1 << 10,
- SublayerTransformChanged = 1 << 11,
- HiddenChanged = 1 << 12,
- GeometryFlippedChanged = 1 << 13,
- DoubleSidedChanged = 1 << 14,
- MasksToBoundsChanged = 1 << 15,
- OpaqueChanged = 1 << 16,
- MaskLayerChanged = 1 << 17,
- ClonedContentsChanged = 1 << 18,
- ContentsRectChanged = 1 << 19,
- ContentsScaleChanged = 1 << 20,
- MinificationFilterChanged = 1 << 21,
- MagnificationFilterChanged = 1 << 22,
- BlendModeChanged = 1 << 23,
- SpeedChanged = 1 << 24,
- TimeOffsetChanged = 1 << 25,
- BackingStoreChanged = 1 << 26,
- FiltersChanged = 1 << 27,
- AnimationsChanged = 1 << 28,
- EdgeAntialiasingMaskChanged = 1 << 29,
- CustomAppearanceChanged = 1 << 30,
- CustomBehaviorChanged = 1 << 31
+ NoChange = 0,
+ NameChanged = 1LLU << 1,
+ ChildrenChanged = 1LLU << 2,
+ PositionChanged = 1LLU << 3,
+ BoundsChanged = 1LLU << 4,
+ BackgroundColorChanged = 1LLU << 5,
+ AnchorPointChanged = 1LLU << 6,
+ BorderWidthChanged = 1LLU << 7,
+ BorderColorChanged = 1LLU << 8,
+ OpacityChanged = 1LLU << 9,
+ TransformChanged = 1LLU << 10,
+ SublayerTransformChanged = 1LLU << 11,
+ HiddenChanged = 1LLU << 12,
+ GeometryFlippedChanged = 1LLU << 13,
+ DoubleSidedChanged = 1LLU << 14,
+ MasksToBoundsChanged = 1LLU << 15,
+ OpaqueChanged = 1LLU << 16,
+ MaskLayerChanged = 1LLU << 17,
+ ClonedContentsChanged = 1LLU << 18,
+ ContentsRectChanged = 1LLU << 19,
+ ContentsScaleChanged = 1LLU << 20,
+ CornerRadiusChanged = 1LLU << 21,
+ ShapeRoundedRectChanged = 1LLU << 22,
+ MinificationFilterChanged = 1LLU << 23,
+ MagnificationFilterChanged = 1LLU << 24,
+ BlendModeChanged = 1LLU << 25,
+ SpeedChanged = 1LLU << 26,
+ TimeOffsetChanged = 1LLU << 27,
+ BackingStoreChanged = 1LLU << 28,
+ FiltersChanged = 1LLU << 29,
+ AnimationsChanged = 1LLU << 30,
+ EdgeAntialiasingMaskChanged = 1LLU << 31,
+ CustomAppearanceChanged = 1LLU << 32,
+ CustomBehaviorChanged = 1LLU << 33
};
- typedef unsigned LayerChange;
+ typedef uint64_t LayerChange;
struct LayerCreationProperties {
LayerCreationProperties();
@@ -122,6 +124,8 @@
String name;
std::unique_ptr<WebCore::TransformationMatrix> transform;
std::unique_ptr<WebCore::TransformationMatrix> sublayerTransform;
+ std::unique_ptr<WebCore::FloatRoundedRect> shapeRoundedRect;
+
Vector<WebCore::GraphicsLayer::PlatformLayerID> children;
Vector<std::pair<String, PlatformCAAnimationRemote::Properties>> addedAnimations;
@@ -138,6 +142,7 @@
double timeOffset;
float speed;
float contentsScale;
+ float cornerRadius;
float borderWidth;
float opacity;
WebCore::Color backgroundColor;
Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm (175793 => 175794)
--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm 2014-11-09 19:42:17 UTC (rev 175794)
@@ -86,6 +86,7 @@
, timeOffset(0)
, speed(1)
, contentsScale(1)
+ , cornerRadius(0)
, borderWidth(0)
, opacity(1)
, backgroundColor(Color::transparent)
@@ -120,6 +121,7 @@
, timeOffset(other.timeOffset)
, speed(other.speed)
, contentsScale(other.contentsScale)
+ , cornerRadius(other.cornerRadius)
, borderWidth(other.borderWidth)
, opacity(other.opacity)
, backgroundColor(other.backgroundColor)
@@ -218,6 +220,12 @@
if (changedProperties & ContentsScaleChanged)
encoder << contentsScale;
+ if (changedProperties & CornerRadiusChanged)
+ encoder << cornerRadius;
+
+ if (changedProperties & ShapeRoundedRectChanged)
+ encoder << *shapeRoundedRect;
+
if (changedProperties & MinificationFilterChanged)
encoder.encodeEnum(minificationFilter);
@@ -377,6 +385,19 @@
return false;
}
+ if (result.changedProperties & CornerRadiusChanged) {
+ if (!decoder.decode(result.cornerRadius))
+ return false;
+ }
+
+ if (result.changedProperties & ShapeRoundedRectChanged) {
+ FloatRoundedRect roundedRect;
+ if (!decoder.decode(roundedRect))
+ return false;
+
+ result.shapeRoundedRect = std::make_unique<FloatRoundedRect>(roundedRect);
+ }
+
if (result.changedProperties & MinificationFilterChanged) {
if (!decoder.decodeEnum(result.minificationFilter))
return false;
@@ -599,6 +620,7 @@
RemoteLayerTreeTextStream& operator<<(const TransformationMatrix&);
RemoteLayerTreeTextStream& operator<<(PlatformCALayer::FilterType);
+ RemoteLayerTreeTextStream& operator<<(const FloatRoundedRect&);
RemoteLayerTreeTextStream& operator<<(FloatPoint3D);
RemoteLayerTreeTextStream& operator<<(Color);
RemoteLayerTreeTextStream& operator<<(FloatRect);
@@ -651,6 +673,25 @@
return ts;
}
+RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const FloatRoundedRect& roundedRect)
+{
+ RemoteLayerTreeTextStream& ts = *this;
+ ts << roundedRect.rect().x() << " " << roundedRect.rect().y() << " " << roundedRect.rect().width() << " " << roundedRect.rect().height() << "\n";
+
+ ts.increaseIndent();
+ ts.writeIndent();
+ ts << "topLeft=" << roundedRect.topLeftCorner().width() << " " << roundedRect.topLeftCorner().height() << "\n";
+ ts.writeIndent();
+ ts << "topRight=" << roundedRect.topRightCorner().width() << " " << roundedRect.topRightCorner().height() << "\n";
+ ts.writeIndent();
+ ts << "bottomLeft=" << roundedRect.bottomLeftCorner().width() << " " << roundedRect.bottomLeftCorner().height() << "\n";
+ ts.writeIndent();
+ ts << "bottomRight=" << roundedRect.bottomRightCorner().width() << " " << roundedRect.bottomRightCorner().height();
+ ts.decreaseIndent();
+
+ return ts;
+}
+
RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(PlatformCALayer::FilterType filterType)
{
RemoteLayerTreeTextStream& ts = *this;
@@ -1083,6 +1124,12 @@
if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsScaleChanged)
dumpProperty(ts, "contentsScale", layerProperties.contentsScale);
+ if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CornerRadiusChanged)
+ dumpProperty(ts, "cornerRadius", layerProperties.cornerRadius);
+
+ if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ShapeRoundedRectChanged)
+ dumpProperty(ts, "shapeRect", layerProperties.shapeRoundedRect ? *layerProperties.shapeRoundedRect : FloatRoundedRect());
+
if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MinificationFilterChanged)
dumpProperty(ts, "minificationFilter", layerProperties.minificationFilter);
@@ -1189,6 +1236,9 @@
case PlatformCALayer::LayerTypeWebGLLayer:
ts << "web-gl-layer (context-id " << createdLayer.hostingContextID << ")";
break;
+ case PlatformCALayer::LayerTypeShapeLayer:
+ ts << "shape-layer";
+ break;
case PlatformCALayer::LayerTypeCustom:
ts << "custom-layer (context-id " << createdLayer.hostingContextID << ")";
break;
Modified: trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm (175793 => 175794)
--- trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm 2014-11-09 19:42:17 UTC (rev 175794)
@@ -83,6 +83,7 @@
@end
@implementation WKCompositingView
+
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
return [self _findDescendantViewAtPoint:point withEvent:event];
@@ -94,12 +95,14 @@
NSString *webKitDetails = [NSString stringWithFormat:@" layerID = %llu \"%@\"", WebKit::RemoteLayerTreeHost::layerID(self.layer), self.layer.name ? self.layer.name : @""];
return [viewDescription stringByAppendingString:webKitDetails];
}
+
@end
@interface WKTransformView : WKCompositingView
@end
@implementation WKTransformView
+
+ (Class)layerClass
{
return [CATransformLayer self];
@@ -118,10 +121,23 @@
@end
+@interface WKShapeView : WKCompositingView
+@end
+
+@implementation WKShapeView
+
++ (Class)layerClass
+{
+ return [CAShapeLayer self];
+}
+
+@end
+
@interface WKRemoteView : WKCompositingView
@end
@implementation WKRemoteView
+
- (instancetype)initWithFrame:(CGRect)frame contextID:(uint32_t)contextID hostingDeviceScaleFactor:(float)scaleFactor
{
if ((self = [super initWithFrame:frame])) {
@@ -179,6 +195,9 @@
else
view = adoptNS([[WKCompositingView alloc] init]);
break;
+ case PlatformCALayer::LayerTypeSimpleLayer:
+ view = adoptNS([[WKShapeView alloc] init]);
+ break;
default:
ASSERT_NOT_REACHED();
}
Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm (175793 => 175794)
--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm 2014-11-09 19:42:17 UTC (rev 175794)
@@ -243,6 +243,9 @@
else
layer = adoptNS([[CALayer alloc] init]);
break;
+ case PlatformCALayer::LayerTypeShapeLayer:
+ layer = adoptNS([[CAShapeLayer alloc] init]);
+ break;
default:
ASSERT_NOT_REACHED();
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp (175793 => 175794)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp 2014-11-09 19:42:17 UTC (rev 175794)
@@ -132,8 +132,14 @@
clone.setOpaque(isOpaque());
clone.setBackgroundColor(backgroundColor());
clone.setContentsScale(contentsScale());
+ clone.setCornerRadius(cornerRadius());
+
+ if (m_properties.shapeRoundedRect)
+ clone.setShapeRoundedRect(*m_properties.shapeRoundedRect);
+
if (m_properties.filters)
clone.copyFiltersFrom(*this);
+
clone.updateCustomAppearance(customAppearance());
}
@@ -360,6 +366,12 @@
return m_animations.get(key);
}
+static inline bool isEquivalentLayer(const PlatformCALayer* layer, GraphicsLayer::PlatformLayerID layerID)
+{
+ GraphicsLayer::PlatformLayerID newLayerID = layer ? layer->layerID() : 0;
+ return layerID == newLayerID;
+}
+
void PlatformCALayerRemote::animationStarted(const String& key, CFTimeInterval beginTime)
{
auto it = m_animations.find(key);
@@ -378,6 +390,9 @@
void PlatformCALayerRemote::setMask(PlatformCALayer* layer)
{
+ if (isEquivalentLayer(layer, m_properties.maskLayerID))
+ return;
+
if (layer) {
m_maskLayer = downcast<PlatformCALayerRemote>(layer);
m_properties.maskLayerID = m_maskLayer->layerID();
@@ -391,6 +406,9 @@
void PlatformCALayerRemote::setClonedLayer(const PlatformCALayer* layer)
{
+ if (isEquivalentLayer(layer, m_properties.clonedLayerID))
+ return;
+
if (layer)
m_properties.clonedLayerID = layer->layerID();
else
@@ -656,12 +674,40 @@
updateBackingStore();
}
+float PlatformCALayerRemote::cornerRadius() const
+{
+ return m_properties.cornerRadius;
+}
+
+void PlatformCALayerRemote::setCornerRadius(float value)
+{
+ if (m_properties.cornerRadius == value)
+ return;
+
+ m_properties.cornerRadius = value;
+ m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::CornerRadiusChanged);
+}
+
void PlatformCALayerRemote::setEdgeAntialiasingMask(unsigned value)
{
m_properties.edgeAntialiasingMask = value;
m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged);
}
+FloatRoundedRect PlatformCALayerRemote::shapeRoundedRect() const
+{
+ return m_properties.shapeRoundedRect ? *m_properties.shapeRoundedRect : FloatRoundedRect(FloatRect());
+}
+
+void PlatformCALayerRemote::setShapeRoundedRect(const FloatRoundedRect& roundedRect)
+{
+ if (m_properties.shapeRoundedRect && *m_properties.shapeRoundedRect == roundedRect)
+ return;
+
+ m_properties.shapeRoundedRect = std::make_unique<FloatRoundedRect>(roundedRect);
+ m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ShapeRoundedRectChanged);
+}
+
bool PlatformCALayerRemote::requiresCustomAppearanceUpdateOnBoundsChange() const
{
return m_properties.customAppearance == GraphicsLayer::ScrollingShadow;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h (175793 => 175794)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h 2014-11-09 18:27:56 UTC (rev 175793)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h 2014-11-09 19:42:17 UTC (rev 175794)
@@ -139,8 +139,14 @@
virtual float contentsScale() const override;
virtual void setContentsScale(float) override;
+ virtual float cornerRadius() const override;
+ virtual void setCornerRadius(float) override;
+
virtual void setEdgeAntialiasingMask(unsigned) override;
+ virtual WebCore::FloatRoundedRect shapeRoundedRect() const override;
+ virtual void setShapeRoundedRect(const WebCore::FloatRoundedRect&) override;
+
virtual WebCore::GraphicsLayer::CustomAppearance customAppearance() const override;
virtual void updateCustomAppearance(WebCore::GraphicsLayer::CustomAppearance) override;