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

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: Fix build and tests after rebase 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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 release_callback->Run(sync_point, lost_resource); 751 release_callback->Run(sync_point, lost_resource);
748 } 752 }
749 ReturnSubscriberTexture(dfh, subscriber_texture, sync_point); 753 ReturnSubscriberTexture(dfh, subscriber_texture, sync_point);
750 } 754 }
751 755
752 // static 756 // static
753 void DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo( 757 void DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo(
754 base::WeakPtr<DelegatedFrameHost> dfh, 758 base::WeakPtr<DelegatedFrameHost> dfh,
755 scoped_refptr<OwnedMailbox> subscriber_texture, 759 scoped_refptr<OwnedMailbox> subscriber_texture,
756 scoped_refptr<media::VideoFrame> video_frame, 760 scoped_refptr<media::VideoFrame> video_frame,
757 const base::Callback<void(bool)>& callback, 761 const base::Callback<void(const gfx::Rect&, bool)>& callback,
758 scoped_ptr<cc::CopyOutputResult> result) { 762 scoped_ptr<cc::CopyOutputResult> result) {
759 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); 763 base::ScopedClosureRunner scoped_callback_runner(
764 base::Bind(callback, gfx::Rect(), false));
760 base::ScopedClosureRunner scoped_return_subscriber_texture( 765 base::ScopedClosureRunner scoped_return_subscriber_texture(
761 base::Bind(&ReturnSubscriberTexture, dfh, subscriber_texture, 0)); 766 base::Bind(&ReturnSubscriberTexture, dfh, subscriber_texture, 0));
762 767
763 if (!dfh) 768 if (!dfh)
764 return; 769 return;
765 if (result->IsEmpty()) 770 if (result->IsEmpty())
766 return; 771 return;
767 if (result->size().IsEmpty()) 772 if (result->size().IsEmpty())
768 return; 773 return;
769 774
(...skipping 30 matching lines...) Expand all
800 { 805 {
801 SkAutoLockPixels scaled_bitmap_locker(scaled_bitmap); 806 SkAutoLockPixels scaled_bitmap_locker(scaled_bitmap);
802 807
803 media::CopyRGBToVideoFrame( 808 media::CopyRGBToVideoFrame(
804 reinterpret_cast<uint8*>(scaled_bitmap.getPixels()), 809 reinterpret_cast<uint8*>(scaled_bitmap.getPixels()),
805 scaled_bitmap.rowBytes(), 810 scaled_bitmap.rowBytes(),
806 region_in_frame, 811 region_in_frame,
807 video_frame.get()); 812 video_frame.get());
808 } 813 }
809 ignore_result(scoped_callback_runner.Release()); 814 ignore_result(scoped_callback_runner.Release());
810 callback.Run(true); 815 callback.Run(region_in_frame, true);
811 return; 816 return;
812 } 817 }
813 818
814 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 819 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
815 GLHelper* gl_helper = factory->GetGLHelper(); 820 GLHelper* gl_helper = factory->GetGLHelper();
816 if (!gl_helper) 821 if (!gl_helper)
817 return; 822 return;
818 if (subscriber_texture.get() && !subscriber_texture->texture_id()) 823 if (subscriber_texture.get() && !subscriber_texture->texture_id())
819 return; 824 return;
820 825
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 result_rect.size(), 858 result_rect.size(),
854 result_rect, 859 result_rect,
855 region_in_frame.size(), 860 region_in_frame.size(),
856 true, 861 true,
857 true)); 862 true));
858 yuv_readback_pipeline = dfh->yuv_readback_pipeline_.get(); 863 yuv_readback_pipeline = dfh->yuv_readback_pipeline_.get();
859 } 864 }
860 865
861 ignore_result(scoped_callback_runner.Release()); 866 ignore_result(scoped_callback_runner.Release());
862 ignore_result(scoped_return_subscriber_texture.Release()); 867 ignore_result(scoped_return_subscriber_texture.Release());
868
863 base::Callback<void(bool result)> finished_callback = base::Bind( 869 base::Callback<void(bool result)> finished_callback = base::Bind(
864 &DelegatedFrameHost::CopyFromCompositingSurfaceFinishedForVideo, 870 &DelegatedFrameHost::CopyFromCompositingSurfaceFinishedForVideo,
865 dfh->AsWeakPtr(), 871 dfh->AsWeakPtr(), base::Bind(callback, region_in_frame),
866 callback, 872 subscriber_texture, base::Passed(&release_callback));
867 subscriber_texture,
868 base::Passed(&release_callback));
869 yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(), 873 yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(),
870 texture_mailbox.sync_point(), 874 texture_mailbox.sync_point(),
871 video_frame.get(), 875 video_frame.get(),
872 region_in_frame.origin(), 876 region_in_frame.origin(),
873 finished_callback); 877 finished_callback);
874 } 878 }
875 879
876 //////////////////////////////////////////////////////////////////////////////// 880 ////////////////////////////////////////////////////////////////////////////////
877 // DelegatedFrameHost, ui::CompositorObserver implementation: 881 // DelegatedFrameHost, ui::CompositorObserver implementation:
878 882
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 1048 cc::SurfaceManager* manager = factory->GetSurfaceManager();
1045 new_layer->SetShowSurface( 1049 new_layer->SetShowSurface(
1046 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), 1050 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)),
1047 base::Bind(&RequireCallback, base::Unretained(manager)), 1051 base::Bind(&RequireCallback, base::Unretained(manager)),
1048 current_surface_size_, current_scale_factor_, 1052 current_surface_size_, current_scale_factor_,
1049 current_frame_size_in_dip_); 1053 current_frame_size_in_dip_);
1050 } 1054 }
1051 } 1055 }
1052 1056
1053 } // namespace content 1057 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698