Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: third_party/WebKit/Source/platform/graphics/BitmapImage.cpp

Issue 2810423003: Schedule bitmap animation timers on the compositor task runner. (Closed)
Patch Set: fix up comment about a method changed by blink reformat Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
index f1524ed4ee789d4e4adcd82d0fa19939b901f40e..a6a92481e1513134e2e427d185a8875df6ae3e00 100644
--- a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
+++ b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
@@ -56,20 +56,24 @@ ColorBehavior DefaultColorBehavior() {
} // namespace
PassRefPtr<BitmapImage> BitmapImage::CreateWithOrientationForTesting(
+ RefPtr<WebTaskRunner> task_runner,
const SkBitmap& bitmap,
ImageOrientation orientation) {
if (bitmap.isNull()) {
- return BitmapImage::Create();
+ return BitmapImage::Create(task_runner);
}
- RefPtr<BitmapImage> result = AdoptRef(new BitmapImage(bitmap));
+ RefPtr<BitmapImage> result = AdoptRef(new BitmapImage(task_runner, bitmap));
result->frames_[0].orientation_ = orientation;
if (orientation.UsesWidthAsHeight())
result->size_respecting_orientation_ = result->size_.TransposedSize();
return result.Release();
}
-BitmapImage::BitmapImage(ImageObserver* observer)
+BitmapImage::BitmapImage() : BitmapImage(TimerBase::GetTimerTaskRunner()) {}
Dan Elphick 2017/04/27 14:41:39 I guess I could just inline that function here: P
Sami 2017/04/27 17:38:17 So this is the case where we can't tie the image t
fs 2017/04/27 17:42:54 Sorry to say, but Images don't have a 1:1 relation
Dan Elphick 2017/05/03 09:41:06 I've reworked it all now to get the Compositor tas
+
+BitmapImage::BitmapImage(RefPtr<WebTaskRunner> task_runner,
+ ImageObserver* observer)
: Image(observer),
current_frame_(0),
cached_frame_index_(0),
@@ -83,9 +87,12 @@ BitmapImage::BitmapImage(ImageObserver* observer)
all_data_received_(false),
have_size_(false),
size_available_(false),
- have_frame_count_(false) {}
+ have_frame_count_(false),
+ task_runner_(task_runner) {}
-BitmapImage::BitmapImage(const SkBitmap& bitmap, ImageObserver* observer)
+BitmapImage::BitmapImage(RefPtr<WebTaskRunner> task_runner,
+ const SkBitmap& bitmap,
+ ImageObserver* observer)
: Image(observer),
size_(bitmap.width(), bitmap.height()),
current_frame_(0),
@@ -100,7 +107,8 @@ BitmapImage::BitmapImage(const SkBitmap& bitmap, ImageObserver* observer)
all_data_received_(true),
have_size_(true),
size_available_(true),
- have_frame_count_(true) {
+ have_frame_count_(true),
+ task_runner_(task_runner) {
// Since we don't have a decoder, we can't figure out the image orientation.
// Set m_sizeRespectingOrientation to be the same as m_size so it's not 0x0.
size_respecting_orientation_ = size_;
@@ -517,8 +525,8 @@ void BitmapImage::StartAnimation(CatchUpAnimation catch_up_if_necessary) {
if (catch_up_if_necessary == kDoNotCatchUp ||
time < desired_frame_start_time_) {
// Haven't yet reached time for next frame to start; delay until then.
- frame_timer_ = WTF::WrapUnique(
- new Timer<BitmapImage>(this, &BitmapImage::AdvanceAnimation));
+ frame_timer_ = WTF::WrapUnique(new TaskRunnerTimer<BitmapImage>(
+ task_runner_, this, &BitmapImage::AdvanceAnimation));
frame_timer_->StartOneShot(std::max(desired_frame_start_time_ - time, 0.),
BLINK_FROM_HERE);
} else {
@@ -548,8 +556,8 @@ void BitmapImage::StartAnimation(CatchUpAnimation catch_up_if_necessary) {
// may be in the past, meaning the next time through this function we'll
// kick off the next advancement sooner than this frame's duration would
// suggest.
- frame_timer_ = WTF::WrapUnique(new Timer<BitmapImage>(
- this, &BitmapImage::AdvanceAnimationWithoutCatchUp));
+ frame_timer_ = WTF::WrapUnique(new TaskRunnerTimer<BitmapImage>(
+ task_runner_, this, &BitmapImage::AdvanceAnimationWithoutCatchUp));
frame_timer_->StartOneShot(0, BLINK_FROM_HERE);
}
}
@@ -631,8 +639,9 @@ bool BitmapImage::InternalAdvanceAnimation(AnimationAdvancement advancement) {
// last frame. Skipping frames occurs while painting so we do not
// synchronously notify the observer which could cause a layout.
if (advancement == kSkipFramesToCatchUp) {
- frame_timer_ = WTF::WrapUnique(new Timer<BitmapImage>(
- this, &BitmapImage::NotifyObserversOfAnimationAdvance));
+ frame_timer_ = WTF::WrapUnique(new TaskRunnerTimer<BitmapImage>(
+ task_runner_, this,
+ &BitmapImage::NotifyObserversOfAnimationAdvance));
frame_timer_->StartOneShot(0, BLINK_FROM_HERE);
}

Powered by Google App Engine
This is Rietveld 408576698