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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/LayoutObjectDrawingRecorder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/LayoutObjectDrawingRecorder.h" 6 #include "core/paint/LayoutObjectDrawingRecorder.h"
7 7
8 #include "core/layout/LayoutTestHelper.h" 8 #include "core/layout/LayoutTestHelper.h"
9 #include "core/layout/LayoutView.h" 9 #include "core/layout/LayoutView.h"
10 #include "core/paint/DeprecatedPaintLayer.h" 10 #include "core/paint/DeprecatedPaintLayer.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 drawRect(context, layoutView(), PaintPhaseForeground, bound); 116 drawRect(context, layoutView(), PaintPhaseForeground, bound);
117 EXPECT_EQ((size_t)2, newDisplayItemsBeforeUpdate().size()); 117 EXPECT_EQ((size_t)2, newDisplayItemsBeforeUpdate().size());
118 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[0])); 118 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[0]));
119 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[1])); 119 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[1]));
120 rootDisplayItemList().commitNewDisplayItems(); 120 rootDisplayItemList().commitNewDisplayItems();
121 EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size()); 121 EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size());
122 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[0])); 122 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[0]));
123 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[1])); 123 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[1]));
124 } 124 }
125 125
126 template <typename T>
127 FloatRect drawAndGetCullRect(DisplayItemList& list, const LayoutObject& layoutOb ject, const T& bounds)
128 {
129 list.invalidateAll();
130 {
131 // Draw some things which will produce a non-null picture.
132 GraphicsContext context(&list);
133 LayoutObjectDrawingRecorder recorder(
134 context, layoutObject, DisplayItem::BoxDecorationBackground, bounds) ;
135 context.drawRect(enclosedIntRect(bounds));
136 }
137 list.commitNewDisplayItems();
138 const auto& drawing = static_cast<const DrawingDisplayItem&>(list.displayIte ms()[0]);
139 return drawing.picture()->cullRect();
140 }
141
142 TEST_F(LayoutObjectDrawingRecorderTest, CullRectMatchesProvidedClip)
143 {
144 // It's safe for the picture's cull rect to be expanded (though doing so
145 // excessively may harm performance), but it cannot be contracted.
146 // For now, this test expects the two rects to match completely.
147 //
148 // This rect is chosen so that in the x direction, pixel snapping rounds in
149 // the opposite direction to enclosing, and in the y direction, the edges
150 // are exactly on a half-pixel boundary. The numbers chosen map nicely to
151 // both float and LayoutUnit, to make equality checking reliable.
152 FloatRect rect(20.75, -5.5, 5.375, 10);
153 EXPECT_EQ(rect, drawAndGetCullRect(rootDisplayItemList(), layoutView(), rect ));
154 EXPECT_EQ(rect, drawAndGetCullRect(rootDisplayItemList(), layoutView(), Layo utRect(rect)));
155 }
156
126 } // namespace 157 } // namespace
127 } // namespace blink 158 } // namespace blink
OLDNEW
« 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