#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/animation/compositor_animations.h"
#include <algorithm>
#include <cmath>
#include <memory>
#include "cc/animation/animation_id_provider.h"
#include "cc/animation/filter_animation_curve.h"
#include "cc/base/features.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/core/animation/animation_effect.h"
#include "third_party/blink/renderer/core/animation/css/compositor_keyframe_color.h"
#include "third_party/blink/renderer/core/animation/css/compositor_keyframe_double.h"
#include "third_party/blink/renderer/core/animation/css/compositor_keyframe_filter_operations.h"
#include "third_party/blink/renderer/core/animation/css/compositor_keyframe_transform.h"
#include "third_party/blink/renderer/core/animation/css/compositor_keyframe_value.h"
#include "third_party/blink/renderer/core/animation/element_animations.h"
#include "third_party/blink/renderer/core/animation/keyframe_effect_model.h"
#include "third_party/blink/renderer/core/css/background_color_paint_image_generator.h"
#include "third_party/blink/renderer/core/css/box_shadow_paint_image_generator.h"
#include "third_party/blink/renderer/core/css/clip_path_paint_image_generator.h"
#include "third_party/blink/renderer/core/css/properties/computed_style_utils.h"
#include "third_party/blink/renderer/core/css/properties/longhands.h"
#include "third_party/blink/renderer/core/dom/dom_node_ids.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/layout_box_model_object.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_transformable_container.h"
#include "third_party/blink/renderer/core/paint/filter_effect_builder.h"
#include "third_party/blink/renderer/core/paint/object_paint_properties.h"
#include "third_party/blink/renderer/platform/animation/animation_translation_util.h"
#include "third_party/blink/renderer/platform/animation/compositor_animation.h"
#include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h"
#include "third_party/blink/renderer/platform/graphics/platform_paint_worklet_layer_painter.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "ui/gfx/animation/keyframe/animation_curve.h"
#include "ui/gfx/animation/keyframe/keyframed_animation_curve.h"
namespace blink {
namespace {
constexpr CSSPropertyID kCompositableProperties[] = …;
const size_t kNumCompositableCSSProperties = …;
bool ConsiderAnimationAsIncompatible(const Animation& animation,
const Animation& animation_to_add,
const EffectModel& effect_to_add) { … }
bool IsTransformRelatedCSSProperty(const PropertyHandle property) { … }
bool HasIncompatibleAnimations(const Element& target_element,
const Animation& animation_to_add,
const EffectModel& effect_to_add) { … }
void DefaultToUnsupportedProperty(
PropertyHandleSet* unsupported_properties,
const PropertyHandle& property,
CompositorAnimations::FailureReasons* reasons) { … }
bool IsNoOpBGColorOrVariableAnimation(const PropertyHandle& property,
const LayoutObject* layout_object) { … }
bool CompositedAnimationRequiresProperties(const PropertyHandle& property,
LayoutObject* layout_object) { … }
}
CompositorElementIdNamespace
CompositorAnimations::CompositorElementNamespaceForProperty(
CSSPropertyID property) { … }
CompositorAnimations::FailureReasons
CompositorAnimations::CheckCanStartEffectOnCompositor(
const Timing& timing,
const Timing::NormalizedTiming& normalized_timing,
const Element& target_element,
const Animation* animation_to_add,
const EffectModel& effect,
const PaintArtifactCompositor* paint_artifact_compositor,
double animation_playback_rate,
PropertyHandleSet* unsupported_properties) { … }
bool CompositorAnimations::CompositorPropertyAnimationsHaveNoEffect(
const Element& target_element,
const EffectModel& effect,
const PaintArtifactCompositor* paint_artifact_compositor) { … }
CompositorAnimations::FailureReasons
CompositorAnimations::CheckCanStartElementOnCompositor(
const Element& target_element,
const EffectModel& model) { … }
CompositorAnimations::FailureReasons
CompositorAnimations::CheckCanStartAnimationOnCompositor(
const Timing& timing,
const Timing::NormalizedTiming& normalized_timing,
const Element& target_element,
const Animation* animation_to_add,
const EffectModel& effect,
const PaintArtifactCompositor* paint_artifact_compositor,
double animation_playback_rate,
PropertyHandleSet* unsupported_properties) { … }
void CompositorAnimations::CancelIncompatibleAnimationsOnCompositor(
const Element& target_element,
const Animation& animation_to_add,
const EffectModel& effect_to_add) { … }
void CompositorAnimations::StartAnimationOnCompositor(
const Element& element,
int group,
std::optional<double> start_time,
base::TimeDelta time_offset,
const Timing& timing,
const Timing::NormalizedTiming& normalized_timing,
const Animation* animation,
CompositorAnimation& compositor_animation,
const EffectModel& effect,
Vector<int>& started_keyframe_model_ids,
double animation_playback_rate,
bool is_monotonic_timeline,
bool is_boundary_aligned) { … }
void CompositorAnimations::CancelAnimationOnCompositor(
const Element& element,
CompositorAnimation* compositor_animation,
int id,
const EffectModel& model) { … }
void CompositorAnimations::PauseAnimationForTestingOnCompositor(
const Element& element,
const Animation& animation,
int id,
base::TimeDelta pause_time,
const EffectModel& model) { … }
void CompositorAnimations::AttachCompositedLayers(
Element& element,
CompositorAnimation* compositor_animation) { … }
bool CompositorAnimations::ConvertTimingForCompositor(
const Timing& timing,
const Timing::NormalizedTiming& normalized_timing,
base::TimeDelta time_offset,
CompositorTiming& out,
double animation_playback_rate,
bool is_monotonic_timeline,
bool is_boundary_aligned) { … }
namespace {
void AddKeyframeToCurve(cc::KeyframedFilterAnimationCurve& curve,
Keyframe::PropertySpecificKeyframe* keyframe,
const CompositorKeyframeValue* value,
const TimingFunction& keyframe_timing_function) { … }
void AddKeyframeToCurve(gfx::KeyframedFloatAnimationCurve& curve,
Keyframe::PropertySpecificKeyframe* keyframe,
const CompositorKeyframeValue* value,
const TimingFunction& keyframe_timing_function) { … }
void AddKeyframeToCurve(gfx::KeyframedColorAnimationCurve& curve,
Keyframe::PropertySpecificKeyframe* keyframe,
const CompositorKeyframeValue* value,
const TimingFunction& keyframe_timing_function) { … }
void AddKeyframeToCurve(gfx::KeyframedTransformAnimationCurve& curve,
Keyframe::PropertySpecificKeyframe* keyframe,
const CompositorKeyframeValue* value,
const TimingFunction& keyframe_timing_function,
const gfx::SizeF& box_size) { … }
template <typename PlatformAnimationCurveType, typename... Args>
void AddKeyframesToCurve(PlatformAnimationCurveType& curve,
const PropertySpecificKeyframeVector& keyframes,
Args... parameters) { … }
void AddKeyframesForPaintWorkletAnimation(
gfx::KeyframedFloatAnimationCurve& curve) { … }
}
bool CompositorAnimations::CompositedPropertyRequiresSnapshot(
const PropertyHandle& property) { … }
void CompositorAnimations::GetAnimationOnCompositor(
const Element& target_element,
const Timing& timing,
const Timing::NormalizedTiming& normalized_timing,
int group,
std::optional<double> start_time,
base::TimeDelta time_offset,
const KeyframeEffectModelBase& effect,
Vector<std::unique_ptr<cc::KeyframeModel>>& keyframe_models,
double animation_playback_rate,
bool is_monotonic_timeline,
bool is_boundary_aligned) { … }
bool CompositorAnimations::CanStartScrollTimelineOnCompositor(Node* target) { … }
CompositorAnimations::FailureReasons
CompositorAnimations::CheckCanStartSVGElementOnCompositor(
const SVGElement& svg_element) { … }
CompositorAnimations::FailureReasons
CompositorAnimations::CheckCanStartTransformAnimationOnCompositorForSVG(
const SVGElement& svg_element) { … }
bool CompositorAnimations::CanStartTransformAnimationOnCompositorForSVG(
const SVGElement& svg_element) { … }
}