#ifndef CC_ANIMATION_KEYFRAME_MODEL_H_
#define CC_ANIMATION_KEYFRAME_MODEL_H_
#include <memory>
#include <string>
#include "base/check.h"
#include "cc/animation/animation_export.h"
#include "cc/paint/element_id.h"
#include "cc/paint/paint_worklet_input.h"
#include "ui/gfx/animation/keyframe/keyframe_model.h"
namespace base {
class TimeTicks;
}
namespace cc {
class CC_ANIMATION_EXPORT KeyframeModel : public gfx::KeyframeModel {
public:
static const KeyframeModel* ToCcKeyframeModel(
const gfx::KeyframeModel* keyframe_model);
static KeyframeModel* ToCcKeyframeModel(gfx::KeyframeModel* keyframe_model);
static const int kInvalidGroup = -1;
class CC_ANIMATION_EXPORT TargetPropertyId {
public:
explicit TargetPropertyId(int target_property_type);
TargetPropertyId(int target_property_type,
const std::string& custom_property_name);
TargetPropertyId(
int target_property_type,
PaintWorkletInput::NativePropertyType native_property_type);
TargetPropertyId(const TargetPropertyId&);
TargetPropertyId(TargetPropertyId&&);
~TargetPropertyId();
TargetPropertyId& operator=(TargetPropertyId&& other);
int target_property_type() const { return target_property_type_; }
const std::string& custom_property_name() const {
return custom_property_name_;
}
PaintWorkletInput::NativePropertyType native_property_type() const {
return native_property_type_;
}
private:
int target_property_type_;
std::string custom_property_name_;
PaintWorkletInput::NativePropertyType native_property_type_;
};
static std::unique_ptr<KeyframeModel> Create(
std::unique_ptr<gfx::AnimationCurve> curve,
int keyframe_model_id,
int group_id,
TargetPropertyId target_property_id);
std::unique_ptr<KeyframeModel> CreateImplInstance(
RunState initial_run_state) const;
KeyframeModel(const KeyframeModel&) = delete;
~KeyframeModel() override;
KeyframeModel& operator=(const KeyframeModel&) = delete;
int group() const { return group_; }
void ungroup() { group_ = kInvalidGroup; }
int TargetProperty() const override;
void SetRunState(RunState run_state, base::TimeTicks monotonic_time) override;
ElementId element_id() const { return element_id_; }
void set_element_id(ElementId element_id) { element_id_ = element_id; }
bool InEffect(base::TimeTicks monotonic_time) const;
bool needs_synchronized_start_time() const {
return needs_synchronized_start_time_;
}
void set_needs_synchronized_start_time(bool needs_synchronized_start_time) {
needs_synchronized_start_time_ = needs_synchronized_start_time;
}
bool received_finished_event() const { return received_finished_event_; }
void set_received_finished_event(bool received_finished_event) {
received_finished_event_ = received_finished_event;
}
void set_is_controlling_instance_for_test(bool is_controlling_instance) {
is_controlling_instance_ = is_controlling_instance;
}
bool is_controlling_instance() const { return is_controlling_instance_; }
void PushPropertiesTo(KeyframeModel* other) const;
std::string ToString() const;
void SetIsImplOnly();
bool is_impl_only() const { return is_impl_only_; }
void set_affects_active_elements(bool affects_active_elements) {
affects_active_elements_ = affects_active_elements;
}
bool affects_active_elements() const { return affects_active_elements_; }
void set_affects_pending_elements(bool affects_pending_elements) {
affects_pending_elements_ = affects_pending_elements;
}
bool affects_pending_elements() const { return affects_pending_elements_; }
const std::string& custom_property_name() const {
return target_property_id_.custom_property_name();
}
PaintWorkletInput::NativePropertyType native_property_type() const {
return target_property_id_.native_property_type();
}
bool StartShouldBeDeferred() const override;
private:
KeyframeModel(std::unique_ptr<gfx::AnimationCurve> curve,
int keyframe_model_id,
int group_id,
TargetPropertyId target_property_id);
int group_;
TargetPropertyId target_property_id_;
ElementId element_id_;
#if DCHECK_IS_ON()
int debug_id_ = 0;
#endif
bool needs_synchronized_start_time_;
bool received_finished_event_;
bool is_controlling_instance_;
bool is_impl_only_;
bool affects_active_elements_;
bool affects_pending_elements_;
};
}
#endif