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_HIT_TEST_HIT_TEST_AGGREGATOR_H_ | |
6 #define COMPONENTS_VIZ_HIT_TEST_HIT_TEST_AGGREGATOR_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <map> | |
11 #include <memory> | |
12 | |
13 #include "cc/surfaces/surface_id.h" | |
14 #include "cc/surfaces/surface_observer.h" | |
15 #include "components/viz/hit_test/display_hit_test_data.h" | |
16 #include "components/viz/hit_test/hit_test_export.h" | |
17 #include "components/viz/hit_test/public/interfaces/hit_test_data.mojom.h" | |
18 #include "ui/gfx/geometry/quad_f.h" | |
19 | |
20 namespace viz { | |
21 | |
22 namespace hit_test { | |
23 namespace test { | |
24 class HitTestAggregatorTest; | |
25 } | |
26 } | |
27 | |
28 // HitTest maintains maping between display regions and associated surfaces | |
29 // in shared memory to enable efficient hit testing across processes. | |
30 // | |
31 // This is intended to be created in the viz or GPU process. For mus+ash this | |
32 // will be true after the mus process split. | |
33 | |
rjkroege
2017/06/07 21:19:06
nit: remove blank?
And: since when can you preser
gklassen
2017/06/08 20:33:21
Yes - although I believe it may be possible to mov
| |
34 typedef std::map<cc::SurfaceId, hit_test::mojom::HitTestDataPtr> HitTestDataMap; | |
35 | |
36 class HIT_TEST_EXPORT HitTestAggregator : public cc::SurfaceObserver { | |
37 friend class hit_test::test::HitTestAggregatorTest; | |
38 | |
39 public: | |
40 HitTestAggregator(); | |
41 ~HitTestAggregator(); | |
42 | |
43 // Called when HitTestData is submitted along with every call | |
44 // to SubmitCompositorFrame. This is collected in pending_ until | |
45 // surfaces are aggregated and put on screen. | |
46 void SubmitHitTestData(hit_test::mojom::HitTestDataPtr hit_test_data); | |
rjkroege
2017/06/07 21:19:06
Need a TODO for what to do if the submitted data i
gklassen
2017/06/08 20:33:21
Good call. TODO added to the implementaiton. Done.
| |
47 | |
48 // Called when surfaces have been aggregated. Used to aggregate | |
49 // HitTestData into the tree structure in shared memory and used | |
50 // for event targetting. | |
51 void Aggregate(cc::SurfaceId display_surface_id); | |
52 | |
53 // Called at BeginFrame to swap buffers in shared memory. | |
54 void Swap(); | |
55 | |
56 // SurfaceObserver | |
57 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override {} | |
58 void OnSurfaceDestroyed(const cc::SurfaceId& surface_id) override {} | |
59 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, | |
60 const cc::BeginFrameAck& ack, | |
61 bool* changed) override {} | |
62 void OnSurfaceDiscarded(const cc::SurfaceId& surface_id) override; | |
63 void OnSurfaceDamageExpected(const cc::SurfaceId& surface_id, | |
64 const cc::BeginFrameArgs& args) override {} | |
65 | |
rjkroege
2017/06/07 21:19:06
remove blank
gklassen
2017/06/08 20:33:21
Done.
| |
66 // Called when a surface has been aggregated and added to the | |
67 // display frame. HitTestData objects are held but ignored until | |
68 // this happens. HitTestData for the surface is copied from pending_ | |
69 // to active_ in this method. | |
70 void OnSurfaceWillDraw(const cc::SurfaceId& surface_id) override; | |
71 | |
72 DisplayHitTestData* display_hit_test_data_; | |
rjkroege
2017/06/07 21:19:05
Does it need to be public? Have an accessor?
gklassen
2017/06/08 20:33:21
Good call. Done.
| |
73 | |
74 DisplayHitTestRegion* GetCurrentRegions(); | |
75 | |
76 private: | |
77 HitTestDataMap pending_; | |
78 HitTestDataMap active_; | |
79 | |
80 void AllocateDisplayHitTestData(); | |
rjkroege
2017/06/07 21:19:05
method comments would be convenient for people unf
gklassen
2017/06/08 20:33:21
Agreed. Done.
| |
81 void AllocateDisplayHitTestData(int size); | |
82 | |
83 int GetBackIndex(); | |
84 | |
85 int Append(cc::SurfaceId surface_id, int index); | |
86 int Append(const hit_test::mojom::HitTestRegionPtr& region, int index); | |
87 }; | |
88 | |
89 } // namespace viz | |
90 | |
91 #endif // COMPONENTS_VIZ_HIT_TEST_HIT_TEST_AGGREGATOR_H_ | |
OLD | NEW |