Commit de8ee9ce authored by jbroman@chromium.org's avatar jbroman@chromium.org

Drawing bounds should not be pixel-snapped.

Review URL: https://codereview.chromium.org/1313633003

git-svn-id: svn://svn.chromium.org/blink/trunk@201243 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 4bc95805
......@@ -42,9 +42,6 @@ public:
LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& layoutObject, PaintPhase phase, const FloatRect& clip)
: LayoutObjectDrawingRecorder(context, layoutObject, DisplayItem::paintPhaseToDrawingType(phase), clip) { }
LayoutObjectDrawingRecorder(GraphicsContext& context, const LayoutObject& layoutObject, DisplayItem::Type type, const LayoutRect& clip)
: LayoutObjectDrawingRecorder(context, layoutObject, type, pixelSnappedIntRect(clip)) { }
#if ENABLE(ASSERT)
void setUnderInvalidationCheckingMode(DrawingDisplayItem::UnderInvalidationCheckingMode mode) { m_drawingRecorder->setUnderInvalidationCheckingMode(mode); }
#endif
......
......@@ -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
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