Chromium Code Reviews| 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. | |
| 35 void set_aggregated_hit_test_region_list( | |
|
gklassen
2017/07/18 13:12:57
A recommendation: One method to set both the list
riajiang
2017/07/19 17:45:55
Good point! Done.
| |
| 36 AggregatedHitTestRegion* aggregated_hit_test_region_list) { | |
| 37 aggregated_hit_test_region_list_ = aggregated_hit_test_region_list; | |
| 38 } | |
| 39 void set_aggregated_hit_test_region_list_size( | |
| 40 uint32_t aggregated_hit_test_region_list_size) { | |
| 41 aggregated_hit_test_region_list_size_ = | |
| 42 aggregated_hit_test_region_list_size; | |
| 43 } | |
| 44 | |
| 45 // Finds Target for |location_in_root|, including the FrameSinkId of the | |
| 46 // target, updated location in the coordinate system of the target and | |
| 47 // hit-test flags for the target. | |
| 48 // Assumptions about the AggregatedHitTestRegion list received. | |
| 49 // 1. The list is in ascending (front to back) z-order. | |
| 50 // 2. Children count includes children of children. | |
| 51 // 3. After applying transform to the incoming point, point is in the same | |
| 52 // coordinate system as the bounds it is comparing against. | |
| 53 // For example, | |
| 54 // +e-------------+ | |
| 55 // | +c---------| | |
| 56 // | 1 |+a--+ | | |
| 57 // | || 2 | | | |
| 58 // | |+b--------| | |
| 59 // | || | | |
| 60 // | || 3 | | |
| 61 // +--------------+ | |
| 62 // In this case, after applying identity transform, 1 is in the coordinate | |
| 63 // system of e; apply the transfrom-from-e-to-c and transform-from-c-to-a | |
| 64 // then we get 2 in the coordinate system of a; apply the | |
| 65 // transfrom-from-e-to-c and transform-from-c-to-b then we get 3 in the | |
| 66 // coordinate system of b. | |
| 67 Target FindTargetForLocation(const gfx::Point& location_in_root); | |
| 68 | |
| 69 private: | |
| 70 // Helper function to find |target| for |location_in_parent| in the |region|, | |
| 71 // returns true if a target is found and false otherwise. |location_in_parent| | |
| 72 // is in the coordinate space of |region|'s parent. | |
| 73 bool FindTargetInRegionForLocation(const gfx::Point& location_in_parent, | |
| 74 AggregatedHitTestRegion* region, | |
| 75 Target* target) const; | |
| 76 | |
| 77 AggregatedHitTestRegion* aggregated_hit_test_region_list_ = nullptr; | |
| 78 uint32_t aggregated_hit_test_region_list_size_ = 0; | |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(HitTestQuery); | |
| 81 }; | |
| 82 | |
| 83 } // namespace viz | |
| 84 | |
| 85 #endif // COMPONENTS_VIZ_HOST_HIT_TEST_HIT_TEST_QUERY_H_ | |
| OLD | NEW |