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/DrawingRecorder.h" | 6 #include "core/paint/DrawingRecorder.h" |
7 | 7 |
| 8 #include "core/rendering/RenderLayer.h" |
8 #include "core/rendering/RenderView.h" | 9 #include "core/rendering/RenderView.h" |
9 #include "core/rendering/RenderingTestHelper.h" | 10 #include "core/rendering/RenderingTestHelper.h" |
10 #include "platform/graphics/GraphicsContext.h" | 11 #include "platform/graphics/GraphicsContext.h" |
| 12 #include "platform/graphics/GraphicsLayer.h" |
| 13 #include "platform/graphics/paint/DisplayItemList.h" |
11 #include <gtest/gtest.h> | 14 #include <gtest/gtest.h> |
12 | 15 |
13 namespace blink { | 16 namespace blink { |
14 namespace { | 17 namespace { |
15 | 18 |
16 class DrawingRecorderTest : public RenderingTest { | 19 class DrawingRecorderTest : public RenderingTest { |
17 public: | 20 public: |
18 DrawingRecorderTest() : m_renderView(nullptr) { } | 21 DrawingRecorderTest() : m_renderView(nullptr) { } |
19 | 22 |
20 protected: | 23 protected: |
21 RenderView* renderView() { return m_renderView; } | 24 RenderView* renderView() { return m_renderView; } |
| 25 DisplayItemList& rootDisplayItemList() { return renderView()->layer()->graph
icsLayerBacking()->displayItemList(); } |
22 | 26 |
23 private: | 27 private: |
24 virtual void SetUp() override | 28 virtual void SetUp() override |
25 { | 29 { |
26 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); | 30 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); |
27 | 31 |
28 RenderingTest::SetUp(); | 32 RenderingTest::SetUp(); |
| 33 enableCompositing(); |
29 | 34 |
30 m_renderView = document().view()->renderView(); | 35 m_renderView = document().view()->renderView(); |
31 ASSERT_TRUE(m_renderView); | 36 ASSERT_TRUE(m_renderView); |
32 } | 37 } |
33 | 38 |
34 RenderView* m_renderView; | 39 RenderView* m_renderView; |
35 }; | 40 }; |
36 | 41 |
37 void drawNothing(GraphicsContext* context, RenderView* renderer, PaintPhase phas
e, const FloatRect& bound) | 42 void drawNothing(GraphicsContext* context, RenderView* renderer, PaintPhase phas
e, const FloatRect& bound) |
38 { | 43 { |
39 DrawingRecorder drawingRecorder(context, renderer, phase, bound); | 44 DrawingRecorder drawingRecorder(context, renderer, phase, bound); |
40 } | 45 } |
41 | 46 |
42 void drawRect(GraphicsContext* context, RenderView* renderer, PaintPhase phase,
const FloatRect& bound) | 47 void drawRect(GraphicsContext* context, RenderView* renderer, PaintPhase phase,
const FloatRect& bound) |
43 { | 48 { |
44 DrawingRecorder drawingRecorder(context, renderer, phase, bound); | 49 DrawingRecorder drawingRecorder(context, renderer, phase, bound); |
45 IntRect rect(0, 0, 10, 10); | 50 IntRect rect(0, 0, 10, 10); |
46 context->drawRect(rect); | 51 context->drawRect(rect); |
47 } | 52 } |
48 | 53 |
49 | 54 |
50 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Nothing) | 55 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Nothing) |
51 { | 56 { |
52 GraphicsContext* context = new GraphicsContext(nullptr); | 57 GraphicsContext* context = new GraphicsContext(nullptr); |
53 FloatRect bound = renderView()->viewRect(); | 58 FloatRect bound = renderView()->viewRect(); |
54 EXPECT_EQ((size_t)0, renderView()->viewDisplayList().paintList().size()); | 59 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size()); |
55 | 60 |
56 drawNothing(context, renderView(), PaintPhaseForeground, bound); | 61 drawNothing(context, renderView(), PaintPhaseForeground, bound); |
57 EXPECT_EQ((size_t)0, renderView()->viewDisplayList().paintList().size()); | 62 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size()); |
58 } | 63 } |
59 | 64 |
60 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect) | 65 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect) |
61 { | 66 { |
62 GraphicsContext* context = new GraphicsContext(nullptr); | 67 GraphicsContext* context = new GraphicsContext(nullptr); |
63 FloatRect bound = renderView()->viewRect(); | 68 FloatRect bound = renderView()->viewRect(); |
64 drawRect(context, renderView(), PaintPhaseForeground, bound); | 69 drawRect(context, renderView(), PaintPhaseForeground, bound); |
65 EXPECT_EQ((size_t)1, renderView()->viewDisplayList().paintList().size()); | 70 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); |
66 } | 71 } |
67 | 72 |
68 } | 73 } |
69 } | 74 } |
OLD | NEW |