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

Side by Side Diff: components/viz/client/client_compositor_frame_sink.cc

Issue 2923583002: Remove RendererCompositorFrameSink and use ClientCompositorFrameSink instead (Closed)
Patch Set: Address comments 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
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_compositor_frame_sink.h" 5 #include "components/viz/client/client_compositor_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/compositor_frame_sink_client.h" 11 #include "cc/output/compositor_frame_sink_client.h"
12 #include "components/viz/client/local_surface_id_provider.h"
12 13
13 namespace viz { 14 namespace viz {
14 15
15 ClientCompositorFrameSink::ClientCompositorFrameSink( 16 ClientCompositorFrameSink::ClientCompositorFrameSink(
16 scoped_refptr<cc::ContextProvider> context_provider, 17 scoped_refptr<cc::ContextProvider> context_provider,
17 scoped_refptr<cc::ContextProvider> worker_context_provider, 18 scoped_refptr<cc::ContextProvider> worker_context_provider,
18 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 19 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
19 cc::SharedBitmapManager* shared_bitmap_manager, 20 cc::SharedBitmapManager* shared_bitmap_manager,
20 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, 21 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source,
21 cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info, 22 cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info,
22 cc::mojom::MojoCompositorFrameSinkClientRequest client_request, 23 cc::mojom::MojoCompositorFrameSinkClientRequest client_request,
24 std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider,
23 bool enable_surface_synchronization) 25 bool enable_surface_synchronization)
24 : cc::CompositorFrameSink(std::move(context_provider), 26 : cc::CompositorFrameSink(std::move(context_provider),
25 std::move(worker_context_provider), 27 std::move(worker_context_provider),
26 gpu_memory_buffer_manager, 28 gpu_memory_buffer_manager,
27 shared_bitmap_manager), 29 shared_bitmap_manager),
30 local_surface_id_provider_(std::move(local_surface_id_provider)),
28 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), 31 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)),
29 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), 32 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)),
30 client_request_(std::move(client_request)), 33 client_request_(std::move(client_request)),
31 client_binding_(this), 34 client_binding_(this),
32 enable_surface_synchronization_(enable_surface_synchronization) { 35 enable_surface_synchronization_(enable_surface_synchronization) {
33 DETACH_FROM_THREAD(thread_checker_); 36 DETACH_FROM_THREAD(thread_checker_);
34 } 37 }
35 38
36 ClientCompositorFrameSink::ClientCompositorFrameSink( 39 ClientCompositorFrameSink::ClientCompositorFrameSink(
37 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, 40 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider,
38 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, 41 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source,
39 cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info, 42 cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info,
40 cc::mojom::MojoCompositorFrameSinkClientRequest client_request, 43 cc::mojom::MojoCompositorFrameSinkClientRequest client_request,
44 std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider,
41 bool enable_surface_synchronization) 45 bool enable_surface_synchronization)
42 : cc::CompositorFrameSink(std::move(vulkan_context_provider)), 46 : cc::CompositorFrameSink(std::move(vulkan_context_provider)),
47 local_surface_id_provider_(std::move(local_surface_id_provider)),
43 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), 48 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)),
44 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), 49 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)),
45 client_request_(std::move(client_request)), 50 client_request_(std::move(client_request)),
46 client_binding_(this), 51 client_binding_(this),
47 enable_surface_synchronization_(enable_surface_synchronization) { 52 enable_surface_synchronization_(enable_surface_synchronization) {
48 DETACH_FROM_THREAD(thread_checker_); 53 DETACH_FROM_THREAD(thread_checker_);
49 } 54 }
50 55
51 ClientCompositorFrameSink::~ClientCompositorFrameSink() {} 56 ClientCompositorFrameSink::~ClientCompositorFrameSink() {}
52 57
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 local_surface_id_ = local_surface_id; 92 local_surface_id_ = local_surface_id;
88 } 93 }
89 94
90 void ClientCompositorFrameSink::SubmitCompositorFrame( 95 void ClientCompositorFrameSink::SubmitCompositorFrame(
91 cc::CompositorFrame frame) { 96 cc::CompositorFrame frame) {
92 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); 97 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
93 DCHECK(frame.metadata.begin_frame_ack.has_damage); 98 DCHECK(frame.metadata.begin_frame_ack.has_damage);
94 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, 99 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber,
95 frame.metadata.begin_frame_ack.sequence_number); 100 frame.metadata.begin_frame_ack.sequence_number);
96 101
97 if (!enable_surface_synchronization_ && 102 if (enable_surface_synchronization_) {
98 (!local_surface_id_.is_valid() || ShouldAllocateNewLocalSurfaceId(frame))) 103 compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_,
99 local_surface_id_ = id_allocator_.GenerateId(); 104 std::move(frame));
100 105 } else {
101 surface_size_ = frame.render_pass_list.back()->output_rect.size(); 106 compositor_frame_sink_->SubmitCompositorFrame(
102 device_scale_factor_ = frame.metadata.device_scale_factor; 107 local_surface_id_provider_->GetLocalSurfaceIdForFrame(frame),
103 108 std::move(frame));
104 compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_, 109 }
105 std::move(frame));
106 } 110 }
107 111
108 void ClientCompositorFrameSink::DidNotProduceFrame( 112 void ClientCompositorFrameSink::DidNotProduceFrame(
109 const cc::BeginFrameAck& ack) { 113 const cc::BeginFrameAck& ack) {
110 DCHECK(!ack.has_damage); 114 DCHECK(!ack.has_damage);
111 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, ack.sequence_number); 115 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, ack.sequence_number);
112 compositor_frame_sink_->DidNotProduceFrame(ack); 116 compositor_frame_sink_->DidNotProduceFrame(ack);
113 } 117 }
114 118
115 void ClientCompositorFrameSink::DidReceiveCompositorFrameAck( 119 void ClientCompositorFrameSink::DidReceiveCompositorFrameAck(
116 const cc::ReturnedResourceArray& resources) { 120 const cc::ReturnedResourceArray& resources) {
117 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); 121 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
118 client_->ReclaimResources(resources); 122 client_->ReclaimResources(resources);
119 client_->DidReceiveCompositorFrameAck(); 123 client_->DidReceiveCompositorFrameAck();
120 } 124 }
121 125
122 void ClientCompositorFrameSink::OnBeginFrame( 126 void ClientCompositorFrameSink::OnBeginFrame(
123 const cc::BeginFrameArgs& begin_frame_args) { 127 const cc::BeginFrameArgs& begin_frame_args) {
124 if (begin_frame_source_) 128 if (begin_frame_source_)
125 begin_frame_source_->OnBeginFrame(begin_frame_args); 129 begin_frame_source_->OnBeginFrame(begin_frame_args);
126 } 130 }
127 131
128 void ClientCompositorFrameSink::ReclaimResources( 132 void ClientCompositorFrameSink::ReclaimResources(
129 const cc::ReturnedResourceArray& resources) { 133 const cc::ReturnedResourceArray& resources) {
130 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); 134 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
131 client_->ReclaimResources(resources); 135 client_->ReclaimResources(resources);
132 } 136 }
133 137
134 bool ClientCompositorFrameSink::ShouldAllocateNewLocalSurfaceId(
135 const cc::CompositorFrame& frame) {
136 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
137 return frame_size != surface_size_ ||
138 device_scale_factor_ != frame.metadata.device_scale_factor;
139 }
140
141 void ClientCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { 138 void ClientCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) {
142 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames); 139 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames);
143 } 140 }
144 141
145 } // namespace viz 142 } // namespace viz
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698