OLD | NEW |
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 "core/paint/LayoutObjectDrawingRecorder.h" | 5 #include "core/paint/LayoutObjectDrawingRecorder.h" |
6 | 6 |
7 #include "core/layout/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
9 #include "core/paint/PaintControllerPaintTest.h" | 9 #include "core/paint/PaintControllerPaintTest.h" |
10 #include "core/paint/PaintLayer.h" | 10 #include "core/paint/PaintLayer.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 { | 112 { |
113 // Draw some things which will produce a non-null picture. | 113 // Draw some things which will produce a non-null picture. |
114 GraphicsContext context(controller); | 114 GraphicsContext context(controller); |
115 LayoutObjectDrawingRecorder recorder( | 115 LayoutObjectDrawingRecorder recorder( |
116 context, layout_object, DisplayItem::kBoxDecorationBackground, bounds); | 116 context, layout_object, DisplayItem::kBoxDecorationBackground, bounds); |
117 context.DrawRect(EnclosedIntRect(FloatRect(bounds))); | 117 context.DrawRect(EnclosedIntRect(FloatRect(bounds))); |
118 } | 118 } |
119 controller.CommitNewDisplayItems(); | 119 controller.CommitNewDisplayItems(); |
120 const auto& drawing = static_cast<const DrawingDisplayItem&>( | 120 const auto& drawing = static_cast<const DrawingDisplayItem&>( |
121 controller.GetDisplayItemList()[0]); | 121 controller.GetDisplayItemList()[0]); |
122 return drawing.GetPaintRecord()->cullRect(); | 122 return drawing.GetPaintRecordBounds(); |
123 } | 123 } |
124 | 124 |
125 TEST_F(LayoutObjectDrawingRecorderTest, CullRectMatchesProvidedClip) { | 125 TEST_F(LayoutObjectDrawingRecorderTest, CullRectMatchesProvidedClip) { |
126 // It's safe for the picture's cull rect to be expanded (though doing so | 126 // It's safe for the picture's cull rect to be expanded (though doing so |
127 // excessively may harm performance), but it cannot be contracted. | 127 // excessively may harm performance), but it cannot be contracted. |
128 // For now, this test expects the two rects to match completely. | 128 // For now, this test expects the two rects to match completely. |
129 // | 129 // |
130 // This rect is chosen so that in the x direction, pixel snapping rounds in | 130 // This rect is chosen so that in the x direction, pixel snapping rounds in |
131 // the opposite direction to enclosing, and in the y direction, the edges | 131 // the opposite direction to enclosing, and in the y direction, the edges |
132 // are exactly on a half-pixel boundary. The numbers chosen map nicely to | 132 // are exactly on a half-pixel boundary. The numbers chosen map nicely to |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // Ensure the new paint offset can be used. | 183 // Ensure the new paint offset can be used. |
184 EXPECT_TRUE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context,
layoutView(), PaintPhaseForeground)); | 184 EXPECT_TRUE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context,
layoutView(), PaintPhaseForeground)); |
185 rootPaintController().commitNewDisplayItems(); | 185 rootPaintController().commitNewDisplayItems(); |
186 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 1, | 186 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 1, |
187 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground))); | 187 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground))); |
188 } | 188 } |
189 #endif | 189 #endif |
190 | 190 |
191 } // namespace | 191 } // namespace |
192 } // namespace blink | 192 } // namespace blink |
OLD | NEW |