| 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/PassOwnPtr.h" | 22 #include "wtf/PassOwnPtr.h" |
| 23 #include "wtf/Utility.h" | |
| 24 #include "wtf/Vector.h" | 23 #include "wtf/Vector.h" |
| 24 #include <utility> |
| 25 | 25 |
| 26 namespace blink { | 26 namespace blink { |
| 27 | 27 |
| 28 class GraphicsContext; | 28 class GraphicsContext; |
| 29 | 29 |
| 30 static const size_t kInitialDisplayItemListCapacityBytes = 512; | 30 static const size_t kInitialDisplayItemListCapacityBytes = 512; |
| 31 | 31 |
| 32 // Responsible for processing display items as they are produced, and producing | 32 // Responsible for processing display items as they are produced, and producing |
| 33 // a final paint artifact when complete. This class includes logic for caching, | 33 // a final paint artifact when complete. This class includes logic for caching, |
| 34 // cache invalidation, and merging. | 34 // cache invalidation, and merging. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 template <typename DisplayItemClass, typename... Args> | 69 template <typename DisplayItemClass, typename... Args> |
| 70 void createAndAppend(Args&&... args) | 70 void createAndAppend(Args&&... args) |
| 71 { | 71 { |
| 72 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value, | 72 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value, |
| 73 "Can only createAndAppend subclasses of DisplayItem."); | 73 "Can only createAndAppend subclasses of DisplayItem."); |
| 74 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize, | 74 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize, |
| 75 "DisplayItem subclass is larger than kMaximumDisplayItemSize."); | 75 "DisplayItem subclass is larger than kMaximumDisplayItemSize."); |
| 76 | 76 |
| 77 if (displayItemConstructionIsDisabled()) | 77 if (displayItemConstructionIsDisabled()) |
| 78 return; | 78 return; |
| 79 DisplayItemClass& displayItem = m_newDisplayItemList.allocateAndConstruc
t<DisplayItemClass>(WTF::forward<Args>(args)...); | 79 DisplayItemClass& displayItem = m_newDisplayItemList.allocateAndConstruc
t<DisplayItemClass>(std::forward<Args>(args)...); |
| 80 processNewItem(displayItem); | 80 processNewItem(displayItem); |
| 81 } | 81 } |
| 82 | 82 |
| 83 // Creates and appends an ending display item to pair with a preceding | 83 // Creates and appends an ending display item to pair with a preceding |
| 84 // beginning item iff the display item actually draws content. For no-op | 84 // beginning item iff the display item actually draws content. For no-op |
| 85 // items, rather than creating an ending item, the begin item will | 85 // items, rather than creating an ending item, the begin item will |
| 86 // instead be removed, thereby maintaining brevity of the list. If display | 86 // instead be removed, thereby maintaining brevity of the list. If display |
| 87 // item construction is disabled, no list mutations will be performed. | 87 // item construction is disabled, no list mutations will be performed. |
| 88 template <typename DisplayItemClass, typename... Args> | 88 template <typename DisplayItemClass, typename... Args> |
| 89 void endItem(Args&&... args) | 89 void endItem(Args&&... args) |
| 90 { | 90 { |
| 91 if (displayItemConstructionIsDisabled()) | 91 if (displayItemConstructionIsDisabled()) |
| 92 return; | 92 return; |
| 93 if (lastDisplayItemIsNoopBegin()) | 93 if (lastDisplayItemIsNoopBegin()) |
| 94 removeLastDisplayItem(); | 94 removeLastDisplayItem(); |
| 95 else | 95 else |
| 96 createAndAppend<DisplayItemClass>(WTF::forward<Args>(args)...); | 96 createAndAppend<DisplayItemClass>(std::forward<Args>(args)...); |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Scopes must be used to avoid duplicated display item ids when we paint so
me object | 99 // Scopes must be used to avoid duplicated display item ids when we paint so
me object |
| 100 // multiple times and generate multiple display items with the same type. | 100 // multiple times and generate multiple display items with the same type. |
| 101 // We don't cache display items added in scopes. | 101 // We don't cache display items added in scopes. |
| 102 void beginScope(); | 102 void beginScope(); |
| 103 void endScope(); | 103 void endScope(); |
| 104 | 104 |
| 105 // True if the last display item is a begin that doesn't draw content. | 105 // True if the last display item is a begin that doesn't draw content. |
| 106 bool lastDisplayItemIsNoopBegin() const; | 106 bool lastDisplayItemIsNoopBegin() const; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // easily find where the duplicated ids are from. | 262 // easily find where the duplicated ids are from. |
| 263 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; | 263 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; |
| 264 #endif | 264 #endif |
| 265 | 265 |
| 266 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; | 266 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; |
| 267 }; | 267 }; |
| 268 | 268 |
| 269 } // namespace blink | 269 } // namespace blink |
| 270 | 270 |
| 271 #endif // PaintController_h | 271 #endif // PaintController_h |
| OLD | NEW |