diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index d32b1fcf4fd..f5ed8b18f95 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -443,14 +443,14 @@ Layer::SetAnimations(const AnimationArray& aAnimations) endValue.SetAndAdoptCSSValueListValue(endList, nsStyleAnimation::eUnit_Transform); endValues->AppendElement(endValue); } else { - NS_ASSERTION(segment.endState().type() == Animatable::TOpacity, + NS_ASSERTION(segment.endState().type() == Animatable::Tfloat, "Unknown Animatable type"); nsStyleAnimation::Value startValue; - startValue.SetFloatValue(segment.startState().get_Opacity().value()); + startValue.SetFloatValue(segment.startState().get_float()); startValues->AppendElement(startValue); nsStyleAnimation::Value endValue; - endValue.SetFloatValue(segment.endState().get_Opacity().value()); + endValue.SetFloatValue(segment.endState().get_float()); endValues->AppendElement(endValue); } } diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index 02c10ca9a1f..7ade5d48862 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -580,9 +580,6 @@ SetShadowProperties(Layer* aLayer) } } -// SampleValue should eventually take the CSS property as an argument. This -// will be needed if we ever animate two values with the same type but different -// interpolation rules. static void SampleValue(float aPortion, Animation& aAnimation, nsStyleAnimation::Value& aStart, nsStyleAnimation::Value& aEnd, Animatable* aValue) @@ -591,28 +588,24 @@ SampleValue(float aPortion, Animation& aAnimation, nsStyleAnimation::Value& aSta NS_ASSERTION(aStart.GetUnit() == aEnd.GetUnit() || aStart.GetUnit() == nsStyleAnimation::eUnit_None || aEnd.GetUnit() == nsStyleAnimation::eUnit_None, "Must have same unit"); - if (aStart.GetUnit() == nsStyleAnimation::eUnit_Transform || - aEnd.GetUnit() == nsStyleAnimation::eUnit_Transform) { - nsStyleAnimation::Interpolate(eCSSProperty_transform, aStart, aEnd, - aPortion, interpolatedValue); - nsCSSValueList* interpolatedList = interpolatedValue.GetCSSValueListValue(); - - TransformData& data = aAnimation.data().get_TransformData(); - gfx3DMatrix transform = - nsDisplayTransform::GetResultingTransformMatrix(nullptr, data.origin(), nsDeviceContext::AppUnitsPerCSSPixel(), - &data.bounds(), interpolatedList, &data.mozOrigin(), - &data.perspectiveOrigin(), &data.perspective()); - - InfallibleTArray* functions = new InfallibleTArray(); - functions->AppendElement(TransformMatrix(transform)); - *aValue = *functions; + nsStyleAnimation::Interpolate(aAnimation.property(), aStart, aEnd, + aPortion, interpolatedValue); + if (aAnimation.property() == eCSSProperty_opacity) { + *aValue = interpolatedValue.GetFloatValue(); return; } - NS_ASSERTION(aStart.GetUnit() == nsStyleAnimation::eUnit_Float, "Should be opacity"); - nsStyleAnimation::Interpolate(eCSSProperty_opacity, aStart, aEnd, - aPortion, interpolatedValue); - *aValue = interpolatedValue.GetFloatValue(); + nsCSSValueList* interpolatedList = interpolatedValue.GetCSSValueListValue(); + + TransformData& data = aAnimation.data().get_TransformData(); + gfx3DMatrix transform = + nsDisplayTransform::GetResultingTransformMatrix(nullptr, data.origin(), nsDeviceContext::AppUnitsPerCSSPixel(), + &data.bounds(), interpolatedList, &data.mozOrigin(), + &data.perspectiveOrigin(), &data.perspective()); + + InfallibleTArray* functions = new InfallibleTArray(); + functions->AppendElement(TransformMatrix(transform)); + *aValue = *functions; } static bool @@ -665,11 +658,11 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint) SampleValue(portion, animation, animData.mStartValues[segmentIndex], animData.mEndValues[segmentIndex], &interpolatedValue); ShadowLayer* shadow = aLayer->AsShadowLayer(); - switch (interpolatedValue.type()) { - case Animatable::TOpacity: - shadow->SetShadowOpacity(interpolatedValue.get_Opacity().value()); + switch (animation.property()) { + case eCSSProperty_opacity: + shadow->SetShadowOpacity(interpolatedValue.get_float()); break; - case Animatable::TArrayOfTransformFunction: { + case eCSSProperty_transform: { gfx3DMatrix matrix = interpolatedValue.get_ArrayOfTransformFunction()[0].get_TransformMatrix().value(); shadow->SetShadowTransform(matrix); break; diff --git a/gfx/layers/ipc/PLayers.ipdl b/gfx/layers/ipc/PLayers.ipdl index 768e7aab413..cb254c22a88 100644 --- a/gfx/layers/ipc/PLayers.ipdl +++ b/gfx/layers/ipc/PLayers.ipdl @@ -6,7 +6,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ include LayersSurfaces; -using mozilla::ScreenRotation; include protocol PCompositor; include protocol PGrallocBuffer; include protocol PLayer; @@ -15,6 +14,7 @@ include protocol PRenderFrame; include "gfxipc/ShadowLayerUtils.h"; include "mozilla/WidgetUtils.h"; include "mozilla/TimeStamp.h"; +include "nsCSSProperty.h"; using gfxPoint3D; using nscoord; @@ -22,6 +22,8 @@ using nsRect; using nsPoint; using mozilla::TimeDuration; using mozilla::TimeStamp; +using mozilla::ScreenRotation; +using nsCSSProperty; /** * The layers protocol is spoken between thread contexts that manage @@ -78,7 +80,6 @@ union TimingFunction { }; struct Color { gfxRGBA value; }; -struct Opacity { float value; }; struct Perspective { float value; }; struct RotationX { float radians; }; struct RotationY { float radians; }; @@ -119,8 +120,7 @@ union TransformFunction { }; union Animatable { - Color; - Opacity; + float; TransformFunction[]; }; @@ -158,6 +158,7 @@ struct Animation { float numIterations; // This uses the NS_STYLE_ANIMATION_DIRECTION_* constants. int32_t direction; + nsCSSProperty property; AnimationData data; }; @@ -168,7 +169,7 @@ struct CommonLayerAttributes { float postXScale; float postYScale; PRUint32 contentFlags; - Opacity opacity; + float opacity; bool useClipRect; nsIntRect clipRect; bool isFixedPosition; diff --git a/gfx/layers/ipc/ShadowLayersParent.cpp b/gfx/layers/ipc/ShadowLayersParent.cpp index ef59ee392d8..0a1186a368b 100644 --- a/gfx/layers/ipc/ShadowLayersParent.cpp +++ b/gfx/layers/ipc/ShadowLayersParent.cpp @@ -215,7 +215,7 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray& cset, const CommonLayerAttributes& common = attrs.common(); layer->SetVisibleRegion(common.visibleRegion()); layer->SetContentFlags(common.contentFlags()); - layer->SetOpacity(common.opacity().value()); + layer->SetOpacity(common.opacity()); layer->SetClipRect(common.useClipRect() ? &common.clipRect() : NULL); layer->SetBaseTransform(common.transform().value()); layer->SetPostScale(common.postXScale(), common.postYScale()); diff --git a/ipc/glue/IPCMessageUtils.h b/ipc/glue/IPCMessageUtils.h index 64318076599..36e1c78dea3 100644 --- a/ipc/glue/IPCMessageUtils.h +++ b/ipc/glue/IPCMessageUtils.h @@ -30,6 +30,7 @@ #include "jsapi.h" #include "LayersTypes.h" #include "FrameMetrics.h" +#include "nsCSSProperty.h" #ifdef _MSC_VER #pragma warning( disable : 4800 ) @@ -602,6 +603,14 @@ struct ParamTraits gfxASurface::ImageFormatUnknown> {}; +template <> +struct ParamTraits + : public EnumSerializer +{}; + + template<> struct ParamTraits { diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 38b02beee9a..6b2e6397ea0 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -310,8 +310,8 @@ AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty, segment->mFromKey, segment->mToKey, ToTimingFunction(segment->mTimingFunction))); } else if (aProperty == eCSSProperty_opacity) { - segments.AppendElement(AnimationSegment(Opacity(segment->mFromValue.GetFloatValue()), - Opacity(segment->mToValue.GetFloatValue()), + segments.AppendElement(AnimationSegment(segment->mFromValue.GetFloatValue(), + segment->mToValue.GetFloatValue(), segment->mFromKey, segment->mToKey, ToTimingFunction(segment->mTimingFunction))); @@ -323,6 +323,7 @@ AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty, segments, iterations, ea->mDirection, + aProperty, aData)); } }