| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 RenderingTest::SetUp(); | 32 RenderingTest::SetUp(); |
| 33 enableCompositing(); | 33 enableCompositing(); |
| 34 | 34 |
| 35 m_layoutView = document().view()->layoutView(); | 35 m_layoutView = document().view()->layoutView(); |
| 36 ASSERT_TRUE(m_layoutView); | 36 ASSERT_TRUE(m_layoutView); |
| 37 } | 37 } |
| 38 | 38 |
| 39 virtual void TearDown() override | 39 virtual void TearDown() override |
| 40 { | 40 { |
| 41 RuntimeEnabledFeatures::setSlimmingPaintEnabled(false); | 41 RuntimeEnabledFeatures::setSlimmingPaintEnabled(false); |
| 42 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(false); | |
| 43 } | 42 } |
| 44 | 43 |
| 45 LayoutView* m_layoutView; | 44 LayoutView* m_layoutView; |
| 46 }; | 45 }; |
| 47 | 46 |
| 48 void drawNothing(GraphicsContext* context, LayoutView* renderer, PaintPhase phas
e, const FloatRect& bound) | 47 void drawNothing(GraphicsContext* context, LayoutView* renderer, PaintPhase phas
e, const FloatRect& bound) |
| 49 { | 48 { |
| 50 LayoutObjectDrawingRecorder drawingRecorder(context, *renderer, phase, bound
); | 49 LayoutObjectDrawingRecorder drawingRecorder(context, *renderer, phase, bound
); |
| 51 | 50 |
| 52 // Redundant when there's nothing to draw but we must always do this check. | 51 // Redundant when there's nothing to draw but we must always do this check. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 80 GraphicsContext context(nullptr, &rootDisplayItemList()); | 79 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 81 FloatRect bound = layoutView()->viewRect(); | 80 FloatRect bound = layoutView()->viewRect(); |
| 82 drawRect(&context, layoutView(), PaintPhaseForeground, bound); | 81 drawRect(&context, layoutView(), PaintPhaseForeground, bound); |
| 83 rootDisplayItemList().endNewPaints(); | 82 rootDisplayItemList().endNewPaints(); |
| 84 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); | 83 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); |
| 85 EXPECT_TRUE(rootDisplayItemList().paintList()[0]->isDrawing()); | 84 EXPECT_TRUE(rootDisplayItemList().paintList()[0]->isDrawing()); |
| 86 } | 85 } |
| 87 | 86 |
| 88 TEST_F(LayoutObjectDrawingRecorderTest, Cached) | 87 TEST_F(LayoutObjectDrawingRecorderTest, Cached) |
| 89 { | 88 { |
| 90 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true); | |
| 91 | |
| 92 GraphicsContext context(nullptr, &rootDisplayItemList()); | 89 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 93 FloatRect bound = layoutView()->viewRect(); | 90 FloatRect bound = layoutView()->viewRect(); |
| 94 drawNothing(&context, layoutView(), PaintPhaseBlockBackground, bound); | 91 drawNothing(&context, layoutView(), PaintPhaseBlockBackground, bound); |
| 95 drawRect(&context, layoutView(), PaintPhaseForeground, bound); | 92 drawRect(&context, layoutView(), PaintPhaseForeground, bound); |
| 96 rootDisplayItemList().endNewPaints(); | 93 rootDisplayItemList().endNewPaints(); |
| 97 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); | 94 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); |
| 98 EXPECT_TRUE(rootDisplayItemList().paintList()[0]->isDrawing()); | 95 EXPECT_TRUE(rootDisplayItemList().paintList()[0]->isDrawing()); |
| 99 | 96 |
| 100 drawNothing(&context, layoutView(), PaintPhaseBlockBackground, bound); | 97 drawNothing(&context, layoutView(), PaintPhaseBlockBackground, bound); |
| 101 drawRect(&context, layoutView(), PaintPhaseForeground, bound); | 98 drawRect(&context, layoutView(), PaintPhaseForeground, bound); |
| 102 EXPECT_EQ((size_t)2, newPaintListBeforeUpdate().size()); | 99 EXPECT_EQ((size_t)2, newPaintListBeforeUpdate().size()); |
| 103 EXPECT_TRUE(newPaintListBeforeUpdate()[0]->isCached()); | 100 EXPECT_TRUE(newPaintListBeforeUpdate()[0]->isCached()); |
| 104 EXPECT_TRUE(newPaintListBeforeUpdate()[1]->isCached()); | 101 EXPECT_TRUE(newPaintListBeforeUpdate()[1]->isCached()); |
| 105 rootDisplayItemList().endNewPaints(); | 102 rootDisplayItemList().endNewPaints(); |
| 106 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); | 103 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); |
| 107 EXPECT_TRUE(rootDisplayItemList().paintList()[0]->isDrawing()); | 104 EXPECT_TRUE(rootDisplayItemList().paintList()[0]->isDrawing()); |
| 108 } | 105 } |
| 109 | 106 |
| 110 } | 107 } |
| OLD | NEW |