| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 rootPaintController().commitNewDisplayItems(); | 58 rootPaintController().commitNewDisplayItems(); |
| 59 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 1, | 59 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 1, |
| 60 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground))); | 60 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground))); |
| 61 } | 61 } |
| 62 | 62 |
| 63 TEST_F(LayoutObjectDrawingRecorderTest, Cached) | 63 TEST_F(LayoutObjectDrawingRecorderTest, Cached) |
| 64 { | 64 { |
| 65 rootPaintController().invalidateAll(); | 65 rootPaintController().invalidateAll(); |
| 66 GraphicsContext context(rootPaintController()); | 66 GraphicsContext context(rootPaintController()); |
| 67 LayoutRect bound = layoutView().viewRect(); | 67 LayoutRect bound = layoutView().viewRect(); |
| 68 drawNothing(context, layoutView(), PaintPhaseSelfBlockBackground, bound); | 68 drawNothing(context, layoutView(), PaintPhaseSelfBlockBackgroundOnly, bound)
; |
| 69 drawRect(context, layoutView(), PaintPhaseForeground, bound); | 69 drawRect(context, layoutView(), PaintPhaseForeground, bound); |
| 70 rootPaintController().commitNewDisplayItems(); | 70 rootPaintController().commitNewDisplayItems(); |
| 71 | 71 |
| 72 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2, | 72 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2, |
| 73 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseSelfBlockBackground)), | 73 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseSelfBlockBackgroundOnly)), |
| 74 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground))); | 74 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground))); |
| 75 | 75 |
| 76 drawNothing(context, layoutView(), PaintPhaseSelfBlockBackground, bound); | 76 drawNothing(context, layoutView(), PaintPhaseSelfBlockBackgroundOnly, bound)
; |
| 77 drawRect(context, layoutView(), PaintPhaseForeground, bound); | 77 drawRect(context, layoutView(), PaintPhaseForeground, bound); |
| 78 | 78 |
| 79 EXPECT_DISPLAY_LIST(rootPaintController().newDisplayItemList(), 2, | 79 EXPECT_DISPLAY_LIST(rootPaintController().newDisplayItemList(), 2, |
| 80 TestDisplayItem(layoutView(), DisplayItem::drawingTypeToCachedDrawingTyp
e(DisplayItem::paintPhaseToDrawingType(PaintPhaseSelfBlockBackground))), | 80 TestDisplayItem(layoutView(), DisplayItem::drawingTypeToCachedDrawingTyp
e(DisplayItem::paintPhaseToDrawingType(PaintPhaseSelfBlockBackgroundOnly))), |
| 81 TestDisplayItem(layoutView(), DisplayItem::drawingTypeToCachedDrawingTyp
e(DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)))); | 81 TestDisplayItem(layoutView(), DisplayItem::drawingTypeToCachedDrawingTyp
e(DisplayItem::paintPhaseToDrawingType(PaintPhaseForeground)))); |
| 82 | 82 |
| 83 rootPaintController().commitNewDisplayItems(); | 83 rootPaintController().commitNewDisplayItems(); |
| 84 | 84 |
| 85 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2, | 85 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 2, |
| 86 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseSelfBlockBackground)), | 86 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseSelfBlockBackgroundOnly)), |
| 87 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground))); | 87 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground))); |
| 88 } | 88 } |
| 89 | 89 |
| 90 template <typename T> | 90 template <typename T> |
| 91 FloatRect drawAndGetCullRect(PaintController& controller, const LayoutObject& la
youtObject, const T& bounds) | 91 FloatRect drawAndGetCullRect(PaintController& controller, const LayoutObject& la
youtObject, const T& bounds) |
| 92 { | 92 { |
| 93 controller.invalidateAll(); | 93 controller.invalidateAll(); |
| 94 { | 94 { |
| 95 // Draw some things which will produce a non-null picture. | 95 // Draw some things which will produce a non-null picture. |
| 96 GraphicsContext context(controller); | 96 GraphicsContext context(controller); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 // Ensure the new paint offset can be used. | 159 // Ensure the new paint offset can be used. |
| 160 EXPECT_TRUE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context,
layoutView(), PaintPhaseForeground, newPaintOffset)); | 160 EXPECT_TRUE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context,
layoutView(), PaintPhaseForeground, newPaintOffset)); |
| 161 rootPaintController().commitNewDisplayItems(); | 161 rootPaintController().commitNewDisplayItems(); |
| 162 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 1, | 162 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 1, |
| 163 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground))); | 163 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground))); |
| 164 } | 164 } |
| 165 | 165 |
| 166 } // namespace | 166 } // namespace |
| 167 } // namespace blink | 167 } // namespace blink |
| OLD | NEW |