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

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

Issue 2449853004: Getting rid of DelegatedFrameData (Closed)
Patch Set: nit Created 4 years, 1 month 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 surface_factory_->RequestCopyOfSurface(local_frame_id_, 399 surface_factory_->RequestCopyOfSurface(local_frame_id_,
400 std::move(request)); 400 std::move(request));
401 } else { 401 } else {
402 request->set_area(gfx::Rect(current_frame_size_in_dip_)); 402 request->set_area(gfx::Rect(current_frame_size_in_dip_));
403 RequestCopyOfOutput(std::move(request)); 403 RequestCopyOfOutput(std::move(request));
404 } 404 }
405 } 405 }
406 406
407 void DelegatedFrameHost::SwapDelegatedFrame(uint32_t compositor_frame_sink_id, 407 void DelegatedFrameHost::SwapDelegatedFrame(uint32_t compositor_frame_sink_id,
408 cc::CompositorFrame frame) { 408 cc::CompositorFrame frame) {
409 DCHECK(frame.delegated_frame_data.get());
410 #if defined(OS_CHROMEOS) 409 #if defined(OS_CHROMEOS)
411 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled()); 410 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled());
412 #endif 411 #endif
413 cc::DelegatedFrameData* frame_data = frame.delegated_frame_data.get();
414 float frame_device_scale_factor = frame.metadata.device_scale_factor; 412 float frame_device_scale_factor = frame.metadata.device_scale_factor;
415 413
416 DCHECK(!frame_data->render_pass_list.empty()); 414 DCHECK(!frame.render_pass_list.empty());
417 415
418 cc::RenderPass* root_pass = frame_data->render_pass_list.back().get(); 416 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
419 417
420 gfx::Size frame_size = root_pass->output_rect.size(); 418 gfx::Size frame_size = root_pass->output_rect.size();
421 gfx::Size frame_size_in_dip = 419 gfx::Size frame_size_in_dip =
422 gfx::ConvertSizeToDIP(frame_device_scale_factor, frame_size); 420 gfx::ConvertSizeToDIP(frame_device_scale_factor, frame_size);
423 421
424 gfx::Rect damage_rect = root_pass->damage_rect; 422 gfx::Rect damage_rect = root_pass->damage_rect;
425 damage_rect.Intersect(gfx::Rect(frame_size)); 423 damage_rect.Intersect(gfx::Rect(frame_size));
426 gfx::Rect damage_rect_in_dip = 424 gfx::Rect damage_rect_in_dip =
427 gfx::ConvertRectToDIP(frame_device_scale_factor, damage_rect); 425 gfx::ConvertRectToDIP(frame_device_scale_factor, damage_rect);
428 426
429 if (ShouldSkipFrame(frame_size_in_dip)) { 427 if (ShouldSkipFrame(frame_size_in_dip)) {
430 cc::ReturnedResourceArray resources; 428 cc::ReturnedResourceArray resources;
431 cc::TransferableResource::ReturnResources(frame_data->resource_list, 429 cc::TransferableResource::ReturnResources(frame.resource_list, &resources);
432 &resources);
433 430
434 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(), 431 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(),
435 frame.metadata.latency_info.begin(), 432 frame.metadata.latency_info.begin(),
436 frame.metadata.latency_info.end()); 433 frame.metadata.latency_info.end());
437 434
438 client_->DelegatedFrameHostSendReclaimCompositorResources( 435 client_->DelegatedFrameHostSendReclaimCompositorResources(
439 compositor_frame_sink_id, true /* is_swap_ack*/, resources); 436 compositor_frame_sink_id, true /* is_swap_ack*/, resources);
440 skipped_frames_ = true; 437 skipped_frames_ = true;
441 return; 438 return;
442 } 439 }
443 440
444 if (skipped_frames_) { 441 if (skipped_frames_) {
445 skipped_frames_ = false; 442 skipped_frames_ = false;
446 damage_rect = gfx::Rect(frame_size); 443 damage_rect = gfx::Rect(frame_size);
447 damage_rect_in_dip = gfx::Rect(frame_size_in_dip); 444 damage_rect_in_dip = gfx::Rect(frame_size_in_dip);
448 445
449 // Give the same damage rect to the compositor. 446 // Give the same damage rect to the compositor.
450 cc::RenderPass* root_pass = frame_data->render_pass_list.back().get(); 447 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
451 root_pass->damage_rect = damage_rect; 448 root_pass->damage_rect = damage_rect;
452 } 449 }
453 450
454 if (compositor_frame_sink_id != last_compositor_frame_sink_id_) { 451 if (compositor_frame_sink_id != last_compositor_frame_sink_id_) {
455 // Resource ids are scoped by the output surface. 452 // Resource ids are scoped by the output surface.
456 // If the originating output surface doesn't match the last one, it 453 // If the originating output surface doesn't match the last one, it
457 // indicates the renderer's output surface may have been recreated, in which 454 // indicates the renderer's output surface may have been recreated, in which
458 // case we should recreate the DelegatedRendererLayer, to avoid matching 455 // case we should recreate the DelegatedRendererLayer, to avoid matching
459 // resources from the old one with resources from the new one which would 456 // resources from the old one with resources from the new one which would
460 // have the same id. Changing the layer to showing painted content destroys 457 // have the same id. Changing the layer to showing painted content destroys
461 // the DelegatedRendererLayer. 458 // the DelegatedRendererLayer.
462 EvictDelegatedFrame(); 459 EvictDelegatedFrame();
463 460
464 surface_factory_->Reset(); 461 surface_factory_->Reset();
465 if (!surface_returned_resources_.empty()) { 462 if (!surface_returned_resources_.empty()) {
466 SendReclaimCompositorResources(last_compositor_frame_sink_id_, 463 SendReclaimCompositorResources(last_compositor_frame_sink_id_,
467 false /* is_swap_ack */); 464 false /* is_swap_ack */);
468 } 465 }
469 last_compositor_frame_sink_id_ = compositor_frame_sink_id; 466 last_compositor_frame_sink_id_ = compositor_frame_sink_id;
470 } 467 }
471 bool skip_frame = false; 468 bool skip_frame = false;
472 pending_delegated_ack_count_++; 469 pending_delegated_ack_count_++;
473 470
474 background_color_ = frame.metadata.root_background_color; 471 background_color_ = frame.metadata.root_background_color;
475 472
476 if (frame_size.IsEmpty()) { 473 if (frame_size.IsEmpty()) {
477 DCHECK(frame_data->resource_list.empty()); 474 DCHECK(frame.resource_list.empty());
478 EvictDelegatedFrame(); 475 EvictDelegatedFrame();
479 } else { 476 } else {
480 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 477 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
481 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 478 cc::SurfaceManager* manager = factory->GetSurfaceManager();
482 if (!local_frame_id_.is_valid() || frame_size != current_surface_size_ || 479 if (!local_frame_id_.is_valid() || frame_size != current_surface_size_ ||
483 frame_size_in_dip != current_frame_size_in_dip_) { 480 frame_size_in_dip != current_frame_size_in_dip_) {
484 if (local_frame_id_.is_valid()) 481 if (local_frame_id_.is_valid())
485 surface_factory_->Destroy(local_frame_id_); 482 surface_factory_->Destroy(local_frame_id_);
486 local_frame_id_ = id_allocator_->GenerateId(); 483 local_frame_id_ = id_allocator_->GenerateId();
487 surface_factory_->Create(local_frame_id_); 484 surface_factory_->Create(local_frame_id_);
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 std::move(request)); 881 std::move(request));
885 } 882 }
886 } 883 }
887 884
888 void DelegatedFrameHost::UnlockResources() { 885 void DelegatedFrameHost::UnlockResources() {
889 DCHECK(local_frame_id_.is_valid()); 886 DCHECK(local_frame_id_.is_valid());
890 delegated_frame_evictor_->UnlockFrame(); 887 delegated_frame_evictor_->UnlockFrame();
891 } 888 }
892 889
893 } // namespace content 890 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/browser_compositor_view_mac.mm ('k') | content/browser/renderer_host/render_widget_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698