Bug 1340005 - Part 3: Use AnimationValue on the compositor thread. r=birtles

MozReview-Commit-ID: CtnDLsdcr9x

--HG--
extra : rebase_source : 3d4a0f40e2f522471555c04c88474cb08e082851
This commit is contained in:
Boris Chiou 2017-09-21 17:01:48 +08:00
Родитель 7086921688
Коммит 743614effe
6 изменённых файлов: 43 добавлений и 40 удалений

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

@ -195,11 +195,12 @@ SampleValue(double aPortion, const layers::Animation& aAnimation,
}
bool
AnimationHelper::SampleAnimationForEachNode(TimeStamp aTime,
AnimationArray& aAnimations,
InfallibleTArray<AnimData>& aAnimationData,
StyleAnimationValue& aAnimationValue,
bool& aHasInEffectAnimations)
AnimationHelper::SampleAnimationForEachNode(
TimeStamp aTime,
AnimationArray& aAnimations,
InfallibleTArray<AnimData>& aAnimationData,
AnimationValue& aAnimationValue,
bool& aHasInEffectAnimations)
{
bool activeAnimations = false;
@ -269,20 +270,21 @@ AnimationHelper::SampleAnimationForEachNode(TimeStamp aTime,
computedTiming.mBeforeFlag);
StyleAnimationValueCompositePair from {
animData.mStartValues[segmentIndex],
animData.mStartValues[segmentIndex].mGecko,
static_cast<dom::CompositeOperation>(segment->startComposite())
};
StyleAnimationValueCompositePair to {
animData.mEndValues[segmentIndex],
animData.mEndValues[segmentIndex].mGecko,
static_cast<dom::CompositeOperation>(segment->endComposite())
};
// interpolate the property
aAnimationValue = SampleValue(portion,
animation,
from, to,
animData.mEndValues.LastElement(),
computedTiming.mCurrentIteration,
aAnimationValue);
aAnimationValue.mGecko =
SampleValue(portion,
animation,
from, to,
animData.mEndValues.LastElement().mGecko,
computedTiming.mCurrentIteration,
aAnimationValue.mGecko);
aHasInEffectAnimations = true;
}
@ -493,7 +495,7 @@ ToAnimationValue(const Animatable& aAnimatable)
void
AnimationHelper::SetAnimations(AnimationArray& aAnimations,
InfallibleTArray<AnimData>& aAnimData,
StyleAnimationValue& aBaseAnimationStyle)
AnimationValue& aBaseAnimationStyle)
{
for (uint32_t i = 0; i < aAnimations.Length(); i++) {
Animation& animation = aAnimations[i];
@ -512,19 +514,19 @@ AnimationHelper::SetAnimations(AnimationArray& aAnimations,
}
if (animation.baseStyle().type() != Animatable::Tnull_t) {
aBaseAnimationStyle = ToAnimationValue(animation.baseStyle()).mGecko;
aBaseAnimationStyle = ToAnimationValue(animation.baseStyle());
}
AnimData* data = aAnimData.AppendElement();
InfallibleTArray<Maybe<ComputedTimingFunction>>& functions =
data->mFunctions;
InfallibleTArray<StyleAnimationValue>& startValues = data->mStartValues;
InfallibleTArray<StyleAnimationValue>& endValues = data->mEndValues;
InfallibleTArray<AnimationValue>& startValues = data->mStartValues;
InfallibleTArray<AnimationValue>& endValues = data->mEndValues;
const InfallibleTArray<AnimationSegment>& segments = animation.segments();
for (const AnimationSegment& segment : segments) {
startValues.AppendElement(ToAnimationValue(segment.startState()).mGecko);
endValues.AppendElement(ToAnimationValue(segment.endState()).mGecko);
startValues.AppendElement(ToAnimationValue(segment.startState()));
endValues.AppendElement(ToAnimationValue(segment.endState()));
TimingFunction tf = segment.sampleFn();
Maybe<ComputedTimingFunction> ctf =
@ -562,7 +564,7 @@ AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage,
!iter.Done(); iter.Next()) {
bool hasInEffectAnimations = false;
AnimationArray* animations = iter.UserData();
StyleAnimationValue animationValue;
AnimationValue animationValue;
InfallibleTArray<AnimData> animationData;
AnimationHelper::SetAnimations(*animations,
animationData,
@ -581,12 +583,12 @@ AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage,
Animation& animation = animations->LastElement();
switch (animation.property()) {
case eCSSProperty_opacity: {
aStorage->SetAnimatedValue(iter.Key(),
animationValue.GetFloatValue());
aStorage->SetAnimatedValue(iter.Key(), animationValue.GetOpacity());
break;
}
case eCSSProperty_transform: {
nsCSSValueSharedList* list = animationValue.GetCSSValueSharedListValue();
// TODO: Convert AnimationValue into css shared list.
nsCSSValueSharedList* list = animationValue.mGecko.GetCSSValueSharedListValue();
const TransformData& transformData = animation.data().get_TransformData();
nsPoint origin = transformData.origin();
// we expect all our transform data to arrive in device pixels

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

@ -13,15 +13,15 @@
namespace mozilla {
class StyleAnimationValue;
struct AnimationValue;
namespace layers {
class Animation;
typedef InfallibleTArray<layers::Animation> AnimationArray;
struct AnimData {
InfallibleTArray<mozilla::StyleAnimationValue> mStartValues;
InfallibleTArray<mozilla::StyleAnimationValue> mEndValues;
InfallibleTArray<mozilla::AnimationValue> mStartValues;
InfallibleTArray<mozilla::AnimationValue> mEndValues;
InfallibleTArray<Maybe<mozilla::ComputedTimingFunction>> mFunctions;
};
@ -203,7 +203,7 @@ public:
SampleAnimationForEachNode(TimeStamp aTime,
AnimationArray& aAnimations,
InfallibleTArray<AnimData>& aAnimationData,
StyleAnimationValue& aAnimationValue,
AnimationValue& aAnimationValue,
bool& aHasInEffectAnimations);
/**
* Populates AnimData stuctures into |aAnimData| and |aBaseAnimationStyle|
@ -212,7 +212,7 @@ public:
static void
SetAnimations(AnimationArray& aAnimations,
InfallibleTArray<AnimData>& aAnimData,
StyleAnimationValue& aBaseAnimationStyle);
AnimationValue& aBaseAnimationStyle);
/**
* Get a unique id to represent the compositor animation between child

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

@ -50,7 +50,7 @@ public:
void TransferMutatedFlagToLayer(Layer* aLayer);
uint64_t GetCompositorAnimationsId() { return mCompositorAnimationsId; }
StyleAnimationValue GetBaseAnimationStyle() const { return mBaseAnimationStyle; }
AnimationValue GetBaseAnimationStyle() const { return mBaseAnimationStyle; }
InfallibleTArray<AnimData>& GetAnimationData() { return mAnimationData; }
AnimationArray& GetAnimations() { return mAnimations; }
bool ApplyPendingUpdatesForThisTransaction();
@ -66,7 +66,7 @@ protected:
// If this layer is used for OMTA, then this counter is used to ensure we
// stay in sync with the animation manager
uint64_t mAnimationGeneration;
StyleAnimationValue mBaseAnimationStyle;
AnimationValue mBaseAnimationStyle;
bool mMutated;
};

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

@ -1436,7 +1436,7 @@ public:
bool HasTransformAnimation() const;
bool HasOpacityAnimation() const;
StyleAnimationValue GetBaseAnimationStyle() const
AnimationValue GetBaseAnimationStyle() const
{
return mAnimationInfo.GetBaseAnimationStyle();
}

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

@ -579,30 +579,29 @@ ApplyAnimatedValue(Layer* aLayer,
CompositorAnimationStorage* aStorage,
nsCSSPropertyID aProperty,
const AnimationData& aAnimationData,
const StyleAnimationValue& aValue)
const AnimationValue& aValue)
{
if (aValue.IsNull()) {
// Return gracefully if we have no valid StyleAnimationValue.
// Return gracefully if we have no valid AnimationValue.
return;
}
HostLayer* layerCompositor = aLayer->AsHostLayer();
switch (aProperty) {
case eCSSProperty_opacity: {
MOZ_ASSERT(aValue.GetUnit() == StyleAnimationValue::eUnit_Float,
"Interpolated value for opacity should be float");
layerCompositor->SetShadowOpacity(aValue.GetFloatValue());
layerCompositor->SetShadowOpacity(aValue.GetOpacity());
layerCompositor->SetShadowOpacitySetByAnimation(true);
aStorage->SetAnimatedValue(aLayer->GetCompositorAnimationsId(),
aValue.GetFloatValue());
aValue.GetOpacity());
break;
}
case eCSSProperty_transform: {
MOZ_ASSERT(aValue.GetUnit() == StyleAnimationValue::eUnit_Transform,
MOZ_ASSERT(aValue.mGecko.GetUnit() == StyleAnimationValue::eUnit_Transform,
"The unit of interpolated value for transform should be "
"transform");
nsCSSValueSharedList* list = aValue.GetCSSValueSharedListValue();
// TODO: Convert AnimationValue into css shared list.
nsCSSValueSharedList* list = aValue.mGecko.GetCSSValueSharedListValue();
const TransformData& transformData = aAnimationData.get_TransformData();
nsPoint origin = transformData.origin();
@ -669,7 +668,7 @@ SampleAnimations(Layer* aLayer,
}
bool hasInEffectAnimations = false;
StyleAnimationValue animationValue = layer->GetBaseAnimationStyle();
AnimationValue animationValue = layer->GetBaseAnimationStyle();
if (AnimationHelper::SampleAnimationForEachNode(aTime,
layer->GetAnimations(),
layer->GetAnimationData(),

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

@ -5354,6 +5354,8 @@ float
AnimationValue::GetOpacity() const
{
MOZ_ASSERT(!mServo != mGecko.IsNull());
MOZ_ASSERT(mServo || mGecko.GetUnit() == StyleAnimationValue::eUnit_Float,
"Should have the correct unit on Gecko backend");
return mServo ? Servo_AnimationValue_GetOpacity(mServo)
: mGecko.GetFloatValue();
}