| 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/renderer/child_frame_compositing_helper.h" | 5 #include "content/renderer/child_frame_compositing_helper.h" |
| 6 | 6 |
| 7 #include "cc/blink/web_layer_impl.h" | 7 #include "cc/blink/web_layer_impl.h" |
| 8 #include "cc/layers/delegated_frame_provider.h" | 8 #include "cc/layers/delegated_frame_provider.h" |
| 9 #include "cc/layers/delegated_frame_resource_collection.h" | 9 #include "cc/layers/delegated_frame_resource_collection.h" |
| 10 #include "cc/layers/delegated_renderer_layer.h" | 10 #include "cc/layers/delegated_renderer_layer.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } else if (render_frame_proxy_) { | 133 } else if (render_frame_proxy_) { |
| 134 render_frame_proxy_->Send( | 134 render_frame_proxy_->Send( |
| 135 new FrameHostMsg_ReclaimCompositorResources(host_routing_id_, params)); | 135 new FrameHostMsg_ReclaimCompositorResources(host_routing_id_, params)); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 void ChildFrameCompositingHelper::CopyFromCompositingSurface( | 139 void ChildFrameCompositingHelper::CopyFromCompositingSurface( |
| 140 int request_id, | 140 int request_id, |
| 141 gfx::Rect source_rect, | 141 gfx::Rect source_rect, |
| 142 gfx::Size dest_size) { | 142 gfx::Size dest_size) { |
| 143 CHECK(background_layer_); | 143 CHECK(background_layer_.get()); |
| 144 scoped_ptr<cc::CopyOutputRequest> request = | 144 scoped_ptr<cc::CopyOutputRequest> request = |
| 145 cc::CopyOutputRequest::CreateBitmapRequest(base::Bind( | 145 cc::CopyOutputRequest::CreateBitmapRequest(base::Bind( |
| 146 &ChildFrameCompositingHelper::CopyFromCompositingSurfaceHasResult, | 146 &ChildFrameCompositingHelper::CopyFromCompositingSurfaceHasResult, |
| 147 this, | 147 this, |
| 148 request_id, | 148 request_id, |
| 149 dest_size)); | 149 dest_size)); |
| 150 request->set_area(source_rect); | 150 request->set_area(source_rect); |
| 151 background_layer_->RequestCopyOfOutput(request.Pass()); | 151 background_layer_->RequestCopyOfOutput(request.Pass()); |
| 152 } | 152 } |
| 153 | 153 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 269 } |
| 270 case SOFTWARE_COMPOSITOR_FRAME: | 270 case SOFTWARE_COMPOSITOR_FRAME: |
| 271 break; | 271 break; |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 void ChildFrameCompositingHelper::OnContainerDestroy() { | 275 void ChildFrameCompositingHelper::OnContainerDestroy() { |
| 276 if (GetContainer()) | 276 if (GetContainer()) |
| 277 GetContainer()->setWebLayer(NULL); | 277 GetContainer()->setWebLayer(NULL); |
| 278 | 278 |
| 279 if (resource_collection_) | 279 if (resource_collection_.get()) |
| 280 resource_collection_->SetClient(NULL); | 280 resource_collection_->SetClient(NULL); |
| 281 | 281 |
| 282 ack_pending_ = false; | 282 ack_pending_ = false; |
| 283 software_ack_pending_ = false; | 283 software_ack_pending_ = false; |
| 284 resource_collection_ = NULL; | 284 resource_collection_ = NULL; |
| 285 frame_provider_ = NULL; | 285 frame_provider_ = NULL; |
| 286 texture_layer_ = NULL; | 286 texture_layer_ = NULL; |
| 287 delegated_layer_ = NULL; | 287 delegated_layer_ = NULL; |
| 288 background_layer_ = NULL; | 288 background_layer_ = NULL; |
| 289 web_layer_.reset(); | 289 web_layer_.reset(); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 last_route_id_ = route_id; | 441 last_route_id_ = route_id; |
| 442 last_output_surface_id_ = output_surface_id; | 442 last_output_surface_id_ = output_surface_id; |
| 443 last_host_id_ = host_id; | 443 last_host_id_ = host_id; |
| 444 return; | 444 return; |
| 445 } | 445 } |
| 446 | 446 |
| 447 DCHECK(!texture_layer_.get()); | 447 DCHECK(!texture_layer_.get()); |
| 448 | 448 |
| 449 cc::DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); | 449 cc::DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); |
| 450 // Do nothing if we are getting destroyed or have no frame data. | 450 // Do nothing if we are getting destroyed or have no frame data. |
| 451 if (!frame_data || !background_layer_) | 451 if (!frame_data || !background_layer_.get()) |
| 452 return; | 452 return; |
| 453 | 453 |
| 454 DCHECK(!frame_data->render_pass_list.empty()); | 454 DCHECK(!frame_data->render_pass_list.empty()); |
| 455 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); | 455 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); |
| 456 gfx::Size frame_size = root_pass->output_rect.size(); | 456 gfx::Size frame_size = root_pass->output_rect.size(); |
| 457 | 457 |
| 458 if (last_route_id_ != route_id || | 458 if (last_route_id_ != route_id || |
| 459 last_output_surface_id_ != output_surface_id || | 459 last_output_surface_id_ != output_surface_id || |
| 460 last_host_id_ != host_id) { | 460 last_host_id_ != host_id) { |
| 461 // Resource ids are scoped by the output surface. | 461 // Resource ids are scoped by the output surface. |
| 462 // If the originating output surface doesn't match the last one, it | 462 // If the originating output surface doesn't match the last one, it |
| 463 // indicates the guest's output surface may have been recreated, in which | 463 // indicates the guest's output surface may have been recreated, in which |
| 464 // case we should recreate the DelegatedRendererLayer, to avoid matching | 464 // case we should recreate the DelegatedRendererLayer, to avoid matching |
| 465 // resources from the old one with resources from the new one which would | 465 // resources from the old one with resources from the new one which would |
| 466 // have the same id. | 466 // have the same id. |
| 467 frame_provider_ = NULL; | 467 frame_provider_ = NULL; |
| 468 | 468 |
| 469 // Drop the cc::DelegatedFrameResourceCollection so that we will not return | 469 // Drop the cc::DelegatedFrameResourceCollection so that we will not return |
| 470 // any resources from the old output surface with the new output surface id. | 470 // any resources from the old output surface with the new output surface id. |
| 471 if (resource_collection_) { | 471 if (resource_collection_.get()) { |
| 472 resource_collection_->SetClient(NULL); | 472 resource_collection_->SetClient(NULL); |
| 473 | 473 |
| 474 if (resource_collection_->LoseAllResources()) | 474 if (resource_collection_->LoseAllResources()) |
| 475 SendReturnedDelegatedResources(); | 475 SendReturnedDelegatedResources(); |
| 476 resource_collection_ = NULL; | 476 resource_collection_ = NULL; |
| 477 } | 477 } |
| 478 last_output_surface_id_ = output_surface_id; | 478 last_output_surface_id_ = output_surface_id; |
| 479 last_route_id_ = route_id; | 479 last_route_id_ = route_id; |
| 480 last_host_id_ = host_id; | 480 last_host_id_ = host_id; |
| 481 } | 481 } |
| 482 if (!resource_collection_) { | 482 if (!resource_collection_.get()) { |
| 483 resource_collection_ = new cc::DelegatedFrameResourceCollection; | 483 resource_collection_ = new cc::DelegatedFrameResourceCollection; |
| 484 resource_collection_->SetClient(this); | 484 resource_collection_->SetClient(this); |
| 485 } | 485 } |
| 486 if (!frame_provider_.get() || frame_provider_->frame_size() != frame_size) { | 486 if (!frame_provider_.get() || frame_provider_->frame_size() != frame_size) { |
| 487 frame_provider_ = new cc::DelegatedFrameProvider( | 487 frame_provider_ = new cc::DelegatedFrameProvider( |
| 488 resource_collection_.get(), frame->delegated_frame_data.Pass()); | 488 resource_collection_.get(), frame->delegated_frame_data.Pass()); |
| 489 if (delegated_layer_.get()) | 489 if (delegated_layer_.get()) |
| 490 delegated_layer_->RemoveFromParent(); | 490 delegated_layer_->RemoveFromParent(); |
| 491 delegated_layer_ = | 491 delegated_layer_ = |
| 492 cc::DelegatedRendererLayer::Create(frame_provider_.get()); | 492 cc::DelegatedRendererLayer::Create(frame_provider_.get()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 514 | 514 |
| 515 void ChildFrameCompositingHelper::UnusedResourcesAreAvailable() { | 515 void ChildFrameCompositingHelper::UnusedResourcesAreAvailable() { |
| 516 if (ack_pending_) | 516 if (ack_pending_) |
| 517 return; | 517 return; |
| 518 | 518 |
| 519 SendReturnedDelegatedResources(); | 519 SendReturnedDelegatedResources(); |
| 520 } | 520 } |
| 521 | 521 |
| 522 void ChildFrameCompositingHelper::SendReturnedDelegatedResources() { | 522 void ChildFrameCompositingHelper::SendReturnedDelegatedResources() { |
| 523 FrameHostMsg_ReclaimCompositorResources_Params params; | 523 FrameHostMsg_ReclaimCompositorResources_Params params; |
| 524 if (resource_collection_) | 524 if (resource_collection_.get()) |
| 525 resource_collection_->TakeUnusedResourcesForChildCompositor( | 525 resource_collection_->TakeUnusedResourcesForChildCompositor( |
| 526 ¶ms.ack.resources); | 526 ¶ms.ack.resources); |
| 527 DCHECK(!params.ack.resources.empty()); | 527 DCHECK(!params.ack.resources.empty()); |
| 528 | 528 |
| 529 params.route_id = last_route_id_; | 529 params.route_id = last_route_id_; |
| 530 params.output_surface_id = last_output_surface_id_; | 530 params.output_surface_id = last_output_surface_id_; |
| 531 params.renderer_host_id = last_host_id_; | 531 params.renderer_host_id = last_host_id_; |
| 532 SendReclaimCompositorResourcesToBrowser(params); | 532 SendReclaimCompositorResourcesToBrowser(params); |
| 533 } | 533 } |
| 534 | 534 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 558 dest_size.height()); | 558 dest_size.height()); |
| 559 } | 559 } |
| 560 if (GetBrowserPluginManager()) { | 560 if (GetBrowserPluginManager()) { |
| 561 GetBrowserPluginManager()->Send( | 561 GetBrowserPluginManager()->Send( |
| 562 new BrowserPluginHostMsg_CopyFromCompositingSurfaceAck( | 562 new BrowserPluginHostMsg_CopyFromCompositingSurfaceAck( |
| 563 host_routing_id_, GetInstanceID(), request_id, resized_bitmap)); | 563 host_routing_id_, GetInstanceID(), request_id, resized_bitmap)); |
| 564 } | 564 } |
| 565 } | 565 } |
| 566 | 566 |
| 567 } // namespace content | 567 } // namespace content |
| OLD | NEW |