| 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" |
| 11 #include "core/paint/DeprecatedPaintLayer.h" | 11 #include "core/paint/DeprecatedPaintLayer.h" |
| 12 #include "core/paint/LayoutObjectDrawingRecorder.h" | 12 #include "core/paint/LayoutObjectDrawingRecorder.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/DisplayItemList.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() : m_layoutView(nullptr) { } | 23 LayerClipRecorderTest() |
| 24 : m_layoutView(nullptr) |
| 25 , m_originalSlimmingPaintEnabled(RuntimeEnabledFeatures::slimmingPaintEn
abled()) { } |
| 24 | 26 |
| 25 protected: | 27 protected: |
| 26 LayoutView& layoutView() { return *m_layoutView; } | 28 LayoutView& layoutView() { return *m_layoutView; } |
| 27 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } | 29 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } |
| 28 | 30 |
| 29 private: | 31 private: |
| 30 virtual void SetUp() override | 32 virtual void SetUp() override |
| 31 { | 33 { |
| 32 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); | 34 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); |
| 33 | 35 |
| 34 RenderingTest::SetUp(); | 36 RenderingTest::SetUp(); |
| 35 enableCompositing(); | 37 enableCompositing(); |
| 36 | 38 |
| 37 m_layoutView = document().view()->layoutView(); | 39 m_layoutView = document().view()->layoutView(); |
| 38 ASSERT_TRUE(m_layoutView); | 40 ASSERT_TRUE(m_layoutView); |
| 39 } | 41 } |
| 42 virtual void TearDown() override |
| 43 { |
| 44 RuntimeEnabledFeatures::setSlimmingPaintEnabled(m_originalSlimmingPaintE
nabled); |
| 45 } |
| 40 | 46 |
| 41 LayoutView* m_layoutView; | 47 LayoutView* m_layoutView; |
| 48 bool m_originalSlimmingPaintEnabled; |
| 42 }; | 49 }; |
| 43 | 50 |
| 44 void drawEmptyClip(GraphicsContext& context, LayoutView& layoutView, PaintPhase
phase, const FloatRect& bound) | 51 void drawEmptyClip(GraphicsContext& context, LayoutView& layoutView, PaintPhase
phase, const FloatRect& bound) |
| 45 { | 52 { |
| 46 LayoutRect rect(1, 1, 9, 9); | 53 LayoutRect rect(1, 1, 9, 9); |
| 47 ClipRect clipRect(rect); | 54 ClipRect clipRect(rect); |
| 48 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()); |
| 49 } | 56 } |
| 50 | 57 |
| 51 void drawRectInClip(GraphicsContext& context, LayoutView& layoutView, PaintPhase
phase, const FloatRect& bound) | 58 void drawRectInClip(GraphicsContext& context, LayoutView& layoutView, PaintPhase
phase, const FloatRect& bound) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 78 FloatRect bound = layoutView().viewRect(); | 85 FloatRect bound = layoutView().viewRect(); |
| 79 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); | 86 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); |
| 80 | 87 |
| 81 drawEmptyClip(context, layoutView(), PaintPhaseForeground, bound); | 88 drawEmptyClip(context, layoutView(), PaintPhaseForeground, bound); |
| 82 rootDisplayItemList().commitNewDisplayItems(); | 89 rootDisplayItemList().commitNewDisplayItems(); |
| 83 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); | 90 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); |
| 84 } | 91 } |
| 85 | 92 |
| 86 } | 93 } |
| 87 } | 94 } |
| OLD | NEW |