OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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 COMPONENTS_VIZ_HOST_HIT_TEST_HIT_TEST_QUERY_H_ | |
6 #define COMPONENTS_VIZ_HOST_HIT_TEST_HIT_TEST_QUERY_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/macros.h" | |
11 #include "components/viz/common/hit_test/aggregated_hit_test_region.h" | |
12 #include "ui/gfx/geometry/point.h" | |
13 | |
14 namespace viz { | |
15 | |
16 struct Target { | |
17 FrameSinkId frame_sink_id; | |
18 // Coordinates in the coordinate system of the target FrameSinkId. | |
19 gfx::Point location_in_target; | |
20 // Different flags are defined in services/viz/hit_test/public/interfaces/ | |
21 // hit_test_region_list.mojom. | |
22 uint32_t flags = 0; | |
23 }; | |
24 | |
25 // Finds the target for a given location based on the AggregatedHitTestRegion | |
26 // list aggregated by HitTestAggregator. | |
27 // TODO(riajiang): Handle 3d space cases correctly. | |
28 class HitTestQuery { | |
29 public: | |
30 HitTestQuery(); | |
31 ~HitTestQuery(); | |
32 | |
33 // TODO(riajiang): Read from shmem directly once it's set up and delete this | |
34 // function. For now, use fake data. Also need to validate the data received. | |
35 // http://crbug.com/746470 | |
36 void set_aggregated_hit_test_region_list( | |
37 AggregatedHitTestRegion* aggregated_hit_test_region_list, | |
38 uint32_t aggregated_hit_test_region_list_size) { | |
39 aggregated_hit_test_region_list_ = aggregated_hit_test_region_list; | |
40 aggregated_hit_test_region_list_size_ = | |
41 aggregated_hit_test_region_list_size; | |
42 } | |
43 | |
44 // Finds Target for |location_in_root|, including the FrameSinkId of the | |
45 // target, updated location in the coordinate system of the target and | |
46 // hit-test flags for the target. | |
47 // Assumptions about the AggregatedHitTestRegion list received. | |
48 // 1. The list is in ascending (front to back) z-order. | |
49 // 2. Children count includes children of children. | |
50 // 3. After applying transform to the incoming point, point is in the same | |
51 // coordinate system as the bounds it is comparing against. | |
52 // For example, | |
53 // +e-------------+ | |
54 // | +c---------| | |
55 // | 1 |+a--+ | | |
56 // | || 2 | | | |
57 // | |+b--------| | |
58 // | || | | |
59 // | || 3 | | |
60 // +--------------+ | |
61 // In this case, after applying identity transform, 1 is in the coordinate | |
62 // system of e; apply the transfrom-from-e-to-c and transform-from-c-to-a | |
63 // then we get 2 in the coordinate system of a; apply the | |
64 // transfrom-from-e-to-c and transform-from-c-to-b then we get 3 in the | |
65 // coordinate system of b. | |
66 Target FindTargetForLocation(const gfx::Point& location_in_root); | |
sadrul
2017/07/21 17:18:11
This too can be a const method, I think?
riajiang
2017/07/22 04:23:05
Done.
| |
67 | |
68 private: | |
69 // Helper function to find |target| for |location_in_parent| in the |region|, | |
70 // returns true if a target is found and false otherwise. |location_in_parent| | |
71 // is in the coordinate space of |region|'s parent. | |
72 bool FindTargetInRegionForLocation(const gfx::Point& location_in_parent, | |
73 AggregatedHitTestRegion* region, | |
74 Target* target) const; | |
75 | |
76 AggregatedHitTestRegion* aggregated_hit_test_region_list_ = nullptr; | |
77 uint32_t aggregated_hit_test_region_list_size_ = 0; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(HitTestQuery); | |
80 }; | |
81 | |
82 } // namespace viz | |
83 | |
84 #endif // COMPONENTS_VIZ_HOST_HIT_TEST_HIT_TEST_QUERY_H_ | |
OLD | NEW |