File: invalidatable_interpolation.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (114 lines) | stat: -rw-r--r-- 4,794 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_ANIMATION_INVALIDATABLE_INTERPOLATION_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_ANIMATION_INVALIDATABLE_INTERPOLATION_H_

#include <memory>
#include "third_party/blink/renderer/core/animation/interpolation.h"
#include "third_party/blink/renderer/core/animation/interpolation_type.h"
#include "third_party/blink/renderer/core/animation/interpolation_types_map.h"
#include "third_party/blink/renderer/core/animation/primitive_interpolation.h"
#include "third_party/blink/renderer/core/animation/typed_interpolation_value.h"
#include "third_party/blink/renderer/core/core_export.h"

namespace blink {

// See the documentation of Interpolation for general information about this
// class hierarchy.
//
// The InvalidatableInterpolation subclass stores the start and end keyframes as
// PropertySpecificKeyframe objects.
//
// InvalidatableInterpolation uses conversion checkers and the interpolation
// environment to respond to changes to the underlying property value during
// interpolation.
//
// InvalidatableInterpolation is used to implement additive animations. During
// the effect application phase of animation computation, the current animated
// value of the property is applied to the element by calling the static
// ApplyStack function with an ordered list of InvalidatableInterpolation
// objects.
class CORE_EXPORT InvalidatableInterpolation : public Interpolation {
 public:
  InvalidatableInterpolation(const PropertyHandle& property,
                             PropertySpecificKeyframe* start_keyframe,
                             PropertySpecificKeyframe* end_keyframe)
      : Interpolation(),
        property_(property),
        interpolation_types_version_(0),
        start_keyframe_(start_keyframe),
        end_keyframe_(end_keyframe),
        current_fraction_(std::numeric_limits<double>::quiet_NaN()),
        is_conversion_cached_(false) {}

  const PropertyHandle& GetProperty() const final { return property_; }
  void Interpolate(int iteration, double fraction) override;
  bool DependsOnUnderlyingValue() const final;
  static void ApplyStack(const ActiveInterpolations&,
                         CSSInterpolationEnvironment&);

  bool IsInvalidatableInterpolation() const override { return true; }

  const TypedInterpolationValue* GetCachedValueForTesting() const {
    return cached_value_.Get();
  }

  void Trace(Visitor* visitor) const override {
    visitor->Trace(interpolation_types_);
    visitor->Trace(start_keyframe_);
    visitor->Trace(end_keyframe_);
    visitor->Trace(cached_pair_conversion_);
    visitor->Trace(conversion_checkers_);
    visitor->Trace(cached_value_);
    Interpolation::Trace(visitor);
  }

 private:
  using ConversionCheckers = InterpolationType::ConversionCheckers;

  TypedInterpolationValue* MaybeConvertUnderlyingValue(
      const CSSInterpolationEnvironment&) const;
  const TypedInterpolationValue* EnsureValidConversion(
      CSSInterpolationEnvironment&,
      const UnderlyingValueOwner&) const;
  void EnsureValidInterpolationTypes(CSSInterpolationEnvironment&) const;
  void ClearConversionCache(CSSInterpolationEnvironment& environment) const;
  bool IsConversionCacheValid(const CSSInterpolationEnvironment&,
                              const UnderlyingValueOwner&) const;
  bool IsNeutralKeyframeActive() const;
  PairwisePrimitiveInterpolation* MaybeConvertPairwise(
      const CSSInterpolationEnvironment&,
      const UnderlyingValueOwner&) const;
  TypedInterpolationValue* ConvertSingleKeyframe(
      const PropertySpecificKeyframe&,
      const CSSInterpolationEnvironment&,
      const UnderlyingValueOwner&) const;
  void AddConversionCheckers(const InterpolationType*,
                             ConversionCheckers&) const;
  void SetFlagIfInheritUsed(CSSInterpolationEnvironment&) const;
  double UnderlyingFraction() const;

  const PropertyHandle property_;
  mutable Member<const InterpolationTypes> interpolation_types_;
  mutable size_t interpolation_types_version_;
  Member<PropertySpecificKeyframe> start_keyframe_;
  Member<PropertySpecificKeyframe> end_keyframe_;
  double current_fraction_;
  mutable bool is_conversion_cached_;
  mutable Member<PrimitiveInterpolation> cached_pair_conversion_;
  mutable ConversionCheckers conversion_checkers_;
  mutable Member<TypedInterpolationValue> cached_value_;
};

template <>
struct DowncastTraits<InvalidatableInterpolation> {
  static bool AllowFrom(const Interpolation& value) {
    return value.IsInvalidatableInterpolation();
  }
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_ANIMATION_INVALIDATABLE_INTERPOLATION_H_