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