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

Unified Diff: Source/core/paint/LayoutObjectDrawingRecorderTest.cpp

Issue 1313633003: Drawing bounds should not be pixel-snapped. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: one rect only Created 5 years, 4 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 | « Source/core/paint/LayoutObjectDrawingRecorder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/LayoutObjectDrawingRecorderTest.cpp
diff --git a/Source/core/paint/LayoutObjectDrawingRecorderTest.cpp b/Source/core/paint/LayoutObjectDrawingRecorderTest.cpp
index 54bb66ddc6e69b6bd4555cde13e7d584b203ebbc..7873f3bb7992eca40b39a68b8767d7bd8866025a 100644
--- a/Source/core/paint/LayoutObjectDrawingRecorderTest.cpp
+++ b/Source/core/paint/LayoutObjectDrawingRecorderTest.cpp
@@ -123,5 +123,36 @@ TEST_F(LayoutObjectDrawingRecorderTest, Cached)
EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[1]));
}
+template <typename T>
+FloatRect drawAndGetCullRect(DisplayItemList& list, const LayoutObject& layoutObject, const T& bounds)
+{
+ list.invalidateAll();
+ {
+ // Draw some things which will produce a non-null picture.
+ GraphicsContext context(&list);
+ LayoutObjectDrawingRecorder recorder(
+ context, layoutObject, DisplayItem::BoxDecorationBackground, bounds);
+ context.drawRect(enclosedIntRect(bounds));
+ }
+ list.commitNewDisplayItems();
+ const auto& drawing = static_cast<const DrawingDisplayItem&>(list.displayItems()[0]);
+ return drawing.picture()->cullRect();
+}
+
+TEST_F(LayoutObjectDrawingRecorderTest, CullRectMatchesProvidedClip)
+{
+ // It's safe for the picture's cull rect to be expanded (though doing so
+ // excessively may harm performance), but it cannot be contracted.
+ // For now, this test expects the two rects to match completely.
+ //
+ // This rect is chosen so that in the x direction, pixel snapping rounds in
+ // the opposite direction to enclosing, and in the y direction, the edges
+ // are exactly on a half-pixel boundary. The numbers chosen map nicely to
+ // both float and LayoutUnit, to make equality checking reliable.
+ FloatRect rect(20.75, -5.5, 5.375, 10);
+ EXPECT_EQ(rect, drawAndGetCullRect(rootDisplayItemList(), layoutView(), rect));
+ EXPECT_EQ(rect, drawAndGetCullRect(rootDisplayItemList(), layoutView(), LayoutRect(rect)));
+}
+
} // namespace
} // namespace blink
« no previous file with comments | « Source/core/paint/LayoutObjectDrawingRecorder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698