Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(559)

Side by Side Diff: public/platform/WebDisplayItemTransformTree.h

Issue 1296963002: Put transform tree building in DisplayItemPropertyTreeBuilder. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove unused include. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 WebDisplayItemTransformTree_h 5 #ifndef WebDisplayItemTransformTree_h
6 #define WebDisplayItemTransformTree_h 6 #define WebDisplayItemTransformTree_h
7 7
8 #include "public/platform/WebCommon.h" 8 #include "public/platform/WebCommon.h"
9 #include "public/platform/WebFloatSize.h" 9 #include "public/platform/WebFloatSize.h"
10 #include "public/platform/WebPrivateOwnPtr.h" 10 #include "public/platform/WebPrivateOwnPtr.h"
11 #include "third_party/skia/include/utils/SkMatrix44.h" 11 #include "third_party/skia/include/utils/SkMatrix44.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class DisplayItemTransformTree; 15 class DisplayItemTransformTree;
16 16
17 // Represents the hierarchy of transforms which apply to ranges of a display 17 // Represents the hierarchy of transforms which apply to ranges of a display
18 // item list and may be of interest to the compositor. 18 // item list and may be of interest to the compositor.
19 // 19 //
20 // It consists of a tree of "transform nodes", stored in a flattened 20 // It consists of a tree of "transform nodes", stored in a flattened
21 // representation in which their order is not guaranteed. Each node has a 21 // representation in which their order is not guaranteed. Each node has a
22 // parent, relative to whom its transform should be interpreted (i.e. the 22 // parent, relative to whom its transform should be interpreted (i.e. the
23 // total transform at a node is the product of its transform and its parent's 23 // total transform at a node is the product of its transform and its parent's
24 // total transform). 24 // total transform).
25 // 25 class BLINK_PLATFORM_EXPORT WebDisplayItemTransformTree {
26 // These nodes are associated with a display item list through the associated
27 // "range records", which correspond to non-overlapping ranges of display items
28 // in the list, in sorted order. Since the begin/end display items that create
29 // transform nodes are not included in these ranges, and empty ranges are
30 // omitted, these ranges are not a partition. Rather, they constitute a partial
31 // map from display item indices to transform node indices.
32 //
33 // Similarly, there may be transform nodes with no associated range records.
34 // This doesn't necessarily mean that it can be ignored -- it may be the parent
35 // of one or more other transform nodes.
36 class WebDisplayItemTransformTree {
37 public: 26 public:
38 enum : size_t { kInvalidIndex = static_cast<size_t>(-1) }; 27 enum : size_t { kInvalidIndex = static_cast<size_t>(-1) };
39 28
40 struct TransformNode { 29 struct TransformNode {
41 TransformNode(size_t parent, const SkMatrix44& matrix44) 30 TransformNode(size_t parent, const SkMatrix44& matrix44)
42 : parentNodeIndex(parent) 31 : parentNodeIndex(parent)
43 , matrix(matrix44) 32 , matrix(matrix44)
44 { 33 {
45 } 34 }
46 35
47 bool isRoot() const { return parentNodeIndex == kInvalidIndex; } 36 bool isRoot() const { return parentNodeIndex == kInvalidIndex; }
48 37
49 // Index of parent in m_nodes (kInvalidIndex for root). 38 // Index of parent in m_nodes (kInvalidIndex for root).
50 size_t parentNodeIndex; 39 size_t parentNodeIndex;
51 40
52 // Transformation matrix of this node, relative to its parent. 41 // Transformation matrix of this node, relative to its parent.
53 SkMatrix44 matrix; 42 SkMatrix44 matrix;
54 }; 43 };
55 44
56 struct RangeRecord { 45 WebDisplayItemTransformTree();
57 RangeRecord(size_t beginIndex, size_t endIndex, size_t nodeIndex, const WebFloatSize& drawingOffset = WebFloatSize())
58 : displayListBeginIndex(beginIndex)
59 , displayListEndIndex(endIndex)
60 , transformNodeIndex(nodeIndex)
61 , offset(drawingOffset)
62 {
63 }
64
65 bool operator==(const RangeRecord& other) const
66 {
67 return displayListBeginIndex == other.displayListBeginIndex
68 && displayListEndIndex == other.displayListEndIndex
69 && transformNodeIndex == other.transformNodeIndex
70 && offset == other.offset;
71 }
72 bool operator!=(const RangeRecord& other) const { return !(*this == othe r); }
73
74 // Index of first affected display item.
75 size_t displayListBeginIndex;
76
77 // Index of first unaffected display item after |displayListBeginIndex|.
78 size_t displayListEndIndex;
79
80 // Index of a the applicable transform node (in |m_nodes|).
81 size_t transformNodeIndex;
82
83 // The offset of this range's drawing in the coordinate space of the
84 // transform node.
85 WebFloatSize offset;
86 };
87
88 BLINK_PLATFORM_EXPORT WebDisplayItemTransformTree();
89 #if INSIDE_BLINK 46 #if INSIDE_BLINK
90 BLINK_PLATFORM_EXPORT WebDisplayItemTransformTree( 47 WebDisplayItemTransformTree(const WTF::PassOwnPtr<DisplayItemTransformTree>& );
91 const WTF::PassOwnPtr<DisplayItemTransformTree>&);
92 #endif 48 #endif
93 49
94 BLINK_PLATFORM_EXPORT ~WebDisplayItemTransformTree(); 50 ~WebDisplayItemTransformTree();
95 51
96 // Returns the number of nodes in the transform tree. 52 // Returns the number of nodes in the transform tree.
97 BLINK_PLATFORM_EXPORT size_t nodeCount() const; 53 size_t nodeCount() const;
98 54
99 // Returns a node in the transform tree by its index (from 0 to nodeCount() - 1). 55 // Returns a node in the transform tree by its index (from 0 to nodeCount() - 1).
100 BLINK_PLATFORM_EXPORT const TransformNode& nodeAt(size_t index) const; 56 const TransformNode& nodeAt(size_t index) const;
101
102 // Returns the parent of the given node.
103 // Do not call this with the root node.
104 BLINK_PLATFORM_EXPORT const TransformNode& parentNode(const TransformNode&) const;
105
106 // Returns the number of display item ranges.
107 BLINK_PLATFORM_EXPORT size_t rangeRecordCount() const;
108
109 // Returns the requested display item range, sorted by position in the
110 // display item list.
111 BLINK_PLATFORM_EXPORT const RangeRecord& rangeRecordAt(size_t index) const;
112 57
113 private: 58 private:
114 WebPrivateOwnPtr<const DisplayItemTransformTree> m_private; 59 WebPrivateOwnPtr<const DisplayItemTransformTree> m_private;
pdr. 2015/08/17 22:25:08 Why "m_private" instead of "m_transformTree"?
jbroman 2015/08/17 23:57:19 The majority of cases of this pattern use that nam
pdr. 2015/08/18 04:31:42 Sadness. But, when in Rome..
115 }; 60 };
116 61
117 } // namespace blink 62 } // namespace blink
118 63
119 #endif // WebDisplayItemTransformTree_h 64 #endif // WebDisplayItemTransformTree_h
OLDNEW
« public/platform/WebDisplayItemClipTree.h ('K') | « public/platform/WebDisplayItemClipTree.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698