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/RenderDrawingRecorder.h" | 6 #include "core/paint/RenderDrawingRecorder.h" |
7 | 7 |
8 #include "core/rendering/RenderLayer.h" | 8 #include "core/rendering/RenderLayer.h" |
9 #include "core/rendering/RenderView.h" | 9 #include "core/rendering/RenderView.h" |
10 #include "core/rendering/RenderingTestHelper.h" | 10 #include "core/rendering/RenderingTestHelper.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 m_renderView = document().view()->renderView(); | 35 m_renderView = document().view()->renderView(); |
36 ASSERT_TRUE(m_renderView); | 36 ASSERT_TRUE(m_renderView); |
37 } | 37 } |
38 | 38 |
39 RenderView* m_renderView; | 39 RenderView* m_renderView; |
40 }; | 40 }; |
41 | 41 |
42 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) |
43 { | 43 { |
44 RenderDrawingRecorder drawingRecorder(context, renderer, phase, bound); | 44 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); |
45 } | 45 } |
46 | 46 |
47 void drawRect(GraphicsContext* context, RenderView* renderer, PaintPhase phase,
const FloatRect& bound) | 47 void drawRect(GraphicsContext* context, RenderView* renderer, PaintPhase phase,
const FloatRect& bound) |
48 { | 48 { |
49 RenderDrawingRecorder drawingRecorder(context, renderer, phase, bound); | 49 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); |
| 50 if (drawingRecorder.canUseCachedDrawing()) |
| 51 return; |
50 IntRect rect(0, 0, 10, 10); | 52 IntRect rect(0, 0, 10, 10); |
51 context->drawRect(rect); | 53 context->drawRect(rect); |
52 } | 54 } |
53 | 55 |
54 | 56 |
55 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Nothing) | 57 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Nothing) |
56 { | 58 { |
57 GraphicsContext context(nullptr, &rootDisplayItemList()); | 59 GraphicsContext context(nullptr, &rootDisplayItemList()); |
58 FloatRect bound = renderView()->viewRect(); | 60 FloatRect bound = renderView()->viewRect(); |
59 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size()); | 61 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size()); |
60 | 62 |
61 drawNothing(&context, renderView(), PaintPhaseForeground, bound); | 63 drawNothing(&context, renderView(), PaintPhaseForeground, bound); |
62 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size()); | 64 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size()); |
63 } | 65 } |
64 | 66 |
65 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect) | 67 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect) |
66 { | 68 { |
67 GraphicsContext context(nullptr, &rootDisplayItemList()); | 69 GraphicsContext context(nullptr, &rootDisplayItemList()); |
68 FloatRect bound = renderView()->viewRect(); | 70 FloatRect bound = renderView()->viewRect(); |
69 drawRect(&context, renderView(), PaintPhaseForeground, bound); | 71 drawRect(&context, renderView(), PaintPhaseForeground, bound); |
70 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); | 72 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); |
71 } | 73 } |
72 | 74 |
73 } | 75 } |
74 } | 76 } |
OLD | NEW |