Chromium Code Reviews| 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 [DartPackage="mojo_services"] | 5 [DartPackage="mojo_services"] |
| 6 module mojo.gfx.composition; | 6 module mojo.gfx.composition; |
| 7 | 7 |
| 8 import "mojo/services/geometry/interfaces/geometry.mojom"; | 8 import "mojo/services/geometry/interfaces/geometry.mojom"; |
| 9 import "mojo/services/gfx/composition/interfaces/scene_token.mojom"; | 9 import "mojo/services/gfx/composition/interfaces/scene_token.mojom"; |
| 10 | 10 |
| 11 // Indicates that hit testing is not needed for a given node. | 11 // Determines how a node behaves during hit testing. |
| 12 const uint32 kHitIdNone = 0; | 12 // |
| 13 // See |Node| for more details of the hit testing traversal process. | |
| 14 struct HitTestBehavior { | |
| 15 // The visibility specifies how a node itself is hit and its effect on | |
| 16 // the hit testing traversal. | |
| 17 enum Visibility { | |
| 18 // The node can be hit and prevents other targets visually behind the | |
| 19 // node from being hit. This is the default. | |
| 20 // | |
| 21 // Opaque targets are useful for UI elements like buttons which cover and | |
| 22 // block interaction with content visually behind them. | |
| 23 OPAQUE, | |
| 13 | 24 |
| 14 // Provides information about the point of intersection of a hit test with | 25 // The node can be hit and allows other targets visually behind the node |
| 15 // a node in a scene graph. | 26 // to also be hit. |
| 16 struct Hit { | 27 // |
| 17 // The scene token of the scene which was hit. | 28 // Translucent targets are useful for UI elements like dimissed drawers |
| 29 // which may not obscure content visually behind them but which do need | |
| 30 // to intercept gestures in that area (perhaps to reveal themselves). | |
| 31 TRANSLUCENT, | |
| 32 | |
| 33 // The node cannot be hit. | |
| 34 // | |
| 35 // Invisible targets are useful for explicitly suppressing hit testing | |
| 36 // for a node and its children when combined with the |prune| flag. | |
| 37 INVISIBLE, | |
| 38 }; | |
| 39 | |
| 40 // Specifies the visibility of the node for hit testing purposes. | |
| 41 // The default is opaque. | |
| 42 Visibility visibility = Visibility.OPAQUE; | |
| 43 | |
| 44 // When set to true, prevents a node's children from being hit tested. | |
| 45 bool prune = false; | |
| 46 | |
| 47 // The rectangle within the node's content space to test for hits. | |
| 48 // If null, the node's entire clip region is tested for hits. | |
| 49 // | |
| 50 // TODO(jeffbrown): Support more complex hit test regions and masks. | |
| 51 mojo.Rect? hit_rect; | |
| 52 }; | |
| 53 | |
| 54 // The result of a hit test operation. | |
| 55 // | |
| 56 // Hit test results form a tree which describes which nodes were hit within | |
| 57 // the scene graph. It is essentially a subtree of the scene graph which | |
| 58 // only includes nodes which were hit by the hit test. Structural information | |
| 59 // about the scene graph is retained but only limited information about the | |
| 60 // nodes themselves is included. | |
| 61 // | |
| 62 // To walk the hits in dispatch order, perform a post-order traversal of the | |
| 63 // hit tree, processing children before their parents. | |
| 64 struct HitTestResult { | |
| 65 // If a hit occurred, contains information about hits which occurred within | |
| 66 // the root scene of the scene graph. | |
| 67 SceneHit? scene_hit; | |
| 68 }; | |
| 69 | |
| 70 // Describes a collection of hits within a scene in the scene graph. | |
| 71 struct SceneHit { | |
| 72 // The scene token of the scene which contains the hit. | |
| 18 SceneToken scene_token; | 73 SceneToken scene_token; |
| 19 | 74 |
| 20 // The version of the scene which was consulted as part of evaluating the | 75 // The version of the scene which was consulted at the time the hit test |
| 21 // hit test. | 76 // was performed. |
| 22 uint32 scene_version; | 77 uint32 scene_version; |
| 23 | 78 |
| 79 // The nodes which were hit, in order of traversal. | |
| 80 // This list always contains at least one node. | |
| 81 array<NodeHit> node_hits; | |
| 82 }; | |
| 83 | |
| 84 // Describes the point of intersection of a hit test with a particular | |
| 85 // node within a scene. | |
| 86 struct NodeHit { | |
| 24 // The node id of the node which was hit. | 87 // The node id of the node which was hit. |
| 25 uint32 node_id; | 88 uint32 node_id; |
| 26 | 89 |
| 27 // The hit test id of the node which was hit. | 90 // True if the node was visible to hit testing and would like to receive |
| 28 uint32 hit_id; | 91 // events related to the hit. False if the node is only being included |
| 92 // for structural reasons because of a scene which it references which | |
| 93 // was hit. | |
| 94 bool visible; | |
| 29 | 95 |
| 30 // The coordinates of the hit within the node's content space. | 96 // The coordinates of the hit within the node's content space. |
| 31 mojo.Point intersection; | 97 mojo.Point intersection; |
| 32 }; | |
| 33 | 98 |
| 34 // The result of a hit test operation. | 99 // If the node had a |SceneNodeOp| and a hit occurred within the scene |
| 35 struct HitTestResult { | 100 // which it referenced, contains information about the hits which occurred |
| 36 // A sorted list of hits in dispatch order from the top-most hit node | 101 // within that scene. |
| 37 // to the nodes underneath it and containing it, or an empty array if none. | 102 SceneHit? scene_hit; |
| 38 // Omits nodes for which the hit_id was |kHitIdNone|. | |
| 39 array<Hit> hits; | |
| 40 }; | 103 }; |
|
abarth
2016/03/01 17:33:43
I was expecting NodeHit to have an array<NodeHit>,
jeffbrown
2016/03/02 00:51:52
Good point. I'm not reflecting the entire node st
| |
| 41 | 104 |
| 42 // A hit testing service for scene graphs. | 105 // A hit testing service for scene graphs. |
| 43 interface HitTester { | 106 interface HitTester { |
| 44 // Performs a hit test on the specified point. | 107 // Performs a hit test on the specified point. |
| 45 // | 108 // |
| 46 // TODO(jeffbrown): Specify a timestamp to allow for hit-tests of geometry | 109 // TODO(jeffbrown): Specify a timestamp to allow for hit-tests of geometry |
| 47 // as it appeared in the recent past. | 110 // as it appeared in the recent past. |
| 48 HitTest(mojo.Point point) => (HitTestResult result); | 111 HitTest(mojo.Point point) => (HitTestResult result); |
| 49 }; | 112 }; |
| OLD | NEW |