| Index: components/viz/client/client_compositor_frame_sink.cc
|
| diff --git a/components/viz/client/client_compositor_frame_sink.cc b/components/viz/client/client_compositor_frame_sink.cc
|
| index e363f8c58e75735b9ef737af62a2f795a56f7762..d1503089f8351daa11260d3cfb84557c4d88f7b6 100644
|
| --- a/components/viz/client/client_compositor_frame_sink.cc
|
| +++ b/components/viz/client/client_compositor_frame_sink.cc
|
| @@ -20,11 +20,13 @@ ClientCompositorFrameSink::ClientCompositorFrameSink(
|
| std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source,
|
| cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info,
|
| cc::mojom::MojoCompositorFrameSinkClientRequest client_request,
|
| + std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider,
|
| bool enable_surface_synchronization)
|
| : cc::CompositorFrameSink(std::move(context_provider),
|
| std::move(worker_context_provider),
|
| gpu_memory_buffer_manager,
|
| shared_bitmap_manager),
|
| + local_surface_id_provider_(std::move(local_surface_id_provider)),
|
| synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)),
|
| compositor_frame_sink_info_(std::move(compositor_frame_sink_info)),
|
| client_request_(std::move(client_request)),
|
| @@ -38,8 +40,10 @@ ClientCompositorFrameSink::ClientCompositorFrameSink(
|
| std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source,
|
| cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info,
|
| cc::mojom::MojoCompositorFrameSinkClientRequest client_request,
|
| + std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider,
|
| bool enable_surface_synchronization)
|
| : cc::CompositorFrameSink(std::move(vulkan_context_provider)),
|
| + local_surface_id_provider_(std::move(local_surface_id_provider)),
|
| synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)),
|
| compositor_frame_sink_info_(std::move(compositor_frame_sink_info)),
|
| client_request_(std::move(client_request)),
|
| @@ -94,15 +98,14 @@ void ClientCompositorFrameSink::SubmitCompositorFrame(
|
| DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber,
|
| frame.metadata.begin_frame_ack.sequence_number);
|
|
|
| - if (!enable_surface_synchronization_ &&
|
| - (!local_surface_id_.is_valid() || ShouldAllocateNewLocalSurfaceId(frame)))
|
| - local_surface_id_ = id_allocator_.GenerateId();
|
| -
|
| - surface_size_ = frame.render_pass_list.back()->output_rect.size();
|
| - device_scale_factor_ = frame.metadata.device_scale_factor;
|
| -
|
| - compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_,
|
| - std::move(frame));
|
| + if (enable_surface_synchronization_) {
|
| + compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_,
|
| + std::move(frame));
|
| + } else {
|
| + compositor_frame_sink_->SubmitCompositorFrame(
|
| + local_surface_id_provider_->GetLocalSurfaceIdForFrame(frame),
|
| + std::move(frame));
|
| + }
|
| }
|
|
|
| void ClientCompositorFrameSink::DidNotProduceFrame(
|
| @@ -131,15 +134,21 @@ void ClientCompositorFrameSink::ReclaimResources(
|
| client_->ReclaimResources(resources);
|
| }
|
|
|
| -bool ClientCompositorFrameSink::ShouldAllocateNewLocalSurfaceId(
|
| - const cc::CompositorFrame& frame) {
|
| - gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
|
| - return frame_size != surface_size_ ||
|
| - device_scale_factor_ != frame.metadata.device_scale_factor;
|
| -}
|
| -
|
| void ClientCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) {
|
| compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames);
|
| }
|
|
|
| +const cc::LocalSurfaceId&
|
| +DefaultLocalSurfaceIdProvider::GetLocalSurfaceIdForFrame(
|
| + const cc::CompositorFrame& frame) {
|
| + gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
|
| + if (!local_surface_id_.is_valid() || surface_size_ != frame_size ||
|
| + frame.metadata.device_scale_factor != device_scale_factor_) {
|
| + local_surface_id_ = local_surface_id_allocator_.GenerateId();
|
| + }
|
| + surface_size_ = frame_size;
|
| + device_scale_factor_ = frame.metadata.device_scale_factor;
|
| + return local_surface_id_;
|
| +}
|
| +
|
| } // namespace viz
|
|
|