Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: content/browser/renderer_host/delegated_frame_host.cc

Issue 2780713004: Hide compositor_frame_sink_id from RenderWidgetHostView* (Closed)
Patch Set: Added a comment in android Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 30 matching lines...) Expand all
41 41
42 //////////////////////////////////////////////////////////////////////////////// 42 ////////////////////////////////////////////////////////////////////////////////
43 // DelegatedFrameHost 43 // DelegatedFrameHost
44 44
45 DelegatedFrameHost::DelegatedFrameHost(const cc::FrameSinkId& frame_sink_id, 45 DelegatedFrameHost::DelegatedFrameHost(const cc::FrameSinkId& frame_sink_id,
46 DelegatedFrameHostClient* client) 46 DelegatedFrameHostClient* client)
47 : frame_sink_id_(frame_sink_id), 47 : frame_sink_id_(frame_sink_id),
48 client_(client), 48 client_(client),
49 compositor_(nullptr), 49 compositor_(nullptr),
50 tick_clock_(new base::DefaultTickClock()), 50 tick_clock_(new base::DefaultTickClock()),
51 last_compositor_frame_sink_id_(0),
52 skipped_frames_(false), 51 skipped_frames_(false),
53 background_color_(SK_ColorRED), 52 background_color_(SK_ColorRED),
54 current_scale_factor_(1.f), 53 current_scale_factor_(1.f),
55 can_lock_compositor_(YES_CAN_LOCK), 54 can_lock_compositor_(YES_CAN_LOCK),
56 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { 55 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) {
57 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 56 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
58 factory->GetContextFactory()->AddObserver(this); 57 factory->GetContextFactory()->AddObserver(this);
59 factory->GetContextFactoryPrivate()->GetSurfaceManager()->RegisterFrameSinkId( 58 factory->GetContextFactoryPrivate()->GetSurfaceManager()->RegisterFrameSinkId(
60 frame_sink_id_); 59 frame_sink_id_);
61 CreateCompositorFrameSinkSupport(); 60 CreateCompositorFrameSinkSupport();
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 382
384 // To avoid unnecessary browser composites, try to go directly to the Surface 383 // To avoid unnecessary browser composites, try to go directly to the Surface
385 // rather than through the Layer (which goes through the browser compositor). 384 // rather than through the Layer (which goes through the browser compositor).
386 if (has_frame_ && request_copy_of_output_callback_for_testing_.is_null()) { 385 if (has_frame_ && request_copy_of_output_callback_for_testing_.is_null()) {
387 support_->RequestCopyOfSurface(std::move(request)); 386 support_->RequestCopyOfSurface(std::move(request));
388 } else { 387 } else {
389 RequestCopyOfOutput(std::move(request)); 388 RequestCopyOfOutput(std::move(request));
390 } 389 }
391 } 390 }
392 391
393 void DelegatedFrameHost::SwapDelegatedFrame( 392 void DelegatedFrameHost::DidCreateNewRendererCompositorFrameSink() {
394 uint32_t compositor_frame_sink_id, 393 ResetCompositorFrameSinkSupport();
394 CreateCompositorFrameSinkSupport();
395 has_frame_ = false;
396 }
397
398 void DelegatedFrameHost::SubmitCompositorFrame(
395 const cc::LocalSurfaceId& local_surface_id, 399 const cc::LocalSurfaceId& local_surface_id,
396 cc::CompositorFrame frame) { 400 cc::CompositorFrame frame) {
397 #if defined(OS_CHROMEOS) 401 #if defined(OS_CHROMEOS)
398 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled()); 402 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled());
399 #endif 403 #endif
400 float frame_device_scale_factor = frame.metadata.device_scale_factor; 404 float frame_device_scale_factor = frame.metadata.device_scale_factor;
401 cc::BeginFrameAck ack(frame.metadata.begin_frame_ack); 405 cc::BeginFrameAck ack(frame.metadata.begin_frame_ack);
402 406
403 DCHECK(!frame.render_pass_list.empty()); 407 DCHECK(!frame.render_pass_list.empty());
404 408
(...skipping 10 matching lines...) Expand all
415 419
416 if (ShouldSkipFrame(frame_size_in_dip)) { 420 if (ShouldSkipFrame(frame_size_in_dip)) {
417 cc::ReturnedResourceArray resources; 421 cc::ReturnedResourceArray resources;
418 cc::TransferableResource::ReturnResources(frame.resource_list, &resources); 422 cc::TransferableResource::ReturnResources(frame.resource_list, &resources);
419 423
420 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(), 424 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(),
421 frame.metadata.latency_info.begin(), 425 frame.metadata.latency_info.begin(),
422 frame.metadata.latency_info.end()); 426 frame.metadata.latency_info.end());
423 427
424 client_->DelegatedFrameHostSendReclaimCompositorResources( 428 client_->DelegatedFrameHostSendReclaimCompositorResources(
425 compositor_frame_sink_id, true /* is_swap_ack*/, resources); 429 true /* is_swap_ack*/, resources);
426 skipped_frames_ = true; 430 skipped_frames_ = true;
427 BeginFrameDidNotSwap(ack); 431 BeginFrameDidNotSwap(ack);
428 return; 432 return;
429 } 433 }
430 434
431 if (skipped_frames_) { 435 if (skipped_frames_) {
432 skipped_frames_ = false; 436 skipped_frames_ = false;
433 damage_rect = gfx::Rect(frame_size); 437 damage_rect = gfx::Rect(frame_size);
434 damage_rect_in_dip = gfx::Rect(frame_size_in_dip); 438 damage_rect_in_dip = gfx::Rect(frame_size_in_dip);
435 439
436 // Give the same damage rect to the compositor. 440 // Give the same damage rect to the compositor.
437 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); 441 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
438 root_pass->damage_rect = damage_rect; 442 root_pass->damage_rect = damage_rect;
439 } 443 }
440 444
441 if (compositor_frame_sink_id != last_compositor_frame_sink_id_) {
442 // Resource ids are scoped by the output surface.
443 // If the originating output surface doesn't match the last one, it
444 // indicates the renderer's output surface may have been recreated, in which
445 // case we should recreate the DelegatedRendererLayer, to avoid matching
446 // resources from the old one with resources from the new one which would
447 // have the same id. Changing the layer to showing painted content destroys
448 // the DelegatedRendererLayer.
449 local_surface_id_ = cc::LocalSurfaceId();
450 ResetCompositorFrameSinkSupport();
451 CreateCompositorFrameSinkSupport();
452 last_compositor_frame_sink_id_ = compositor_frame_sink_id;
453 }
454
455 background_color_ = frame.metadata.root_background_color; 445 background_color_ = frame.metadata.root_background_color;
456 446
457 if (frame_size.IsEmpty()) { 447 if (frame_size.IsEmpty()) {
458 DCHECK(frame.resource_list.empty()); 448 DCHECK(frame.resource_list.empty());
459 EvictDelegatedFrame(); 449 EvictDelegatedFrame();
460 } else { 450 } else {
461 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 451 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
462 cc::SurfaceManager* manager = 452 cc::SurfaceManager* manager =
463 factory->GetContextFactoryPrivate()->GetSurfaceManager(); 453 factory->GetContextFactoryPrivate()->GetSurfaceManager();
464 454
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 496
507 DidFinishFrame(ack); 497 DidFinishFrame(ack);
508 } 498 }
509 499
510 void DelegatedFrameHost::ClearDelegatedFrame() { 500 void DelegatedFrameHost::ClearDelegatedFrame() {
511 EvictDelegatedFrame(); 501 EvictDelegatedFrame();
512 } 502 }
513 503
514 void DelegatedFrameHost::DidReceiveCompositorFrameAck() { 504 void DelegatedFrameHost::DidReceiveCompositorFrameAck() {
515 client_->DelegatedFrameHostSendReclaimCompositorResources( 505 client_->DelegatedFrameHostSendReclaimCompositorResources(
516 last_compositor_frame_sink_id_, true /* is_swap_ack */, 506 true /* is_swap_ack */, cc::ReturnedResourceArray());
517 cc::ReturnedResourceArray());
518 } 507 }
519 508
520 void DelegatedFrameHost::ReclaimResources( 509 void DelegatedFrameHost::ReclaimResources(
521 const cc::ReturnedResourceArray& resources) { 510 const cc::ReturnedResourceArray& resources) {
522 client_->DelegatedFrameHostSendReclaimCompositorResources( 511 client_->DelegatedFrameHostSendReclaimCompositorResources(
523 last_compositor_frame_sink_id_, false /* is_swap_ack */, resources); 512 false /* is_swap_ack */, resources);
524 } 513 }
525 514
526 void DelegatedFrameHost::WillDrawSurface(const cc::LocalSurfaceId& id, 515 void DelegatedFrameHost::WillDrawSurface(const cc::LocalSurfaceId& id,
527 const gfx::Rect& damage_rect) { 516 const gfx::Rect& damage_rect) {
528 // Frame subscribers are only interested in changes to the target surface, so 517 // Frame subscribers are only interested in changes to the target surface, so
529 // do not attempt capture if |damage_rect| is empty. This prevents the draws 518 // do not attempt capture if |damage_rect| is empty. This prevents the draws
530 // of parent surfaces from triggering extra frame captures, which can affect 519 // of parent surfaces from triggering extra frame captures, which can affect
531 // smoothness. 520 // smoothness.
532 if (id != local_surface_id_ || damage_rect.IsEmpty()) 521 if (id != local_surface_id_ || damage_rect.IsEmpty())
533 return; 522 return;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 } 863 }
875 864
876 if (!skipped_frames_) { 865 if (!skipped_frames_) {
877 latest_confirmed_begin_frame_source_id_ = ack.source_id; 866 latest_confirmed_begin_frame_source_id_ = ack.source_id;
878 latest_confirmed_begin_frame_sequence_number_ = 867 latest_confirmed_begin_frame_sequence_number_ =
879 ack.latest_confirmed_sequence_number; 868 ack.latest_confirmed_sequence_number;
880 } 869 }
881 } 870 }
882 871
883 } // namespace content 872 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/delegated_frame_host.h ('k') | content/browser/renderer_host/delegated_frame_host_client_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698