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 #ifndef PaintController_h | 5 #ifndef PaintController_h |
6 #define PaintController_h | 6 #define PaintController_h |
7 | 7 |
8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
9 #include "platform/RuntimeEnabledFeatures.h" | 9 #include "platform/RuntimeEnabledFeatures.h" |
10 #include "platform/geometry/IntRect.h" | 10 #include "platform/geometry/IntRect.h" |
11 #include "platform/geometry/LayoutPoint.h" | 11 #include "platform/geometry/LayoutPoint.h" |
12 #include "platform/graphics/ContiguousContainer.h" | 12 #include "platform/graphics/ContiguousContainer.h" |
13 #include "platform/graphics/PaintInvalidationReason.h" | 13 #include "platform/graphics/PaintInvalidationReason.h" |
14 #include "platform/graphics/paint/DisplayItem.h" | 14 #include "platform/graphics/paint/DisplayItem.h" |
15 #include "platform/graphics/paint/DisplayItemList.h" | 15 #include "platform/graphics/paint/DisplayItemList.h" |
16 #include "platform/graphics/paint/PaintArtifact.h" | 16 #include "platform/graphics/paint/PaintArtifact.h" |
17 #include "platform/graphics/paint/PaintChunk.h" | 17 #include "platform/graphics/paint/PaintChunk.h" |
18 #include "platform/graphics/paint/PaintChunker.h" | 18 #include "platform/graphics/paint/PaintChunker.h" |
19 #include "platform/graphics/paint/Transform3DDisplayItem.h" | 19 #include "platform/graphics/paint/Transform3DDisplayItem.h" |
20 #include "wtf/Alignment.h" | 20 #include "wtf/Alignment.h" |
21 #include "wtf/HashMap.h" | 21 #include "wtf/HashMap.h" |
22 #include "wtf/HashSet.h" | 22 #include "wtf/HashSet.h" |
23 #include "wtf/PassOwnPtr.h" | 23 #include "wtf/PassOwnPtr.h" |
24 #include "wtf/Utility.h" | |
25 #include "wtf/Vector.h" | 24 #include "wtf/Vector.h" |
| 25 #include <utility> |
26 | 26 |
27 namespace blink { | 27 namespace blink { |
28 | 28 |
29 class GraphicsContext; | 29 class GraphicsContext; |
30 | 30 |
31 static const size_t kInitialDisplayItemListCapacityBytes = 512; | 31 static const size_t kInitialDisplayItemListCapacityBytes = 512; |
32 | 32 |
33 // Responsible for processing display items as they are produced, and producing | 33 // Responsible for processing display items as they are produced, and producing |
34 // a final paint artifact when complete. This class includes logic for caching, | 34 // a final paint artifact when complete. This class includes logic for caching, |
35 // cache invalidation, and merging. | 35 // cache invalidation, and merging. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 template <typename DisplayItemClass, typename... Args> | 70 template <typename DisplayItemClass, typename... Args> |
71 void createAndAppend(Args&&... args) | 71 void createAndAppend(Args&&... args) |
72 { | 72 { |
73 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value, | 73 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value, |
74 "Can only createAndAppend subclasses of DisplayItem."); | 74 "Can only createAndAppend subclasses of DisplayItem."); |
75 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize, | 75 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize, |
76 "DisplayItem subclass is larger than kMaximumDisplayItemSize."); | 76 "DisplayItem subclass is larger than kMaximumDisplayItemSize."); |
77 | 77 |
78 if (displayItemConstructionIsDisabled()) | 78 if (displayItemConstructionIsDisabled()) |
79 return; | 79 return; |
80 DisplayItemClass& displayItem = m_newDisplayItemList.allocateAndConstruc
t<DisplayItemClass>(WTF::forward<Args>(args)...); | 80 DisplayItemClass& displayItem = m_newDisplayItemList.allocateAndConstruc
t<DisplayItemClass>(std::forward<Args>(args)...); |
81 processNewItem(displayItem); | 81 processNewItem(displayItem); |
82 } | 82 } |
83 | 83 |
84 // Creates and appends an ending display item to pair with a preceding | 84 // Creates and appends an ending display item to pair with a preceding |
85 // beginning item iff the display item actually draws content. For no-op | 85 // beginning item iff the display item actually draws content. For no-op |
86 // items, rather than creating an ending item, the begin item will | 86 // items, rather than creating an ending item, the begin item will |
87 // instead be removed, thereby maintaining brevity of the list. If display | 87 // instead be removed, thereby maintaining brevity of the list. If display |
88 // item construction is disabled, no list mutations will be performed. | 88 // item construction is disabled, no list mutations will be performed. |
89 template <typename DisplayItemClass, typename... Args> | 89 template <typename DisplayItemClass, typename... Args> |
90 void endItem(Args&&... args) | 90 void endItem(Args&&... args) |
91 { | 91 { |
92 if (displayItemConstructionIsDisabled()) | 92 if (displayItemConstructionIsDisabled()) |
93 return; | 93 return; |
94 if (lastDisplayItemIsNoopBegin()) | 94 if (lastDisplayItemIsNoopBegin()) |
95 removeLastDisplayItem(); | 95 removeLastDisplayItem(); |
96 else | 96 else |
97 createAndAppend<DisplayItemClass>(WTF::forward<Args>(args)...); | 97 createAndAppend<DisplayItemClass>(std::forward<Args>(args)...); |
98 } | 98 } |
99 | 99 |
100 // Scopes must be used to avoid duplicated display item ids when we paint so
me object | 100 // Scopes must be used to avoid duplicated display item ids when we paint so
me object |
101 // multiple times and generate multiple display items with the same type. | 101 // multiple times and generate multiple display items with the same type. |
102 // We don't cache display items added in scopes. | 102 // We don't cache display items added in scopes. |
103 void beginScope(); | 103 void beginScope(); |
104 void endScope(); | 104 void endScope(); |
105 | 105 |
106 // True if the last display item is a begin that doesn't draw content. | 106 // True if the last display item is a begin that doesn't draw content. |
107 bool lastDisplayItemIsNoopBegin() const; | 107 bool lastDisplayItemIsNoopBegin() const; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // easily find where the duplicated ids are from. | 278 // easily find where the duplicated ids are from. |
279 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; | 279 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; |
280 #endif | 280 #endif |
281 | 281 |
282 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; | 282 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; |
283 }; | 283 }; |
284 | 284 |
285 } // namespace blink | 285 } // namespace blink |
286 | 286 |
287 #endif // PaintController_h | 287 #endif // PaintController_h |
OLD | NEW |