#include "cc/trees/image_animation_controller.h"
#include <algorithm>
#include <sstream>
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/notreached.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "cc/base/features.h"
#include "cc/paint/image_animation_count.h"
namespace cc {
namespace {
const base::TimeDelta kAnimationResyncCutoff = …;
base::TimeTicks SnappedTickTimeFromFrameTime(
const viz::BeginFrameArgs& args,
base::TimeTicks desired_frame_time) { … }
}
ImageAnimationController::ImageAnimationController(
base::SingleThreadTaskRunner* task_runner,
Client* client,
bool enable_image_animation_resync)
: … { … }
ImageAnimationController::~ImageAnimationController() = default;
void ImageAnimationController::UpdateAnimatedImage(
const DiscardableImageMap::AnimatedImageMetadata& data) { … }
void ImageAnimationController::RegisterAnimationDriver(
PaintImage::Id paint_image_id,
AnimationDriver* driver) { … }
void ImageAnimationController::UnregisterAnimationDriver(
PaintImage::Id paint_image_id,
AnimationDriver* driver) { … }
bool ImageAnimationController::IsRegistered(PaintImage::Id paint_image_id) { … }
const PaintImageIdFlatSet& ImageAnimationController::AnimateForSyncTree(
const viz::BeginFrameArgs& args) { … }
void ImageAnimationController::UpdateStateFromDrivers() { … }
void ImageAnimationController::DidActivate() { … }
size_t ImageAnimationController::GetFrameIndexForImage(
PaintImage::Id paint_image_id,
WhichTree tree) const { … }
void ImageAnimationController::WillBeginImplFrame(
const viz::BeginFrameArgs& args) { … }
const base::flat_set<
raw_ptr<ImageAnimationController::AnimationDriver, CtnExperimental>>&
ImageAnimationController::GetDriversForTesting(
PaintImage::Id paint_image_id) const { … }
size_t ImageAnimationController::GetLastNumOfFramesSkippedForTesting(
PaintImage::Id paint_image_id) const { … }
std::optional<ImageAnimationController::ConsistentFrameDuration>
ImageAnimationController::GetConsistentContentFrameDuration() { … }
ImageAnimationController::AnimationState::AnimationState() = default;
ImageAnimationController::AnimationState::AnimationState(
AnimationState&& other) = default;
ImageAnimationController::AnimationState&
ImageAnimationController::AnimationState::operator=(AnimationState&& other) =
default;
ImageAnimationController::AnimationState::~AnimationState() { … }
bool ImageAnimationController::AnimationState::ShouldAnimate() const { … }
bool ImageAnimationController::AnimationState::ShouldAnimate(
int repetitions_completed,
size_t pending_index) const { … }
bool ImageAnimationController::AnimationState::AdvanceFrame(
const viz::BeginFrameArgs& args,
bool enable_image_animation_resync,
bool use_resume_behavior) { … }
ImageAnimationController::AnimationState::AnimationAdvancementState
ImageAnimationController::AnimationState::AdvanceAnimationState(
AnimationAdvancementState animation_advancement_state,
const viz::BeginFrameArgs& args,
base::TimeTicks start,
bool enable_image_animation_resync) const { … }
void ImageAnimationController::AnimationState::UpdateMetadata(
const DiscardableImageMap::AnimatedImageMetadata& data) { … }
void ImageAnimationController::AnimationState::PushPendingToActive() { … }
std::optional<base::TimeDelta>
ImageAnimationController::AnimationState::GetConsistentContentFrameDuration() { … }
void ImageAnimationController::AnimationState::
ComputeConsistentContentFrameDuration() { … }
void ImageAnimationController::AnimationState::AddDriver(
AnimationDriver* driver) { … }
void ImageAnimationController::AnimationState::RemoveDriver(
AnimationDriver* driver) { … }
void ImageAnimationController::AnimationState::UpdateStateFromDrivers() { … }
void ImageAnimationController::AnimationState::ResetAnimation() { … }
std::string ImageAnimationController::AnimationState::ToString() const { … }
size_t ImageAnimationController::AnimationState::NextFrameIndex(
size_t pending_index) const { … }
ImageAnimationController::InvalidationScheduler::InvalidationScheduler(
base::SingleThreadTaskRunner* task_runner,
Client* client)
: … { … }
ImageAnimationController::InvalidationScheduler::~InvalidationScheduler() { … }
void ImageAnimationController::InvalidationScheduler::Schedule(
base::TimeTicks animation_time) { … }
void ImageAnimationController::InvalidationScheduler::Cancel() { … }
void ImageAnimationController::InvalidationScheduler::RequestBeginFrame() { … }
void ImageAnimationController::InvalidationScheduler::WillAnimate() { … }
void ImageAnimationController::InvalidationScheduler::WillBeginImplFrame(
const viz::BeginFrameArgs& args) { … }
void ImageAnimationController::InvalidationScheduler::RequestInvalidation() { … }
}