Bug 1250490 - Part 2. Remove DetermineMaskUsage and ComputeOpacity from nsSVGIntegrationUtils. r=mstange

MozReview-Commit-ID: 4gHW7PyMNhd

--HG--
extra : rebase_source : 68507df64232ebef68535e85cc9934833a428456
This commit is contained in:
cku 2016-11-03 11:16:46 +08:00
Родитель 511431abbf
Коммит 282a24594a
3 изменённых файлов: 9 добавлений и 102 удалений

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

@ -7090,8 +7090,8 @@ bool nsDisplayMask::ShouldPaintOnMaskLayer(LayerManager* aManager)
return false;
}
nsSVGIntegrationUtils::MaskUsage maskUsage;
nsSVGIntegrationUtils::DetermineMaskUsage(mFrame, mHandleOpacity, maskUsage);
nsSVGUtils::MaskUsage maskUsage;
nsSVGUtils::DetermineMaskUsage(mFrame, mHandleOpacity, maskUsage);
if (!maskUsage.shouldGenerateMaskLayer ||
maskUsage.opacity != 1.0 || maskUsage.shouldApplyClipPath ||

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

@ -576,19 +576,6 @@ CreateAndPaintMaskSurface(const PaintFramesParams& aParams,
return DrawResult::SUCCESS;
}
static float
ComputeOpacity(nsIFrame* aFrame, bool aHandleOpacity)
{
float opacity = aFrame->StyleEffects()->mOpacity;
if (opacity != 1.0f &&
(nsSVGUtils::CanOptimizeOpacity(aFrame) || !aHandleOpacity)) {
return 1.0f;
}
return opacity;
}
static bool
ValidateSVGFrame(nsIFrame* aFrame)
{
@ -685,72 +672,6 @@ SetupContextMatrix(nsIFrame* aFrame, const PaintFramesParams& aParams,
}
}
void
nsSVGIntegrationUtils::DetermineMaskUsage(nsIFrame* aFrame,
bool aHandleOpacity,
MaskUsage& aUsage)
{
aUsage.opacity = ComputeOpacity(aFrame, aHandleOpacity);
nsIFrame* firstFrame =
nsLayoutUtils::FirstContinuationOrIBSplitSibling(aFrame);
nsSVGEffects::EffectProperties effectProperties =
nsSVGEffects::GetEffectProperties(firstFrame);
const nsStyleSVGReset *svgReset = firstFrame->StyleSVGReset();
nsTArray<nsSVGMaskFrame*> maskFrames = effectProperties.GetMaskFrames();
#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
// For a HTML doc:
// According to css-masking spec, always create a mask surface when we
// have any item in maskFrame even if all of those items are
// non-resolvable <mask-sources> or <images>, we still need to create a
// transparent black mask layer under this condition.
// For a SVG doc:
// SVG 1.1 say that if we fail to resolve a mask, we should draw the
// object unmasked.
aUsage.shouldGenerateMaskLayer =
(aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT)
? maskFrames.Length() == 1 && maskFrames[0]
: maskFrames.Length() > 0;
#else
// Since we do not support image mask so far, we should treat any
// unresolvable mask as no mask. Otherwise, any object with a valid image
// mask, e.g. url("xxx.png"), will become invisible just because we can not
// handle image mask correctly. (See bug 1294171)
aUsage.shouldGenerateMaskLayer = maskFrames.Length() == 1 && maskFrames[0];
#endif
bool isOK = effectProperties.HasNoFilterOrHasValidFilter();
nsSVGClipPathFrame *clipPathFrame = effectProperties.GetClipPathFrame(&isOK);
MOZ_ASSERT_IF(clipPathFrame,
svgReset->mClipPath.GetType() == StyleShapeSourceType::URL);
switch (svgReset->mClipPath.GetType()) {
case StyleShapeSourceType::URL:
if (clipPathFrame) {
if (clipPathFrame->IsTrivial()) {
aUsage.shouldApplyClipPath = true;
} else {
aUsage.shouldGenerateClipMaskLayer = true;
}
}
break;
case StyleShapeSourceType::Shape:
case StyleShapeSourceType::Box:
aUsage.shouldApplyBasicShape = true;
break;
case StyleShapeSourceType::None:
MOZ_ASSERT(!aUsage.shouldGenerateClipMaskLayer &&
!aUsage.shouldApplyClipPath && !aUsage.shouldApplyBasicShape);
break;
default:
MOZ_ASSERT_UNREACHABLE("Unsupported clip-path type.");
break;
}
}
bool
nsSVGIntegrationUtils::IsMaskResourceReady(nsIFrame* aFrame)
{
@ -780,8 +701,9 @@ nsSVGIntegrationUtils::IsMaskResourceReady(nsIFrame* aFrame)
DrawResult
nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams)
{
MaskUsage maskUsage;
DetermineMaskUsage(aParams.frame, aParams.handleOpacity, maskUsage);
nsSVGUtils::MaskUsage maskUsage;
nsSVGUtils::DetermineMaskUsage(aParams.frame, aParams.handleOpacity,
maskUsage);
MOZ_ASSERT(maskUsage.shouldGenerateMaskLayer);
nsIFrame* frame = aParams.frame;
@ -841,8 +763,9 @@ nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
return result;
}
MaskUsage maskUsage;
DetermineMaskUsage(aParams.frame, aParams.handleOpacity, maskUsage);
nsSVGUtils::MaskUsage maskUsage;
nsSVGUtils::DetermineMaskUsage(aParams.frame, aParams.handleOpacity,
maskUsage);
if (maskUsage.opacity == 0.0f) {
return DrawResult::SUCCESS;
@ -1007,7 +930,7 @@ nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams)
return DrawResult::SUCCESS;
}
float opacity = ComputeOpacity(frame, aParams.handleOpacity);
float opacity = nsSVGUtils::ComputeOpacity(frame, aParams.handleOpacity);
if (opacity == 0.0f) {
return DrawResult::SUCCESS;
}

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

@ -167,22 +167,6 @@ public:
static DrawResult
PaintMask(const PaintFramesParams& aParams);
struct MaskUsage {
bool shouldGenerateMaskLayer;
bool shouldGenerateClipMaskLayer;
bool shouldApplyClipPath;
bool shouldApplyBasicShape;
float opacity;
MaskUsage()
: shouldGenerateMaskLayer(false), shouldGenerateClipMaskLayer(false),
shouldApplyClipPath(false), shouldApplyBasicShape(false), opacity(0.0)
{ }
};
static void
DetermineMaskUsage(nsIFrame* aFrame, bool aHandleOpacity, MaskUsage& aUsage);
/**
* Return true if all the mask resource of aFrame are ready.
*/