haikuwebkit/LayoutTests/compositing/video/video-border-radius-expecte...

62 lines
1.2 KiB
HTML
Raw Permalink Normal View History

Implement round-rect clipping on video elements https://bugs.webkit.org/show_bug.cgi?id=138537 rdar://problem/9534399 Reviewed by Darin Adler. Source/WebCore: 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. Source/WebKit2: 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: LayoutTests: 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: Canonical link: https://commits.webkit.org/156374@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@175794 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-11-09 19:42:17 +00:00
<!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>