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_ | |
rjkroege
2017/06/15 21:58:44
structuring convention: components/viz/service/hit
gklassen
2017/06/16 21:49:39
Done.
| |
6 #define COMPONENTS_VIZ_HIT_TEST_HIT_TEST_AGGREGATOR_H_ | |
7 | |
8 #include <stdint.h> | |
rjkroege
2017/06/15 21:58:44
check for unnecessary includes?
gklassen
2017/06/16 21:49:39
Done.
( is there a script or other tool to make t
| |
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/display_hit_test_data_factory.h" | |
17 #include "components/viz/hit_test/hit_test_export.h" | |
18 #include "components/viz/hit_test/public/interfaces/hit_test_data.mojom.h" | |
rjkroege
2017/06/15 21:58:44
Please move stuff around per discussion in person.
gklassen
2017/06/16 21:49:39
Done.
| |
19 | |
20 namespace viz { | |
21 namespace hit_test { | |
22 | |
23 namespace test { | |
24 class HitTestAggregatorTest; | |
25 } | |
26 | |
27 // HitTest maintains maping between display regions and associated surfaces | |
28 // in shared memory to enable efficient hit testing across processes. | |
29 // | |
30 // This is intended to be created in the viz or GPU process. For mus+ash this | |
31 // will be true after the mus process split. | |
32 | |
33 using HitTestDataMap = std::map<cc::SurfaceId, hit_test::mojom::HitTestDataPtr>; | |
34 | |
35 class HIT_TEST_EXPORT HitTestAggregator : public cc::SurfaceObserver { | |
36 public: | |
37 HitTestAggregator( | |
38 std::unique_ptr<DisplayHitTestDataFactory> display_hit_test_data_factory); | |
39 ~HitTestAggregator(); | |
40 | |
41 // Called when HitTestData is submitted along with every call | |
42 // to SubmitCompositorFrame. This is collected in pending_ until | |
43 // surfaces are aggregated and put on the display. | |
44 void SubmitHitTestData(hit_test::mojom::HitTestDataPtr hit_test_data); | |
45 | |
46 // Called after surfaces have been aggregated into the DisplayFrame. | |
47 // In this call HitTestData structures received from active surfaces | |
48 // are aggregated into the DisplayHitTestData structure in | |
49 // shared memory used for event targetting. | |
50 void PostTaskAggregate(cc::SurfaceId display_surface_id); | |
51 void Aggregate(cc::SurfaceId display_surface_id); | |
rjkroege
2017/06/15 21:58:44
Aggregate can have a separate description?
gklassen
2017/06/16 21:49:39
Done.
| |
52 | |
53 // Called at BeginFrame to swap buffers in shared memory. | |
rjkroege
2017/06/15 21:58:44
see my previous blither about other way to do this
gklassen
2017/06/16 21:49:39
Thank you. I will investigate. Any pointers to t
| |
54 void Swap(); | |
55 | |
56 // SurfaceObserver | |
rjkroege
2017/06/15 21:58:44
overrides can be private.
gklassen
2017/06/16 21:49:39
Done.
| |
57 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override {} | |
58 void OnSurfaceDestroyed(const cc::SurfaceId& surface_id) override {} | |
59 bool OnSurfaceDamaged(const cc::SurfaceId& surface_id, | |
60 const cc::BeginFrameAck& ack) override; | |
61 void OnSurfaceDiscarded(const cc::SurfaceId& surface_id) override; | |
62 void OnSurfaceDamageExpected(const cc::SurfaceId& surface_id, | |
63 const cc::BeginFrameArgs& args) override {} | |
64 // Called when a surface has been aggregated and added to the | |
65 // display frame. HitTestData objects are held but ignored until | |
66 // this happens. HitTestData for the surface is copied from pending_ | |
67 // to active_ in this method. | |
68 void OnSurfaceWillDraw(const cc::SurfaceId& surface_id) override; | |
69 | |
70 DisplayHitTestData* GetDisplayHitTestData(); | |
rjkroege
2017/06/15 21:58:44
do we need? why?
gklassen
2017/06/16 21:49:39
Done.
| |
71 DisplayHitTestRegion* GetCurrentRegions(); | |
72 | |
73 private: | |
74 friend class test::HitTestAggregatorTest; | |
75 | |
76 HitTestDataMap pending_; | |
77 HitTestDataMap active_; | |
78 | |
79 // Keep track of the number of regions in the active list | |
80 // so that we know when we exceed the available length. | |
81 int active_region_count_; | |
82 | |
83 std::unique_ptr<DisplayHitTestDataFactory> display_hit_test_data_factory_; | |
84 | |
85 DisplayHitTestData* display_hit_test_data_; | |
86 | |
87 // Allocates memory for the DisplayHitTestData Structure. | |
88 void AllocateDisplayHitTestData(); | |
89 void AllocateDisplayHitTestData(int length); | |
90 | |
91 // Resize the memory for the DispalyHitTestData Structure. | |
rjkroege
2017/06/15 21:58:44
DisplayHitTestData
gklassen
2017/06/16 21:49:39
Done.
Good eye. Thank you.
| |
92 // Copies current data and marks the structure | |
93 void ResizeDisplayHitTestData(int length); | |
94 | |
95 int GetBackIndex(); | |
96 | |
97 int Append(cc::SurfaceId surface_id, int index); | |
98 int Append(const hit_test::mojom::HitTestRegionPtr& region, int index); | |
99 | |
100 // WeakPtr to handle the case when this object is deleted after | |
101 // the PostTaskAggregation call is scheduled but before invocation. | |
102 base::WeakPtrFactory<HitTestAggregator> weak_ptr_factory_; | |
103 | |
104 DISALLOW_COPY_AND_ASSIGN(HitTestAggregator); | |
105 }; | |
106 | |
107 } // namespace hit_test | |
108 } // namespace viz | |
109 | |
110 #endif // COMPONENTS_VIZ_HIT_TEST_HIT_TEST_AGGREGATOR_H_ | |
OLD | NEW |