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

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

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