| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 if (resource_collection_.get()) { | 336 if (resource_collection_.get()) { |
| 337 resource_collection_->SetClient(NULL); | 337 resource_collection_->SetClient(NULL); |
| 338 | 338 |
| 339 if (resource_collection_->LoseAllResources()) | 339 if (resource_collection_->LoseAllResources()) |
| 340 SendReturnedDelegatedResources(last_output_surface_id_); | 340 SendReturnedDelegatedResources(last_output_surface_id_); |
| 341 | 341 |
| 342 resource_collection_ = NULL; | 342 resource_collection_ = NULL; |
| 343 } | 343 } |
| 344 last_output_surface_id_ = output_surface_id; | 344 last_output_surface_id_ = output_surface_id; |
| 345 } | 345 } |
| 346 bool modified_layers = false; |
| 346 if (frame_size.IsEmpty()) { | 347 if (frame_size.IsEmpty()) { |
| 347 DCHECK(frame_data->resource_list.empty()); | 348 DCHECK(frame_data->resource_list.empty()); |
| 348 EvictDelegatedFrame(); | 349 EvictDelegatedFrame(); |
| 350 modified_layers = true; |
| 349 } else { | 351 } else { |
| 350 if (use_surfaces_) { | 352 if (use_surfaces_) { |
| 351 if (!surface_factory_) { | 353 if (!surface_factory_) { |
| 352 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 354 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 353 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 355 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 354 id_allocator_ = factory->CreateSurfaceIdAllocator(); | 356 id_allocator_ = factory->CreateSurfaceIdAllocator(); |
| 355 surface_factory_ = | 357 surface_factory_ = |
| 356 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); | 358 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); |
| 357 } | 359 } |
| 358 if (surface_id_.is_null() || frame_size != current_surface_size_ || | 360 if (surface_id_.is_null() || frame_size != current_surface_size_ || |
| 359 frame_size_in_dip != current_frame_size_in_dip_) { | 361 frame_size_in_dip != current_frame_size_in_dip_) { |
| 362 // TODO(jbauman): Wait to destroy this surface until the parent has |
| 363 // finished using it. |
| 360 if (!surface_id_.is_null()) | 364 if (!surface_id_.is_null()) |
| 361 surface_factory_->Destroy(surface_id_); | 365 surface_factory_->Destroy(surface_id_); |
| 362 surface_id_ = id_allocator_->GenerateId(); | 366 surface_id_ = id_allocator_->GenerateId(); |
| 363 surface_factory_->Create(surface_id_, frame_size); | 367 surface_factory_->Create(surface_id_, frame_size); |
| 364 client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip); | 368 client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip); |
| 365 current_surface_size_ = frame_size; | 369 current_surface_size_ = frame_size; |
| 370 modified_layers = true; |
| 366 } | 371 } |
| 367 scoped_ptr<cc::CompositorFrame> compositor_frame = | 372 scoped_ptr<cc::CompositorFrame> compositor_frame = |
| 368 make_scoped_ptr(new cc::CompositorFrame()); | 373 make_scoped_ptr(new cc::CompositorFrame()); |
| 369 compositor_frame->delegated_frame_data = frame_data.Pass(); | 374 compositor_frame->delegated_frame_data = frame_data.Pass(); |
| 370 surface_factory_->SubmitFrame(surface_id_, compositor_frame.Pass()); | 375 surface_factory_->SubmitFrame(surface_id_, compositor_frame.Pass()); |
| 371 } else { | 376 } else { |
| 372 if (!resource_collection_) { | 377 if (!resource_collection_) { |
| 373 resource_collection_ = new cc::DelegatedFrameResourceCollection; | 378 resource_collection_ = new cc::DelegatedFrameResourceCollection; |
| 374 resource_collection_->SetClient(this); | 379 resource_collection_->SetClient(this); |
| 375 } | 380 } |
| 376 // If the physical frame size changes, we need a new |frame_provider_|. If | 381 // If the physical frame size changes, we need a new |frame_provider_|. If |
| 377 // the physical frame size is the same, but the size in DIP changed, we | 382 // the physical frame size is the same, but the size in DIP changed, we |
| 378 // need to adjust the scale at which the frames will be drawn, and we do | 383 // need to adjust the scale at which the frames will be drawn, and we do |
| 379 // this by making a new |frame_provider_| also to ensure the scale change | 384 // this by making a new |frame_provider_| also to ensure the scale change |
| 380 // is presented in sync with the new frame content. | 385 // is presented in sync with the new frame content. |
| 381 if (!frame_provider_.get() || | 386 if (!frame_provider_.get() || |
| 382 frame_size != frame_provider_->frame_size() || | 387 frame_size != frame_provider_->frame_size() || |
| 383 frame_size_in_dip != current_frame_size_in_dip_) { | 388 frame_size_in_dip != current_frame_size_in_dip_) { |
| 384 frame_provider_ = new cc::DelegatedFrameProvider( | 389 frame_provider_ = new cc::DelegatedFrameProvider( |
| 385 resource_collection_.get(), frame_data.Pass()); | 390 resource_collection_.get(), frame_data.Pass()); |
| 386 client_->GetLayer()->SetShowDelegatedContent(frame_provider_.get(), | 391 client_->GetLayer()->SetShowDelegatedContent(frame_provider_.get(), |
| 387 frame_size_in_dip); | 392 frame_size_in_dip); |
| 388 } else { | 393 } else { |
| 389 frame_provider_->SetFrameData(frame_data.Pass()); | 394 frame_provider_->SetFrameData(frame_data.Pass()); |
| 390 } | 395 } |
| 396 modified_layers = true; |
| 391 } | 397 } |
| 392 } | 398 } |
| 393 released_front_lock_ = NULL; | 399 released_front_lock_ = NULL; |
| 394 current_frame_size_in_dip_ = frame_size_in_dip; | 400 current_frame_size_in_dip_ = frame_size_in_dip; |
| 395 CheckResizeLock(); | 401 CheckResizeLock(); |
| 396 | 402 |
| 397 client_->SchedulePaintInRect(damage_rect_in_dip); | 403 if (modified_layers) { |
| 404 // TODO(jbauman): Need to always tell the window observer about the |
| 405 // damage. |
| 406 client_->SchedulePaintInRect(damage_rect_in_dip); |
| 407 } |
| 398 | 408 |
| 399 pending_delegated_ack_count_++; | 409 pending_delegated_ack_count_++; |
| 400 | 410 |
| 401 ui::Compositor* compositor = client_->GetCompositor(); | 411 ui::Compositor* compositor = client_->GetCompositor(); |
| 402 if (!compositor) { | 412 if (!compositor || !modified_layers) { |
| 403 SendDelegatedFrameAck(output_surface_id); | 413 SendDelegatedFrameAck(output_surface_id); |
| 404 } else { | 414 } else { |
| 405 std::vector<ui::LatencyInfo>::const_iterator it; | 415 std::vector<ui::LatencyInfo>::const_iterator it; |
| 406 for (it = latency_info.begin(); it != latency_info.end(); ++it) | 416 for (it = latency_info.begin(); it != latency_info.end(); ++it) |
| 407 compositor->SetLatencyInfo(*it); | 417 compositor->SetLatencyInfo(*it); |
| 408 // If we've previously skipped any latency infos add them. | 418 // If we've previously skipped any latency infos add them. |
| 409 for (it = skipped_latency_info_list_.begin(); | 419 for (it = skipped_latency_info_list_.begin(); |
| 410 it != skipped_latency_info_list_.end(); | 420 it != skipped_latency_info_list_.end(); |
| 411 ++it) | 421 ++it) |
| 412 compositor->SetLatencyInfo(*it); | 422 compositor->SetLatencyInfo(*it); |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 if (frame_provider_.get()) { | 918 if (frame_provider_.get()) { |
| 909 new_layer->SetShowDelegatedContent(frame_provider_.get(), | 919 new_layer->SetShowDelegatedContent(frame_provider_.get(), |
| 910 current_frame_size_in_dip_); | 920 current_frame_size_in_dip_); |
| 911 } | 921 } |
| 912 if (!surface_id_.is_null()) { | 922 if (!surface_id_.is_null()) { |
| 913 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); | 923 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); |
| 914 } | 924 } |
| 915 } | 925 } |
| 916 | 926 |
| 917 } // namespace content | 927 } // namespace content |
| OLD | NEW |