Commit 0dbeb028 authored by Minoru Chikamune's avatar Minoru Chikamune Committed by Chromium LUCI CQ

[MBI] Migrate SVGImageChromeClient to use per-ASG CompositorTaskRunner

Before this CL, SVGImageChromeClient uses per-thread CompositorTaskRunner.

After this CL, SVGImageChromeClient will use per-ASG CompositorTaskRunner.

Bug: 1105403
Change-Id: I8aee7c032baa96e3d86bfa255d1e76f0464f2cea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2626684
Commit-Queue: Minoru Chikamune <chikamune@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845027}
parent a4df03d0
......@@ -808,6 +808,9 @@ Image::SizeAvailability SVGImage::DataChanged(bool all_data_received) {
page->GetSettings().SetPreferredColorScheme(
default_settings.GetPreferredColorScheme());
}
chrome_client_->InitAnimationTimer(page->GetPageScheduler()
->GetAgentGroupScheduler()
.CompositorTaskRunner());
}
LocalFrame* frame = nullptr;
......
......@@ -42,12 +42,15 @@ static constexpr base::TimeDelta kAnimationFrameDelay =
SVGImageChromeClient::SVGImageChromeClient(SVGImage* image)
: image_(image),
animation_timer_(std::make_unique<TaskRunnerTimer<SVGImageChromeClient>>(
ThreadScheduler::Current()->CompositorTaskRunner(),
this,
&SVGImageChromeClient::AnimationTimerFired)),
timeline_state_(kRunning) {}
void SVGImageChromeClient::InitAnimationTimer(
scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner) {
animation_timer_ = std::make_unique<TaskRunnerTimer<SVGImageChromeClient>>(
std::move(compositor_task_runner), this,
&SVGImageChromeClient::AnimationTimerFired);
}
bool SVGImageChromeClient::IsSVGImageChromeClient() const {
return true;
}
......@@ -93,6 +96,7 @@ void SVGImageChromeClient::RestoreAnimationIfNeeded() {
void SVGImageChromeClient::ScheduleAnimation(const LocalFrameView*,
base::TimeDelta fire_time) {
DCHECK(animation_timer_);
// Because a single SVGImage can be shared by multiple pages, we can't key
// our svg image layout on the page's real animation frame. Therefore, we
// run this fake animation timer to trigger layout in SVGImages. The name,
......@@ -113,7 +117,8 @@ void SVGImageChromeClient::ScheduleAnimation(const LocalFrameView*,
animation_timer_->StartOneShot(fire_time, FROM_HERE);
}
void SVGImageChromeClient::SetTimer(std::unique_ptr<TimerBase> timer) {
void SVGImageChromeClient::SetTimerForTesting(
std::unique_ptr<TimerBase> timer) {
animation_timer_ = std::move(timer);
}
......
......@@ -44,6 +44,9 @@ class CORE_EXPORT SVGImageChromeClient final : public EmptyChromeClient {
public:
explicit SVGImageChromeClient(SVGImage*);
void InitAnimationTimer(
scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner);
bool IsSVGImageChromeClient() const override;
SVGImage* GetImage() const { return image_; }
......@@ -60,7 +63,7 @@ class CORE_EXPORT SVGImageChromeClient final : public EmptyChromeClient {
void ScheduleAnimation(const LocalFrameView*,
base::TimeDelta = base::TimeDelta()) override;
void SetTimer(std::unique_ptr<TimerBase>);
void SetTimerForTesting(std::unique_ptr<TimerBase>);
TimerBase* GetTimerForTesting() const { return animation_timer_.get(); }
void AnimationTimerFired(TimerBase*);
......
......@@ -118,7 +118,7 @@ TEST_F(SVGImageTest, TimelineSuspendAndResume) {
new TaskRunnerTimer<SVGImageChromeClient>(
scheduler::GetSingleThreadTaskRunnerForTesting(), &chrome_client,
&SVGImageChromeClient::AnimationTimerFired);
chrome_client.SetTimer(base::WrapUnique(timer));
chrome_client.SetTimerForTesting(base::WrapUnique(timer));
// Simulate a draw. Cause a frame (timer) to be scheduled.
PumpFrame();
......@@ -147,7 +147,7 @@ TEST_F(SVGImageTest, ResetAnimation) {
new TaskRunnerTimer<SVGImageChromeClient>(
scheduler::GetSingleThreadTaskRunnerForTesting(), &chrome_client,
&SVGImageChromeClient::AnimationTimerFired);
chrome_client.SetTimer(base::WrapUnique(timer));
chrome_client.SetTimerForTesting(base::WrapUnique(timer));
// Simulate a draw. Cause a frame (timer) to be scheduled.
PumpFrame();
......
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