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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 LayoutView* m_layoutView; | 47 LayoutView* m_layoutView; |
48 bool m_originalSlimmingPaintEnabled; | 48 bool m_originalSlimmingPaintEnabled; |
49 }; | 49 }; |
50 | 50 |
51 namespace { | 51 namespace { |
52 | 52 |
53 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) |
54 { | 54 { |
| 55 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutV
iew, phase)) |
| 56 return; |
| 57 |
55 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun
d); | 58 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun
d); |
56 | |
57 // Redundant when there's nothing to draw but we must always do this check. | |
58 if (drawingRecorder.canUseCachedDrawing()) | |
59 return; | |
60 } | 59 } |
61 | 60 |
62 void drawRect(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase
, const FloatRect& bound) | 61 void drawRect(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase
, const FloatRect& bound) |
63 { | 62 { |
| 63 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutV
iew, phase)) |
| 64 return; |
64 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun
d); | 65 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun
d); |
65 if (drawingRecorder.canUseCachedDrawing()) | |
66 return; | |
67 IntRect rect(0, 0, 10, 10); | 66 IntRect rect(0, 0, 10, 10); |
68 context.drawRect(rect); | 67 context.drawRect(rect); |
69 } | 68 } |
70 | 69 |
71 bool isDrawing(const DisplayItem& item) | 70 bool isDrawing(const DisplayItem& item) |
72 { | 71 { |
73 return DisplayItem::isDrawingType(item.type()); | 72 return DisplayItem::isDrawingType(item.type()); |
74 } | 73 } |
75 | 74 |
76 bool isCached(const DisplayItem& item) | 75 bool isCached(const DisplayItem& item) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 EXPECT_TRUE(isCached(*newDisplayItemsBeforeUpdate().elementAt(0))); | 118 EXPECT_TRUE(isCached(*newDisplayItemsBeforeUpdate().elementAt(0))); |
120 EXPECT_TRUE(isCached(*newDisplayItemsBeforeUpdate().elementAt(1))); | 119 EXPECT_TRUE(isCached(*newDisplayItemsBeforeUpdate().elementAt(1))); |
121 rootDisplayItemList().commitNewDisplayItems(); | 120 rootDisplayItemList().commitNewDisplayItems(); |
122 EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size()); | 121 EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size()); |
123 EXPECT_TRUE(isDrawing(*rootDisplayItemList().displayItems().elementAt(0))); | 122 EXPECT_TRUE(isDrawing(*rootDisplayItemList().displayItems().elementAt(0))); |
124 EXPECT_TRUE(isDrawing(*rootDisplayItemList().displayItems().elementAt(1))); | 123 EXPECT_TRUE(isDrawing(*rootDisplayItemList().displayItems().elementAt(1))); |
125 } | 124 } |
126 | 125 |
127 } // namespace | 126 } // namespace |
128 } // namespace blink | 127 } // namespace blink |
OLD | NEW |