Bug 1358437 - pass layer's transform attributes for transform animation, r?kats

MozReview-Commit-ID: J7JHuwvWuet
This commit is contained in:
peter chang 2017-04-17 11:35:42 +08:00
Родитель c03a85af76
Коммит e8e398dcd1
5 изменённых файлов: 44 добавлений и 20 удалений

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

@ -540,21 +540,18 @@ AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage,
transformData.appUnitsPerDevPixel(), transformData.appUnitsPerDevPixel(),
0, &transformData.bounds()); 0, &transformData.bounds());
gfx::Matrix4x4 frameTransform = transform; gfx::Matrix4x4 frameTransform = transform;
// If the parent has perspective transform, then the offset into reference
//TODO how do we support this without layer information // frame coordinates is already on this transform. If not, then we need to ask
// If our parent layer is a perspective layer, then the offset into reference
// frame coordinates is already on that layer. If not, then we need to ask
// for it to be added here. // for it to be added here.
// if (!aLayer->GetParent() || if (!transformData.hasPerspectiveParent()) {
// !aLayer->GetParent()->GetTransformIsPerspective()) { nsLayoutUtils::PostTranslate(transform, origin,
// nsLayoutUtils::PostTranslate(transform, origin, transformData.appUnitsPerDevPixel(),
// transformData.appUnitsPerDevPixel(), true);
// true); }
// }
// if (ContainerLayer* c = aLayer->AsContainerLayer()) { transform.PostScale(transformData.inheritedXScale(),
// transform.PostScale(c->GetInheritedXScale(), c->GetInheritedYScale(), 1); transformData.inheritedYScale(),
// } 1);
aStorage->SetAnimatedValue(iter.Key(), aStorage->SetAnimatedValue(iter.Key(),
Move(transform), Move(frameTransform), Move(transform), Move(frameTransform),

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

@ -187,6 +187,11 @@ struct TransformData {
Point3D transformOrigin; Point3D transformOrigin;
nsRect bounds; nsRect bounds;
int32_t appUnitsPerDevPixel; int32_t appUnitsPerDevPixel;
// The resolution scale inherited from the parent
float inheritedXScale;
float inheritedYScale;
// True if the parent has perspective transform
bool hasPerspectiveParent;
}; };
union AnimationData { union AnimationData {

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

@ -27,6 +27,21 @@ WebRenderContainerLayer::ClearAnimations()
Layer::ClearAnimations(); Layer::ClearAnimations();
} }
void
WebRenderContainerLayer::UpdateTransformDataForAnimation()
{
for (Animation& animation : mAnimations) {
if (animation.property() == eCSSProperty_transform) {
TransformData& transformData = animation.data().get_TransformData();
transformData.inheritedXScale() = GetInheritedXScale();
transformData.inheritedYScale() = GetInheritedYScale();
transformData.hasPerspectiveParent() =
GetParent() && GetParent()->GetTransformIsPerspective();
}
}
}
}
void void
WebRenderContainerLayer::RenderLayer(wr::DisplayListBuilder& aBuilder) WebRenderContainerLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
{ {
@ -42,18 +57,19 @@ WebRenderContainerLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
!GetAnimations().IsEmpty()) { !GetAnimations().IsEmpty()) {
MOZ_ASSERT(GetCompositorAnimationsId()); MOZ_ASSERT(GetCompositorAnimationsId());
animationsId = GetCompositorAnimationsId();
CompositorAnimations anim;
anim.animations() = GetAnimations();
anim.id() = animationsId;
WrBridge()->AddWebRenderParentCommand(OpAddCompositorAnimations(anim));
if (!HasOpacityAnimation()) { if (!HasOpacityAnimation()) {
maybeOpacity = nullptr; maybeOpacity = nullptr;
} }
if (!HasTransformAnimation()) { if (!HasTransformAnimation()) {
maybeTransform = nullptr; maybeTransform = nullptr;
UpdateTransformDataForAnimation();
} }
animationsId = GetCompositorAnimationsId();
CompositorAnimations anim;
anim.animations() = GetAnimations();
anim.id() = animationsId;
WrBridge()->AddWebRenderParentCommand(OpAddCompositorAnimations(anim));
} }
StackingContextHelper sc(aBuilder, this, animationsId, maybeOpacity, maybeTransform); StackingContextHelper sc(aBuilder, this, animationsId, maybeOpacity, maybeTransform);

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

@ -38,6 +38,8 @@ protected:
MOZ_COUNT_DTOR(WebRenderContainerLayer); MOZ_COUNT_DTOR(WebRenderContainerLayer);
} }
void UpdateTransformDataForAnimation();
public: public:
Layer* GetLayer() override { return this; } Layer* GetLayer() override { return this; }
void RenderLayer(wr::DisplayListBuilder& aBuilder) override; void RenderLayer(wr::DisplayListBuilder& aBuilder) override;

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

@ -823,6 +823,9 @@ nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer,
Point3D offsetToTransformOrigin = Point3D offsetToTransformOrigin =
nsDisplayTransform::GetDeltaToTransformOrigin(aFrame, scale, &bounds); nsDisplayTransform::GetDeltaToTransformOrigin(aFrame, scale, &bounds);
nsPoint origin; nsPoint origin;
float scaleX = 1.0f;
float scaleY = 1.0f;
bool hasPerspectiveParent = false;
if (aItem) { if (aItem) {
// This branch is for display items to leverage the cache of // This branch is for display items to leverage the cache of
// nsDisplayListBuilder. // nsDisplayListBuilder.
@ -839,7 +842,8 @@ nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer,
} }
data = TransformData(origin, offsetToTransformOrigin, data = TransformData(origin, offsetToTransformOrigin,
bounds, devPixelsToAppUnits); bounds, devPixelsToAppUnits,
scaleX, scaleY, hasPerspectiveParent);
} else if (aProperty == eCSSProperty_opacity) { } else if (aProperty == eCSSProperty_opacity) {
data = null_t(); data = null_t();
} }