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 "base/time/default_tick_clock.h" | 9 #include "base/time/default_tick_clock.h" |
10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 if (resource_collection_.get()) { | 369 if (resource_collection_.get()) { |
370 resource_collection_->SetClient(NULL); | 370 resource_collection_->SetClient(NULL); |
371 | 371 |
372 if (resource_collection_->LoseAllResources()) | 372 if (resource_collection_->LoseAllResources()) |
373 SendReturnedDelegatedResources(last_output_surface_id_); | 373 SendReturnedDelegatedResources(last_output_surface_id_); |
374 | 374 |
375 resource_collection_ = NULL; | 375 resource_collection_ = NULL; |
376 } | 376 } |
377 last_output_surface_id_ = output_surface_id; | 377 last_output_surface_id_ = output_surface_id; |
378 } | 378 } |
379 bool immediate_ack = !compositor_; | 379 bool skip_frame_size_mismatch = false; |
380 pending_delegated_ack_count_++; | 380 pending_delegated_ack_count_++; |
381 | 381 |
382 if (frame_size.IsEmpty()) { | 382 if (frame_size.IsEmpty()) { |
383 DCHECK(frame_data->resource_list.empty()); | 383 DCHECK(frame_data->resource_list.empty()); |
384 EvictDelegatedFrame(); | 384 EvictDelegatedFrame(); |
385 } else { | 385 } else { |
386 if (use_surfaces_) { | 386 if (use_surfaces_) { |
387 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 387 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
388 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 388 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
389 if (!surface_factory_) { | 389 if (!surface_factory_) { |
(...skipping 21 matching lines...) Expand all Loading... |
411 | 411 |
412 compositor_frame->metadata.latency_info.swap(skipped_latency_info_list_); | 412 compositor_frame->metadata.latency_info.swap(skipped_latency_info_list_); |
413 compositor_frame->metadata.latency_info.insert( | 413 compositor_frame->metadata.latency_info.insert( |
414 compositor_frame->metadata.latency_info.end(), | 414 compositor_frame->metadata.latency_info.end(), |
415 latency_info.begin(), | 415 latency_info.begin(), |
416 latency_info.end()); | 416 latency_info.end()); |
417 compositor_frame->metadata.satisfies_sequences.swap(*satisfies_sequences); | 417 compositor_frame->metadata.satisfies_sequences.swap(*satisfies_sequences); |
418 | 418 |
419 gfx::Size desired_size = client_->DelegatedFrameHostDesiredSizeInDIP(); | 419 gfx::Size desired_size = client_->DelegatedFrameHostDesiredSizeInDIP(); |
420 if (desired_size != frame_size_in_dip && !desired_size.IsEmpty()) | 420 if (desired_size != frame_size_in_dip && !desired_size.IsEmpty()) |
421 immediate_ack = true; | 421 skip_frame_size_mismatch = true; |
422 | 422 |
423 cc::SurfaceFactory::DrawCallback ack_callback; | 423 cc::SurfaceFactory::DrawCallback ack_callback; |
424 if (compositor_ && !immediate_ack) { | 424 if (compositor_ && !skip_frame_size_mismatch) { |
425 ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, | 425 ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, |
426 AsWeakPtr(), output_surface_id); | 426 AsWeakPtr(), output_surface_id); |
427 } | 427 } |
428 surface_factory_->SubmitCompositorFrame( | 428 surface_factory_->SubmitCompositorFrame( |
429 surface_id_, compositor_frame.Pass(), ack_callback); | 429 surface_id_, compositor_frame.Pass(), ack_callback); |
430 } else { | 430 } else { |
431 if (!resource_collection_.get()) { | 431 if (!resource_collection_.get()) { |
432 resource_collection_ = new cc::DelegatedFrameResourceCollection; | 432 resource_collection_ = new cc::DelegatedFrameResourceCollection; |
433 resource_collection_->SetClient(this); | 433 resource_collection_->SetClient(this); |
434 } | 434 } |
(...skipping 15 matching lines...) Expand all Loading... |
450 } | 450 } |
451 } | 451 } |
452 released_front_lock_ = NULL; | 452 released_front_lock_ = NULL; |
453 current_frame_size_in_dip_ = frame_size_in_dip; | 453 current_frame_size_in_dip_ = frame_size_in_dip; |
454 CheckResizeLock(); | 454 CheckResizeLock(); |
455 | 455 |
456 if (!damage_rect_in_dip.IsEmpty()) | 456 if (!damage_rect_in_dip.IsEmpty()) |
457 client_->DelegatedFrameHostGetLayer()->OnDelegatedFrameDamage( | 457 client_->DelegatedFrameHostGetLayer()->OnDelegatedFrameDamage( |
458 damage_rect_in_dip); | 458 damage_rect_in_dip); |
459 | 459 |
460 if (immediate_ack) { | 460 // Note that |compositor_| may be reset by SetShowSurface or |
| 461 // SetShowDelegatedContent above. |
| 462 if (!compositor_ || skip_frame_size_mismatch) { |
461 SendDelegatedFrameAck(output_surface_id); | 463 SendDelegatedFrameAck(output_surface_id); |
462 } else if (!use_surfaces_) { | 464 } else if (!use_surfaces_) { |
463 std::vector<ui::LatencyInfo>::const_iterator it; | 465 std::vector<ui::LatencyInfo>::const_iterator it; |
464 for (it = latency_info.begin(); it != latency_info.end(); ++it) | 466 for (it = latency_info.begin(); it != latency_info.end(); ++it) |
465 compositor_->SetLatencyInfo(*it); | 467 compositor_->SetLatencyInfo(*it); |
466 // If we've previously skipped any latency infos add them. | 468 // If we've previously skipped any latency infos add them. |
467 for (it = skipped_latency_info_list_.begin(); | 469 for (it = skipped_latency_info_list_.begin(); |
468 it != skipped_latency_info_list_.end(); | 470 it != skipped_latency_info_list_.end(); |
469 ++it) | 471 ++it) |
470 compositor_->SetLatencyInfo(*it); | 472 compositor_->SetLatencyInfo(*it); |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 1046 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
1045 new_layer->SetShowSurface( | 1047 new_layer->SetShowSurface( |
1046 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 1048 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
1047 base::Bind(&RequireCallback, base::Unretained(manager)), | 1049 base::Bind(&RequireCallback, base::Unretained(manager)), |
1048 current_surface_size_, current_scale_factor_, | 1050 current_surface_size_, current_scale_factor_, |
1049 current_frame_size_in_dip_); | 1051 current_frame_size_in_dip_); |
1050 } | 1052 } |
1051 } | 1053 } |
1052 | 1054 |
1053 } // namespace content | 1055 } // namespace content |
OLD | NEW |