OLD | NEW |
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 // Primitives express the geometry of the scene, such as quads and references | 5 // Primitives express the geometry of the scene, such as quads and references |
6 // to embedded scenes. Primitives are arranged hierarchically as nodes, | 6 // to embedded scenes. Primitives are arranged hierarchically as nodes, |
7 // each with an associated transformation matrix. | 7 // each with an associated transformation matrix. |
8 | 8 |
9 [DartPackage="mojo_services"] | 9 [DartPackage="mojo_services"] |
10 module mojo.gfx.composition; | 10 module mojo.gfx.composition; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // children will not appear in the output. | 48 // children will not appear in the output. |
49 // | 49 // |
50 // With the |FALLBACK| combinator, the first unblocked child of a node is | 50 // With the |FALLBACK| combinator, the first unblocked child of a node is |
51 // drawn and the remaining nodes are ignored. If the node has children | 51 // drawn and the remaining nodes are ignored. If the node has children |
52 // and all of them are blocked then the node itself is blocked. | 52 // and all of them are blocked then the node itself is blocked. |
53 // | 53 // |
54 // Combinators make it possible to express complex rules such as substituting | 54 // Combinators make it possible to express complex rules such as substituting |
55 // missing content for an earlier version of that content or for a placeholder | 55 // missing content for an earlier version of that content or for a placeholder |
56 // if not available. | 56 // if not available. |
57 // | 57 // |
| 58 // HIT TESTING |
| 59 // |
| 60 // Hit testing is the process of determining which nodes within a scene graph |
| 61 // should be responsible for handling events which occur within their visual |
| 62 // space on the screen. |
| 63 // |
| 64 // For example, when the user touches objects on a touch screen, the input |
| 65 // system asks the compositor to performs a hit test at the contact point to |
| 66 // find the nodes which represent the objects the user wants to interact with. |
| 67 // The result of the hit test is a list of nodes, in dispatch order, which |
| 68 // have asked to participate in handling events related to the contact point. |
| 69 // |
| 70 // Nodes may be opaque, translucent, or invisible to the hit testing |
| 71 // process depending on whether they prevent or allow targets visually |
| 72 // behind them from being hit and whether they can actually be hit, |
| 73 // as specified by |HitTestBehavior.visibility|. |
| 74 // |
| 75 // Nodes are added to the hit test result whenever one of their opaque children |
| 76 // is hit. This is useful for scrolling containers which may need to intercept |
| 77 // certain gestures within the space of their children and therefore need to |
| 78 // be added to the hit test result themselves. |
| 79 // |
| 80 // Nodes can also request to prune hit testing for their children, which |
| 81 // prevents their children from being hit. |
| 82 // |
| 83 // Hit testing proceeds recursively in post-order traversal (the reverse of |
| 84 // the drawing order). Intuitively, this means that the most specific |
| 85 // (deepest) nodes of the tree are tested before their ancestors. |
| 86 // |
| 87 // Starting from the root, the compositor transforms the point of interest |
| 88 // into the node's coordinate system, rejects the node if the point is |
| 89 // outside of the node's clip region, otherwise recursively tests the |
| 90 // node's children (those which were selected by the combinator rule) |
| 91 // until the first opaque target hit is found, then evaluates the node's |
| 92 // |HitTestBehavior| to determine whether the node was hit. Nodes are |
| 93 // accumulated into a hit test result in the order in which they were |
| 94 // determined to have been hit. |
| 95 // |
| 96 // See |HitTestBehavior| for more details. |
| 97 // |
58 // INSTANCING | 98 // INSTANCING |
59 // | 99 // |
60 // The compositor allows nodes to be referenced and reused multiple times | 100 // The compositor allows nodes to be referenced and reused multiple times |
61 // within a scene (this is known as instancing). Instancing makes it easier | 101 // within a scene (this is known as instancing). Instancing makes it easier |
62 // to take advantage of combinators for interleaving placeholder content | 102 // to take advantage of combinators for interleaving placeholder content |
63 // when certain nodes are blocked from rendering (see above). It also allows | 103 // when certain nodes are blocked from rendering (see above). It also allows |
64 // common elements to be reused if desired. | 104 // common elements to be reused if desired. |
65 // | 105 // |
66 // Likewise, the compositor allows scenes to be multiply referenced so that | 106 // Likewise, the compositor allows scenes to be multiply referenced so that |
67 // the same content can be presented simultaneously in several places. | 107 // the same content can be presented simultaneously in several places. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // it is drawn at X = 100 relative to its containing node's origin, simply | 161 // it is drawn at X = 100 relative to its containing node's origin, simply |
122 // set a transformation matrix with the X translation component equal to 100. | 162 // set a transformation matrix with the X translation component equal to 100. |
123 // Take care not to specify the inverse transform by mistake. | 163 // Take care not to specify the inverse transform by mistake. |
124 mojo.Transform? content_transform; | 164 mojo.Transform? content_transform; |
125 | 165 |
126 // The clip rectangle to apply to this node's content and to its children | 166 // The clip rectangle to apply to this node's content and to its children |
127 // in content space in addition to any clipping performed by the container. | 167 // in content space in addition to any clipping performed by the container. |
128 // If null, the node does not apply any clipping of its own. | 168 // If null, the node does not apply any clipping of its own. |
129 mojo.Rect? content_clip; | 169 mojo.Rect? content_clip; |
130 | 170 |
131 // The hit test id to report if anything within the node is hit. | |
132 // Use |kHitIdNone| if the node should not be hit tested. | |
133 // | |
134 // TODO(jeffbrown): This scheme is probably too naive. | |
135 uint32 hit_id = kHitIdNone; | |
136 | |
137 // The Combinator to apply when processing the children of this node. | 171 // The Combinator to apply when processing the children of this node. |
138 Combinator combinator = Combinator.MERGE; | 172 Combinator combinator = Combinator.MERGE; |
139 | 173 |
| 174 // The hit testing behavior of the node. |
| 175 // If null, the node is considered invisible for hit testing. |
| 176 HitTestBehavior? hit_test_behavior; |
| 177 |
140 // The ids of the children of this node. | 178 // The ids of the children of this node. |
141 // It is an error to specify a node id that does not refer to a valid | 179 // It is an error to specify a node id that does not refer to a valid |
142 // node or which creates a cycle in the graph; the compositor will close | 180 // node or which creates a cycle in the graph; the compositor will close |
143 // the connection when the scene is published. | 181 // the connection when the scene is published. |
144 array<uint32>? child_node_ids; | 182 array<uint32>? child_node_ids; |
145 | 183 |
146 // The drawing operation to apply when processing this node. | 184 // The drawing operation to apply when processing this node. |
147 // If null, no drawing operation occurs at this node. | 185 // If null, no drawing operation occurs at this node. |
148 NodeOp? op; | 186 NodeOp? op; |
149 }; | 187 }; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 }; | 280 }; |
243 | 281 |
244 // Specifies how blending should take place. | 282 // Specifies how blending should take place. |
245 struct Blend { | 283 struct Blend { |
246 // The opacity for composition in a range from 0 (fully transparent) | 284 // The opacity for composition in a range from 0 (fully transparent) |
247 // to 255 (fully opaque). | 285 // to 255 (fully opaque). |
248 uint8 alpha = 255; | 286 uint8 alpha = 255; |
249 | 287 |
250 // TODO(jeffbrown): Blend modes and texture filtering. | 288 // TODO(jeffbrown): Blend modes and texture filtering. |
251 }; | 289 }; |
OLD | NEW |