Chromium Code Reviews| 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_SERVICE_HIT_TEST_HIT_TEST_AGGREGATOR_H_ | |
| 6 #define COMPONENTS_VIZ_SERVICE_HIT_TEST_HIT_TEST_AGGREGATOR_H_ | |
| 7 | |
| 8 #include "cc/surfaces/surface_id.h" | |
| 9 #include "cc/surfaces/surface_observer.h" | |
| 10 #include "components/viz/common/hit_test/display_hit_test_data.h" | |
| 11 #include "components/viz/service/hit_test/display_hit_test_data_factory.h" | |
| 12 #include "components/viz/service/viz_service_export.h" | |
| 13 #include "services/viz/hit_test/public/interfaces/hit_test_data.mojom.h" | |
| 14 | |
| 15 namespace viz { | |
| 16 namespace hit_test { | |
| 17 | |
| 18 namespace test { | |
| 19 class HitTestAggregatorTest; | |
| 20 } | |
| 21 | |
| 22 // 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.
| |
| 23 // in shared memory to enable efficient hit testing across processes. | |
| 24 // | |
| 25 // This is intended to be created in the viz or GPU process. For mus+ash this | |
| 26 // will be true after the mus process split. | |
| 27 | |
| 28 using HitTestDataMap = std::map<cc::SurfaceId, hit_test::mojom::HitTestDataPtr>; | |
| 29 | |
| 30 class VIZ_SERVICE_EXPORT HitTestAggregator : public cc::SurfaceObserver { | |
| 31 public: | |
| 32 HitTestAggregator( | |
| 33 std::unique_ptr<DisplayHitTestDataFactory> display_hit_test_data_factory); | |
| 34 ~HitTestAggregator(); | |
| 35 | |
| 36 // Called when HitTestData is submitted along with every call | |
| 37 // to SubmitCompositorFrame. This is collected in pending_ until | |
| 38 // surfaces are aggregated and put on the display. | |
| 39 void SubmitHitTestData(hit_test::mojom::HitTestDataPtr hit_test_data); | |
| 40 | |
| 41 // Called after surfaces have been aggregated into the DisplayFrame. | |
| 42 // In this call HitTestData structures received from active surfaces | |
| 43 // are aggregated into the DisplayHitTestData structure in | |
| 44 // shared memory used for event targetting. | |
| 45 void Aggregate(cc::SurfaceId display_surface_id); | |
| 46 | |
| 47 // Performs the work of Aggregate by creating a PostTask so that | |
| 48 // the work is not directly on the call. | |
| 49 void PostTaskAggregate(cc::SurfaceId display_surface_id); | |
| 50 | |
| 51 // 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.
| |
| 52 void Swap(); | |
| 53 | |
| 54 DisplayHitTestRegion* GetCurrentRegions(); | |
|
varkha
2017/06/19 21:15:05
Comment?
gklassen
2017/06/20 16:09:38
Done.
| |
| 55 | |
| 56 private: | |
| 57 friend class test::HitTestAggregatorTest; | |
| 58 | |
| 59 HitTestDataMap pending_; | |
| 60 HitTestDataMap active_; | |
|
varkha
2017/06/19 21:15:04
nit: move after methods?
gklassen
2017/06/20 16:09:39
Done.
| |
| 61 | |
| 62 // 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.
| |
| 63 // so that we know when we exceed the available length. | |
| 64 int active_region_count_; | |
| 65 | |
| 66 std::unique_ptr<DisplayHitTestDataFactory> display_hit_test_data_factory_; | |
| 67 | |
| 68 DisplayHitTestData* display_hit_test_data_; | |
| 69 | |
| 70 // Allocates memory for the DisplayHitTestData Structure. | |
| 71 void AllocateDisplayHitTestData(); | |
| 72 void AllocateDisplayHitTestData(int length); | |
| 73 | |
| 74 // Resize the memory for the DisplayHitTestData Structure. | |
|
varkha
2017/06/19 21:15:04
nit: Resizes.
gklassen
2017/06/20 16:09:39
Done.
| |
| 75 // 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.
| |
| 76 void ResizeDisplayHitTestData(int length); | |
| 77 | |
| 78 int GetBackIndex(); | |
| 79 | |
| 80 int Append(cc::SurfaceId surface_id, int index); | |
| 81 int Append(const hit_test::mojom::HitTestRegionPtr& region, int index); | |
| 82 | |
| 83 // SurfaceObserver | |
|
varkha
2017/06/19 21:15:05
nit: cc::SurfaceObserver:
gklassen
2017/06/20 16:09:38
Done.
| |
| 84 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override {} | |
| 85 void OnSurfaceDestroyed(const cc::SurfaceId& surface_id) override {} | |
| 86 bool OnSurfaceDamaged(const cc::SurfaceId& surface_id, | |
| 87 const cc::BeginFrameAck& ack) override; | |
| 88 void OnSurfaceDiscarded(const cc::SurfaceId& surface_id) override; | |
| 89 void OnSurfaceDamageExpected(const cc::SurfaceId& surface_id, | |
| 90 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.
| |
| 91 // Called when a surface has been aggregated and added to the | |
| 92 // display frame. HitTestData objects are held but ignored until | |
| 93 // this happens. HitTestData for the surface is copied from pending_ | |
| 94 // 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.
| |
| 95 void OnSurfaceWillDraw(const cc::SurfaceId& surface_id) override; | |
| 96 | |
| 97 // WeakPtr to handle the case when this object is deleted after | |
| 98 // the PostTaskAggregation call is scheduled but before invocation. | |
| 99 base::WeakPtrFactory<HitTestAggregator> weak_ptr_factory_; | |
| 100 | |
| 101 DISALLOW_COPY_AND_ASSIGN(HitTestAggregator); | |
| 102 }; | |
| 103 | |
| 104 } // namespace hit_test | |
| 105 } // namespace viz | |
| 106 | |
| 107 #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.
| |
| OLD | NEW |