mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1540190 - replace the AnimationData IPDL union with native Maybe syntax; r=kats
Differential Revision: https://phabricator.services.mozilla.com/D25425 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
9ebd6eb639
commit
44989b091f
@ -361,19 +361,19 @@ AnimationHelper::SampleResult AnimationHelper::SampleAnimationForEachNode(
|
||||
|
||||
#ifdef DEBUG
|
||||
// Sanity check that all of animation data are the same.
|
||||
const AnimationData& lastData =
|
||||
const Maybe<TransformData>& lastData =
|
||||
aPropertyAnimationGroups.LastElement().mAnimationData;
|
||||
for (const PropertyAnimationGroup& group : aPropertyAnimationGroups) {
|
||||
const AnimationData& data = group.mAnimationData;
|
||||
MOZ_ASSERT(data.type() == lastData.type(),
|
||||
const Maybe<TransformData>& data = group.mAnimationData;
|
||||
MOZ_ASSERT(data.isSome() == lastData.isSome(),
|
||||
"The type of AnimationData should be the same");
|
||||
if (data.type() == AnimationData::Tnull_t) {
|
||||
if (data.isNothing()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(data.type() == AnimationData::TTransformData);
|
||||
const TransformData& transformData = data.get_TransformData();
|
||||
const TransformData& lastTransformData = lastData.get_TransformData();
|
||||
MOZ_ASSERT(data.isSome());
|
||||
const TransformData& transformData = data.ref();
|
||||
const TransformData& lastTransformData = lastData.ref();
|
||||
MOZ_ASSERT(transformData.origin() == lastTransformData.origin() &&
|
||||
transformData.transformOrigin() ==
|
||||
lastTransformData.transformOrigin() &&
|
||||
@ -573,7 +573,7 @@ bool AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage,
|
||||
case eCSSProperty_translate:
|
||||
case eCSSProperty_transform: {
|
||||
const TransformData& transformData =
|
||||
lastPropertyAnimationGroup.mAnimationData.get_TransformData();
|
||||
lastPropertyAnimationGroup.mAnimationData.ref();
|
||||
|
||||
gfx::Matrix4x4 transform =
|
||||
ServoAnimationValueToMatrix4x4(animationValues, transformData);
|
||||
|
@ -61,7 +61,7 @@ struct PropertyAnimation {
|
||||
|
||||
struct PropertyAnimationGroup {
|
||||
nsCSSPropertyID mProperty;
|
||||
AnimationData mAnimationData;
|
||||
Maybe<TransformData> mAnimationData;
|
||||
|
||||
nsTArray<PropertyAnimation> mAnimations;
|
||||
RefPtr<RawServoAnimationValue> mBaseStyle;
|
||||
|
@ -593,7 +593,7 @@ static Matrix4x4 FrameTransformToTransformInDevice(
|
||||
|
||||
static void ApplyAnimatedValue(
|
||||
Layer* aLayer, CompositorAnimationStorage* aStorage,
|
||||
nsCSSPropertyID aProperty, const AnimationData& aAnimationData,
|
||||
nsCSSPropertyID aProperty, const Maybe<TransformData>& aAnimationData,
|
||||
const nsTArray<RefPtr<RawServoAnimationValue>>& aValues) {
|
||||
MOZ_ASSERT(!aValues.IsEmpty());
|
||||
|
||||
@ -629,7 +629,7 @@ static void ApplyAnimatedValue(
|
||||
case eCSSProperty_scale:
|
||||
case eCSSProperty_translate:
|
||||
case eCSSProperty_transform: {
|
||||
const TransformData& transformData = aAnimationData.get_TransformData();
|
||||
const TransformData& transformData = aAnimationData.ref();
|
||||
|
||||
Matrix4x4 frameTransform =
|
||||
AnimationHelper::ServoAnimationValueToMatrix4x4(aValues,
|
||||
@ -719,7 +719,7 @@ static bool SampleAnimations(Layer* aLayer,
|
||||
MOZ_ASSERT(previousValue);
|
||||
#ifdef DEBUG
|
||||
const TransformData& transformData =
|
||||
lastPropertyAnimationGroup.mAnimationData.get_TransformData();
|
||||
lastPropertyAnimationGroup.mAnimationData.ref();
|
||||
Matrix4x4 frameTransform =
|
||||
AnimationHelper::ServoAnimationValueToMatrix4x4(animationValues,
|
||||
transformData);
|
||||
|
@ -724,10 +724,10 @@ mozilla::ipc::IPCResult LayerTransactionParent::RecvGetTransform(
|
||||
Point3D transformOrigin;
|
||||
for (const PropertyAnimationGroup& group :
|
||||
layer->GetPropertyAnimationGroups()) {
|
||||
if (group.mAnimationData.type() != AnimationData::TTransformData) {
|
||||
if (group.mAnimationData.isNothing()) {
|
||||
continue;
|
||||
}
|
||||
const TransformData& data = group.mAnimationData.get_TransformData();
|
||||
const TransformData& data = group.mAnimationData.ref();
|
||||
scale = data.appUnitsPerDevPixel();
|
||||
scaledOrigin = Point3D(
|
||||
NS_round(NSAppUnitsToFloatPixels(data.origin().x, scale)),
|
||||
|
@ -198,11 +198,6 @@ struct TransformData {
|
||||
bool hasPerspectiveParent;
|
||||
};
|
||||
|
||||
union AnimationData {
|
||||
null_t;
|
||||
TransformData;
|
||||
};
|
||||
|
||||
struct Animation {
|
||||
// The zero time of this Animation's timeline. May be null if isNotPlaying is
|
||||
// true.
|
||||
@ -237,7 +232,7 @@ struct Animation {
|
||||
// This uses dom::FillMode.
|
||||
uint8_t fillMode;
|
||||
nsCSSPropertyID property;
|
||||
AnimationData data;
|
||||
TransformData? data;
|
||||
float playbackRate;
|
||||
// When performing an asynchronous update to the playbackRate, |playbackRate|
|
||||
// above is the updated playbackRate while |previousPlaybackRate| is the
|
||||
|
@ -521,7 +521,8 @@ enum class Send {
|
||||
static void AddAnimationForProperty(nsIFrame* aFrame,
|
||||
const AnimationProperty& aProperty,
|
||||
dom::Animation* aAnimation,
|
||||
const AnimationData& aData, Send aSendFlag,
|
||||
const Maybe<TransformData>& aData,
|
||||
Send aSendFlag,
|
||||
AnimationInfo& aAnimationInfo) {
|
||||
MOZ_ASSERT(aAnimation->GetEffect(),
|
||||
"Should not be adding an animation without an effect");
|
||||
@ -690,8 +691,8 @@ GroupAnimationsByProperty(const nsTArray<RefPtr<dom::Animation>>& aAnimations,
|
||||
static void AddAnimationsForProperty(
|
||||
nsIFrame* aFrame, const EffectSet* aEffects,
|
||||
const nsTArray<RefPtr<dom::Animation>>& aCompositorAnimations,
|
||||
const AnimationData& aData, nsCSSPropertyID aProperty, Send aSendFlag,
|
||||
AnimationInfo& aAnimationInfo) {
|
||||
const Maybe<TransformData>& aData, nsCSSPropertyID aProperty,
|
||||
Send aSendFlag, AnimationInfo& aAnimationInfo) {
|
||||
// Add from first to last (since last overrides)
|
||||
for (dom::Animation* anim : aCompositorAnimations) {
|
||||
if (!anim->IsRelevant()) {
|
||||
@ -739,11 +740,11 @@ static void AddAnimationsForProperty(
|
||||
}
|
||||
}
|
||||
|
||||
static AnimationData CreateAnimationData(nsIFrame* aFrame, nsDisplayItem* aItem,
|
||||
DisplayItemType aType,
|
||||
layers::LayersBackend aLayersBackend) {
|
||||
static Maybe<TransformData> CreateAnimationData(
|
||||
nsIFrame* aFrame, nsDisplayItem* aItem, DisplayItemType aType,
|
||||
layers::LayersBackend aLayersBackend) {
|
||||
if (aType != DisplayItemType::TYPE_TRANSFORM) {
|
||||
return AnimationData(null_t());
|
||||
return Nothing();
|
||||
}
|
||||
|
||||
// XXX Performance here isn't ideal for SVG. We'd prefer to avoid resolving
|
||||
@ -781,9 +782,9 @@ static AnimationData CreateAnimationData(nsIFrame* aFrame, nsDisplayItem* aItem,
|
||||
origin = aFrame->GetOffsetToCrossDoc(referenceFrame);
|
||||
}
|
||||
|
||||
return AnimationData(TransformData(origin, offsetToTransformOrigin, bounds,
|
||||
devPixelsToAppUnits, scaleX, scaleY,
|
||||
hasPerspectiveParent));
|
||||
return Some(TransformData(origin, offsetToTransformOrigin, bounds,
|
||||
devPixelsToAppUnits, scaleX, scaleY,
|
||||
hasPerspectiveParent));
|
||||
}
|
||||
|
||||
static void AddAnimationsForDisplayItem(nsIFrame* aFrame,
|
||||
@ -828,7 +829,7 @@ static void AddAnimationsForDisplayItem(nsIFrame* aFrame,
|
||||
return;
|
||||
}
|
||||
|
||||
const AnimationData data =
|
||||
const Maybe<TransformData> data =
|
||||
CreateAnimationData(aFrame, aItem, aType, aLayersBackend);
|
||||
const HashMap<nsCSSPropertyID, nsTArray<RefPtr<dom::Animation>>>
|
||||
compositorAnimations =
|
||||
|
Loading…
Reference in New Issue
Block a user