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" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 rootPaintController().invalidateAll(); |
63 GraphicsContext context(rootPaintController()); | 64 GraphicsContext context(rootPaintController()); |
64 LayoutRect bound = layoutView().viewRect(); | 65 LayoutRect bound = layoutView().viewRect(); |
65 EXPECT_EQ((size_t)0, rootPaintController().displayItemList().size()); | 66 EXPECT_EQ((size_t)0, rootPaintController().displayItemList().size()); |
66 | 67 |
67 drawRectInClip(context, layoutView(), PaintPhaseForeground, bound); | 68 drawRectInClip(context, layoutView(), PaintPhaseForeground, bound); |
68 rootPaintController().commitNewDisplayItems(); | 69 rootPaintController().commitNewDisplayItems(); |
69 EXPECT_EQ((size_t)3, rootPaintController().displayItemList().size()); | 70 EXPECT_EQ((size_t)3, rootPaintController().displayItemList().size()); |
70 EXPECT_TRUE(DisplayItem::isClipType(rootPaintController().displayItemList()[
0].type())); | 71 EXPECT_TRUE(DisplayItem::isClipType(rootPaintController().displayItemList()[
0].type())); |
71 EXPECT_TRUE(DisplayItem::isDrawingType(rootPaintController().displayItemList
()[1].type())); | 72 EXPECT_TRUE(DisplayItem::isDrawingType(rootPaintController().displayItemList
()[1].type())); |
72 EXPECT_TRUE(DisplayItem::isEndClipType(rootPaintController().displayItemList
()[2].type())); | 73 EXPECT_TRUE(DisplayItem::isEndClipType(rootPaintController().displayItemList
()[2].type())); |
73 } | 74 } |
74 | 75 |
75 TEST_F(LayerClipRecorderTest, Empty) | 76 TEST_F(LayerClipRecorderTest, Empty) |
76 { | 77 { |
| 78 rootPaintController().invalidateAll(); |
77 GraphicsContext context(rootPaintController()); | 79 GraphicsContext context(rootPaintController()); |
78 EXPECT_EQ((size_t)0, rootPaintController().displayItemList().size()); | 80 EXPECT_EQ((size_t)0, rootPaintController().displayItemList().size()); |
79 | 81 |
80 drawEmptyClip(context, layoutView(), PaintPhaseForeground); | 82 drawEmptyClip(context, layoutView(), PaintPhaseForeground); |
81 rootPaintController().commitNewDisplayItems(); | 83 rootPaintController().commitNewDisplayItems(); |
82 EXPECT_EQ((size_t)0, rootPaintController().displayItemList().size()); | 84 EXPECT_EQ((size_t)0, rootPaintController().displayItemList().size()); |
83 } | 85 } |
84 | 86 |
85 } | 87 } |
86 } | 88 } |
OLD | NEW |