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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 resource_collection_->SetClient(NULL); | 353 resource_collection_->SetClient(NULL); |
354 | 354 |
355 if (resource_collection_->LoseAllResources()) | 355 if (resource_collection_->LoseAllResources()) |
356 SendReturnedDelegatedResources(last_output_surface_id_); | 356 SendReturnedDelegatedResources(last_output_surface_id_); |
357 | 357 |
358 resource_collection_ = NULL; | 358 resource_collection_ = NULL; |
359 } | 359 } |
360 last_output_surface_id_ = output_surface_id; | 360 last_output_surface_id_ = output_surface_id; |
361 } | 361 } |
362 bool modified_layers = false; | 362 bool modified_layers = false; |
| 363 ui::Compositor* compositor = client_->GetCompositor(); |
363 if (frame_size.IsEmpty()) { | 364 if (frame_size.IsEmpty()) { |
364 DCHECK(frame_data->resource_list.empty()); | 365 DCHECK(frame_data->resource_list.empty()); |
365 EvictDelegatedFrame(); | 366 EvictDelegatedFrame(); |
366 modified_layers = true; | 367 modified_layers = true; |
367 } else { | 368 } else { |
368 if (use_surfaces_) { | 369 if (use_surfaces_) { |
369 if (!surface_factory_) { | 370 if (!surface_factory_) { |
370 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 371 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
371 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 372 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
372 id_allocator_ = factory->CreateSurfaceIdAllocator(); | 373 id_allocator_ = factory->CreateSurfaceIdAllocator(); |
373 surface_factory_ = | 374 surface_factory_ = |
374 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); | 375 make_scoped_ptr(new cc::SurfaceFactory(manager, this)); |
375 } | 376 } |
376 if (surface_id_.is_null() || frame_size != current_surface_size_ || | 377 if (surface_id_.is_null() || frame_size != current_surface_size_ || |
377 frame_size_in_dip != current_frame_size_in_dip_) { | 378 frame_size_in_dip != current_frame_size_in_dip_) { |
378 // TODO(jbauman): Wait to destroy this surface until the parent has | 379 // TODO(jbauman): Wait to destroy this surface until the parent has |
379 // finished using it. | 380 // finished using it. |
380 if (!surface_id_.is_null()) | 381 if (!surface_id_.is_null()) |
381 surface_factory_->Destroy(surface_id_); | 382 surface_factory_->Destroy(surface_id_); |
382 surface_id_ = id_allocator_->GenerateId(); | 383 surface_id_ = id_allocator_->GenerateId(); |
383 surface_factory_->Create(surface_id_, frame_size); | 384 surface_factory_->Create(surface_id_, frame_size); |
384 client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip); | 385 client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip); |
385 current_surface_size_ = frame_size; | 386 current_surface_size_ = frame_size; |
386 modified_layers = true; | 387 modified_layers = true; |
387 } | 388 } |
388 scoped_ptr<cc::CompositorFrame> compositor_frame = | 389 scoped_ptr<cc::CompositorFrame> compositor_frame = |
389 make_scoped_ptr(new cc::CompositorFrame()); | 390 make_scoped_ptr(new cc::CompositorFrame()); |
390 compositor_frame->delegated_frame_data = frame_data.Pass(); | 391 compositor_frame->delegated_frame_data = frame_data.Pass(); |
| 392 base::Closure ack_callback; |
| 393 if (compositor) { |
| 394 ack_callback = base::Bind(&DelegatedFrameHost::SendDelegatedFrameAck, |
| 395 AsWeakPtr(), |
| 396 output_surface_id); |
| 397 } |
391 surface_factory_->SubmitFrame( | 398 surface_factory_->SubmitFrame( |
392 surface_id_, | 399 surface_id_, compositor_frame.Pass(), ack_callback); |
393 compositor_frame.Pass(), | |
394 base::Bind(&DelegatedFrameHost::SendDelegatedFrameAck, | |
395 AsWeakPtr(), | |
396 output_surface_id)); | |
397 } else { | 400 } else { |
398 if (!resource_collection_.get()) { | 401 if (!resource_collection_.get()) { |
399 resource_collection_ = new cc::DelegatedFrameResourceCollection; | 402 resource_collection_ = new cc::DelegatedFrameResourceCollection; |
400 resource_collection_->SetClient(this); | 403 resource_collection_->SetClient(this); |
401 } | 404 } |
402 // If the physical frame size changes, we need a new |frame_provider_|. If | 405 // If the physical frame size changes, we need a new |frame_provider_|. If |
403 // the physical frame size is the same, but the size in DIP changed, we | 406 // the physical frame size is the same, but the size in DIP changed, we |
404 // need to adjust the scale at which the frames will be drawn, and we do | 407 // need to adjust the scale at which the frames will be drawn, and we do |
405 // this by making a new |frame_provider_| also to ensure the scale change | 408 // this by making a new |frame_provider_| also to ensure the scale change |
406 // is presented in sync with the new frame content. | 409 // is presented in sync with the new frame content. |
(...skipping 15 matching lines...) Expand all Loading... |
422 CheckResizeLock(); | 425 CheckResizeLock(); |
423 | 426 |
424 if (modified_layers && !damage_rect_in_dip.IsEmpty()) { | 427 if (modified_layers && !damage_rect_in_dip.IsEmpty()) { |
425 // TODO(jbauman): Need to always tell the window observer about the | 428 // TODO(jbauman): Need to always tell the window observer about the |
426 // damage. | 429 // damage. |
427 client_->GetLayer()->OnDelegatedFrameDamage(damage_rect_in_dip); | 430 client_->GetLayer()->OnDelegatedFrameDamage(damage_rect_in_dip); |
428 } | 431 } |
429 | 432 |
430 pending_delegated_ack_count_++; | 433 pending_delegated_ack_count_++; |
431 | 434 |
432 ui::Compositor* compositor = client_->GetCompositor(); | |
433 if (!compositor) { | 435 if (!compositor) { |
434 SendDelegatedFrameAck(output_surface_id); | 436 SendDelegatedFrameAck(output_surface_id); |
435 } else if (!use_surfaces_) { | 437 } else if (!use_surfaces_) { |
436 std::vector<ui::LatencyInfo>::const_iterator it; | 438 std::vector<ui::LatencyInfo>::const_iterator it; |
437 for (it = latency_info.begin(); it != latency_info.end(); ++it) | 439 for (it = latency_info.begin(); it != latency_info.end(); ++it) |
438 compositor->SetLatencyInfo(*it); | 440 compositor->SetLatencyInfo(*it); |
439 // If we've previously skipped any latency infos add them. | 441 // If we've previously skipped any latency infos add them. |
440 for (it = skipped_latency_info_list_.begin(); | 442 for (it = skipped_latency_info_list_.begin(); |
441 it != skipped_latency_info_list_.end(); | 443 it != skipped_latency_info_list_.end(); |
442 ++it) | 444 ++it) |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 if (frame_provider_.get()) { | 974 if (frame_provider_.get()) { |
973 new_layer->SetShowDelegatedContent(frame_provider_.get(), | 975 new_layer->SetShowDelegatedContent(frame_provider_.get(), |
974 current_frame_size_in_dip_); | 976 current_frame_size_in_dip_); |
975 } | 977 } |
976 if (!surface_id_.is_null()) { | 978 if (!surface_id_.is_null()) { |
977 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); | 979 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); |
978 } | 980 } |
979 } | 981 } |
980 | 982 |
981 } // namespace content | 983 } // namespace content |
OLD | NEW |