| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 371 |
| 372 // To avoid unnecessary browser composites, try to go directly to the Surface | 372 // To avoid unnecessary browser composites, try to go directly to the Surface |
| 373 // rather than through the Layer (which goes through the browser compositor). | 373 // rather than through the Layer (which goes through the browser compositor). |
| 374 if (has_frame_ && request_copy_of_output_callback_for_testing_.is_null()) { | 374 if (has_frame_ && request_copy_of_output_callback_for_testing_.is_null()) { |
| 375 support_->RequestCopyOfSurface(std::move(request)); | 375 support_->RequestCopyOfSurface(std::move(request)); |
| 376 } else { | 376 } else { |
| 377 RequestCopyOfOutput(std::move(request)); | 377 RequestCopyOfOutput(std::move(request)); |
| 378 } | 378 } |
| 379 } | 379 } |
| 380 | 380 |
| 381 void DelegatedFrameHost::DidCreateNewRendererCompositorFrameSink() { | 381 void DelegatedFrameHost::DidCreateNewRendererCompositorFrameSink( |
| 382 cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink) { |
| 382 ResetCompositorFrameSinkSupport(); | 383 ResetCompositorFrameSinkSupport(); |
| 384 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink; |
| 383 CreateCompositorFrameSinkSupport(); | 385 CreateCompositorFrameSinkSupport(); |
| 384 has_frame_ = false; | 386 has_frame_ = false; |
| 385 } | 387 } |
| 386 | 388 |
| 387 void DelegatedFrameHost::SubmitCompositorFrame( | 389 void DelegatedFrameHost::SubmitCompositorFrame( |
| 388 const cc::LocalSurfaceId& local_surface_id, | 390 const cc::LocalSurfaceId& local_surface_id, |
| 389 cc::CompositorFrame frame) { | 391 cc::CompositorFrame frame) { |
| 390 #if defined(OS_CHROMEOS) | 392 #if defined(OS_CHROMEOS) |
| 391 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled()); | 393 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled()); |
| 392 #endif | 394 #endif |
| (...skipping 14 matching lines...) Expand all Loading... |
| 407 gfx::ConvertRectToDIP(frame_device_scale_factor, damage_rect); | 409 gfx::ConvertRectToDIP(frame_device_scale_factor, damage_rect); |
| 408 | 410 |
| 409 if (ShouldSkipFrame(frame_size_in_dip)) { | 411 if (ShouldSkipFrame(frame_size_in_dip)) { |
| 410 cc::ReturnedResourceArray resources; | 412 cc::ReturnedResourceArray resources; |
| 411 cc::TransferableResource::ReturnResources(frame.resource_list, &resources); | 413 cc::TransferableResource::ReturnResources(frame.resource_list, &resources); |
| 412 | 414 |
| 413 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(), | 415 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(), |
| 414 frame.metadata.latency_info.begin(), | 416 frame.metadata.latency_info.begin(), |
| 415 frame.metadata.latency_info.end()); | 417 frame.metadata.latency_info.end()); |
| 416 | 418 |
| 417 client_->DelegatedFrameHostSendReclaimCompositorResources( | 419 renderer_compositor_frame_sink_->ReclaimResources(resources); |
| 418 true /* is_swap_ack*/, resources); | 420 renderer_compositor_frame_sink_->DidReceiveCompositorFrameAck(); |
| 421 |
| 419 skipped_frames_ = true; | 422 skipped_frames_ = true; |
| 420 BeginFrameDidNotSwap(ack); | 423 BeginFrameDidNotSwap(ack); |
| 421 return; | 424 return; |
| 422 } | 425 } |
| 423 | 426 |
| 424 // If we are allowing one renderer frame through, this would ensure the frame | 427 // If we are allowing one renderer frame through, this would ensure the frame |
| 425 // gets through even if we regrab the lock after the UI compositor makes one | 428 // gets through even if we regrab the lock after the UI compositor makes one |
| 426 // frame. If the renderer frame beats the UI compositor, then we don't need to | 429 // frame. If the renderer frame beats the UI compositor, then we don't need to |
| 427 // allow any more, though. | 430 // allow any more, though. |
| 428 allow_one_renderer_frame_during_resize_lock_ = false; | 431 allow_one_renderer_frame_during_resize_lock_ = false; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 // Note: the frame may have been evicted immediately. | 490 // Note: the frame may have been evicted immediately. |
| 488 | 491 |
| 489 DidFinishFrame(ack); | 492 DidFinishFrame(ack); |
| 490 } | 493 } |
| 491 | 494 |
| 492 void DelegatedFrameHost::ClearDelegatedFrame() { | 495 void DelegatedFrameHost::ClearDelegatedFrame() { |
| 493 EvictDelegatedFrame(); | 496 EvictDelegatedFrame(); |
| 494 } | 497 } |
| 495 | 498 |
| 496 void DelegatedFrameHost::DidReceiveCompositorFrameAck() { | 499 void DelegatedFrameHost::DidReceiveCompositorFrameAck() { |
| 497 client_->DelegatedFrameHostSendReclaimCompositorResources( | 500 renderer_compositor_frame_sink_->DidReceiveCompositorFrameAck(); |
| 498 true /* is_swap_ack */, cc::ReturnedResourceArray()); | |
| 499 } | 501 } |
| 500 | 502 |
| 501 void DelegatedFrameHost::ReclaimResources( | 503 void DelegatedFrameHost::ReclaimResources( |
| 502 const cc::ReturnedResourceArray& resources) { | 504 const cc::ReturnedResourceArray& resources) { |
| 503 client_->DelegatedFrameHostSendReclaimCompositorResources( | 505 renderer_compositor_frame_sink_->ReclaimResources(resources); |
| 504 false /* is_swap_ack */, resources); | |
| 505 } | 506 } |
| 506 | 507 |
| 507 void DelegatedFrameHost::WillDrawSurface(const cc::LocalSurfaceId& id, | 508 void DelegatedFrameHost::WillDrawSurface(const cc::LocalSurfaceId& id, |
| 508 const gfx::Rect& damage_rect) { | 509 const gfx::Rect& damage_rect) { |
| 509 // Frame subscribers are only interested in changes to the target surface, so | 510 // Frame subscribers are only interested in changes to the target surface, so |
| 510 // do not attempt capture if |damage_rect| is empty. This prevents the draws | 511 // do not attempt capture if |damage_rect| is empty. This prevents the draws |
| 511 // of parent surfaces from triggering extra frame captures, which can affect | 512 // of parent surfaces from triggering extra frame captures, which can affect |
| 512 // smoothness. | 513 // smoothness. |
| 513 if (id != local_surface_id_ || damage_rect.IsEmpty()) | 514 if (id != local_surface_id_ || damage_rect.IsEmpty()) |
| 514 return; | 515 return; |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 } | 863 } |
| 863 | 864 |
| 864 if (!skipped_frames_) { | 865 if (!skipped_frames_) { |
| 865 latest_confirmed_begin_frame_source_id_ = ack.source_id; | 866 latest_confirmed_begin_frame_source_id_ = ack.source_id; |
| 866 latest_confirmed_begin_frame_sequence_number_ = | 867 latest_confirmed_begin_frame_sequence_number_ = |
| 867 ack.latest_confirmed_sequence_number; | 868 ack.latest_confirmed_sequence_number; |
| 868 } | 869 } |
| 869 } | 870 } |
| 870 | 871 |
| 871 } // namespace content | 872 } // namespace content |
| OLD | NEW |