Commit c004564d authored by Stephen McGruer's avatar Stephen McGruer Committed by Commit Bot

Clear cached data when we change the composite mode

Previously we would change the composite member, but wouldn't actually
invalidate any of the (many) layers of caching we have. This meant that
the changed composite mode wouldn't actually take effect.

Bug: 1005915
Change-Id: I684ccb5011736edbc8b38cba5d2174095ccff9a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1815608Reviewed-by: default avatarKevin Ellis <kevers@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699848}
parent 2f4b4966
...@@ -140,6 +140,9 @@ String KeyframeEffect::composite() const { ...@@ -140,6 +140,9 @@ String KeyframeEffect::composite() const {
void KeyframeEffect::setComposite(String composite_string) { void KeyframeEffect::setComposite(String composite_string) {
Model()->SetComposite( Model()->SetComposite(
EffectModel::StringToCompositeOperation(composite_string).value()); EffectModel::StringToCompositeOperation(composite_string).value());
ClearEffects();
InvalidateAndNotifyOwner();
} }
HeapVector<ScriptValue> KeyframeEffect::getKeyframes( HeapVector<ScriptValue> KeyframeEffect::getKeyframes(
......
...@@ -62,11 +62,8 @@ template <class K> ...@@ -62,11 +62,8 @@ template <class K>
void KeyframeEffectModelBase::SetFrames(HeapVector<K>& keyframes) { void KeyframeEffectModelBase::SetFrames(HeapVector<K>& keyframes) {
// TODO(samli): Should also notify/invalidate the animation // TODO(samli): Should also notify/invalidate the animation
keyframes_.clear(); keyframes_.clear();
keyframe_groups_ = nullptr;
interpolation_effect_->Clear();
last_fraction_ = std::numeric_limits<double>::quiet_NaN();
keyframes_.AppendVector(keyframes); keyframes_.AppendVector(keyframes);
needs_compositor_keyframes_snapshot_ = true; ClearCachedData();
} }
template CORE_EXPORT void KeyframeEffectModelBase::SetFrames( template CORE_EXPORT void KeyframeEffectModelBase::SetFrames(
...@@ -74,6 +71,11 @@ template CORE_EXPORT void KeyframeEffectModelBase::SetFrames( ...@@ -74,6 +71,11 @@ template CORE_EXPORT void KeyframeEffectModelBase::SetFrames(
template CORE_EXPORT void KeyframeEffectModelBase::SetFrames( template CORE_EXPORT void KeyframeEffectModelBase::SetFrames(
HeapVector<Member<StringKeyframe>>& keyframes); HeapVector<Member<StringKeyframe>>& keyframes);
void KeyframeEffectModelBase::SetComposite(CompositeOperation composite) {
composite_ = composite;
ClearCachedData();
}
bool KeyframeEffectModelBase::Sample( bool KeyframeEffectModelBase::Sample(
int iteration, int iteration,
double fraction, double fraction,
...@@ -391,6 +393,13 @@ void KeyframeEffectModelBase::EnsureInterpolationEffectPopulated() const { ...@@ -391,6 +393,13 @@ void KeyframeEffectModelBase::EnsureInterpolationEffectPopulated() const {
interpolation_effect_->SetPopulated(); interpolation_effect_->SetPopulated();
} }
void KeyframeEffectModelBase::ClearCachedData() {
keyframe_groups_ = nullptr;
interpolation_effect_->Clear();
last_fraction_ = std::numeric_limits<double>::quiet_NaN();
needs_compositor_keyframes_snapshot_ = true;
}
bool KeyframeEffectModelBase::IsReplaceOnly() const { bool KeyframeEffectModelBase::IsReplaceOnly() const {
EnsureKeyframeGroups(); EnsureKeyframeGroups();
for (const auto& entry : *keyframe_groups_) { for (const auto& entry : *keyframe_groups_) {
......
...@@ -91,7 +91,7 @@ class CORE_EXPORT KeyframeEffectModelBase : public EffectModel { ...@@ -91,7 +91,7 @@ class CORE_EXPORT KeyframeEffectModelBase : public EffectModel {
void SetFrames(HeapVector<K>& keyframes); void SetFrames(HeapVector<K>& keyframes);
CompositeOperation Composite() const { return composite_; } CompositeOperation Composite() const { return composite_; }
void SetComposite(CompositeOperation composite) { composite_ = composite; } void SetComposite(CompositeOperation composite);
const PropertySpecificKeyframeVector* GetPropertySpecificKeyframes( const PropertySpecificKeyframeVector* GetPropertySpecificKeyframes(
const PropertyHandle& property) const { const PropertyHandle& property) const {
...@@ -170,6 +170,9 @@ class CORE_EXPORT KeyframeEffectModelBase : public EffectModel { ...@@ -170,6 +170,9 @@ class CORE_EXPORT KeyframeEffectModelBase : public EffectModel {
void EnsureKeyframeGroups() const; void EnsureKeyframeGroups() const;
void EnsureInterpolationEffectPopulated() const; void EnsureInterpolationEffectPopulated() const;
// Clears the various bits of cached data that this class has.
void ClearCachedData();
using ShouldSnapshotPropertyCallback = using ShouldSnapshotPropertyCallback =
std::function<bool(const PropertyHandle&)>; std::function<bool(const PropertyHandle&)>;
using ShouldSnapshotKeyframeCallback = using ShouldSnapshotKeyframeCallback =
......
...@@ -4,7 +4,7 @@ PASS Filling effect values reflect changes to font-size on parent element ...@@ -4,7 +4,7 @@ PASS Filling effect values reflect changes to font-size on parent element
PASS Filling effect values reflect changes to variables on element PASS Filling effect values reflect changes to variables on element
PASS Filling effect values reflect changes to variables on parent element PASS Filling effect values reflect changes to variables on parent element
PASS Filling effect values reflect changes to the the animation's keyframes PASS Filling effect values reflect changes to the the animation's keyframes
FAIL Filling effect values reflect changes to the the animation's composite mode assert_equals: Effect value after updating the composite mode expected "300px" but got "200px" PASS Filling effect values reflect changes to the the animation's composite mode
FAIL Filling effect values reflect changes to the the animation's iteration composite mode assert_equals: Effect value after updating the iteration composite mode expected "200px" but got "100px" FAIL Filling effect values reflect changes to the the animation's iteration composite mode assert_equals: Effect value after updating the iteration composite mode expected "200px" but got "100px"
PASS Filling effect values reflect changes to the base value when using additive animation PASS Filling effect values reflect changes to the base value when using additive animation
PASS Filling effect values reflect changes to the base value when using additive animation on a single keyframe PASS Filling effect values reflect changes to the base value when using additive animation on a single keyframe
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment