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

Side by Side Diff: content/browser/compositor/delegated_frame_host.cc

Issue 553213003: Avoid destroying surface before the parent surface stops referencing it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/compositor/delegated_frame_host.h" 5 #include "content/browser/compositor/delegated_frame_host.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "cc/output/compositor_frame.h" 9 #include "cc/output/compositor_frame.h"
10 #include "cc/output/compositor_frame_ack.h" 10 #include "cc/output/compositor_frame_ack.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 363 }
364 ui::Compositor* compositor = client_->GetCompositor(); 364 ui::Compositor* compositor = client_->GetCompositor();
365 if (frame_size.IsEmpty()) { 365 if (frame_size.IsEmpty()) {
366 DCHECK(frame_data->resource_list.empty()); 366 DCHECK(frame_data->resource_list.empty());
367 EvictDelegatedFrame(); 367 EvictDelegatedFrame();
368 } else { 368 } else {
369 if (use_surfaces_) { 369 if (use_surfaces_) {
370 if (!surface_factory_) { 370 if (!surface_factory_) {
371 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 371 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
372 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 372 cc::SurfaceManager* manager = factory->GetSurfaceManager();
373 id_allocator_ = factory->CreateSurfaceIdAllocator(); 373 id_allocator_ =
374 factory->GetContextFactory()->CreateSurfaceIdAllocator();
374 surface_factory_ = 375 surface_factory_ =
375 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); 376 make_scoped_ptr(new cc::SurfaceFactory(manager, this));
376 } 377 }
377 if (surface_id_.is_null() || frame_size != current_surface_size_ || 378 if (surface_id_.is_null() || frame_size != current_surface_size_ ||
378 frame_size_in_dip != current_frame_size_in_dip_) { 379 frame_size_in_dip != current_frame_size_in_dip_) {
379 // TODO(jbauman): Wait to destroy this surface until the parent has 380 if (!surface_id_.is_null()) {
380 // finished using it. 381 if (compositor) {
381 if (!surface_id_.is_null()) 382 std::set<cc::SurfaceSequence> seq;
382 surface_factory_->Destroy(surface_id_); 383 seq.insert(compositor->InsertSurfaceSequenceForNextFrame());
384 // Destruction of this surface needs to wait for compositors that
385 // have drawn using it to swap frames that don't reference it.
386 // TODO(jbauman): Handle cases where the compositor has been
387 // changed since the last draw.
388 surface_factory_->DestroyOnSequence(surface_id_, seq);
389 } else {
390 surface_factory_->Destroy(surface_id_);
391 }
392 }
383 surface_id_ = id_allocator_->GenerateId(); 393 surface_id_ = id_allocator_->GenerateId();
384 surface_factory_->Create(surface_id_, frame_size); 394 surface_factory_->Create(surface_id_, frame_size);
385 client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip); 395 client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip);
386 current_surface_size_ = frame_size; 396 current_surface_size_ = frame_size;
387 } 397 }
388 scoped_ptr<cc::CompositorFrame> compositor_frame = 398 scoped_ptr<cc::CompositorFrame> compositor_frame =
389 make_scoped_ptr(new cc::CompositorFrame()); 399 make_scoped_ptr(new cc::CompositorFrame());
390 compositor_frame->delegated_frame_data = frame_data.Pass(); 400 compositor_frame->delegated_frame_data = frame_data.Pass();
391 401
392 compositor_frame->metadata.latency_info.swap(skipped_latency_info_list_); 402 compositor_frame->metadata.latency_info.swap(skipped_latency_info_list_);
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 if (frame_provider_.get()) { 992 if (frame_provider_.get()) {
983 new_layer->SetShowDelegatedContent(frame_provider_.get(), 993 new_layer->SetShowDelegatedContent(frame_provider_.get(),
984 current_frame_size_in_dip_); 994 current_frame_size_in_dip_);
985 } 995 }
986 if (!surface_id_.is_null()) { 996 if (!surface_id_.is_null()) {
987 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); 997 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_);
988 } 998 }
989 } 999 }
990 1000
991 } // namespace content 1001 } // namespace content
OLDNEW
« no previous file with comments | « cc/surfaces/surface_sequence.h ('k') | content/browser/compositor/gpu_process_transport_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698