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

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

Issue 2485473003: Remove SurfaceFactory::Create and SurfaceFactory::Destroy (Closed)
Patch Set: up Created 4 years 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 if (flush_pending_update) { 186 if (flush_pending_update) {
187 // Always request a commit when queuing the promise to make sure that any 187 // Always request a commit when queuing the promise to make sure that any
188 // frames pending draws are cleared from the pipeline. 188 // frames pending draws are cleared from the pipeline.
189 host_->QueueSwapPromise(base::MakeUnique<FrameTrackingSwapPromise>( 189 host_->QueueSwapPromise(base::MakeUnique<FrameTrackingSwapPromise>(
190 std::move(copy_request), weak_ptr_factory_.GetWeakPtr(), 190 std::move(copy_request), weak_ptr_factory_.GetWeakPtr(),
191 base::ThreadTaskRunnerHandle::Get())); 191 base::ThreadTaskRunnerHandle::Get()));
192 host_->SetNeedsCommit(); 192 host_->SetNeedsCommit();
193 } else if (local_frame_id_.is_valid()) { 193 } else if (local_frame_id_.is_valid()) {
194 // Make a copy request for the surface directly. 194 // Make a copy request for the surface directly.
195 surface_factory_->RequestCopyOfSurface(local_frame_id_, 195 surface_factory_->RequestCopyOfSurface(std::move(copy_request));
196 std::move(copy_request));
197 } 196 }
198 } 197 }
199 198
200 void BlimpCompositor::UpdateLayerTreeHost() { 199 void BlimpCompositor::UpdateLayerTreeHost() {
201 // UpdateLayerTreeHost marks the end of reporting of any deltas from the impl 200 // UpdateLayerTreeHost marks the end of reporting of any deltas from the impl
202 // thread. So send a client state update if the local state was modified now. 201 // thread. So send a client state update if the local state was modified now.
203 FlushClientState(); 202 FlushClientState();
204 203
205 if (pending_frame_update_) { 204 if (pending_frame_update_) {
206 compositor_state_deserializer_->DeserializeCompositorUpdate( 205 compositor_state_deserializer_->DeserializeCompositorUpdate(
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 DCHECK(bound_to_proxy_); 317 DCHECK(bound_to_proxy_);
319 318
320 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); 319 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
321 gfx::Size surface_size = root_pass->output_rect.size(); 320 gfx::Size surface_size = root_pass->output_rect.size();
322 321
323 if (!local_frame_id_.is_valid() || current_surface_size_ != surface_size) { 322 if (!local_frame_id_.is_valid() || current_surface_size_ != surface_size) {
324 DestroyDelegatedContent(); 323 DestroyDelegatedContent();
325 DCHECK(layer_->children().empty()); 324 DCHECK(layer_->children().empty());
326 325
327 local_frame_id_ = surface_id_allocator_->GenerateId(); 326 local_frame_id_ = surface_id_allocator_->GenerateId();
328 surface_factory_->Create(local_frame_id_);
329 current_surface_size_ = surface_size; 327 current_surface_size_ = surface_size;
330 328
331 // manager must outlive compositors using it. 329 // manager must outlive compositors using it.
332 cc::SurfaceManager* surface_manager = 330 cc::SurfaceManager* surface_manager =
333 GetEmbedderDeps()->GetSurfaceManager(); 331 GetEmbedderDeps()->GetSurfaceManager();
334 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create( 332 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create(
335 base::Bind(&SatisfyCallback, base::Unretained(surface_manager)), 333 base::Bind(&SatisfyCallback, base::Unretained(surface_manager)),
336 base::Bind(&RequireCallback, base::Unretained(surface_manager))); 334 base::Bind(&RequireCallback, base::Unretained(surface_manager)));
337 content_layer->SetSurfaceId( 335 content_layer->SetSurfaceId(
338 cc::SurfaceId(surface_factory_->frame_sink_id(), local_frame_id_), 1.f, 336 cc::SurfaceId(surface_factory_->frame_sink_id(), local_frame_id_), 1.f,
339 surface_size); 337 surface_size);
340 content_layer->SetBounds(current_surface_size_); 338 content_layer->SetBounds(current_surface_size_);
341 content_layer->SetIsDrawable(true); 339 content_layer->SetIsDrawable(true);
342 content_layer->SetContentsOpaque(true); 340 content_layer->SetContentsOpaque(true);
343 341
344 layer_->AddChild(content_layer); 342 layer_->AddChild(content_layer);
345 } 343 }
346 344
347 surface_factory_->SubmitCompositorFrame( 345 surface_factory_->SubmitCompositorFrame(
348 local_frame_id_, std::move(frame), 346 local_frame_id_, std::move(frame),
349 base::Bind(&BlimpCompositor::SubmitCompositorFrameAck, 347 base::Bind(&BlimpCompositor::SubmitCompositorFrameAck,
350 weak_ptr_factory_.GetWeakPtr())); 348 weak_ptr_factory_.GetWeakPtr()));
351 349
352 for (auto& copy_request : copy_requests_for_next_swap_) { 350 for (auto& copy_request : copy_requests_for_next_swap_) {
353 surface_factory_->RequestCopyOfSurface(local_frame_id_, 351 surface_factory_->RequestCopyOfSurface(std::move(copy_request));
354 std::move(copy_request));
355 } 352 }
356 copy_requests_for_next_swap_.clear(); 353 copy_requests_for_next_swap_.clear();
357 } 354 }
358 355
359 void BlimpCompositor::SubmitCompositorFrameAck() { 356 void BlimpCompositor::SubmitCompositorFrameAck() {
360 compositor_dependencies_->GetCompositorTaskRunner()->PostTask( 357 compositor_dependencies_->GetCompositorTaskRunner()->PostTask(
361 FROM_HERE, 358 FROM_HERE,
362 base::Bind(&BlimpCompositorFrameSinkProxyClient::SubmitCompositorFrameAck, 359 base::Bind(&BlimpCompositorFrameSinkProxyClient::SubmitCompositorFrameAck,
363 proxy_client_)); 360 proxy_client_));
364 } 361 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 return compositor_dependencies_->GetEmbedderDependencies(); 413 return compositor_dependencies_->GetEmbedderDependencies();
417 } 414 }
418 415
419 void BlimpCompositor::DestroyDelegatedContent() { 416 void BlimpCompositor::DestroyDelegatedContent() {
420 if (!local_frame_id_.is_valid()) 417 if (!local_frame_id_.is_valid())
421 return; 418 return;
422 419
423 // Remove any references for the surface layer that uses this 420 // Remove any references for the surface layer that uses this
424 // |local_frame_id_|. 421 // |local_frame_id_|.
425 layer_->RemoveAllChildren(); 422 layer_->RemoveAllChildren();
426 surface_factory_->Destroy(local_frame_id_); 423 surface_factory_->EvictSurface();
427 local_frame_id_ = cc::LocalFrameId(); 424 local_frame_id_ = cc::LocalFrameId();
428 } 425 }
429 426
430 std::unique_ptr<cc::LayerTreeHostInProcess> 427 std::unique_ptr<cc::LayerTreeHostInProcess>
431 BlimpCompositor::CreateLayerTreeHost() { 428 BlimpCompositor::CreateLayerTreeHost() {
432 DCHECK(animation_host_); 429 DCHECK(animation_host_);
433 std::unique_ptr<cc::LayerTreeHostInProcess> host; 430 std::unique_ptr<cc::LayerTreeHostInProcess> host;
434 431
435 cc::LayerTreeHostInProcess::InitParams params; 432 cc::LayerTreeHostInProcess::InitParams params;
436 params.client = this; 433 params.client = this;
(...skipping 26 matching lines...) Expand all
463 // Destroy the old LayerTreeHost state. 460 // Destroy the old LayerTreeHost state.
464 host_.reset(); 461 host_.reset();
465 462
466 // Cancel any outstanding CompositorFrameSink requests. That way if we get an 463 // Cancel any outstanding CompositorFrameSink requests. That way if we get an
467 // async callback related to the old request we know to drop it. 464 // async callback related to the old request we know to drop it.
468 compositor_frame_sink_request_pending_ = false; 465 compositor_frame_sink_request_pending_ = false;
469 } 466 }
470 467
471 } // namespace client 468 } // namespace client
472 } // namespace blimp 469 } // namespace blimp
OLDNEW
« no previous file with comments | « android_webview/browser/surfaces_instance.cc ('k') | cc/surfaces/direct_compositor_frame_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698