Index: components/viz/service/hit_test/hit_test_aggregator.h |
diff --git a/components/viz/service/hit_test/hit_test_aggregator.h b/components/viz/service/hit_test/hit_test_aggregator.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..42c902ce0035bfa67a4e5c94b99022e2ba3e7b5c |
--- /dev/null |
+++ b/components/viz/service/hit_test/hit_test_aggregator.h |
@@ -0,0 +1,107 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_VIZ_SERVICE_HIT_TEST_HIT_TEST_AGGREGATOR_H_ |
+#define COMPONENTS_VIZ_SERVICE_HIT_TEST_HIT_TEST_AGGREGATOR_H_ |
+ |
+#include "cc/surfaces/surface_id.h" |
+#include "cc/surfaces/surface_observer.h" |
+#include "components/viz/common/hit_test/display_hit_test_data.h" |
+#include "components/viz/service/hit_test/display_hit_test_data_factory.h" |
+#include "components/viz/service/viz_service_export.h" |
+#include "services/viz/hit_test/public/interfaces/hit_test_data.mojom.h" |
+ |
+namespace viz { |
+namespace hit_test { |
+ |
+namespace test { |
+class HitTestAggregatorTest; |
+} |
+ |
+// HitTest maintains maping between display regions and associated surfaces |
varkha
2017/06/19 21:15:05
HitTestAggregator?
gklassen
2017/06/20 16:09:39
Done.
|
+// in shared memory to enable efficient hit testing across processes. |
+// |
+// This is intended to be created in the viz or GPU process. For mus+ash this |
+// will be true after the mus process split. |
+ |
+using HitTestDataMap = std::map<cc::SurfaceId, hit_test::mojom::HitTestDataPtr>; |
+ |
+class VIZ_SERVICE_EXPORT HitTestAggregator : public cc::SurfaceObserver { |
+ public: |
+ HitTestAggregator( |
+ std::unique_ptr<DisplayHitTestDataFactory> display_hit_test_data_factory); |
+ ~HitTestAggregator(); |
+ |
+ // Called when HitTestData is submitted along with every call |
+ // to SubmitCompositorFrame. This is collected in pending_ until |
+ // surfaces are aggregated and put on the display. |
+ void SubmitHitTestData(hit_test::mojom::HitTestDataPtr hit_test_data); |
+ |
+ // Called after surfaces have been aggregated into the DisplayFrame. |
+ // In this call HitTestData structures received from active surfaces |
+ // are aggregated into the DisplayHitTestData structure in |
+ // shared memory used for event targetting. |
+ void Aggregate(cc::SurfaceId display_surface_id); |
+ |
+ // Performs the work of Aggregate by creating a PostTask so that |
+ // the work is not directly on the call. |
+ void PostTaskAggregate(cc::SurfaceId display_surface_id); |
+ |
+ // Called at BeginFrame to swap buffers in shared memory. |
varkha
2017/06/19 21:15:05
nit: Maybe "Called at BeginFrame. Swaps buffers in
gklassen
2017/06/20 16:09:39
Done.
|
+ void Swap(); |
+ |
+ DisplayHitTestRegion* GetCurrentRegions(); |
varkha
2017/06/19 21:15:05
Comment?
gklassen
2017/06/20 16:09:38
Done.
|
+ |
+ private: |
+ friend class test::HitTestAggregatorTest; |
+ |
+ HitTestDataMap pending_; |
+ HitTestDataMap active_; |
varkha
2017/06/19 21:15:04
nit: move after methods?
gklassen
2017/06/20 16:09:39
Done.
|
+ |
+ // Keep track of the number of regions in the active list |
varkha
2017/06/19 21:15:04
nit: Keeps.
gklassen
2017/06/20 16:09:39
Done.
|
+ // so that we know when we exceed the available length. |
+ int active_region_count_; |
+ |
+ std::unique_ptr<DisplayHitTestDataFactory> display_hit_test_data_factory_; |
+ |
+ DisplayHitTestData* display_hit_test_data_; |
+ |
+ // Allocates memory for the DisplayHitTestData Structure. |
+ void AllocateDisplayHitTestData(); |
+ void AllocateDisplayHitTestData(int length); |
+ |
+ // Resize the memory for the DisplayHitTestData Structure. |
varkha
2017/06/19 21:15:04
nit: Resizes.
gklassen
2017/06/20 16:09:39
Done.
|
+ // Copies current data and marks the structure |
varkha
2017/06/19 21:15:05
nit. Sentence ends in .
gklassen
2017/06/20 16:09:38
Done.
|
+ void ResizeDisplayHitTestData(int length); |
+ |
+ int GetBackIndex(); |
+ |
+ int Append(cc::SurfaceId surface_id, int index); |
+ int Append(const hit_test::mojom::HitTestRegionPtr& region, int index); |
+ |
+ // SurfaceObserver |
varkha
2017/06/19 21:15:05
nit: cc::SurfaceObserver:
gklassen
2017/06/20 16:09:38
Done.
|
+ void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override {} |
+ void OnSurfaceDestroyed(const cc::SurfaceId& surface_id) override {} |
+ bool OnSurfaceDamaged(const cc::SurfaceId& surface_id, |
+ const cc::BeginFrameAck& ack) override; |
+ void OnSurfaceDiscarded(const cc::SurfaceId& surface_id) override; |
+ void OnSurfaceDamageExpected(const cc::SurfaceId& surface_id, |
+ const cc::BeginFrameArgs& args) override {} |
varkha
2017/06/19 21:15:05
nit: ws after this line.
gklassen
2017/06/20 16:09:39
Done.
|
+ // Called when a surface has been aggregated and added to the |
+ // display frame. HitTestData objects are held but ignored until |
+ // this happens. HitTestData for the surface is copied from pending_ |
+ // to active_ in this method. |
varkha
2017/06/19 21:15:05
nit: pending_ and active_ refer to variables so wr
gklassen
2017/06/20 16:09:38
Done.
|
+ void OnSurfaceWillDraw(const cc::SurfaceId& surface_id) override; |
+ |
+ // WeakPtr to handle the case when this object is deleted after |
+ // the PostTaskAggregation call is scheduled but before invocation. |
+ base::WeakPtrFactory<HitTestAggregator> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(HitTestAggregator); |
+}; |
+ |
+} // namespace hit_test |
+} // namespace viz |
+ |
+#endif // COMPONENTS_VIZ_SERVICE_HIT_TEST_HIT_TEST_AGGREGATOR_H_ |
varkha
2017/06/19 21:15:04
nit: remove extra space after //
gklassen
2017/06/26 21:55:19
Done.
|