OLD | NEW |
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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 ui::Compositor* compositor = client_->GetCompositor(); | 365 ui::Compositor* compositor = client_->GetCompositor(); |
366 if (frame_size.IsEmpty()) { | 366 if (frame_size.IsEmpty()) { |
367 DCHECK(frame_data->resource_list.empty()); | 367 DCHECK(frame_data->resource_list.empty()); |
368 EvictDelegatedFrame(); | 368 EvictDelegatedFrame(); |
369 modified_layers = true; | 369 modified_layers = true; |
370 } else { | 370 } else { |
371 if (use_surfaces_) { | 371 if (use_surfaces_) { |
372 if (!surface_factory_) { | 372 if (!surface_factory_) { |
373 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 373 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
374 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 374 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
375 id_allocator_ = factory->CreateSurfaceIdAllocator(); | 375 id_allocator_ = |
| 376 factory->GetContextFactory()->CreateSurfaceIdAllocator(); |
376 surface_factory_ = | 377 surface_factory_ = |
377 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); | 378 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); |
378 } | 379 } |
379 if (surface_id_.is_null() || frame_size != current_surface_size_ || | 380 if (surface_id_.is_null() || frame_size != current_surface_size_ || |
380 frame_size_in_dip != current_frame_size_in_dip_) { | 381 frame_size_in_dip != current_frame_size_in_dip_) { |
381 // TODO(jbauman): Wait to destroy this surface until the parent has | 382 if (!surface_id_.is_null()) { |
382 // finished using it. | 383 if (compositor) { |
383 if (!surface_id_.is_null()) | 384 std::set<cc::SurfaceSequence> seq; |
384 surface_factory_->Destroy(surface_id_); | 385 seq.insert(compositor->CreateSurfaceSequence()); |
| 386 surface_factory_->DestroyOnSequence(surface_id_, seq); |
| 387 } else { |
| 388 surface_factory_->Destroy(surface_id_); |
| 389 } |
| 390 } |
385 surface_id_ = id_allocator_->GenerateId(); | 391 surface_id_ = id_allocator_->GenerateId(); |
386 surface_factory_->Create(surface_id_, frame_size); | 392 surface_factory_->Create(surface_id_, frame_size); |
387 client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip); | 393 client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip); |
388 current_surface_size_ = frame_size; | 394 current_surface_size_ = frame_size; |
389 modified_layers = true; | 395 modified_layers = true; |
390 } | 396 } |
391 scoped_ptr<cc::CompositorFrame> compositor_frame = | 397 scoped_ptr<cc::CompositorFrame> compositor_frame = |
392 make_scoped_ptr(new cc::CompositorFrame()); | 398 make_scoped_ptr(new cc::CompositorFrame()); |
393 compositor_frame->delegated_frame_data = frame_data.Pass(); | 399 compositor_frame->delegated_frame_data = frame_data.Pass(); |
394 base::Closure ack_callback; | 400 base::Closure ack_callback; |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 if (frame_provider_.get()) { | 985 if (frame_provider_.get()) { |
980 new_layer->SetShowDelegatedContent(frame_provider_.get(), | 986 new_layer->SetShowDelegatedContent(frame_provider_.get(), |
981 current_frame_size_in_dip_); | 987 current_frame_size_in_dip_); |
982 } | 988 } |
983 if (!surface_id_.is_null()) { | 989 if (!surface_id_.is_null()) { |
984 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); | 990 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); |
985 } | 991 } |
986 } | 992 } |
987 | 993 |
988 } // namespace content | 994 } // namespace content |
OLD | NEW |