| 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/LayoutObjectDrawingRecorder.h" | 6 #include "core/paint/LayoutObjectDrawingRecorder.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/paint/DeprecatedPaintLayer.h" | 10 #include "core/paint/DeprecatedPaintLayer.h" |
| 11 #include "platform/graphics/GraphicsContext.h" | 11 #include "platform/graphics/GraphicsContext.h" |
| 12 #include "platform/graphics/GraphicsLayer.h" | 12 #include "platform/graphics/GraphicsLayer.h" |
| 13 #include "platform/graphics/paint/DisplayItemList.h" | 13 #include "platform/graphics/paint/DisplayItemList.h" |
| 14 #include "platform/graphics/paint/DrawingDisplayItem.h" | 14 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 15 #include <gtest/gtest.h> | 15 #include <gtest/gtest.h> |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class LayoutObjectDrawingRecorderTest : public RenderingTest { | 19 class LayoutObjectDrawingRecorderTest : public RenderingTest { |
| 20 public: | 20 public: |
| 21 LayoutObjectDrawingRecorderTest() : m_layoutView(nullptr) { } | 21 LayoutObjectDrawingRecorderTest() |
| 22 : m_layoutView(nullptr) |
| 23 , m_originalSlimmingPaintEnabled(RuntimeEnabledFeatures::slimmingPaintEn
abled()) { } |
| 22 | 24 |
| 23 protected: | 25 protected: |
| 24 LayoutView& layoutView() { return *m_layoutView; } | 26 LayoutView& layoutView() { return *m_layoutView; } |
| 25 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } | 27 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph
icsLayerBacking()->displayItemList(); } |
| 26 const DisplayItems& newDisplayItemsBeforeUpdate() { return rootDisplayItemLi
st().m_newDisplayItems; } | 28 const DisplayItems& newDisplayItemsBeforeUpdate() { return rootDisplayItemLi
st().m_newDisplayItems; } |
| 27 | 29 |
| 28 private: | 30 private: |
| 29 virtual void SetUp() override | 31 virtual void SetUp() override |
| 30 { | 32 { |
| 31 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); | 33 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); |
| 32 | 34 |
| 33 RenderingTest::SetUp(); | 35 RenderingTest::SetUp(); |
| 34 enableCompositing(); | 36 enableCompositing(); |
| 35 | 37 |
| 36 m_layoutView = document().view()->layoutView(); | 38 m_layoutView = document().view()->layoutView(); |
| 37 ASSERT_TRUE(m_layoutView); | 39 ASSERT_TRUE(m_layoutView); |
| 38 } | 40 } |
| 39 | 41 |
| 40 virtual void TearDown() override | 42 virtual void TearDown() override |
| 41 { | 43 { |
| 42 RuntimeEnabledFeatures::setSlimmingPaintEnabled(false); | 44 RuntimeEnabledFeatures::setSlimmingPaintEnabled(m_originalSlimmingPaintE
nabled); |
| 43 } | 45 } |
| 44 | 46 |
| 45 LayoutView* m_layoutView; | 47 LayoutView* m_layoutView; |
| 48 bool m_originalSlimmingPaintEnabled; |
| 46 }; | 49 }; |
| 47 | 50 |
| 48 namespace { | 51 namespace { |
| 49 | 52 |
| 50 void drawNothing(GraphicsContext& context, const LayoutView& layoutView, PaintPh
ase phase, const FloatRect& bound) | 53 void drawNothing(GraphicsContext& context, const LayoutView& layoutView, PaintPh
ase phase, const FloatRect& bound) |
| 51 { | 54 { |
| 52 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun
d); | 55 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun
d); |
| 53 | 56 |
| 54 // Redundant when there's nothing to draw but we must always do this check. | 57 // Redundant when there's nothing to draw but we must always do this check. |
| 55 if (drawingRecorder.canUseCachedDrawing()) | 58 if (drawingRecorder.canUseCachedDrawing()) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[0])); | 119 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[0])); |
| 117 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[1])); | 120 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[1])); |
| 118 rootDisplayItemList().commitNewDisplayItems(); | 121 rootDisplayItemList().commitNewDisplayItems(); |
| 119 EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size()); | 122 EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size()); |
| 120 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[0])); | 123 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[0])); |
| 121 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[1])); | 124 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[1])); |
| 122 } | 125 } |
| 123 | 126 |
| 124 } // namespace | 127 } // namespace |
| 125 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |