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/LayerClipRecorder.h" | 5 #include "core/paint/LayerClipRecorder.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/layout/compositing/PaintLayerCompositor.h" | 9 #include "core/layout/compositing/PaintLayerCompositor.h" |
10 #include "core/paint/LayoutObjectDrawingRecorder.h" | 10 #include "core/paint/LayoutObjectDrawingRecorder.h" |
11 #include "core/paint/PaintLayer.h" | 11 #include "core/paint/PaintLayer.h" |
12 #include "platform/graphics/GraphicsContext.h" | 12 #include "platform/graphics/GraphicsContext.h" |
13 #include "platform/graphics/GraphicsLayer.h" | 13 #include "platform/graphics/GraphicsLayer.h" |
14 #include "platform/graphics/paint/PaintController.h" | 14 #include "platform/graphics/paint/PaintController.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 namespace { | 18 namespace { |
19 | 19 |
20 class LayerClipRecorderTest : public RenderingTest { | 20 class LayerClipRecorderTest : public RenderingTest { |
21 public: | 21 public: |
22 LayerClipRecorderTest() | 22 LayerClipRecorderTest() |
23 : m_layoutView(nullptr) { } | 23 : m_layoutView(nullptr) { } |
24 | 24 |
25 protected: | 25 protected: |
26 LayoutView& layoutView() { return *m_layoutView; } | 26 LayoutView& layoutView() { return *m_layoutView; } |
27 PaintController& rootPaintController() { return layoutView().layer()->graphi
csLayerBacking()->paintController(); } | 27 PaintController& rootPaintController() { return layoutView().layer()->graphi
csLayerBacking()->getPaintController(); } |
28 | 28 |
29 private: | 29 private: |
30 void SetUp() override | 30 void SetUp() override |
31 { | 31 { |
32 RenderingTest::SetUp(); | 32 RenderingTest::SetUp(); |
33 enableCompositing(); | 33 enableCompositing(); |
34 | 34 |
35 m_layoutView = document().view()->layoutView(); | 35 m_layoutView = document().view()->layoutView(); |
36 ASSERT_TRUE(m_layoutView); | 36 ASSERT_TRUE(m_layoutView); |
37 } | 37 } |
(...skipping 17 matching lines...) Expand all Loading... |
55 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase,
bound); | 55 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase,
bound); |
56 context.drawRect(rect); | 56 context.drawRect(rect); |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 TEST_F(LayerClipRecorderTest, Single) | 60 TEST_F(LayerClipRecorderTest, Single) |
61 { | 61 { |
62 rootPaintController().invalidateAll(); | 62 rootPaintController().invalidateAll(); |
63 GraphicsContext context(rootPaintController()); | 63 GraphicsContext context(rootPaintController()); |
64 LayoutRect bound = layoutView().viewRect(); | 64 LayoutRect bound = layoutView().viewRect(); |
65 EXPECT_EQ((size_t)0, rootPaintController().displayItemList().size()); | 65 EXPECT_EQ((size_t)0, rootPaintController().getDisplayItemList().size()); |
66 | 66 |
67 drawRectInClip(context, layoutView(), PaintPhaseForeground, bound); | 67 drawRectInClip(context, layoutView(), PaintPhaseForeground, bound); |
68 rootPaintController().commitNewDisplayItems(); | 68 rootPaintController().commitNewDisplayItems(); |
69 EXPECT_EQ((size_t)3, rootPaintController().displayItemList().size()); | 69 EXPECT_EQ((size_t)3, rootPaintController().getDisplayItemList().size()); |
70 EXPECT_TRUE(DisplayItem::isClipType(rootPaintController().displayItemList()[
0].getType())); | 70 EXPECT_TRUE(DisplayItem::isClipType(rootPaintController().getDisplayItemList
()[0].getType())); |
71 EXPECT_TRUE(DisplayItem::isDrawingType(rootPaintController().displayItemList
()[1].getType())); | 71 EXPECT_TRUE(DisplayItem::isDrawingType(rootPaintController().getDisplayItemL
ist()[1].getType())); |
72 EXPECT_TRUE(DisplayItem::isEndClipType(rootPaintController().displayItemList
()[2].getType())); | 72 EXPECT_TRUE(DisplayItem::isEndClipType(rootPaintController().getDisplayItemL
ist()[2].getType())); |
73 } | 73 } |
74 | 74 |
75 TEST_F(LayerClipRecorderTest, Empty) | 75 TEST_F(LayerClipRecorderTest, Empty) |
76 { | 76 { |
77 rootPaintController().invalidateAll(); | 77 rootPaintController().invalidateAll(); |
78 GraphicsContext context(rootPaintController()); | 78 GraphicsContext context(rootPaintController()); |
79 EXPECT_EQ((size_t)0, rootPaintController().displayItemList().size()); | 79 EXPECT_EQ((size_t)0, rootPaintController().getDisplayItemList().size()); |
80 | 80 |
81 drawEmptyClip(context, layoutView(), PaintPhaseForeground); | 81 drawEmptyClip(context, layoutView(), PaintPhaseForeground); |
82 rootPaintController().commitNewDisplayItems(); | 82 rootPaintController().commitNewDisplayItems(); |
83 EXPECT_EQ((size_t)0, rootPaintController().displayItemList().size()); | 83 EXPECT_EQ((size_t)0, rootPaintController().getDisplayItemList().size()); |
84 } | 84 } |
85 | 85 |
86 } // namespace | 86 } // namespace |
87 } // namespace blink | 87 } // namespace blink |
OLD | NEW |