Bug 1311620 - Part 3: Incorporate null_t in Animatable. r?birtles
We couldn't tell the difference between a null StyleAnimationValue and
transform:none on the compositor. This was not a problem before, since we didn't
need the null StyleAnimationValue on the compositor, because the null
StyleAnimationValue have to be passed with composite:add flag, and in the case of
composite:add we just used the underlying value, i.e. we didn't use the null
value at all.
But for normal additive animations, we have to check the null StyleAnimationValue
to tell whether we are processing a missing keyframe or not.
So in this patch, Animatable can be null_t to represent the null
StyleAnimationValue, and as a result of this change, we can drop
BaseAnimationStyle.
MozReview-Commit-ID: Au41ujHgPpU
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -427,16 +427,18 @@ CreateCSSValueList(const InfallibleTArra
}
static StyleAnimationValue
ToStyleAnimationValue(const Animatable& aAnimatable)
{
StyleAnimationValue result;
switch (aAnimatable.type()) {
+ case Animatable::Tnull_t:
+ break;
case Animatable::TArrayOfTransformFunction: {
const InfallibleTArray<TransformFunction>& transforms =
aAnimatable.get_ArrayOfTransformFunction();
result.SetTransformValue(CreateCSSValueList(transforms));
break;
}
case Animatable::Tfloat:
result.SetFloatValue(aAnimatable.get_float());
@@ -466,19 +468,18 @@ Layer::SetAnimations(const AnimationArra
break;
case dom::FillMode::Backwards:
animation.fillMode() = static_cast<uint8_t>(dom::FillMode::Both);
break;
default:
break;
}
- if (animation.baseStyle().type() != BaseAnimationStyle::Tnull_t) {
- mBaseAnimationStyle =
- ToStyleAnimationValue(animation.baseStyle().get_Animatable());
+ if (animation.baseStyle().type() != Animatable::Tnull_t) {
+ mBaseAnimationStyle = ToStyleAnimationValue(animation.baseStyle());
}
AnimData* data = mAnimationData.AppendElement();
InfallibleTArray<Maybe<ComputedTimingFunction>>& functions =
data->mFunctions;
const InfallibleTArray<AnimationSegment>& segments = animation.segments();
for (uint32_t j = 0; j < segments.Length(); j++) {
TimingFunction tf = segments.ElementAt(j).sampleFn();
--- a/gfx/layers/ipc/LayersMessages.ipdlh
+++ b/gfx/layers/ipc/LayersMessages.ipdlh
@@ -151,25 +151,21 @@ union TransformFunction {
Skew;
SkewX;
SkewY;
Translation;
TransformMatrix;
};
union Animatable {
+ null_t;
float;
TransformFunction[];
};
-union BaseAnimationStyle {
- null_t;
- Animatable;
-};
-
struct AnimationSegment {
Animatable startState;
Animatable endState;
float startPortion;
float endPortion;
uint8_t startComposite;
uint8_t endComposite;
TimingFunction sampleFn;
@@ -227,17 +223,17 @@ struct Animation {
uint8_t iterationComposite;
// True if the animation has a fixed current time (e.g. paused and
// forward-filling animations).
bool isNotPlaying;
// The base style that animations should composite with. This is only set for
// animations with a composite mode of additive or accumulate, and only for
// the first animation in the set (i.e. the animation that is lowest in the
// stack). In all other cases the value is null_t.
- BaseAnimationStyle baseStyle;
+ Animatable baseStyle;
};
// Change a layer's attributes
struct CommonLayerAttributes {
IntRect layerBounds;
LayerIntRegion visibleRegion;
EventRegions eventRegions;
TransformMatrix transform;
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -389,58 +389,56 @@ static void
SetAnimatable(nsCSSPropertyID aProperty,
const StyleAnimationValue& aAnimationValue,
nsIFrame* aFrame,
const TransformReferenceBox& aRefBox,
layers::Animatable& aAnimatable)
{
MOZ_ASSERT(aFrame);
+ if (aAnimationValue.IsNull()) {
+ aAnimatable = null_t();
+ return;
+ }
+
switch (aProperty) {
case eCSSProperty_opacity:
- if (!aAnimationValue.IsNull()) {
- aAnimatable = aAnimationValue.GetFloatValue();
- } else {
- aAnimatable = 0.0;
- }
+ aAnimatable = aAnimationValue.GetFloatValue();
break;
- case eCSSProperty_transform:
+ case eCSSProperty_transform: {
aAnimatable = InfallibleTArray<TransformFunction>();
- if (!aAnimationValue.IsNull()) {
- nsCSSValueSharedList* list =
- aAnimationValue.GetCSSValueSharedListValue();
- TransformReferenceBox refBox(aFrame);
- AddTransformFunctions(list->mHead,
- aFrame->StyleContext(),
- aFrame->PresContext(),
- refBox,
- aAnimatable.get_ArrayOfTransformFunction());
- }
+ nsCSSValueSharedList* list =
+ aAnimationValue.GetCSSValueSharedListValue();
+ TransformReferenceBox refBox(aFrame);
+ AddTransformFunctions(list->mHead,
+ aFrame->StyleContext(),
+ aFrame->PresContext(),
+ refBox,
+ aAnimatable.get_ArrayOfTransformFunction());
break;
+ }
default:
MOZ_ASSERT_UNREACHABLE("Unsupported property");
}
}
static void
SetBaseAnimationStyle(nsCSSPropertyID aProperty,
nsIFrame* aFrame,
const TransformReferenceBox& aRefBox,
- layers::BaseAnimationStyle& aBaseStyle)
+ layers::Animatable& aBaseStyle)
{
MOZ_ASSERT(aFrame);
StyleAnimationValue baseValue =
EffectCompositor::GetBaseStyle(aProperty, aFrame);
MOZ_ASSERT(!baseValue.IsNull(),
"The base value should be already there");
- layers::Animatable animatable;
- SetAnimatable(aProperty, baseValue, aFrame, aRefBox, animatable);
- aBaseStyle = animatable;
+ SetAnimatable(aProperty, baseValue, aFrame, aRefBox, aBaseStyle);
}
static void
AddAnimationForProperty(nsIFrame* aFrame, const AnimationProperty& aProperty,
dom::Animation* aAnimation, Layer* aLayer,
AnimationData& aData, bool aPending)
{
MOZ_ASSERT(aLayer->AsContainerLayer(), "Should only animate ContainerLayer");