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

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

Issue 2908783002: WIP Hittest Component.
Patch Set: fix z-order in use case tests ( background rects at the back ) 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 screen.
rjkroege 2017/06/09 15:47:08 nit: screen means display. This is important becau
gklassen 2017/06/12 16:30:42 Done.
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 HitTestDataMap pending_;
74 HitTestDataMap active_;
75
76 DisplayHitTestData* display_hit_test_data_;
77
78 void AllocateDisplayHitTestData();
79 void AllocateDisplayHitTestData(int size);
80
81 int GetBackIndex();
82
83 int Append(cc::SurfaceId surface_id, int index);
84 int Append(const hit_test::mojom::HitTestRegionPtr& region, int index);
85
86 // WeakPtr to handle the case when this object is deleted after
87 // the PostTaskAggregation call is scheduled but before invocation.
88 base::WeakPtrFactory<HitTestAggregator> weak_ptr_factory_;
rjkroege 2017/06/09 15:47:08 compiler will want this at the very bottom befpre
gklassen 2017/06/12 16:30:41 Done.
89
90 friend class viz::hit_test::test::HitTestAggregatorTest;
rjkroege 2017/06/09 15:47:08 Goes immediately below the private
gklassen 2017/06/12 16:30:41 Done.
91
92 DISALLOW_COPY_AND_ASSIGN(HitTestAggregator);
93 };
94
95 } // namespace hit_test
96 } // namespace viz
97
98 #endif // COMPONENTS_VIZ_HIT_TEST_HIT_TEST_AGGREGATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698