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

Unified Diff: third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp

Issue 1685933002: Don't use a low-quality filter when painting images while others are animating. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/core/layout/ImageQualityControllerTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp b/third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp
index cefe8ee758deabd9ca1bab26ffefbc611b4082af..6a8b62f95ca0a1e3bb8a700f1645ff50c94397c8 100644
--- a/third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp
@@ -177,6 +177,36 @@ TEST_F(ImageQualityControllerTest, LowQualityFilterForResizingImage)
EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(4, 4)));
}
+TEST_F(ImageQualityControllerTest, MediumQualityFilterForNotAnimatedWhileAnotherAnimates)
+{
+ MockTimer* mockTimer = new MockTimer(controller(), &ImageQualityController::highQualityRepaintTimerFired);
+ controller()->setTimer(mockTimer);
+ setBodyInnerHTML("<img id='myAnimatingImage' src='myimage'></img> <img id='myNonAnimatingImage' src='myimage2'></img>");
+ LayoutImage* animatingImage = toLayoutImage(document().getElementById("myAnimatingImage")->layoutObject());
+ LayoutImage* nonAnimatingImage = toLayoutImage(document().getElementById("myNonAnimatingImage")->layoutObject());
+
+ RefPtr<TestImageLowQuality> testImage = adoptRef(new TestImageLowQuality);
+ OwnPtr<PaintController> paintController = PaintController::create();
+ GraphicsContext context(*paintController);
+
+ // Paint once. This will kick off a timer to see if we resize it during that timer's execution.
+ EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*animatingImage, testImage.get(), testImage.get(), LayoutSize(2, 2)));
+
+ // Go into low-quality mode now that the size changed.
+ EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(*animatingImage, testImage.get(), testImage.get(), LayoutSize(3, 3)));
+
+ // The non-animating image receives a medium-quality filter, even though the other one is animating.
+ EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*nonAnimatingImage, testImage.get(), testImage.get(), LayoutSize(4, 4)));
+
+ // Now the second image has animated, so it also gets painted with a low-quality filter.
+ EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(*nonAnimatingImage, testImage.get(), testImage.get(), LayoutSize(3, 3)));
+
+ mockTimer->fire();
+ // The timer fired before painting at another size, so this doesn't count as animation. Therefore not painting at low quality for any image.
+ EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*animatingImage, testImage.get(), testImage.get(), LayoutSize(4, 4)));
+ EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*nonAnimatingImage, testImage.get(), testImage.get(), LayoutSize(4, 4)));
+}
+
TEST_F(ImageQualityControllerTest, DontKickTheAnimationTimerWhenPaintingAtTheSameSize)
{
MockTimer* mockTimer = new MockTimer(controller(), &ImageQualityController::highQualityRepaintTimerFired);

Powered by Google App Engine
This is Rietveld 408576698