зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1644591 - Store AnimationStorageData as std::unique_ptr in std::unordered_map. r=boris
Differential Revision: https://phabricator.services.mozilla.com/D79000
This commit is contained in:
Родитель
0cd86be789
Коммит
d7e086f85f
|
@ -26,14 +26,14 @@ void CompositorAnimationStorage::Clear() {
|
|||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
|
||||
mAnimatedValues.Clear();
|
||||
mAnimations.Clear();
|
||||
mAnimations.clear();
|
||||
}
|
||||
|
||||
void CompositorAnimationStorage::ClearById(const uint64_t& aId) {
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
|
||||
mAnimatedValues.Remove(aId);
|
||||
mAnimations.Remove(aId);
|
||||
mAnimations.erase(aId);
|
||||
}
|
||||
|
||||
AnimatedValue* CompositorAnimationStorage::GetAnimatedValue(
|
||||
|
@ -126,7 +126,8 @@ void CompositorAnimationStorage::SetAnimatedValue(uint64_t aId,
|
|||
void CompositorAnimationStorage::SetAnimations(uint64_t aId,
|
||||
const AnimationArray& aValue) {
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
mAnimations.Put(aId, AnimationHelper::ExtractAnimations(aValue));
|
||||
mAnimations[aId] = std::make_unique<AnimationStorageData>(
|
||||
AnimationHelper::ExtractAnimations(aValue));
|
||||
}
|
||||
|
||||
enum class CanSkipCompose {
|
||||
|
@ -581,38 +582,37 @@ bool AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage,
|
|||
bool isAnimating = false;
|
||||
|
||||
// Do nothing if there are no compositor animations
|
||||
if (!aStorage->AnimationsCount()) {
|
||||
if (!aStorage->HasAnimations()) {
|
||||
return isAnimating;
|
||||
}
|
||||
|
||||
// Sample the animations in CompositorAnimationStorage
|
||||
for (auto iter = aStorage->ConstAnimationsTableIter(); !iter.Done();
|
||||
iter.Next()) {
|
||||
auto& animationStorageData = iter.Data();
|
||||
if (animationStorageData.mAnimation.IsEmpty()) {
|
||||
for (const auto& iter : aStorage->Animations()) {
|
||||
const auto& animationStorageData = iter.second;
|
||||
if (animationStorageData->mAnimation.IsEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
isAnimating = true;
|
||||
nsTArray<RefPtr<RawServoAnimationValue>> animationValues;
|
||||
AnimatedValue* previousValue = aStorage->GetAnimatedValue(iter.Key());
|
||||
AnimatedValue* previousValue = aStorage->GetAnimatedValue(iter.first);
|
||||
AnimationHelper::SampleResult sampleResult =
|
||||
AnimationHelper::SampleAnimationForEachNode(
|
||||
aPreviousFrameTime, aCurrentFrameTime, previousValue,
|
||||
animationStorageData.mAnimation, animationValues);
|
||||
animationStorageData->mAnimation, animationValues);
|
||||
|
||||
if (sampleResult != AnimationHelper::SampleResult::Sampled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const PropertyAnimationGroup& lastPropertyAnimationGroup =
|
||||
animationStorageData.mAnimation.LastElement();
|
||||
animationStorageData->mAnimation.LastElement();
|
||||
|
||||
// Store the AnimatedValue
|
||||
switch (lastPropertyAnimationGroup.mProperty) {
|
||||
case eCSSProperty_background_color: {
|
||||
aStorage->SetAnimatedValue(
|
||||
iter.Key(), previousValue,
|
||||
iter.first, previousValue,
|
||||
Servo_AnimationValue_GetColor(animationValues[0],
|
||||
NS_RGBA(0, 0, 0, 0)));
|
||||
break;
|
||||
|
@ -620,7 +620,7 @@ bool AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage,
|
|||
case eCSSProperty_opacity: {
|
||||
MOZ_ASSERT(animationValues.Length() == 1);
|
||||
aStorage->SetAnimatedValue(
|
||||
iter.Key(), previousValue,
|
||||
iter.first, previousValue,
|
||||
Servo_AnimationValue_GetOpacity(animationValues[0]));
|
||||
break;
|
||||
}
|
||||
|
@ -632,21 +632,21 @@ bool AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage,
|
|||
case eCSSProperty_offset_distance:
|
||||
case eCSSProperty_offset_rotate:
|
||||
case eCSSProperty_offset_anchor: {
|
||||
MOZ_ASSERT(animationStorageData.mTransformData);
|
||||
MOZ_ASSERT(animationStorageData->mTransformData);
|
||||
|
||||
const TransformData& transformData =
|
||||
*animationStorageData.mTransformData;
|
||||
*animationStorageData->mTransformData;
|
||||
MOZ_ASSERT(transformData.origin() == nsPoint());
|
||||
|
||||
gfx::Matrix4x4 transform = ServoAnimationValueToMatrix4x4(
|
||||
animationValues, transformData,
|
||||
animationStorageData.mCachedMotionPath);
|
||||
animationStorageData->mCachedMotionPath);
|
||||
gfx::Matrix4x4 frameTransform = transform;
|
||||
|
||||
transform.PostScale(transformData.inheritedXScale(),
|
||||
transformData.inheritedYScale(), 1);
|
||||
|
||||
aStorage->SetAnimatedValue(iter.Key(), previousValue,
|
||||
aStorage->SetAnimatedValue(iter.first, previousValue,
|
||||
std::move(transform),
|
||||
std::move(frameTransform), transformData);
|
||||
break;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "mozilla/TimingParams.h"
|
||||
#include "mozilla/Variant.h"
|
||||
#include "X11UndefineNone.h"
|
||||
#include <unordered_map>
|
||||
|
||||
namespace mozilla {
|
||||
struct AnimationValue;
|
||||
|
@ -108,7 +109,7 @@ struct AnimatedValue final {
|
|||
// mechanism).
|
||||
class CompositorAnimationStorage final {
|
||||
typedef nsClassHashtable<nsUint64HashKey, AnimatedValue> AnimatedValueTable;
|
||||
typedef nsDataHashtable<nsUint64HashKey, AnimationStorageData>
|
||||
typedef std::unordered_map<uint64_t, std::unique_ptr<AnimationStorageData>>
|
||||
AnimationsTable;
|
||||
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorAnimationStorage)
|
||||
|
@ -158,14 +159,9 @@ class CompositorAnimationStorage final {
|
|||
*/
|
||||
void SetAnimations(uint64_t aId, const AnimationArray& aAnimations);
|
||||
|
||||
/**
|
||||
* Return the iterator of animations table
|
||||
*/
|
||||
AnimationsTable::Iterator ConstAnimationsTableIter() const {
|
||||
return mAnimations.ConstIter();
|
||||
}
|
||||
const AnimationsTable& Animations() const { return mAnimations; }
|
||||
|
||||
uint32_t AnimationsCount() const { return mAnimations.Count(); }
|
||||
bool HasAnimations() const { return !mAnimations.empty(); }
|
||||
|
||||
/**
|
||||
* Clear AnimatedValues and Animations data
|
||||
|
|
Загрузка…
Ссылка в новой задаче