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