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/display_hit_test_data.h" |
| 12 #include "ui/gfx/geometry/point.h" |
| 13 |
| 14 namespace viz { |
| 15 namespace hit_test { |
| 16 |
| 17 struct Target { |
| 18 cc::FrameSinkId id; |
| 19 // Coordinates in the coordinate system of the target FrameSinkId. |
| 20 gfx::Point location_in_target; |
| 21 // Different flags are defined in services/viz/public/interfaces/ |
| 22 // hit_test_data.mojom. |
| 23 uint32_t flags; |
| 24 }; |
| 25 |
| 26 // Finds the target for a given location based on DisplayHitTestDataList |
| 27 // aggregated by HitTestComponent. |
| 28 // TODO(riajiang): Handle 3d space cases correctly. |
| 29 class HitTestQuery { |
| 30 public: |
| 31 HitTestQuery(); |
| 32 ~HitTestQuery(); |
| 33 |
| 34 // TODO(riajiang): Read from shmem directly once it's set up and delete this |
| 35 // function. For now, use fake data. |
| 36 void set_display_hit_test_data_list( |
| 37 DisplayHitTestDataList display_hit_test_data_list) { |
| 38 display_hit_test_data_list_ = std::move(display_hit_test_data_list); |
| 39 } |
| 40 |
| 41 // Finds Target for |location_in_root|, including the FrameSinkId of the |
| 42 // target, updated location in the coordinate system of the target and |
| 43 // hit-test flags for the target. |
| 44 Target FindTargetForLocation(const gfx::Point& location_in_root); |
| 45 |
| 46 private: |
| 47 // Helper function to find |target| for |location_in_parent| in the |region|, |
| 48 // returns true if a target is found and false otherwise. |location_in_parent| |
| 49 // is in the coordinate space of |region|'s parent. |
| 50 bool FindTargetInRegionForLocation(const gfx::Point& location_in_parent, |
| 51 DisplayHitTestData* region, |
| 52 Target* target) const; |
| 53 |
| 54 DisplayHitTestDataList display_hit_test_data_list_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(HitTestQuery); |
| 57 }; |
| 58 |
| 59 } // namespace hit_test |
| 60 } // namespace viz |
| 61 |
| 62 #endif // COMPONENTS_VIZ_HOST_HIT_TEST_HIT_TEST_QUERY_H_ |
OLD | NEW |