mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
Bug 1611043 - Convert mask-type #defines to an enum class. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D60987 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
d551a31fb6
commit
0c665c265e
@ -140,6 +140,7 @@ rusty-enums = [
|
||||
"mozilla::StyleFlexWrap",
|
||||
"mozilla::StyleTextDecorationSkipInk",
|
||||
"mozilla::StyleTextDecorationLength",
|
||||
"mozilla::StyleMaskType",
|
||||
"mozilla::StyleShapeRendering",
|
||||
"mozilla::StyleTextAnchor",
|
||||
"mozilla::StyleObjectFit",
|
||||
|
@ -751,8 +751,10 @@ enum class StyleDominantBaseline : uint8_t {
|
||||
#define NS_STYLE_IMAGE_RENDERING_CRISP_EDGES 3
|
||||
|
||||
// mask-type
|
||||
#define NS_STYLE_MASK_TYPE_LUMINANCE 0
|
||||
#define NS_STYLE_MASK_TYPE_ALPHA 1
|
||||
enum class StyleMaskType : uint8_t {
|
||||
Luminance,
|
||||
Alpha,
|
||||
};
|
||||
|
||||
// shape-rendering
|
||||
enum class StyleShapeRendering : uint8_t {
|
||||
|
@ -1057,7 +1057,7 @@ nsStyleSVGReset::nsStyleSVGReset(const Document& aDocument)
|
||||
mStopOpacity(1.0f),
|
||||
mFloodOpacity(1.0f),
|
||||
mVectorEffect(NS_STYLE_VECTOR_EFFECT_NONE),
|
||||
mMaskType(NS_STYLE_MASK_TYPE_LUMINANCE) {
|
||||
mMaskType(StyleMaskType::Luminance) {
|
||||
MOZ_COUNT_CTOR(nsStyleSVGReset);
|
||||
}
|
||||
|
||||
|
@ -2204,7 +2204,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVGReset {
|
||||
float mFloodOpacity;
|
||||
|
||||
uint8_t mVectorEffect; // NS_STYLE_VECTOR_EFFECT_*
|
||||
uint8_t mMaskType; // NS_STYLE_MASK_TYPE_*
|
||||
mozilla::StyleMaskType mMaskType;
|
||||
};
|
||||
|
||||
struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleEffects {
|
||||
|
@ -24,19 +24,6 @@ using namespace mozilla::dom::SVGUnitTypes_Binding;
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::image;
|
||||
|
||||
static LuminanceType GetLuminanceType(uint8_t aNSMaskType) {
|
||||
switch (aNSMaskType) {
|
||||
case NS_STYLE_MASK_TYPE_LUMINANCE:
|
||||
return LuminanceType::LUMINANCE;
|
||||
case NS_STYLE_COLOR_INTERPOLATION_LINEARRGB:
|
||||
return LuminanceType::LINEARRGB;
|
||||
default: {
|
||||
NS_WARNING("Unknown SVG mask type, defaulting to luminance");
|
||||
return LuminanceType::LUMINANCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsIFrame* NS_NewSVGMaskFrame(PresShell* aPresShell, ComputedStyle* aStyle) {
|
||||
return new (aPresShell) nsSVGMaskFrame(aStyle, aPresShell->GetPresContext());
|
||||
}
|
||||
@ -66,17 +53,17 @@ already_AddRefed<SourceSurface> nsSVGMaskFrame::GetMaskForMaskedFrame(
|
||||
Rect maskSurfaceRect = ToRect(maskSurfaceRectDouble);
|
||||
maskSurfaceRect.RoundOut();
|
||||
|
||||
uint8_t maskType;
|
||||
StyleMaskType maskType;
|
||||
if (aParams.maskMode == StyleMaskMode::MatchSource) {
|
||||
maskType = StyleSVGReset()->mMaskType;
|
||||
} else {
|
||||
maskType = aParams.maskMode == StyleMaskMode::Luminance
|
||||
? NS_STYLE_MASK_TYPE_LUMINANCE
|
||||
: NS_STYLE_MASK_TYPE_ALPHA;
|
||||
? StyleMaskType::Luminance
|
||||
: StyleMaskType::Alpha;
|
||||
}
|
||||
|
||||
RefPtr<DrawTarget> maskDT;
|
||||
if (maskType == NS_STYLE_MASK_TYPE_LUMINANCE) {
|
||||
if (maskType == StyleMaskType::Luminance) {
|
||||
maskDT = context->GetDrawTarget()->CreateClippedDrawTarget(
|
||||
maskSurfaceRect, SurfaceFormat::B8G8R8A8);
|
||||
} else {
|
||||
@ -109,14 +96,15 @@ already_AddRefed<SourceSurface> nsSVGMaskFrame::GetMaskForMaskedFrame(
|
||||
}
|
||||
|
||||
RefPtr<SourceSurface> surface;
|
||||
if (maskType == NS_STYLE_MASK_TYPE_LUMINANCE) {
|
||||
if (maskType == StyleMaskType::Luminance) {
|
||||
auto luminanceType = LuminanceType::LUMINANCE;
|
||||
if (StyleSVG()->mColorInterpolation ==
|
||||
NS_STYLE_COLOR_INTERPOLATION_LINEARRGB) {
|
||||
maskType = NS_STYLE_COLOR_INTERPOLATION_LINEARRGB;
|
||||
luminanceType = LuminanceType::LINEARRGB;
|
||||
}
|
||||
|
||||
RefPtr<SourceSurface> maskSnapshot = maskDT->IntoLuminanceSource(
|
||||
GetLuminanceType(maskType), aParams.opacity);
|
||||
RefPtr<SourceSurface> maskSnapshot =
|
||||
maskDT->IntoLuminanceSource(luminanceType, aParams.opacity);
|
||||
if (!maskSnapshot) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ ${helpers.single_keyword(
|
||||
"mask-type",
|
||||
"luminance alpha",
|
||||
engines="gecko",
|
||||
gecko_enum_prefix="StyleMaskType",
|
||||
animation_value_type="discrete",
|
||||
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-type",
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user