Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: components/viz/hit_test/hit_test_aggregator.h

Issue 2908783002: WIP Hittest Component.
Patch Set: reviewer comments and handling of memory re-allocation Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 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 ~HitTestAggregator();
39
40 // Called when HitTestData is submitted along with every call
41 // to SubmitCompositorFrame. This is collected in pending_ until
42 // surfaces are aggregated and put on the display.
43 void SubmitHitTestData(hit_test::mojom::HitTestDataPtr hit_test_data);
44
45 // Called when surfaces have been aggregated. Used to aggregate
46 // HitTestData into the tree structure in shared memory and used
47 // for event targetting.
48 void PostTaskAggregate(cc::SurfaceId display_surface_id);
49 void Aggregate(cc::SurfaceId display_surface_id);
50
51 // Called at BeginFrame to swap buffers in shared memory.
52 void Swap();
53
54 // SurfaceObserver
55 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override {}
56 void OnSurfaceDestroyed(const cc::SurfaceId& surface_id) override {}
57 void OnSurfaceDamaged(const cc::SurfaceId& surface_id,
58 const cc::BeginFrameAck& ack,
59 bool* changed) override {}
60 void OnSurfaceDiscarded(const cc::SurfaceId& surface_id) override;
61 void OnSurfaceDamageExpected(const cc::SurfaceId& surface_id,
62 const cc::BeginFrameArgs& args) override {}
63 // Called when a surface has been aggregated and added to the
64 // display frame. HitTestData objects are held but ignored until
65 // this happens. HitTestData for the surface is copied from pending_
66 // to active_ in this method.
67 void OnSurfaceWillDraw(const cc::SurfaceId& surface_id) override;
68
69 DisplayHitTestData* GetDisplayHitTestData();
70 DisplayHitTestRegion* GetCurrentRegions();
71
72 private:
73 friend class viz::hit_test::test::HitTestAggregatorTest;
74
75 HitTestDataMap pending_;
76 HitTestDataMap active_;
77
78 DisplayHitTestData* display_hit_test_data_;
79
80 // Allocates memory for the DisplayHitTestData Structure.
rjkroege 2017/06/12 18:13:01 we discussed having some kind of injected factory
gklassen 2017/06/13 18:54:23 No, I just wasn't quite done. The most recent pat
81 void AllocateDisplayHitTestData();
82 void AllocateDisplayHitTestData(int length);
83
84 // Resize the memory for the DispalyHitTestData Structure.
85 // Copies current data and marks the structure
rjkroege 2017/06/12 18:13:01 I think that we need to talk about how the shared
gklassen 2017/06/13 18:54:23 Agreed. The implementation currently seems to hav
86 void ResizeDisplayHitTestData(int length);
87
88 int GetBackIndex();
89
90 int Append(cc::SurfaceId surface_id, int index);
91 int Append(const hit_test::mojom::HitTestRegionPtr& region, int index);
92
93 // WeakPtr to handle the case when this object is deleted after
94 // the PostTaskAggregation call is scheduled but before invocation.
95 base::WeakPtrFactory<HitTestAggregator> weak_ptr_factory_;
96
97 DISALLOW_COPY_AND_ASSIGN(HitTestAggregator);
98 };
99
100 } // namespace hit_test
101 } // namespace viz
102
103 #endif // COMPONENTS_VIZ_HIT_TEST_HIT_TEST_AGGREGATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698