Bug 1543482 - Extract a helper to identify clip paths WR can handle without masks. r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D27454

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kartikaya Gupta 2019-04-15 11:24:53 +00:00
Родитель 6186f66b37
Коммит 25f7a03029
3 изменённых файлов: 25 добавлений и 10 удалений

Просмотреть файл

@ -9532,19 +9532,12 @@ static Maybe<wr::WrClipId> CreateSimpleClipRegion(
nsIFrame* frame = aDisplayItem.Frame();
auto* style = frame->StyleSVGReset();
MOZ_ASSERT(style->HasClipPath() || style->HasMask());
if (style->HasMask()) {
if (!nsSVGIntegrationUtils::UsingSimpleClipPathForFrame(frame)) {
return Nothing();
}
const auto& clipPath = style->mClipPath;
if (clipPath.GetType() != StyleShapeSourceType::Shape) {
return Nothing();
}
const auto& shape = clipPath.BasicShape();
if (shape.GetShapeType() == StyleBasicShapeType::Polygon) {
return Nothing();
}
auto appUnitsPerDevPixel = frame->PresContext()->AppUnitsPerDevPixel();
const nsRect refBox =
@ -9602,8 +9595,8 @@ static Maybe<wr::WrClipId> CreateSimpleClipRegion(
// Please don't add more exceptions, try to find a way to define the clip
// without using a mask image.
//
// And if you _really really_ need to add an exception, add it to where
// the polygon check is.
// And if you _really really_ need to add an exception, add it to
// nsSVGIntegrationUtils::UsingSimpleClipPathForFrame
MOZ_ASSERT_UNREACHABLE("Unhandled shape id?");
return Nothing();
}

Просмотреть файл

@ -169,6 +169,22 @@ bool nsSVGIntegrationUtils::UsingMaskOrClipPathForFrame(
return style->HasClipPath() || style->HasMask();
}
bool nsSVGIntegrationUtils::UsingSimpleClipPathForFrame(
const nsIFrame* aFrame) {
const nsStyleSVGReset* style = aFrame->StyleSVGReset();
if (!style->HasClipPath() || style->HasMask()) {
return false;
}
const auto& clipPath = style->mClipPath;
if (clipPath.GetType() != StyleShapeSourceType::Shape) {
return false;
}
const auto& shape = clipPath.BasicShape();
return (shape.GetShapeType() != StyleBasicShapeType::Polygon);
}
nsPoint nsSVGIntegrationUtils::GetOffsetToBoundingBox(nsIFrame* aFrame) {
if ((aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT)) {
// Do NOT call GetAllInFlowRectsUnion for SVG - it will get the

Просмотреть файл

@ -68,6 +68,12 @@ class nsSVGIntegrationUtils final {
*/
static bool UsingMaskOrClipPathForFrame(const nsIFrame* aFrame);
/**
* Returns true if the element has a clippath that is simple enough to
* be represented without a mask in WebRender.
*/
static bool UsingSimpleClipPathForFrame(const nsIFrame* aFrame);
/**
* Returns the size of the union of the border-box rects of all of
* aNonSVGFrame's continuations.