Bug 1324591 - Store the corresponding LayersId for each animation on the compositor. r=kats

Depends on D75727

Differential Revision: https://phabricator.services.mozilla.com/D75728
This commit is contained in:
Hiroyuki Ikezoe 2020-07-05 11:42:55 +00:00
parent 2fdb475e75
commit 1c1e6e4963
13 changed files with 28 additions and 12 deletions

View File

@ -315,8 +315,9 @@ static bool HasTransformLikeAnimations(const AnimationArray& aAnimations) {
#endif
AnimationStorageData AnimationHelper::ExtractAnimations(
const AnimationArray& aAnimations) {
const LayersId& aLayersId, const AnimationArray& aAnimations) {
AnimationStorageData storageData;
storageData.mLayersId = aLayersId;
nsCSSPropertyID prevID = eCSSProperty_UNKNOWN;
PropertyAnimationGroup* currData = nullptr;

View File

@ -115,7 +115,7 @@ class AnimationHelper {
* IPC boundary into something we can readily use for sampling.
*/
static AnimationStorageData ExtractAnimations(
const AnimationArray& aAnimations);
const LayersId& aLayersId, const AnimationArray& aAnimations);
/**
* Get a unique id to represent the compositor animation between child

View File

@ -81,11 +81,12 @@ void AnimationInfo::ClearAnimationsForNextTransaction() {
}
void AnimationInfo::SetCompositorAnimations(
const LayersId& aLayersId,
const CompositorAnimations& aCompositorAnimations) {
mCompositorAnimationsId = aCompositorAnimations.id();
mStorageData =
AnimationHelper::ExtractAnimations(aCompositorAnimations.animations());
mStorageData = AnimationHelper::ExtractAnimations(
aLayersId, aCompositorAnimations.animations());
}
bool AnimationInfo::StartPendingAnimations(const TimeStamp& aReadyTime) {

View File

@ -77,6 +77,7 @@ class AnimationInfo final {
void ClearAnimations();
void ClearAnimationsForNextTransaction();
void SetCompositorAnimations(
const LayersId& aLayersId,
const CompositorAnimations& aCompositorAnimations);
bool StartPendingAnimations(const TimeStamp& aReadyTime);
void TransferMutatedFlagToLayer(Layer* aLayer);
@ -91,6 +92,7 @@ class AnimationInfo final {
const Maybe<TransformData>& GetTransformData() const {
return mStorageData.mTransformData;
}
const LayersId& GetLayersId() const { return mStorageData.mLayersId; }
bool ApplyPendingUpdatesForThisTransaction();
bool HasTransformAnimation() const;

View File

@ -10,6 +10,7 @@
#include "mozilla/dom/Nullable.h"
#include "mozilla/ComputedTimingFunction.h" // for ComputedTimingFunction
#include "mozilla/layers/LayersMessages.h" // for TransformData, etc
#include "mozilla/layers/LayersTypes.h" // for LayersId
#include "mozilla/TimeStamp.h" // for TimeStamp
#include "mozilla/TimingParams.h"
#include "X11UndefineNone.h"
@ -75,6 +76,9 @@ struct AnimationStorageData {
Maybe<TransformData> mTransformData;
// For motion path. We cached the gfx path for optimization.
RefPtr<gfx::Path> mCachedMotionPath;
// This is used to communicate with the main-thread. E.g. to tell the fact
// that this animation needs to be pre-rendered again on the main-thread, etc.
LayersId mLayersId;
AnimationStorageData() = default;
AnimationStorageData(AnimationStorageData&& aOther) = default;

View File

@ -137,12 +137,13 @@ void CompositorAnimationStorage::SetAnimatedValue(uint64_t aId,
}
void CompositorAnimationStorage::SetAnimations(uint64_t aId,
const LayersId& aLayersId,
const AnimationArray& aValue) {
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
MutexAutoLock lock(mLock);
mAnimations[aId] = std::make_unique<AnimationStorageData>(
AnimationHelper::ExtractAnimations(aValue));
AnimationHelper::ExtractAnimations(aLayersId, aValue));
// If there is the last animated value, then we need to store the id to remove
// the value if the new animation doesn't produce any animated data (i.e. in

View File

@ -122,7 +122,8 @@ class CompositorAnimationStorage final {
/**
* Set the animations based on the unique id
*/
void SetAnimations(uint64_t aId, const AnimationArray& aAnimations);
void SetAnimations(uint64_t aId, const LayersId& aLayersId,
const AnimationArray& aAnimations);
/**
* Sample animation based the given timestamps and store them in this

View File

@ -187,12 +187,13 @@ Layer::Layer(LayerManager* aManager, void* aImplData)
Layer::~Layer() = default;
void Layer::SetCompositorAnimations(
const LayersId& aLayersId,
const CompositorAnimations& aCompositorAnimations) {
MOZ_LAYERS_LOG_IF_SHADOWABLE(
this, ("Layer::Mutated(%p) SetCompositorAnimations with id=%" PRIu64,
this, mAnimationInfo.GetCompositorAnimationsId()));
mAnimationInfo.SetCompositorAnimations(aCompositorAnimations);
mAnimationInfo.SetCompositorAnimations(aLayersId, aCompositorAnimations);
Mutated();
}

View File

@ -1254,6 +1254,7 @@ class Layer {
// This is only called when the layer tree is updated. Do not call this from
// layout code. To add an animation to this layer, use AddAnimation.
void SetCompositorAnimations(
const LayersId& aLayersId,
const CompositorAnimations& aCompositorAnimations);
// Go through all animations in this layer and its children and, for
// any animations with a null start time, update their start time such
@ -1468,6 +1469,9 @@ class Layer {
const Maybe<TransformData>& GetTransformData() const {
return mAnimationInfo.GetTransformData();
}
const LayersId& GetAnimationLayersId() const {
return mAnimationInfo.GetLayersId();
}
Maybe<uint64_t> GetAnimationGeneration() const {
return mAnimationInfo.GetAnimationGeneration();

View File

@ -524,7 +524,7 @@ bool LayerTransactionParent::SetLayerAttributes(
} else {
layer->SetMaskLayer(nullptr);
}
layer->SetCompositorAnimations(common.compositorAnimations());
layer->SetCompositorAnimations(mId, common.compositorAnimations());
// Clean up the Animations by id in the CompositorAnimationStorage
// if there are no active animations on the layer
if (mAnimStorage && layer->GetCompositorAnimationsId() &&

View File

@ -154,11 +154,12 @@ void OMTASampler::SampleForTesting(const Maybe<TimeStamp>& aTestingSampleTime) {
}
void OMTASampler::SetAnimations(
uint64_t aId, const nsTArray<layers::Animation>& aAnimations) {
uint64_t aId, const LayersId& aLayersId,
const nsTArray<layers::Animation>& aAnimations) {
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
MutexAutoLock lock(mStorageLock);
mAnimStorage->SetAnimations(aId, aAnimations);
mAnimStorage->SetAnimations(aId, aLayersId, aAnimations);
}
bool OMTASampler::HasAnimations() const {

View File

@ -66,7 +66,7 @@ class OMTASampler final {
*/
void SetSampleTime(const TimeStamp& aSampleTime);
void ResetPreviousSampleTime();
void SetAnimations(uint64_t aId,
void SetAnimations(uint64_t aId, const LayersId& aLayersId,
const nsTArray<layers::Animation>& aAnimations);
bool HasAnimations() const;

View File

@ -1387,7 +1387,7 @@ bool WebRenderBridgeParent::ProcessWebRenderParentCommands(
}
if (data.animations().Length()) {
if (RefPtr<OMTASampler> sampler = GetOMTASampler()) {
sampler->SetAnimations(data.id(), data.animations());
sampler->SetAnimations(data.id(), GetLayersId(), data.animations());
const auto activeAnim = mActiveAnimations.find(data.id());
if (activeAnim == mActiveAnimations.end()) {
mActiveAnimations.emplace(data.id(), mWrEpoch);