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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 if (resource_collection_.get()) { | 354 if (resource_collection_.get()) { |
355 resource_collection_->SetClient(NULL); | 355 resource_collection_->SetClient(NULL); |
356 | 356 |
357 if (resource_collection_->LoseAllResources()) | 357 if (resource_collection_->LoseAllResources()) |
358 SendReturnedDelegatedResources(last_output_surface_id_); | 358 SendReturnedDelegatedResources(last_output_surface_id_); |
359 | 359 |
360 resource_collection_ = NULL; | 360 resource_collection_ = NULL; |
361 } | 361 } |
362 last_output_surface_id_ = output_surface_id; | 362 last_output_surface_id_ = output_surface_id; |
363 } | 363 } |
364 bool modified_layers = false; | |
365 ui::Compositor* compositor = client_->GetCompositor(); | 364 ui::Compositor* compositor = client_->GetCompositor(); |
366 if (frame_size.IsEmpty()) { | 365 if (frame_size.IsEmpty()) { |
367 DCHECK(frame_data->resource_list.empty()); | 366 DCHECK(frame_data->resource_list.empty()); |
368 EvictDelegatedFrame(); | 367 EvictDelegatedFrame(); |
369 modified_layers = true; | |
370 } else { | 368 } else { |
371 if (use_surfaces_) { | 369 if (use_surfaces_) { |
372 if (!surface_factory_) { | 370 if (!surface_factory_) { |
373 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 371 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
374 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 372 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
375 id_allocator_ = factory->CreateSurfaceIdAllocator(); | 373 id_allocator_ = factory->CreateSurfaceIdAllocator(); |
376 surface_factory_ = | 374 surface_factory_ = |
377 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); | 375 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); |
378 } | 376 } |
379 if (surface_id_.is_null() || frame_size != current_surface_size_ || | 377 if (surface_id_.is_null() || frame_size != current_surface_size_ || |
380 frame_size_in_dip != current_frame_size_in_dip_) { | 378 frame_size_in_dip != current_frame_size_in_dip_) { |
381 // TODO(jbauman): Wait to destroy this surface until the parent has | 379 // TODO(jbauman): Wait to destroy this surface until the parent has |
382 // finished using it. | 380 // finished using it. |
383 if (!surface_id_.is_null()) | 381 if (!surface_id_.is_null()) |
384 surface_factory_->Destroy(surface_id_); | 382 surface_factory_->Destroy(surface_id_); |
385 surface_id_ = id_allocator_->GenerateId(); | 383 surface_id_ = id_allocator_->GenerateId(); |
386 surface_factory_->Create(surface_id_, frame_size); | 384 surface_factory_->Create(surface_id_, frame_size); |
387 client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip); | 385 client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip); |
388 current_surface_size_ = frame_size; | 386 current_surface_size_ = frame_size; |
389 modified_layers = true; | |
390 } | 387 } |
391 scoped_ptr<cc::CompositorFrame> compositor_frame = | 388 scoped_ptr<cc::CompositorFrame> compositor_frame = |
392 make_scoped_ptr(new cc::CompositorFrame()); | 389 make_scoped_ptr(new cc::CompositorFrame()); |
393 compositor_frame->delegated_frame_data = frame_data.Pass(); | 390 compositor_frame->delegated_frame_data = frame_data.Pass(); |
394 | 391 |
395 compositor_frame->metadata.latency_info.swap(skipped_latency_info_list_); | 392 compositor_frame->metadata.latency_info.swap(skipped_latency_info_list_); |
396 compositor_frame->metadata.latency_info.insert( | 393 compositor_frame->metadata.latency_info.insert( |
397 compositor_frame->metadata.latency_info.end(), | 394 compositor_frame->metadata.latency_info.end(), |
398 latency_info.begin(), | 395 latency_info.begin(), |
399 latency_info.end()); | 396 latency_info.end()); |
(...skipping 19 matching lines...) Expand all Loading... |
419 if (!frame_provider_.get() || | 416 if (!frame_provider_.get() || |
420 frame_size != frame_provider_->frame_size() || | 417 frame_size != frame_provider_->frame_size() || |
421 frame_size_in_dip != current_frame_size_in_dip_) { | 418 frame_size_in_dip != current_frame_size_in_dip_) { |
422 frame_provider_ = new cc::DelegatedFrameProvider( | 419 frame_provider_ = new cc::DelegatedFrameProvider( |
423 resource_collection_.get(), frame_data.Pass()); | 420 resource_collection_.get(), frame_data.Pass()); |
424 client_->GetLayer()->SetShowDelegatedContent(frame_provider_.get(), | 421 client_->GetLayer()->SetShowDelegatedContent(frame_provider_.get(), |
425 frame_size_in_dip); | 422 frame_size_in_dip); |
426 } else { | 423 } else { |
427 frame_provider_->SetFrameData(frame_data.Pass()); | 424 frame_provider_->SetFrameData(frame_data.Pass()); |
428 } | 425 } |
429 modified_layers = true; | |
430 } | 426 } |
431 } | 427 } |
432 released_front_lock_ = NULL; | 428 released_front_lock_ = NULL; |
433 current_frame_size_in_dip_ = frame_size_in_dip; | 429 current_frame_size_in_dip_ = frame_size_in_dip; |
434 CheckResizeLock(); | 430 CheckResizeLock(); |
435 | 431 |
436 if (!damage_rect_in_dip.IsEmpty()) | 432 if (!damage_rect_in_dip.IsEmpty()) |
437 client_->GetLayer()->OnDelegatedFrameDamage(damage_rect_in_dip); | 433 client_->GetLayer()->OnDelegatedFrameDamage(damage_rect_in_dip); |
438 | 434 |
439 pending_delegated_ack_count_++; | 435 pending_delegated_ack_count_++; |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 if (frame_provider_.get()) { | 982 if (frame_provider_.get()) { |
987 new_layer->SetShowDelegatedContent(frame_provider_.get(), | 983 new_layer->SetShowDelegatedContent(frame_provider_.get(), |
988 current_frame_size_in_dip_); | 984 current_frame_size_in_dip_); |
989 } | 985 } |
990 if (!surface_id_.is_null()) { | 986 if (!surface_id_.is_null()) { |
991 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); | 987 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); |
992 } | 988 } |
993 } | 989 } |
994 | 990 |
995 } // namespace content | 991 } // namespace content |
OLD | NEW |