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

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

Issue 1904773004: Revert of Introduce components/display_compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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>
11 11
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/time/default_tick_clock.h" 15 #include "base/time/default_tick_clock.h"
16 #include "cc/output/compositor_frame.h" 16 #include "cc/output/compositor_frame.h"
17 #include "cc/output/compositor_frame_ack.h" 17 #include "cc/output/compositor_frame_ack.h"
18 #include "cc/output/copy_output_request.h" 18 #include "cc/output/copy_output_request.h"
19 #include "cc/resources/single_release_callback.h" 19 #include "cc/resources/single_release_callback.h"
20 #include "cc/resources/texture_mailbox.h" 20 #include "cc/resources/texture_mailbox.h"
21 #include "cc/surfaces/surface.h" 21 #include "cc/surfaces/surface.h"
22 #include "cc/surfaces/surface_factory.h" 22 #include "cc/surfaces/surface_factory.h"
23 #include "cc/surfaces/surface_hittest.h" 23 #include "cc/surfaces/surface_hittest.h"
24 #include "cc/surfaces/surface_manager.h" 24 #include "cc/surfaces/surface_manager.h"
25 #include "components/display_compositor/gl_helper.h" 25 #include "content/browser/compositor/gl_helper.h"
26 #include "content/browser/compositor/surface_utils.h" 26 #include "content/browser/compositor/surface_utils.h"
27 #include "content/browser/gpu/compositor_util.h" 27 #include "content/browser/gpu/compositor_util.h"
28 #include "content/browser/renderer_host/resize_lock.h" 28 #include "content/browser/renderer_host/resize_lock.h"
29 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 29 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
30 #include "content/public/common/content_switches.h" 30 #include "content/public/common/content_switches.h"
31 #include "media/base/video_frame.h" 31 #include "media/base/video_frame.h"
32 #include "media/base/video_util.h" 32 #include "media/base/video_util.h"
33 #include "skia/ext/image_operations.h" 33 #include "skia/ext/image_operations.h"
34 #include "third_party/skia/include/core/SkCanvas.h" 34 #include "third_party/skia/include/core/SkCanvas.h"
35 #include "third_party/skia/include/core/SkPaint.h" 35 #include "third_party/skia/include/core/SkPaint.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; 329 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback;
330 if (!frame_subscriber()->ShouldCaptureFrame(damage_rect, present_time, &frame, 330 if (!frame_subscriber()->ShouldCaptureFrame(damage_rect, present_time, &frame,
331 &callback)) 331 &callback))
332 return; 332 return;
333 333
334 // Get a texture to re-use; else, create a new one. 334 // Get a texture to re-use; else, create a new one.
335 scoped_refptr<OwnedMailbox> subscriber_texture; 335 scoped_refptr<OwnedMailbox> subscriber_texture;
336 if (!idle_frame_subscriber_textures_.empty()) { 336 if (!idle_frame_subscriber_textures_.empty()) {
337 subscriber_texture = idle_frame_subscriber_textures_.back(); 337 subscriber_texture = idle_frame_subscriber_textures_.back();
338 idle_frame_subscriber_textures_.pop_back(); 338 idle_frame_subscriber_textures_.pop_back();
339 } else if (display_compositor::GLHelper* helper = 339 } else if (GLHelper* helper =
340 ImageTransportFactory::GetInstance()->GetGLHelper()) { 340 ImageTransportFactory::GetInstance()->GetGLHelper()) {
341 subscriber_texture = new OwnedMailbox(helper); 341 subscriber_texture = new OwnedMailbox(helper);
342 } 342 }
343 343
344 std::unique_ptr<cc::CopyOutputRequest> request = 344 std::unique_ptr<cc::CopyOutputRequest> request =
345 cc::CopyOutputRequest::CreateRequest(base::Bind( 345 cc::CopyOutputRequest::CreateRequest(base::Bind(
346 &DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo, 346 &DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo,
347 AsWeakPtr(), subscriber_texture, frame, 347 AsWeakPtr(), subscriber_texture, frame,
348 base::Bind(callback, present_time))); 348 base::Bind(callback, present_time)));
349 // Setting the source in this copy request asks that the layer abort any prior 349 // Setting the source in this copy request asks that the layer abort any prior
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 scoped_refptr<media::VideoFrame> video_frame, 589 scoped_refptr<media::VideoFrame> video_frame,
590 base::WeakPtr<DelegatedFrameHost> dfh, 590 base::WeakPtr<DelegatedFrameHost> dfh,
591 const base::Callback<void(bool)>& callback, 591 const base::Callback<void(bool)>& callback,
592 scoped_refptr<OwnedMailbox> subscriber_texture, 592 scoped_refptr<OwnedMailbox> subscriber_texture,
593 std::unique_ptr<cc::SingleReleaseCallback> release_callback, 593 std::unique_ptr<cc::SingleReleaseCallback> release_callback,
594 bool result) { 594 bool result) {
595 callback.Run(result); 595 callback.Run(result);
596 596
597 gpu::SyncToken sync_token; 597 gpu::SyncToken sync_token;
598 if (result) { 598 if (result) {
599 display_compositor::GLHelper* gl_helper = 599 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
600 ImageTransportFactory::GetInstance()->GetGLHelper();
601 gl_helper->GenerateSyncToken(&sync_token); 600 gl_helper->GenerateSyncToken(&sync_token);
602 } 601 }
603 if (release_callback) { 602 if (release_callback) {
604 // A release callback means the texture came from the compositor, so there 603 // A release callback means the texture came from the compositor, so there
605 // should be no |subscriber_texture|. 604 // should be no |subscriber_texture|.
606 DCHECK(!subscriber_texture.get()); 605 DCHECK(!subscriber_texture.get());
607 const bool lost_resource = !sync_token.HasData(); 606 const bool lost_resource = !sync_token.HasData();
608 release_callback->Run(sync_token, lost_resource); 607 release_callback->Run(sync_token, lost_resource);
609 } 608 }
610 ReturnSubscriberTexture(dfh, subscriber_texture, sync_token); 609 ReturnSubscriberTexture(dfh, subscriber_texture, sync_token);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 media::CopyRGBToVideoFrame( 663 media::CopyRGBToVideoFrame(
665 reinterpret_cast<uint8_t*>(scaled_bitmap.getPixels()), 664 reinterpret_cast<uint8_t*>(scaled_bitmap.getPixels()),
666 scaled_bitmap.rowBytes(), region_in_frame, video_frame.get()); 665 scaled_bitmap.rowBytes(), region_in_frame, video_frame.get());
667 } 666 }
668 ignore_result(scoped_callback_runner.Release()); 667 ignore_result(scoped_callback_runner.Release());
669 callback.Run(region_in_frame, true); 668 callback.Run(region_in_frame, true);
670 return; 669 return;
671 } 670 }
672 671
673 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 672 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
674 display_compositor::GLHelper* gl_helper = factory->GetGLHelper(); 673 GLHelper* gl_helper = factory->GetGLHelper();
675 if (!gl_helper) 674 if (!gl_helper)
676 return; 675 return;
677 if (subscriber_texture.get() && !subscriber_texture->texture_id()) 676 if (subscriber_texture.get() && !subscriber_texture->texture_id())
678 return; 677 return;
679 678
680 cc::TextureMailbox texture_mailbox; 679 cc::TextureMailbox texture_mailbox;
681 std::unique_ptr<cc::SingleReleaseCallback> release_callback; 680 std::unique_ptr<cc::SingleReleaseCallback> release_callback;
682 result->TakeTexture(&texture_mailbox, &release_callback); 681 result->TakeTexture(&texture_mailbox, &release_callback);
683 DCHECK(texture_mailbox.IsTexture()); 682 DCHECK(texture_mailbox.IsTexture());
684 683
685 gfx::Rect result_rect(result->size()); 684 gfx::Rect result_rect(result->size());
686 685
687 display_compositor::ReadbackYUVInterface* yuv_readback_pipeline = 686 content::ReadbackYUVInterface* yuv_readback_pipeline =
688 dfh->yuv_readback_pipeline_.get(); 687 dfh->yuv_readback_pipeline_.get();
689 if (yuv_readback_pipeline == NULL || 688 if (yuv_readback_pipeline == NULL ||
690 yuv_readback_pipeline->scaler()->SrcSize() != result_rect.size() || 689 yuv_readback_pipeline->scaler()->SrcSize() != result_rect.size() ||
691 yuv_readback_pipeline->scaler()->SrcSubrect() != result_rect || 690 yuv_readback_pipeline->scaler()->SrcSubrect() != result_rect ||
692 yuv_readback_pipeline->scaler()->DstSize() != region_in_frame.size()) { 691 yuv_readback_pipeline->scaler()->DstSize() != region_in_frame.size()) {
693 // The scaler chosen here is based on performance measurements of full 692 // The scaler chosen here is based on performance measurements of full
694 // end-to-end systems. When down-scaling, always use the "fast" scaler 693 // end-to-end systems. When down-scaling, always use the "fast" scaler
695 // because it performs well on both low- and high- end machines, provides 694 // because it performs well on both low- and high- end machines, provides
696 // decent image quality, and doesn't overwhelm downstream video encoders 695 // decent image quality, and doesn't overwhelm downstream video encoders
697 // with too much entropy (which can drastically increase CPU utilization). 696 // with too much entropy (which can drastically increase CPU utilization).
698 // When up-scaling, always use "best" because the quality improvement is 697 // When up-scaling, always use "best" because the quality improvement is
699 // huge with insignificant performance penalty. Note that this strategy 698 // huge with insignificant performance penalty. Note that this strategy
700 // differs from single-frame snapshot capture. 699 // differs from single-frame snapshot capture.
701 display_compositor::GLHelper::ScalerQuality quality = 700 GLHelper::ScalerQuality quality =
702 ((result_rect.size().width() < region_in_frame.size().width()) && 701 ((result_rect.size().width() < region_in_frame.size().width()) &&
703 (result_rect.size().height() < region_in_frame.size().height())) 702 (result_rect.size().height() < region_in_frame.size().height()))
704 ? display_compositor::GLHelper::SCALER_QUALITY_BEST 703 ? GLHelper::SCALER_QUALITY_BEST
705 : display_compositor::GLHelper::SCALER_QUALITY_FAST; 704 : GLHelper::SCALER_QUALITY_FAST;
706 705
707 dfh->yuv_readback_pipeline_.reset(gl_helper->CreateReadbackPipelineYUV( 706 dfh->yuv_readback_pipeline_.reset(gl_helper->CreateReadbackPipelineYUV(
708 quality, result_rect.size(), result_rect, region_in_frame.size(), true, 707 quality, result_rect.size(), result_rect, region_in_frame.size(), true,
709 true)); 708 true));
710 yuv_readback_pipeline = dfh->yuv_readback_pipeline_.get(); 709 yuv_readback_pipeline = dfh->yuv_readback_pipeline_.get();
711 } 710 }
712 711
713 ignore_result(scoped_callback_runner.Release()); 712 ignore_result(scoped_callback_runner.Release());
714 ignore_result(scoped_return_subscriber_texture.Release()); 713 ignore_result(scoped_return_subscriber_texture.Release());
715 714
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 885 cc::SurfaceManager* manager = factory->GetSurfaceManager();
887 new_layer->SetShowSurface( 886 new_layer->SetShowSurface(
888 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), 887 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)),
889 base::Bind(&RequireCallback, base::Unretained(manager)), 888 base::Bind(&RequireCallback, base::Unretained(manager)),
890 current_surface_size_, current_scale_factor_, 889 current_surface_size_, current_scale_factor_,
891 current_frame_size_in_dip_); 890 current_frame_size_in_dip_);
892 } 891 }
893 } 892 }
894 893
895 } // namespace content 894 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698