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

Unified Diff: cc/playback/discardable_image_map_unittest.cc

Issue 2327903002: gfx: Do the ToEnclosingRect in double precision. (Closed)
Patch Set: update Created 4 years, 3 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
« no previous file with comments | « no previous file | ui/gfx/geometry/rect_conversions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/playback/discardable_image_map_unittest.cc
diff --git a/cc/playback/discardable_image_map_unittest.cc b/cc/playback/discardable_image_map_unittest.cc
index 5c7b4ee785fc1902c5ac140664ce9f4f260ec630..1b880e6a9b7adf47b02a06ce1ddb564c1df43a10 100644
--- a/cc/playback/discardable_image_map_unittest.cc
+++ b/cc/playback/discardable_image_map_unittest.cc
@@ -405,14 +405,19 @@ TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMaxImageMaxLayer) {
images = GetDiscardableImagesInRect(image_map, gfx::Rect(10000, 0, 1, 1));
EXPECT_EQ(2u, images.size());
- int expected10k = static_cast<int>(static_cast<float>(dimension - 10000));
- int expected500 = static_cast<int>(static_cast<float>(dimension - 500));
- EXPECT_EQ(gfx::Rect(10000, 0, expected10k, dimension), images[1].image_rect);
+ EXPECT_EQ(gfx::Rect(10000, 0, dimension - 10000, dimension),
+ images[1].image_rect);
EXPECT_EQ(gfx::Rect(0, 0, dimension, dimension), images[0].image_rect);
+ // Since we adjust negative offsets before using ToEnclosingRect, the expected
+ // width will be converted to float, which means that we lose some precision.
+ // The expected value is whatever the value is converted to float and then
+ // back to int.
+ int expected10k = static_cast<int>(static_cast<float>(dimension - 10000));
images = GetDiscardableImagesInRect(image_map, gfx::Rect(0, 500, 1, 1));
EXPECT_EQ(2u, images.size());
- EXPECT_EQ(gfx::Rect(0, 500, expected10k, expected500), images[1].image_rect);
+ EXPECT_EQ(gfx::Rect(0, 500, expected10k, dimension - 500),
+ images[1].image_rect);
EXPECT_EQ(gfx::Rect(0, 0, dimension, dimension), images[0].image_rect);
}
« no previous file with comments | « no previous file | ui/gfx/geometry/rect_conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698