Chromium Code Reviews| 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/DeprecatedPaintLayerCompositor.h" | 10 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 } | 41 } |
| 42 void TearDown() override | 42 void TearDown() override |
| 43 { | 43 { |
| 44 RuntimeEnabledFeatures::setSlimmingPaintEnabled(m_originalSlimmingPaintE nabled); | 44 RuntimeEnabledFeatures::setSlimmingPaintEnabled(m_originalSlimmingPaintE nabled); |
| 45 } | 45 } |
| 46 | 46 |
| 47 LayoutView* m_layoutView; | 47 LayoutView* m_layoutView; |
| 48 bool m_originalSlimmingPaintEnabled; | 48 bool m_originalSlimmingPaintEnabled; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 void drawEmptyClip(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase, const FloatRect& bound) | 51 void drawEmptyClip(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase) |
| 52 { | 52 { |
| 53 LayoutRect rect(1, 1, 9, 9); | 53 LayoutRect rect(1, 1, 9, 9); |
| 54 ClipRect clipRect(rect); | 54 ClipRect clipRect(rect); |
| 55 LayerClipRecorder LayerClipRecorder(context, *layoutView.compositor()->rootL ayer()->layoutObject(), DisplayItem::ClipLayerForeground, clipRect, 0, LayoutPoi nt(), PaintLayerFlags()); | 55 LayerClipRecorder LayerClipRecorder(context, *layoutView.compositor()->rootL ayer()->layoutObject(), DisplayItem::ClipLayerForeground, clipRect, 0, LayoutPoi nt(), PaintLayerFlags()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void drawRectInClip(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase, const FloatRect& bound) | 58 void drawRectInClip(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase, const LayoutRect& bound) |
|
jbroman
2015/08/26 19:06:43
Unsure, but maybe I think should stay FloatRect; w
chrishtr
2015/08/26 20:53:51
Same reply as for other test.
| |
| 59 { | 59 { |
| 60 IntRect rect(1, 1, 9, 9); | 60 IntRect rect(1, 1, 9, 9); |
| 61 ClipRect clipRect((LayoutRect(rect))); | 61 ClipRect clipRect((LayoutRect(rect))); |
| 62 LayerClipRecorder LayerClipRecorder(context, *layoutView.compositor()->rootL ayer()->layoutObject(), DisplayItem::ClipLayerForeground, clipRect, 0, LayoutPoi nt(), PaintLayerFlags()); | 62 LayerClipRecorder LayerClipRecorder(context, *layoutView.compositor()->rootL ayer()->layoutObject(), DisplayItem::ClipLayerForeground, clipRect, 0, LayoutPoi nt(), PaintLayerFlags()); |
| 63 if (!LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layout View, phase)) { | 63 if (!LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layout View, phase)) { |
| 64 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, bound); | 64 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, bound); |
| 65 context.drawRect(rect); | 65 context.drawRect(rect); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 TEST_F(LayerClipRecorderTest, Single) | 69 TEST_F(LayerClipRecorderTest, Single) |
| 70 { | 70 { |
| 71 GraphicsContext context(&rootDisplayItemList()); | 71 GraphicsContext context(&rootDisplayItemList()); |
| 72 FloatRect bound = layoutView().viewRect(); | 72 LayoutRect bound = layoutView().viewRect(); |
| 73 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); | 73 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); |
| 74 | 74 |
| 75 drawRectInClip(context, layoutView(), PaintPhaseForeground, bound); | 75 drawRectInClip(context, layoutView(), PaintPhaseForeground, bound); |
| 76 rootDisplayItemList().commitNewDisplayItems(); | 76 rootDisplayItemList().commitNewDisplayItems(); |
| 77 EXPECT_EQ((size_t)3, rootDisplayItemList().displayItems().size()); | 77 EXPECT_EQ((size_t)3, rootDisplayItemList().displayItems().size()); |
| 78 EXPECT_TRUE(DisplayItem::isClipType(rootDisplayItemList().displayItems()[0]. type())); | 78 EXPECT_TRUE(DisplayItem::isClipType(rootDisplayItemList().displayItems()[0]. type())); |
| 79 EXPECT_TRUE(DisplayItem::isDrawingType(rootDisplayItemList().displayItems()[ 1].type())); | 79 EXPECT_TRUE(DisplayItem::isDrawingType(rootDisplayItemList().displayItems()[ 1].type())); |
| 80 EXPECT_TRUE(DisplayItem::isEndClipType(rootDisplayItemList().displayItems()[ 2].type())); | 80 EXPECT_TRUE(DisplayItem::isEndClipType(rootDisplayItemList().displayItems()[ 2].type())); |
| 81 } | 81 } |
| 82 | 82 |
| 83 TEST_F(LayerClipRecorderTest, Empty) | 83 TEST_F(LayerClipRecorderTest, Empty) |
| 84 { | 84 { |
| 85 GraphicsContext context(&rootDisplayItemList()); | 85 GraphicsContext context(&rootDisplayItemList()); |
| 86 FloatRect bound = layoutView().viewRect(); | |
| 87 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); | 86 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); |
| 88 | 87 |
| 89 drawEmptyClip(context, layoutView(), PaintPhaseForeground, bound); | 88 drawEmptyClip(context, layoutView(), PaintPhaseForeground); |
| 90 rootDisplayItemList().commitNewDisplayItems(); | 89 rootDisplayItemList().commitNewDisplayItems(); |
| 91 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); | 90 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); |
| 92 } | 91 } |
| 93 | 92 |
| 94 } | 93 } |
| 95 } | 94 } |
| OLD | NEW |