| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/viz/client/client_layer_tree_frame_sink.h" | 5 #include "components/viz/client/client_layer_tree_frame_sink.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "cc/output/begin_frame_args.h" | 9 #include "cc/output/begin_frame_args.h" |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| 11 #include "cc/output/layer_tree_frame_sink_client.h" | 11 #include "cc/output/layer_tree_frame_sink_client.h" |
| 12 #include "components/viz/client/hit_test_data_provider.h" |
| 12 #include "components/viz/client/local_surface_id_provider.h" | 13 #include "components/viz/client/local_surface_id_provider.h" |
| 13 | 14 |
| 14 namespace viz { | 15 namespace viz { |
| 15 | 16 |
| 16 ClientLayerTreeFrameSink::ClientLayerTreeFrameSink( | 17 ClientLayerTreeFrameSink::ClientLayerTreeFrameSink( |
| 17 scoped_refptr<cc::ContextProvider> context_provider, | 18 scoped_refptr<cc::ContextProvider> context_provider, |
| 18 scoped_refptr<cc::ContextProvider> worker_context_provider, | 19 scoped_refptr<cc::ContextProvider> worker_context_provider, |
| 19 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 20 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 20 cc::SharedBitmapManager* shared_bitmap_manager, | 21 cc::SharedBitmapManager* shared_bitmap_manager, |
| 21 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, | 22 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, |
| 22 cc::mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info, | 23 cc::mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info, |
| 23 cc::mojom::CompositorFrameSinkClientRequest client_request, | 24 cc::mojom::CompositorFrameSinkClientRequest client_request, |
| 25 std::unique_ptr<HitTestDataProvider> hit_test_data_provider, |
| 24 std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider, | 26 std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider, |
| 25 bool enable_surface_synchronization) | 27 bool enable_surface_synchronization) |
| 26 : cc::LayerTreeFrameSink(std::move(context_provider), | 28 : cc::LayerTreeFrameSink(std::move(context_provider), |
| 27 std::move(worker_context_provider), | 29 std::move(worker_context_provider), |
| 28 gpu_memory_buffer_manager, | 30 gpu_memory_buffer_manager, |
| 29 shared_bitmap_manager), | 31 shared_bitmap_manager), |
| 32 hit_test_data_provider_(std::move(hit_test_data_provider)), |
| 30 local_surface_id_provider_(std::move(local_surface_id_provider)), | 33 local_surface_id_provider_(std::move(local_surface_id_provider)), |
| 31 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), | 34 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), |
| 32 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), | 35 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), |
| 33 client_request_(std::move(client_request)), | 36 client_request_(std::move(client_request)), |
| 34 client_binding_(this), | 37 client_binding_(this), |
| 35 enable_surface_synchronization_(enable_surface_synchronization), | 38 enable_surface_synchronization_(enable_surface_synchronization), |
| 36 weak_factory_(this) { | 39 weak_factory_(this) { |
| 37 DETACH_FROM_THREAD(thread_checker_); | 40 DETACH_FROM_THREAD(thread_checker_); |
| 38 } | 41 } |
| 39 | 42 |
| 40 ClientLayerTreeFrameSink::ClientLayerTreeFrameSink( | 43 ClientLayerTreeFrameSink::ClientLayerTreeFrameSink( |
| 41 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, | 44 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, |
| 42 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, | 45 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, |
| 43 cc::mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info, | 46 cc::mojom::CompositorFrameSinkPtrInfo compositor_frame_sink_info, |
| 44 cc::mojom::CompositorFrameSinkClientRequest client_request, | 47 cc::mojom::CompositorFrameSinkClientRequest client_request, |
| 48 std::unique_ptr<HitTestDataProvider> hit_test_data_provider, |
| 45 std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider, | 49 std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider, |
| 46 bool enable_surface_synchronization) | 50 bool enable_surface_synchronization) |
| 47 : cc::LayerTreeFrameSink(std::move(vulkan_context_provider)), | 51 : cc::LayerTreeFrameSink(std::move(vulkan_context_provider)), |
| 52 hit_test_data_provider_(std::move(hit_test_data_provider)), |
| 48 local_surface_id_provider_(std::move(local_surface_id_provider)), | 53 local_surface_id_provider_(std::move(local_surface_id_provider)), |
| 49 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), | 54 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), |
| 50 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), | 55 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), |
| 51 client_request_(std::move(client_request)), | 56 client_request_(std::move(client_request)), |
| 52 client_binding_(this), | 57 client_binding_(this), |
| 53 enable_surface_synchronization_(enable_surface_synchronization), | 58 enable_surface_synchronization_(enable_surface_synchronization), |
| 54 weak_factory_(this) { | 59 weak_factory_(this) { |
| 55 DETACH_FROM_THREAD(thread_checker_); | 60 DETACH_FROM_THREAD(thread_checker_); |
| 56 } | 61 } |
| 57 | 62 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 112 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 108 DCHECK(frame.metadata.begin_frame_ack.has_damage); | 113 DCHECK(frame.metadata.begin_frame_ack.has_damage); |
| 109 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, | 114 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, |
| 110 frame.metadata.begin_frame_ack.sequence_number); | 115 frame.metadata.begin_frame_ack.sequence_number); |
| 111 | 116 |
| 112 if (!enable_surface_synchronization_) { | 117 if (!enable_surface_synchronization_) { |
| 113 local_surface_id_ = | 118 local_surface_id_ = |
| 114 local_surface_id_provider_->GetLocalSurfaceIdForFrame(frame); | 119 local_surface_id_provider_->GetLocalSurfaceIdForFrame(frame); |
| 115 } | 120 } |
| 116 | 121 |
| 122 if (hit_test_data_provider_) { |
| 123 std::unique_ptr<HitTestDataProvider::HitTestRegionList> hit_test_data = |
| 124 hit_test_data_provider_->GetHitTestData(); |
| 125 if (!hit_test_data->empty()) { |
| 126 LOG(ERROR) << __FUNCTION__ << "--- " << hit_test_data->size() << " ---"; |
| 127 int i = 0; |
| 128 for (const auto& region : *hit_test_data) { |
| 129 LOG(ERROR) << __FUNCTION__ << "[" << i++ << "] flags=" << region.flags |
| 130 << " cid=" << region.frame_sink_id.client_id() |
| 131 << " sid=" << region.frame_sink_id.sink_id() |
| 132 << " wid=" << (region.window_id & 0xFFFF) |
| 133 << " rect=" << region.rect.ToString(); |
| 134 } |
| 135 } |
| 136 } |
| 117 compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_, | 137 compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_, |
| 118 std::move(frame)); | 138 std::move(frame)); |
| 119 } | 139 } |
| 120 | 140 |
| 121 void ClientLayerTreeFrameSink::DidNotProduceFrame( | 141 void ClientLayerTreeFrameSink::DidNotProduceFrame( |
| 122 const cc::BeginFrameAck& ack) { | 142 const cc::BeginFrameAck& ack) { |
| 123 DCHECK(!ack.has_damage); | 143 DCHECK(!ack.has_damage); |
| 124 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, ack.sequence_number); | 144 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, ack.sequence_number); |
| 125 compositor_frame_sink_->DidNotProduceFrame(ack); | 145 compositor_frame_sink_->DidNotProduceFrame(ack); |
| 126 } | 146 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 150 | 170 |
| 151 // static | 171 // static |
| 152 void ClientLayerTreeFrameSink::OnMojoConnectionError( | 172 void ClientLayerTreeFrameSink::OnMojoConnectionError( |
| 153 uint32_t custom_reason, | 173 uint32_t custom_reason, |
| 154 const std::string& description) { | 174 const std::string& description) { |
| 155 if (custom_reason) | 175 if (custom_reason) |
| 156 DLOG(FATAL) << description; | 176 DLOG(FATAL) << description; |
| 157 } | 177 } |
| 158 | 178 |
| 159 } // namespace viz | 179 } // namespace viz |
| OLD | NEW |