Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | |
|
sadrul
2015/10/29 16:26:36
The new code in this file don't actually seem to u
| |
| 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 Loading... | |
| 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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 release_callback->Run(sync_point, lost_resource); | 766 release_callback->Run(sync_point, lost_resource); |
| 763 } | 767 } |
| 764 ReturnSubscriberTexture(dfh, subscriber_texture, sync_point); | 768 ReturnSubscriberTexture(dfh, subscriber_texture, sync_point); |
| 765 } | 769 } |
| 766 | 770 |
| 767 // static | 771 // static |
| 768 void DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo( | 772 void DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo( |
| 769 base::WeakPtr<DelegatedFrameHost> dfh, | 773 base::WeakPtr<DelegatedFrameHost> dfh, |
| 770 scoped_refptr<OwnedMailbox> subscriber_texture, | 774 scoped_refptr<OwnedMailbox> subscriber_texture, |
| 771 scoped_refptr<media::VideoFrame> video_frame, | 775 scoped_refptr<media::VideoFrame> video_frame, |
| 772 const base::Callback<void(bool)>& callback, | 776 const base::Callback<void(const gfx::Rect&, bool)>& callback, |
| 773 scoped_ptr<cc::CopyOutputResult> result) { | 777 scoped_ptr<cc::CopyOutputResult> result) { |
| 774 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); | 778 base::ScopedClosureRunner scoped_callback_runner( |
| 779 base::Bind(callback, gfx::Rect(), false)); | |
| 775 base::ScopedClosureRunner scoped_return_subscriber_texture( | 780 base::ScopedClosureRunner scoped_return_subscriber_texture( |
| 776 base::Bind(&ReturnSubscriberTexture, dfh, subscriber_texture, 0)); | 781 base::Bind(&ReturnSubscriberTexture, dfh, subscriber_texture, 0)); |
| 777 | 782 |
| 778 if (!dfh) | 783 if (!dfh) |
| 779 return; | 784 return; |
| 780 if (result->IsEmpty()) | 785 if (result->IsEmpty()) |
| 781 return; | 786 return; |
| 782 if (result->size().IsEmpty()) | 787 if (result->size().IsEmpty()) |
| 783 return; | 788 return; |
| 784 | 789 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 815 { | 820 { |
| 816 SkAutoLockPixels scaled_bitmap_locker(scaled_bitmap); | 821 SkAutoLockPixels scaled_bitmap_locker(scaled_bitmap); |
| 817 | 822 |
| 818 media::CopyRGBToVideoFrame( | 823 media::CopyRGBToVideoFrame( |
| 819 reinterpret_cast<uint8*>(scaled_bitmap.getPixels()), | 824 reinterpret_cast<uint8*>(scaled_bitmap.getPixels()), |
| 820 scaled_bitmap.rowBytes(), | 825 scaled_bitmap.rowBytes(), |
| 821 region_in_frame, | 826 region_in_frame, |
| 822 video_frame.get()); | 827 video_frame.get()); |
| 823 } | 828 } |
| 824 ignore_result(scoped_callback_runner.Release()); | 829 ignore_result(scoped_callback_runner.Release()); |
| 825 callback.Run(true); | 830 callback.Run(region_in_frame, true); |
| 826 return; | 831 return; |
| 827 } | 832 } |
| 828 | 833 |
| 829 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 834 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 830 GLHelper* gl_helper = factory->GetGLHelper(); | 835 GLHelper* gl_helper = factory->GetGLHelper(); |
| 831 if (!gl_helper) | 836 if (!gl_helper) |
| 832 return; | 837 return; |
| 833 if (subscriber_texture.get() && !subscriber_texture->texture_id()) | 838 if (subscriber_texture.get() && !subscriber_texture->texture_id()) |
| 834 return; | 839 return; |
| 835 | 840 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 868 result_rect.size(), | 873 result_rect.size(), |
| 869 result_rect, | 874 result_rect, |
| 870 region_in_frame.size(), | 875 region_in_frame.size(), |
| 871 true, | 876 true, |
| 872 true)); | 877 true)); |
| 873 yuv_readback_pipeline = dfh->yuv_readback_pipeline_.get(); | 878 yuv_readback_pipeline = dfh->yuv_readback_pipeline_.get(); |
| 874 } | 879 } |
| 875 | 880 |
| 876 ignore_result(scoped_callback_runner.Release()); | 881 ignore_result(scoped_callback_runner.Release()); |
| 877 ignore_result(scoped_return_subscriber_texture.Release()); | 882 ignore_result(scoped_return_subscriber_texture.Release()); |
| 883 | |
| 878 base::Callback<void(bool result)> finished_callback = base::Bind( | 884 base::Callback<void(bool result)> finished_callback = base::Bind( |
| 879 &DelegatedFrameHost::CopyFromCompositingSurfaceFinishedForVideo, | 885 &DelegatedFrameHost::CopyFromCompositingSurfaceFinishedForVideo, |
| 880 dfh->AsWeakPtr(), | 886 dfh->AsWeakPtr(), base::Bind(callback, region_in_frame), |
| 881 callback, | 887 subscriber_texture, base::Passed(&release_callback)); |
| 882 subscriber_texture, | |
| 883 base::Passed(&release_callback)); | |
| 884 yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(), | 888 yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(), |
| 885 texture_mailbox.sync_point(), | 889 texture_mailbox.sync_point(), |
| 886 video_frame.get(), | 890 video_frame.get(), |
| 887 region_in_frame.origin(), | 891 region_in_frame.origin(), |
| 888 finished_callback); | 892 finished_callback); |
| 889 } | 893 } |
| 890 | 894 |
| 891 //////////////////////////////////////////////////////////////////////////////// | 895 //////////////////////////////////////////////////////////////////////////////// |
| 892 // DelegatedFrameHost, ui::CompositorObserver implementation: | 896 // DelegatedFrameHost, ui::CompositorObserver implementation: |
| 893 | 897 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1059 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 1063 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 1060 new_layer->SetShowSurface( | 1064 new_layer->SetShowSurface( |
| 1061 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 1065 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
| 1062 base::Bind(&RequireCallback, base::Unretained(manager)), | 1066 base::Bind(&RequireCallback, base::Unretained(manager)), |
| 1063 current_surface_size_, current_scale_factor_, | 1067 current_surface_size_, current_scale_factor_, |
| 1064 current_frame_size_in_dip_); | 1068 current_frame_size_in_dip_); |
| 1065 } | 1069 } |
| 1066 } | 1070 } |
| 1067 | 1071 |
| 1068 } // namespace content | 1072 } // namespace content |
| OLD | NEW |