| 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/renderer_host/delegated_frame_host.h" | 5 #include "content/browser/renderer_host/delegated_frame_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 373 |
| 374 // To avoid unnecessary browser composites, try to go directly to the Surface | 374 // To avoid unnecessary browser composites, try to go directly to the Surface |
| 375 // rather than through the Layer (which goes through the browser compositor). | 375 // rather than through the Layer (which goes through the browser compositor). |
| 376 if (has_frame_ && request_copy_of_output_callback_for_testing_.is_null()) { | 376 if (has_frame_ && request_copy_of_output_callback_for_testing_.is_null()) { |
| 377 support_->RequestCopyOfSurface(std::move(request)); | 377 support_->RequestCopyOfSurface(std::move(request)); |
| 378 } else { | 378 } else { |
| 379 RequestCopyOfOutput(std::move(request)); | 379 RequestCopyOfOutput(std::move(request)); |
| 380 } | 380 } |
| 381 } | 381 } |
| 382 | 382 |
| 383 void DelegatedFrameHost::DidCreateNewRendererCompositorFrameSink( | 383 void DelegatedFrameHost::DidCreateNewRendererCompositorFrameSink() { |
| 384 cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink) { | |
| 385 ResetCompositorFrameSinkSupport(); | 384 ResetCompositorFrameSinkSupport(); |
| 386 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink; | |
| 387 CreateCompositorFrameSinkSupport(); | 385 CreateCompositorFrameSinkSupport(); |
| 388 has_frame_ = false; | 386 has_frame_ = false; |
| 389 } | 387 } |
| 390 | 388 |
| 391 void DelegatedFrameHost::SubmitCompositorFrame( | 389 void DelegatedFrameHost::SubmitCompositorFrame( |
| 392 const cc::LocalSurfaceId& local_surface_id, | 390 const cc::LocalSurfaceId& local_surface_id, |
| 393 cc::CompositorFrame frame) { | 391 cc::CompositorFrame frame) { |
| 394 #if defined(OS_CHROMEOS) | 392 #if defined(OS_CHROMEOS) |
| 395 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled()); | 393 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled()); |
| 396 #endif | 394 #endif |
| (...skipping 14 matching lines...) Expand all Loading... |
| 411 gfx::ConvertRectToDIP(frame_device_scale_factor, damage_rect); | 409 gfx::ConvertRectToDIP(frame_device_scale_factor, damage_rect); |
| 412 | 410 |
| 413 if (ShouldSkipFrame(frame_size_in_dip)) { | 411 if (ShouldSkipFrame(frame_size_in_dip)) { |
| 414 cc::ReturnedResourceArray resources; | 412 cc::ReturnedResourceArray resources; |
| 415 cc::TransferableResource::ReturnResources(frame.resource_list, &resources); | 413 cc::TransferableResource::ReturnResources(frame.resource_list, &resources); |
| 416 | 414 |
| 417 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(), | 415 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(), |
| 418 frame.metadata.latency_info.begin(), | 416 frame.metadata.latency_info.begin(), |
| 419 frame.metadata.latency_info.end()); | 417 frame.metadata.latency_info.end()); |
| 420 | 418 |
| 421 renderer_compositor_frame_sink_->DidReceiveCompositorFrameAck(resources); | 419 client_->DelegatedFrameHostSendReclaimCompositorResources( |
| 422 | 420 true /* is_swap_ack*/, resources); |
| 423 skipped_frames_ = true; | 421 skipped_frames_ = true; |
| 424 BeginFrameDidNotSwap(ack); | 422 BeginFrameDidNotSwap(ack); |
| 425 return; | 423 return; |
| 426 } | 424 } |
| 427 | 425 |
| 428 // If we are allowing one renderer frame through, this would ensure the frame | 426 // If we are allowing one renderer frame through, this would ensure the frame |
| 429 // gets through even if we regrab the lock after the UI compositor makes one | 427 // gets through even if we regrab the lock after the UI compositor makes one |
| 430 // frame. If the renderer frame beats the UI compositor, then we don't need to | 428 // frame. If the renderer frame beats the UI compositor, then we don't need to |
| 431 // allow any more, though. | 429 // allow any more, though. |
| 432 allow_one_renderer_frame_during_resize_lock_ = false; | 430 allow_one_renderer_frame_during_resize_lock_ = false; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 | 489 |
| 492 DidFinishFrame(ack); | 490 DidFinishFrame(ack); |
| 493 } | 491 } |
| 494 | 492 |
| 495 void DelegatedFrameHost::ClearDelegatedFrame() { | 493 void DelegatedFrameHost::ClearDelegatedFrame() { |
| 496 EvictDelegatedFrame(); | 494 EvictDelegatedFrame(); |
| 497 } | 495 } |
| 498 | 496 |
| 499 void DelegatedFrameHost::DidReceiveCompositorFrameAck( | 497 void DelegatedFrameHost::DidReceiveCompositorFrameAck( |
| 500 const cc::ReturnedResourceArray& resources) { | 498 const cc::ReturnedResourceArray& resources) { |
| 501 renderer_compositor_frame_sink_->DidReceiveCompositorFrameAck(resources); | 499 client_->DelegatedFrameHostSendReclaimCompositorResources( |
| 500 true /* is_swap_ack */, resources); |
| 502 } | 501 } |
| 503 | 502 |
| 504 void DelegatedFrameHost::ReclaimResources( | 503 void DelegatedFrameHost::ReclaimResources( |
| 505 const cc::ReturnedResourceArray& resources) { | 504 const cc::ReturnedResourceArray& resources) { |
| 506 renderer_compositor_frame_sink_->ReclaimResources(resources); | 505 client_->DelegatedFrameHostSendReclaimCompositorResources( |
| 506 false /* is_swap_ack */, resources); |
| 507 } | 507 } |
| 508 | 508 |
| 509 void DelegatedFrameHost::WillDrawSurface(const cc::LocalSurfaceId& id, | 509 void DelegatedFrameHost::WillDrawSurface(const cc::LocalSurfaceId& id, |
| 510 const gfx::Rect& damage_rect) { | 510 const gfx::Rect& damage_rect) { |
| 511 if (id != local_surface_id_) | 511 if (id != local_surface_id_) |
| 512 return; | 512 return; |
| 513 AttemptFrameSubscriberCapture(damage_rect); | 513 AttemptFrameSubscriberCapture(damage_rect); |
| 514 } | 514 } |
| 515 | 515 |
| 516 void DelegatedFrameHost::OnBeginFrame(const cc::BeginFrameArgs& args) { | 516 void DelegatedFrameHost::OnBeginFrame(const cc::BeginFrameArgs& args) { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 } | 862 } |
| 863 | 863 |
| 864 if (!skipped_frames_) { | 864 if (!skipped_frames_) { |
| 865 latest_confirmed_begin_frame_source_id_ = ack.source_id; | 865 latest_confirmed_begin_frame_source_id_ = ack.source_id; |
| 866 latest_confirmed_begin_frame_sequence_number_ = | 866 latest_confirmed_begin_frame_sequence_number_ = |
| 867 ack.latest_confirmed_sequence_number; | 867 ack.latest_confirmed_sequence_number; |
| 868 } | 868 } |
| 869 } | 869 } |
| 870 | 870 |
| 871 } // namespace content | 871 } // namespace content |
| OLD | NEW |