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