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

Side by Side Diff: blimp/client/core/compositor/blimp_compositor.cc

Issue 2388753003: Introduce cc::LocalFrameId and use in SurfaceFactory (Closed)
Patch Set: Fix exo_unittests Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "blimp/client/core/compositor/blimp_compositor.h" 5 #include "blimp/client/core/compositor/blimp_compositor.h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 frame_sink_id_(compositor_dependencies_->GetEmbedderDependencies() 67 frame_sink_id_(compositor_dependencies_->GetEmbedderDependencies()
68 ->AllocateFrameSinkId()), 68 ->AllocateFrameSinkId()),
69 proxy_client_(nullptr), 69 proxy_client_(nullptr),
70 compositor_frame_sink_request_pending_(false), 70 compositor_frame_sink_request_pending_(false),
71 layer_(cc::Layer::Create()), 71 layer_(cc::Layer::Create()),
72 remote_proto_channel_receiver_(nullptr), 72 remote_proto_channel_receiver_(nullptr),
73 outstanding_commits_(0U), 73 outstanding_commits_(0U),
74 weak_ptr_factory_(this) { 74 weak_ptr_factory_(this) {
75 DCHECK(thread_checker_.CalledOnValidThread()); 75 DCHECK(thread_checker_.CalledOnValidThread());
76 76
77 surface_id_allocator_ = 77 surface_id_allocator_ = base::MakeUnique<cc::SurfaceIdAllocator>();
78 base::MakeUnique<cc::SurfaceIdAllocator>(frame_sink_id_);
79 GetEmbedderDeps()->GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); 78 GetEmbedderDeps()->GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_);
80 CreateLayerTreeHost(); 79 CreateLayerTreeHost();
81 } 80 }
82 81
83 BlimpCompositor::~BlimpCompositor() { 82 BlimpCompositor::~BlimpCompositor() {
84 DCHECK(thread_checker_.CalledOnValidThread()); 83 DCHECK(thread_checker_.CalledOnValidThread());
85 84
86 DestroyLayerTreeHost(); 85 DestroyLayerTreeHost();
87 GetEmbedderDeps()->GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); 86 GetEmbedderDeps()->GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_);
88 87
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 214 }
216 215
217 void BlimpCompositor::SwapCompositorFrame(cc::CompositorFrame frame) { 216 void BlimpCompositor::SwapCompositorFrame(cc::CompositorFrame frame) {
218 DCHECK(thread_checker_.CalledOnValidThread()); 217 DCHECK(thread_checker_.CalledOnValidThread());
219 DCHECK(surface_factory_); 218 DCHECK(surface_factory_);
220 219
221 cc::RenderPass* root_pass = 220 cc::RenderPass* root_pass =
222 frame.delegated_frame_data->render_pass_list.back().get(); 221 frame.delegated_frame_data->render_pass_list.back().get();
223 gfx::Size surface_size = root_pass->output_rect.size(); 222 gfx::Size surface_size = root_pass->output_rect.size();
224 223
225 if (surface_id_.is_null() || current_surface_size_ != surface_size) { 224 if (local_frame_id_.is_null() || current_surface_size_ != surface_size) {
226 DestroyDelegatedContent(); 225 DestroyDelegatedContent();
227 DCHECK(layer_->children().empty()); 226 DCHECK(layer_->children().empty());
228 227
229 surface_id_ = surface_id_allocator_->GenerateId(); 228 local_frame_id_ = surface_id_allocator_->GenerateId();
230 surface_factory_->Create(surface_id_); 229 surface_factory_->Create(local_frame_id_);
231 current_surface_size_ = surface_size; 230 current_surface_size_ = surface_size;
232 231
233 // manager must outlive compositors using it. 232 // manager must outlive compositors using it.
234 cc::SurfaceManager* surface_manager = 233 cc::SurfaceManager* surface_manager =
235 GetEmbedderDeps()->GetSurfaceManager(); 234 GetEmbedderDeps()->GetSurfaceManager();
236 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create( 235 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create(
237 base::Bind(&SatisfyCallback, base::Unretained(surface_manager)), 236 base::Bind(&SatisfyCallback, base::Unretained(surface_manager)),
238 base::Bind(&RequireCallback, base::Unretained(surface_manager))); 237 base::Bind(&RequireCallback, base::Unretained(surface_manager)));
239 content_layer->SetSurfaceId(surface_id_, 1.f, surface_size); 238 content_layer->SetSurfaceId(
239 cc::SurfaceId(surface_factory_->frame_sink_id(), local_frame_id_), 1.f,
240 surface_size);
240 content_layer->SetBounds(current_surface_size_); 241 content_layer->SetBounds(current_surface_size_);
241 content_layer->SetIsDrawable(true); 242 content_layer->SetIsDrawable(true);
242 content_layer->SetContentsOpaque(true); 243 content_layer->SetContentsOpaque(true);
243 244
244 layer_->AddChild(content_layer); 245 layer_->AddChild(content_layer);
245 } 246 }
246 247
247 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), 248 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame),
248 base::Closure()); 249 base::Closure());
249 } 250 }
250 251
251 void BlimpCompositor::UnbindProxyClient() { 252 void BlimpCompositor::UnbindProxyClient() {
252 DCHECK(thread_checker_.CalledOnValidThread()); 253 DCHECK(thread_checker_.CalledOnValidThread());
253 DCHECK(surface_factory_); 254 DCHECK(surface_factory_);
254 255
255 DestroyDelegatedContent(); 256 DestroyDelegatedContent();
256 surface_factory_.reset(); 257 surface_factory_.reset();
257 proxy_client_ = nullptr; 258 proxy_client_ = nullptr;
258 } 259 }
259 260
260 void BlimpCompositor::ReturnResources( 261 void BlimpCompositor::ReturnResources(
261 const cc::ReturnedResourceArray& resources) { 262 const cc::ReturnedResourceArray& resources) {
262 DCHECK(surface_factory_); 263 DCHECK(surface_factory_);
263 compositor_dependencies_->GetCompositorTaskRunner()->PostTask( 264 compositor_dependencies_->GetCompositorTaskRunner()->PostTask(
264 FROM_HERE, 265 FROM_HERE,
265 base::Bind( 266 base::Bind(
266 &BlimpCompositorFrameSinkProxyClient::ReclaimCompositorResources, 267 &BlimpCompositorFrameSinkProxyClient::ReclaimCompositorResources,
267 proxy_client_, resources)); 268 proxy_client_, resources));
268 } 269 }
269 270
270 CompositorDependencies* BlimpCompositor::GetEmbedderDeps() { 271 CompositorDependencies* BlimpCompositor::GetEmbedderDeps() {
271 return compositor_dependencies_->GetEmbedderDependencies(); 272 return compositor_dependencies_->GetEmbedderDependencies();
272 } 273 }
273 274
274 void BlimpCompositor::DestroyDelegatedContent() { 275 void BlimpCompositor::DestroyDelegatedContent() {
275 if (surface_id_.is_null()) 276 if (local_frame_id_.is_null())
276 return; 277 return;
277 278
278 // Remove any references for the surface layer that uses this |surface_id_|. 279 // Remove any references for the surface layer that uses this
280 // |local_frame_id_|.
279 layer_->RemoveAllChildren(); 281 layer_->RemoveAllChildren();
280 surface_factory_->Destroy(surface_id_); 282 surface_factory_->Destroy(local_frame_id_);
281 surface_id_ = cc::SurfaceId(); 283 local_frame_id_ = cc::LocalFrameId();
282 } 284 }
283 285
284 void BlimpCompositor::CreateLayerTreeHost() { 286 void BlimpCompositor::CreateLayerTreeHost() {
285 DCHECK(!host_); 287 DCHECK(!host_);
286 VLOG(1) << "Creating LayerTreeHost for render widget: " << render_widget_id_; 288 VLOG(1) << "Creating LayerTreeHost for render widget: " << render_widget_id_;
287 289
288 // Create the LayerTreeHost 290 // Create the LayerTreeHost
289 cc::LayerTreeHostInProcess::InitParams params; 291 cc::LayerTreeHostInProcess::InitParams params;
290 params.client = this; 292 params.client = this;
291 params.task_graph_runner = compositor_dependencies_->GetTaskGraphRunner(); 293 params.task_graph_runner = compositor_dependencies_->GetTaskGraphRunner();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 it->second.Run(); 351 it->second.Run();
350 it = pending_commit_trackers_.erase(it); 352 it = pending_commit_trackers_.erase(it);
351 } else { 353 } else {
352 ++it; 354 ++it;
353 } 355 }
354 } 356 }
355 } 357 }
356 358
357 } // namespace client 359 } // namespace client
358 } // namespace blimp 360 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698