OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef DisplayItemPropertyTreeBuilder_h |
| 6 #define DisplayItemPropertyTreeBuilder_h |
| 7 |
| 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/geometry/FloatSize.h" |
| 10 #include "wtf/OwnPtr.h" |
| 11 #include "wtf/PassOwnPtr.h" |
| 12 #include "wtf/Vector.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 class DisplayItem; |
| 17 class DisplayItemClipTree; |
| 18 class DisplayItemTransformTree; |
| 19 |
| 20 // Builds property trees from a sequence of (properly nested) display items. |
| 21 // |
| 22 // The produced trees are not independent (for example, the resultant clip tree |
| 23 // may have indicies into the transform tree's node list). Also produced is a |
| 24 // vector of "range records", which correspond to non-overlapping ranges of |
| 25 // display items in the list, in sorted order. |
| 26 // |
| 27 // Since the begin/end display items that create transform nodes are not |
| 28 // included in these ranges, and empty ranges are omitted, these are not a |
| 29 // partition of the display list. Rather, they constitute a partial map from |
| 30 // display item indices to property tree data (node indices, plus a content |
| 31 // offset from the origin of the transform node). |
| 32 // |
| 33 // Similarly, there may be property tree nodes with no associated range records. |
| 34 // This doesn't necessarily mean that they can be ignored. It may be the parent |
| 35 // of one or more other property nodes. |
| 36 // |
| 37 // See also the headers for the particular types of property tree. |
| 38 class PLATFORM_EXPORT DisplayItemPropertyTreeBuilder { |
| 39 public: |
| 40 struct RangeRecord { |
| 41 // Index of the first affected display item. |
| 42 size_t displayListBeginIndex; |
| 43 |
| 44 // Index of the first unaffected display item after |displayListBeginInd
ex|. |
| 45 size_t displayListEndIndex; |
| 46 |
| 47 // Index of the applicable transform node. |
| 48 size_t transformNodeIndex; |
| 49 |
| 50 // The offset of this range's drawing in the coordinate space of the |
| 51 // transform node. |
| 52 FloatSize offset; |
| 53 |
| 54 // Index of the applicable clip node. |
| 55 size_t clipNodeIndex; |
| 56 }; |
| 57 |
| 58 DisplayItemPropertyTreeBuilder(); |
| 59 ~DisplayItemPropertyTreeBuilder(); |
| 60 |
| 61 // Detach the built property trees. |
| 62 PassOwnPtr<DisplayItemTransformTree> releaseTransformTree(); |
| 63 PassOwnPtr<DisplayItemClipTree> releaseClipTree(); |
| 64 Vector<RangeRecord> releaseRangeRecords(); |
| 65 |
| 66 // Process another display item from the list. |
| 67 void processDisplayItem(const DisplayItem&); |
| 68 |
| 69 private: |
| 70 struct BuilderState { |
| 71 // Initial state (root nodes, no display items seen). |
| 72 BuilderState() : transformNode(0), clipNode(0), ignoredBeginCount(0) { } |
| 73 |
| 74 // Index of the current transform node. |
| 75 size_t transformNode; |
| 76 |
| 77 // Offset from the current origin (i.e. where a drawing at (0, 0) would |
| 78 // be) from the transform node's origin. |
| 79 FloatSize offset; |
| 80 |
| 81 // Index of the current clip node. |
| 82 size_t clipNode; |
| 83 |
| 84 // Number of "begin" display items that have been ignored, whose |
| 85 // corresponding "end" display items should be skipped. |
| 86 unsigned ignoredBeginCount; |
| 87 }; |
| 88 |
| 89 // Used to manipulate the current transform node stack. |
| 90 BuilderState& currentState() { return m_stateStack.last(); } |
| 91 |
| 92 // Handle a begin display item. |
| 93 void processBeginItem(const DisplayItem&); |
| 94 |
| 95 // Handle an end display item. |
| 96 void processEndItem(const DisplayItem&); |
| 97 |
| 98 // Emit a range record, unless it would be empty. |
| 99 void finishRange(); |
| 100 |
| 101 OwnPtr<DisplayItemTransformTree> m_transformTree; |
| 102 OwnPtr<DisplayItemClipTree> m_clipTree; |
| 103 Vector<RangeRecord> m_rangeRecords; |
| 104 // TODO(jbroman): Experimentally select a less arbitrary inline capacity. |
| 105 Vector<BuilderState, 40> m_stateStack; |
| 106 size_t m_rangeBeginIndex; |
| 107 size_t m_currentIndex; |
| 108 }; |
| 109 |
| 110 } // namespace blink |
| 111 |
| 112 #endif // DisplayItemPropertyTreeBuilder_h |
OLD | NEW |