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

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

Issue 1412173003: cast: support cursor rendering for tab capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable cursor rendering on windows until resources are available Created 5 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/compositor/delegated_frame_host.h" 5 #include "content/browser/compositor/delegated_frame_host.h"
6 6
7 #include <algorithm>
8 #include <string>
9 #include <vector>
10
7 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
8 #include "base/command_line.h" 12 #include "base/command_line.h"
9 #include "base/time/default_tick_clock.h" 13 #include "base/time/default_tick_clock.h"
10 #include "cc/output/compositor_frame.h" 14 #include "cc/output/compositor_frame.h"
11 #include "cc/output/compositor_frame_ack.h" 15 #include "cc/output/compositor_frame_ack.h"
12 #include "cc/output/copy_output_request.h" 16 #include "cc/output/copy_output_request.h"
13 #include "cc/resources/single_release_callback.h" 17 #include "cc/resources/single_release_callback.h"
14 #include "cc/resources/texture_mailbox.h" 18 #include "cc/resources/texture_mailbox.h"
15 #include "cc/surfaces/surface.h" 19 #include "cc/surfaces/surface.h"
16 #include "cc/surfaces/surface_factory.h" 20 #include "cc/surfaces/surface_factory.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 scoped_ptr<cc::CopyOutputRequest> request = 151 scoped_ptr<cc::CopyOutputRequest> request =
148 cc::CopyOutputRequest::CreateRequest( 152 cc::CopyOutputRequest::CreateRequest(
149 base::Bind(&DelegatedFrameHost::CopyFromCompositingSurfaceHasResult, 153 base::Bind(&DelegatedFrameHost::CopyFromCompositingSurfaceHasResult,
150 output_size, preferred_color_type, callback)); 154 output_size, preferred_color_type, callback));
151 if (!src_subrect.IsEmpty()) 155 if (!src_subrect.IsEmpty())
152 request->set_area(src_subrect); 156 request->set_area(src_subrect);
153 RequestCopyOfOutput(request.Pass()); 157 RequestCopyOfOutput(request.Pass());
154 } 158 }
155 159
156 void DelegatedFrameHost::CopyFromCompositingSurfaceToVideoFrame( 160 void DelegatedFrameHost::CopyFromCompositingSurfaceToVideoFrame(
157 const gfx::Rect& src_subrect, 161 const gfx::Rect& src_subrect,
158 const scoped_refptr<media::VideoFrame>& target, 162 const scoped_refptr<media::VideoFrame>& target,
159 const base::Callback<void(bool)>& callback) { 163 const base::Callback<void(const gfx::Rect&, bool)>& callback) {
160 if (!CanCopyToVideoFrame()) { 164 if (!CanCopyToVideoFrame()) {
161 callback.Run(false); 165 callback.Run(gfx::Rect(), false);
162 return; 166 return;
163 } 167 }
164 168
165 scoped_ptr<cc::CopyOutputRequest> request = 169 scoped_ptr<cc::CopyOutputRequest> request =
166 cc::CopyOutputRequest::CreateRequest(base::Bind( 170 cc::CopyOutputRequest::CreateRequest(base::Bind(
167 &DelegatedFrameHost:: 171 &DelegatedFrameHost::
168 CopyFromCompositingSurfaceHasResultForVideo, 172 CopyFromCompositingSurfaceHasResultForVideo,
169 AsWeakPtr(), // For caching the ReadbackYUVInterface on this class. 173 AsWeakPtr(), // For caching the ReadbackYUVInterface on this class.
170 nullptr, 174 nullptr,
171 target, 175 target,
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 release_callback->Run(sync_token, lost_resource); 743 release_callback->Run(sync_token, lost_resource);
740 } 744 }
741 ReturnSubscriberTexture(dfh, subscriber_texture, sync_token); 745 ReturnSubscriberTexture(dfh, subscriber_texture, sync_token);
742 } 746 }
743 747
744 // static 748 // static
745 void DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo( 749 void DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo(
746 base::WeakPtr<DelegatedFrameHost> dfh, 750 base::WeakPtr<DelegatedFrameHost> dfh,
747 scoped_refptr<OwnedMailbox> subscriber_texture, 751 scoped_refptr<OwnedMailbox> subscriber_texture,
748 scoped_refptr<media::VideoFrame> video_frame, 752 scoped_refptr<media::VideoFrame> video_frame,
749 const base::Callback<void(bool)>& callback, 753 const base::Callback<void(const gfx::Rect&, bool)>& callback,
750 scoped_ptr<cc::CopyOutputResult> result) { 754 scoped_ptr<cc::CopyOutputResult> result) {
751 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); 755 base::ScopedClosureRunner scoped_callback_runner(
752 base::ScopedClosureRunner scoped_return_subscriber_texture(base::Bind( 756 base::Bind(callback, gfx::Rect(), false));
753 &ReturnSubscriberTexture, dfh, subscriber_texture, gpu::SyncToken())); 757 base::ScopedClosureRunner scoped_return_subscriber_texture(
758 base::Bind(&ReturnSubscriberTexture, dfh, subscriber_texture,
759 gpu::SyncToken()));
754 760
755 if (!dfh) 761 if (!dfh)
756 return; 762 return;
757 if (result->IsEmpty()) 763 if (result->IsEmpty())
758 return; 764 return;
759 if (result->size().IsEmpty()) 765 if (result->size().IsEmpty())
760 return; 766 return;
761 767
762 // Compute the dest size we want after the letterboxing resize. Make the 768 // Compute the dest size we want after the letterboxing resize. Make the
763 // coordinates and sizes even because we letterbox in YUV space 769 // coordinates and sizes even because we letterbox in YUV space
(...skipping 28 matching lines...) Expand all
792 { 798 {
793 SkAutoLockPixels scaled_bitmap_locker(scaled_bitmap); 799 SkAutoLockPixels scaled_bitmap_locker(scaled_bitmap);
794 800
795 media::CopyRGBToVideoFrame( 801 media::CopyRGBToVideoFrame(
796 reinterpret_cast<uint8*>(scaled_bitmap.getPixels()), 802 reinterpret_cast<uint8*>(scaled_bitmap.getPixels()),
797 scaled_bitmap.rowBytes(), 803 scaled_bitmap.rowBytes(),
798 region_in_frame, 804 region_in_frame,
799 video_frame.get()); 805 video_frame.get());
800 } 806 }
801 ignore_result(scoped_callback_runner.Release()); 807 ignore_result(scoped_callback_runner.Release());
802 callback.Run(true); 808 callback.Run(region_in_frame, true);
803 return; 809 return;
804 } 810 }
805 811
806 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 812 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
807 GLHelper* gl_helper = factory->GetGLHelper(); 813 GLHelper* gl_helper = factory->GetGLHelper();
808 if (!gl_helper) 814 if (!gl_helper)
809 return; 815 return;
810 if (subscriber_texture.get() && !subscriber_texture->texture_id()) 816 if (subscriber_texture.get() && !subscriber_texture->texture_id())
811 return; 817 return;
812 818
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 result_rect.size(), 851 result_rect.size(),
846 result_rect, 852 result_rect,
847 region_in_frame.size(), 853 region_in_frame.size(),
848 true, 854 true,
849 true)); 855 true));
850 yuv_readback_pipeline = dfh->yuv_readback_pipeline_.get(); 856 yuv_readback_pipeline = dfh->yuv_readback_pipeline_.get();
851 } 857 }
852 858
853 ignore_result(scoped_callback_runner.Release()); 859 ignore_result(scoped_callback_runner.Release());
854 ignore_result(scoped_return_subscriber_texture.Release()); 860 ignore_result(scoped_return_subscriber_texture.Release());
861
855 base::Callback<void(bool result)> finished_callback = base::Bind( 862 base::Callback<void(bool result)> finished_callback = base::Bind(
856 &DelegatedFrameHost::CopyFromCompositingSurfaceFinishedForVideo, 863 &DelegatedFrameHost::CopyFromCompositingSurfaceFinishedForVideo,
857 dfh->AsWeakPtr(), 864 dfh->AsWeakPtr(), base::Bind(callback, region_in_frame),
858 callback, 865 subscriber_texture, base::Passed(&release_callback));
859 subscriber_texture, 866 yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(),
860 base::Passed(&release_callback)); 867 texture_mailbox.sync_token(),
861 yuv_readback_pipeline->ReadbackYUV( 868 video_frame.get(),
862 texture_mailbox.mailbox(), texture_mailbox.sync_token(), 869 region_in_frame.origin(),
863 video_frame.get(), region_in_frame.origin(), finished_callback); 870 finished_callback);
864 } 871 }
865 872
866 //////////////////////////////////////////////////////////////////////////////// 873 ////////////////////////////////////////////////////////////////////////////////
867 // DelegatedFrameHost, ui::CompositorObserver implementation: 874 // DelegatedFrameHost, ui::CompositorObserver implementation:
868 875
869 void DelegatedFrameHost::OnCompositingDidCommit( 876 void DelegatedFrameHost::OnCompositingDidCommit(
870 ui::Compositor* compositor) { 877 ui::Compositor* compositor) {
871 if (can_lock_compositor_ == NO_PENDING_COMMIT) { 878 if (can_lock_compositor_ == NO_PENDING_COMMIT) {
872 can_lock_compositor_ = YES_CAN_LOCK; 879 can_lock_compositor_ = YES_CAN_LOCK;
873 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) 880 if (resize_lock_.get() && resize_lock_->GrabDeferredLock())
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 1041 cc::SurfaceManager* manager = factory->GetSurfaceManager();
1035 new_layer->SetShowSurface( 1042 new_layer->SetShowSurface(
1036 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), 1043 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)),
1037 base::Bind(&RequireCallback, base::Unretained(manager)), 1044 base::Bind(&RequireCallback, base::Unretained(manager)),
1038 current_surface_size_, current_scale_factor_, 1045 current_surface_size_, current_scale_factor_,
1039 current_frame_size_in_dip_); 1046 current_frame_size_in_dip_);
1040 } 1047 }
1041 } 1048 }
1042 1049
1043 } // namespace content 1050 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/delegated_frame_host.h ('k') | content/browser/frame_host/render_widget_host_view_child_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698