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

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

Issue 2923583002: Remove RendererCompositorFrameSink and use ClientCompositorFrameSink instead (Closed)
Patch Set: Fix windows 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 local_surface_id_ =
99 local_surface_id_ = id_allocator_.GenerateId(); 104 local_surface_id_provider_->GetLocalSurfaceIdForFrame(frame);
100 105 }
101 surface_size_ = frame.render_pass_list.back()->output_rect.size();
102 device_scale_factor_ = frame.metadata.device_scale_factor;
103
104 compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_, 106 compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_,
105 std::move(frame)); 107 std::move(frame));
106 } 108 }
107 109
108 void ClientCompositorFrameSink::DidNotProduceFrame( 110 void ClientCompositorFrameSink::DidNotProduceFrame(
109 const cc::BeginFrameAck& ack) { 111 const cc::BeginFrameAck& ack) {
110 DCHECK(!ack.has_damage); 112 DCHECK(!ack.has_damage);
111 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, ack.sequence_number); 113 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, ack.sequence_number);
112 compositor_frame_sink_->DidNotProduceFrame(ack); 114 compositor_frame_sink_->DidNotProduceFrame(ack);
113 } 115 }
(...skipping 10 matching lines...) Expand all
124 if (begin_frame_source_) 126 if (begin_frame_source_)
125 begin_frame_source_->OnBeginFrame(begin_frame_args); 127 begin_frame_source_->OnBeginFrame(begin_frame_args);
126 } 128 }
127 129
128 void ClientCompositorFrameSink::ReclaimResources( 130 void ClientCompositorFrameSink::ReclaimResources(
129 const cc::ReturnedResourceArray& resources) { 131 const cc::ReturnedResourceArray& resources) {
130 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); 132 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
131 client_->ReclaimResources(resources); 133 client_->ReclaimResources(resources);
132 } 134 }
133 135
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) { 136 void ClientCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) {
142 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames); 137 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames);
143 } 138 }
144 139
145 } // namespace viz 140 } // namespace viz
OLDNEW
« no previous file with comments | « components/viz/client/client_compositor_frame_sink.h ('k') | components/viz/client/local_surface_id_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698