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/frame_host/render_widget_host_view_child_frame.h" | 5 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 ack.resources.swap(surface_returned_resources_); | 360 ack.resources.swap(surface_returned_resources_); |
361 if (host_) { | 361 if (host_) { |
362 host_->Send(new ViewMsg_SwapCompositorFrameAck(host_->GetRoutingID(), | 362 host_->Send(new ViewMsg_SwapCompositorFrameAck(host_->GetRoutingID(), |
363 output_surface_id, ack)); | 363 output_surface_id, ack)); |
364 } | 364 } |
365 ack_pending_count_--; | 365 ack_pending_count_--; |
366 } | 366 } |
367 | 367 |
368 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame( | 368 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame( |
369 uint32_t output_surface_id, | 369 uint32_t output_surface_id, |
370 std::unique_ptr<cc::CompositorFrame> frame) { | 370 cc::CompositorFrame frame) { |
371 TRACE_EVENT0("content", | 371 TRACE_EVENT0("content", |
372 "RenderWidgetHostViewChildFrame::OnSwapCompositorFrame"); | 372 "RenderWidgetHostViewChildFrame::OnSwapCompositorFrame"); |
373 | 373 |
374 last_scroll_offset_ = frame->metadata.root_scroll_offset; | 374 last_scroll_offset_ = frame.metadata.root_scroll_offset; |
375 | 375 |
376 if (!frame_connector_) | 376 if (!frame_connector_) |
377 return; | 377 return; |
378 | 378 |
379 cc::RenderPass* root_pass = | 379 cc::RenderPass* root_pass = |
380 frame->delegated_frame_data->render_pass_list.back().get(); | 380 frame.delegated_frame_data->render_pass_list.back().get(); |
381 | 381 |
382 gfx::Size frame_size = root_pass->output_rect.size(); | 382 gfx::Size frame_size = root_pass->output_rect.size(); |
383 float scale_factor = frame->metadata.device_scale_factor; | 383 float scale_factor = frame.metadata.device_scale_factor; |
384 | 384 |
385 // Check whether we need to recreate the cc::Surface, which means the child | 385 // Check whether we need to recreate the cc::Surface, which means the child |
386 // frame renderer has changed its output surface, or size, or scale factor. | 386 // frame renderer has changed its output surface, or size, or scale factor. |
387 if (output_surface_id != last_output_surface_id_ && surface_factory_) { | 387 if (output_surface_id != last_output_surface_id_ && surface_factory_) { |
388 surface_factory_->Destroy(surface_id_); | 388 surface_factory_->Destroy(surface_id_); |
389 surface_factory_.reset(); | 389 surface_factory_.reset(); |
390 } | 390 } |
391 if (output_surface_id != last_output_surface_id_ || | 391 if (output_surface_id != last_output_surface_id_ || |
392 frame_size != current_surface_size_ || | 392 frame_size != current_surface_size_ || |
393 scale_factor != current_surface_scale_factor_) { | 393 scale_factor != current_surface_scale_factor_) { |
(...skipping 21 matching lines...) Expand all Loading... |
415 frame_connector_->SetChildFrameSurface(surface_id_, frame_size, | 415 frame_connector_->SetChildFrameSurface(surface_id_, frame_size, |
416 scale_factor, sequence); | 416 scale_factor, sequence); |
417 } | 417 } |
418 | 418 |
419 cc::SurfaceFactory::DrawCallback ack_callback = | 419 cc::SurfaceFactory::DrawCallback ack_callback = |
420 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(), | 420 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(), |
421 output_surface_id); | 421 output_surface_id); |
422 ack_pending_count_++; | 422 ack_pending_count_++; |
423 // If this value grows very large, something is going wrong. | 423 // If this value grows very large, something is going wrong. |
424 DCHECK_LT(ack_pending_count_, 1000U); | 424 DCHECK_LT(ack_pending_count_, 1000U); |
425 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), | 425 std::unique_ptr<cc::CompositorFrame> frame_copy(new cc::CompositorFrame); |
| 426 *frame_copy = std::move(frame); |
| 427 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame_copy), |
426 ack_callback); | 428 ack_callback); |
427 | 429 |
428 ProcessFrameSwappedCallbacks(); | 430 ProcessFrameSwappedCallbacks(); |
429 } | 431 } |
430 | 432 |
431 void RenderWidgetHostViewChildFrame::ProcessFrameSwappedCallbacks() { | 433 void RenderWidgetHostViewChildFrame::ProcessFrameSwappedCallbacks() { |
432 // We only use callbacks once, therefore we make a new list for registration | 434 // We only use callbacks once, therefore we make a new list for registration |
433 // before we start, and discard the old list entries when we are done. | 435 // before we start, and discard the old list entries when we are done. |
434 FrameSwappedCallbackList process_callbacks; | 436 FrameSwappedCallbackList process_callbacks; |
435 process_callbacks.swap(frame_swapped_callbacks_); | 437 process_callbacks.swap(frame_swapped_callbacks_); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 | 694 |
693 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { | 695 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { |
694 return true; | 696 return true; |
695 } | 697 } |
696 | 698 |
697 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { | 699 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { |
698 return surface_id_; | 700 return surface_id_; |
699 }; | 701 }; |
700 | 702 |
701 } // namespace content | 703 } // namespace content |
OLD | NEW |