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

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

@ -187,6 +187,11 @@ struct TransformData {
Point3D transformOrigin;
nsRect bounds;
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 {

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

@ -27,6 +27,21 @@ WebRenderContainerLayer::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
WebRenderContainerLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
{
@ -42,18 +57,19 @@ WebRenderContainerLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
!GetAnimations().IsEmpty()) {
MOZ_ASSERT(GetCompositorAnimationsId());
animationsId = GetCompositorAnimationsId();
CompositorAnimations anim;
anim.animations() = GetAnimations();
anim.id() = animationsId;
WrBridge()->AddWebRenderParentCommand(OpAddCompositorAnimations(anim));
if (!HasOpacityAnimation()) {
maybeOpacity = nullptr;
}
if (!HasTransformAnimation()) {
maybeTransform = nullptr;
UpdateTransformDataForAnimation();
}
animationsId = GetCompositorAnimationsId();
CompositorAnimations anim;
anim.animations() = GetAnimations();
anim.id() = animationsId;
WrBridge()->AddWebRenderParentCommand(OpAddCompositorAnimations(anim));
}
StackingContextHelper sc(aBuilder, this, animationsId, maybeOpacity, maybeTransform);

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

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

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

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