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

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

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

Powered by Google App Engine
This is Rietveld 408576698