OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
24 #include "base/threading/worker_pool.h" | 24 #include "base/threading/worker_pool.h" |
25 #include "cc/layers/layer.h" | 25 #include "cc/layers/layer.h" |
26 #include "cc/layers/surface_layer.h" | 26 #include "cc/layers/surface_layer.h" |
27 #include "cc/output/compositor_frame.h" | 27 #include "cc/output/compositor_frame.h" |
28 #include "cc/output/compositor_frame_ack.h" | 28 #include "cc/output/compositor_frame_ack.h" |
29 #include "cc/output/copy_output_request.h" | 29 #include "cc/output/copy_output_request.h" |
30 #include "cc/output/copy_output_result.h" | 30 #include "cc/output/copy_output_result.h" |
31 #include "cc/output/latency_info_swap_promise.h" | 31 #include "cc/output/latency_info_swap_promise.h" |
32 #include "cc/resources/single_release_callback.h" | 32 #include "cc/resources/single_release_callback.h" |
33 #include "cc/surfaces/surface.h" | |
34 #include "cc/surfaces/surface_factory.h" | 33 #include "cc/surfaces/surface_factory.h" |
35 #include "cc/surfaces/surface_id_allocator.h" | 34 #include "cc/surfaces/surface_id_allocator.h" |
36 #include "cc/surfaces/surface_manager.h" | |
37 #include "cc/trees/layer_tree_host.h" | 35 #include "cc/trees/layer_tree_host.h" |
38 #include "components/display_compositor/gl_helper.h" | 36 #include "components/display_compositor/gl_helper.h" |
39 #include "content/browser/accessibility/browser_accessibility_manager_android.h" | 37 #include "content/browser/accessibility/browser_accessibility_manager_android.h" |
40 #include "content/browser/android/composited_touch_handle_drawable.h" | 38 #include "content/browser/android/composited_touch_handle_drawable.h" |
41 #include "content/browser/android/content_view_core_impl.h" | 39 #include "content/browser/android/content_view_core_impl.h" |
42 #include "content/browser/android/overscroll_controller_android.h" | 40 #include "content/browser/android/overscroll_controller_android.h" |
43 #include "content/browser/android/popup_touch_handle_drawable.h" | 41 #include "content/browser/android/popup_touch_handle_drawable.h" |
44 #include "content/browser/android/synchronous_compositor_host.h" | 42 #include "content/browser/android/synchronous_compositor_host.h" |
45 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 43 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
46 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 44 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 #include "ui/gfx/android/java_bitmap.h" | 86 #include "ui/gfx/android/java_bitmap.h" |
89 #include "ui/gfx/android/view_configuration.h" | 87 #include "ui/gfx/android/view_configuration.h" |
90 #include "ui/gfx/geometry/dip_util.h" | 88 #include "ui/gfx/geometry/dip_util.h" |
91 #include "ui/gfx/geometry/size_conversions.h" | 89 #include "ui/gfx/geometry/size_conversions.h" |
92 #include "ui/touch_selection/touch_selection_controller.h" | 90 #include "ui/touch_selection/touch_selection_controller.h" |
93 | 91 |
94 namespace content { | 92 namespace content { |
95 | 93 |
96 namespace { | 94 namespace { |
97 | 95 |
98 void SatisfyCallback(cc::SurfaceManager* manager, | |
99 const cc::SurfaceSequence& sequence) { | |
100 std::vector<uint32_t> sequences; | |
101 sequences.push_back(sequence.sequence); | |
102 manager->DidSatisfySequences(sequence.id_namespace, &sequences); | |
103 } | |
104 | |
105 void RequireCallback(cc::SurfaceManager* manager, | |
106 const cc::SurfaceId& id, | |
107 const cc::SurfaceSequence& sequence) { | |
108 cc::Surface* surface = manager->GetSurfaceForId(id); | |
109 if (!surface) { | |
110 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; | |
111 return; | |
112 } | |
113 surface->AddDestructionDependency(sequence); | |
114 } | |
115 | |
116 const int kUndefinedOutputSurfaceId = -1; | 96 const int kUndefinedOutputSurfaceId = -1; |
117 | 97 |
118 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; | 98 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; |
119 | 99 |
120 class GLHelperHolder { | 100 class GLHelperHolder { |
121 public: | 101 public: |
122 static GLHelperHolder* Create(); | 102 static GLHelperHolder* Create(); |
123 | 103 |
124 display_compositor::GLHelper* gl_helper() { return gl_helper_.get(); } | 104 display_compositor::GLHelper* gl_helper() { return gl_helper_.get(); } |
125 bool IsLost() { | 105 bool IsLost() { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { | 257 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { |
278 gfx::RectF rect = controller.GetRectBetweenBounds(); | 258 gfx::RectF rect = controller.GetRectBetweenBounds(); |
279 if (rect.IsEmpty()) | 259 if (rect.IsEmpty()) |
280 return rect; | 260 return rect; |
281 | 261 |
282 rect.Union(controller.GetStartHandleRect()); | 262 rect.Union(controller.GetStartHandleRect()); |
283 rect.Union(controller.GetEndHandleRect()); | 263 rect.Union(controller.GetEndHandleRect()); |
284 return rect; | 264 return rect; |
285 } | 265 } |
286 | 266 |
287 scoped_refptr<cc::SurfaceLayer> CreateSurfaceLayer( | |
288 const cc::SurfaceId& surface_id, | |
289 const gfx::Size& size) { | |
290 DCHECK(!surface_id.is_null()); | |
291 cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager(); | |
292 DCHECK(manager); | |
293 // manager must outlive compositors using it. | |
294 scoped_refptr<cc::SurfaceLayer> surface_layer = cc::SurfaceLayer::Create( | |
295 base::Bind(&SatisfyCallback, base::Unretained(manager)), | |
296 base::Bind(&RequireCallback, base::Unretained(manager))); | |
297 surface_layer->SetSurfaceId(surface_id, 1.f, size); | |
298 surface_layer->SetBounds(size); | |
299 surface_layer->SetIsDrawable(true); | |
300 surface_layer->SetContentsOpaque(true); | |
301 | |
302 return surface_layer; | |
303 } | |
304 | |
305 } // anonymous namespace | 267 } // anonymous namespace |
306 | 268 |
307 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo( | 269 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo( |
308 uint32_t output_id, | 270 uint32_t output_id, |
309 cc::CompositorFrame output_frame) | 271 cc::CompositorFrame output_frame) |
310 : output_surface_id(output_id), frame(std::move(output_frame)) {} | 272 : output_surface_id(output_id), frame(std::move(output_frame)) {} |
311 | 273 |
312 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {} | 274 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {} |
313 | 275 |
314 void RenderWidgetHostViewAndroid::OnContextLost() { | 276 void RenderWidgetHostViewAndroid::OnContextLost() { |
(...skipping 21 matching lines...) Expand all Loading... | |
336 last_output_surface_id_(kUndefinedOutputSurfaceId), | 298 last_output_surface_id_(kUndefinedOutputSurfaceId), |
337 gesture_provider_(ui::GetGestureProviderConfig( | 299 gesture_provider_(ui::GetGestureProviderConfig( |
338 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 300 ui::GestureProviderConfigType::CURRENT_PLATFORM), |
339 this), | 301 this), |
340 stylus_text_selector_(this), | 302 stylus_text_selector_(this), |
341 using_browser_compositor_(CompositorImpl::IsInitialized()), | 303 using_browser_compositor_(CompositorImpl::IsInitialized()), |
342 frame_evictor_(new DelegatedFrameEvictor(this)), | 304 frame_evictor_(new DelegatedFrameEvictor(this)), |
343 locks_on_frame_count_(0), | 305 locks_on_frame_count_(0), |
344 observing_root_window_(false), | 306 observing_root_window_(false), |
345 weak_ptr_factory_(this) { | 307 weak_ptr_factory_(this) { |
346 if (CompositorImpl::GetSurfaceManager()) | |
347 id_allocator_ = CompositorImpl::CreateSurfaceIdAllocator(); | |
348 host_->SetView(this); | 308 host_->SetView(this); |
349 SetContentViewCore(content_view_core); | 309 SetContentViewCore(content_view_core); |
350 } | 310 } |
351 | 311 |
352 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { | 312 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { |
353 if (content_view_core_) | 313 if (content_view_core_) |
354 content_view_core_->RemoveObserver(this); | 314 content_view_core_->RemoveObserver(this); |
355 SetContentViewCore(NULL); | 315 SetContentViewCore(NULL); |
356 DCHECK(ack_callbacks_.empty()); | 316 DCHECK(ack_callbacks_.empty()); |
357 DCHECK(!surface_factory_); | 317 DCHECK(!delegated_frame_host_); |
358 DCHECK(surface_id_.is_null()); | |
359 } | 318 } |
360 | 319 |
361 void RenderWidgetHostViewAndroid::Blur() { | 320 void RenderWidgetHostViewAndroid::Blur() { |
362 host_->Blur(); | 321 host_->Blur(); |
363 if (overscroll_controller_) | 322 if (overscroll_controller_) |
364 overscroll_controller_->Disable(); | 323 overscroll_controller_->Disable(); |
365 } | 324 } |
366 | 325 |
367 bool RenderWidgetHostViewAndroid::OnMessageReceived( | 326 bool RenderWidgetHostViewAndroid::OnMessageReceived( |
368 const IPC::Message& message) { | 327 const IPC::Message& message) { |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
797 void RenderWidgetHostViewAndroid::RenderProcessGone( | 756 void RenderWidgetHostViewAndroid::RenderProcessGone( |
798 base::TerminationStatus status, int error_code) { | 757 base::TerminationStatus status, int error_code) { |
799 Destroy(); | 758 Destroy(); |
800 } | 759 } |
801 | 760 |
802 void RenderWidgetHostViewAndroid::Destroy() { | 761 void RenderWidgetHostViewAndroid::Destroy() { |
803 host_->ViewDestroyed(); | 762 host_->ViewDestroyed(); |
804 RemoveLayers(); | 763 RemoveLayers(); |
805 SetContentViewCore(NULL); | 764 SetContentViewCore(NULL); |
806 | 765 |
807 if (!surface_id_.is_null()) { | 766 delegated_frame_host_.reset(); |
808 DCHECK(surface_factory_.get()); | |
809 surface_factory_->Destroy(surface_id_); | |
810 surface_id_ = cc::SurfaceId(); | |
811 } | |
812 surface_factory_.reset(); | |
813 | 767 |
814 // The RenderWidgetHost's destruction led here, so don't call it. | 768 // The RenderWidgetHost's destruction led here, so don't call it. |
815 host_ = NULL; | 769 host_ = NULL; |
816 | 770 |
817 delete this; | 771 delete this; |
818 } | 772 } |
819 | 773 |
820 void RenderWidgetHostViewAndroid::SetTooltipText( | 774 void RenderWidgetHostViewAndroid::SetTooltipText( |
821 const base::string16& tooltip_text) { | 775 const base::string16& tooltip_text) { |
822 // Tooltips don't makes sense on Android. | 776 // Tooltips don't makes sense on Android. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback, | 842 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback, |
889 preferred_color_type); | 843 preferred_color_type); |
890 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", | 844 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", |
891 base::TimeTicks::Now() - start_time); | 845 base::TimeTicks::Now() - start_time); |
892 return; | 846 return; |
893 } | 847 } |
894 | 848 |
895 ui::WindowAndroidCompositor* compositor = | 849 ui::WindowAndroidCompositor* compositor = |
896 content_view_core_->GetWindowAndroid()->GetCompositor(); | 850 content_view_core_->GetWindowAndroid()->GetCompositor(); |
897 DCHECK(compositor); | 851 DCHECK(compositor); |
898 DCHECK(!surface_id_.is_null()); | 852 DCHECK(delegated_frame_host_->HasDelegatedContent()); |
899 std::unique_ptr<cc::CopyOutputRequest> request = | 853 std::unique_ptr<cc::CopyOutputRequest> request = |
900 cc::CopyOutputRequest::CreateRequest(base::Bind( | 854 cc::CopyOutputRequest::CreateRequest(base::Bind( |
901 &PrepareTextureCopyOutputResult, weak_ptr_factory_.GetWeakPtr(), | 855 &PrepareTextureCopyOutputResult, weak_ptr_factory_.GetWeakPtr(), |
902 dst_size_in_pixel, preferred_color_type, start_time, callback)); | 856 dst_size_in_pixel, preferred_color_type, start_time, callback)); |
903 if (!src_subrect_in_pixel.IsEmpty()) | 857 if (!src_subrect_in_pixel.IsEmpty()) |
904 request->set_area(src_subrect_in_pixel); | 858 request->set_area(src_subrect_in_pixel); |
905 // Make sure the layer doesn't get deleted until we fulfill the request. | 859 // Make sure the layer doesn't get deleted until we fulfill the request. |
906 LockCompositingSurface(); | 860 LockCompositingSurface(); |
907 layer_->RequestCopyOfOutput(std::move(request)); | 861 layer_->RequestCopyOfOutput(std::move(request)); |
908 } | 862 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
948 uint32_t output_surface_id) { | 902 uint32_t output_surface_id) { |
949 DCHECK(host_); | 903 DCHECK(host_); |
950 cc::CompositorFrameAck ack; | 904 cc::CompositorFrameAck ack; |
951 DCHECK(!surface_returned_resources_.empty()); | 905 DCHECK(!surface_returned_resources_.empty()); |
952 ack.resources.swap(surface_returned_resources_); | 906 ack.resources.swap(surface_returned_resources_); |
953 | 907 |
954 host_->Send(new ViewMsg_ReclaimCompositorResources(host_->GetRoutingID(), | 908 host_->Send(new ViewMsg_ReclaimCompositorResources(host_->GetRoutingID(), |
955 output_surface_id, ack)); | 909 output_surface_id, ack)); |
956 } | 910 } |
957 | 911 |
958 void RenderWidgetHostViewAndroid::ReturnResources( | 912 void RenderWidgetHostViewAndroid::ReturnCompositorFrameResources( |
959 const cc::ReturnedResourceArray& resources) { | 913 const cc::ReturnedResourceArray& resources) { |
960 if (resources.empty()) | 914 if (resources.empty()) |
961 return; | 915 return; |
962 std::copy(resources.begin(), resources.end(), | 916 std::copy(resources.begin(), resources.end(), |
963 std::back_inserter(surface_returned_resources_)); | 917 std::back_inserter(surface_returned_resources_)); |
964 if (ack_callbacks_.empty()) | 918 if (ack_callbacks_.empty()) |
965 SendReturnedDelegatedResources(last_output_surface_id_); | 919 SendReturnedDelegatedResources(last_output_surface_id_); |
966 } | 920 } |
967 | 921 |
968 void RenderWidgetHostViewAndroid::SetBeginFrameSource( | 922 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() { |
969 cc::BeginFrameSource* begin_frame_source) { | 923 if (!delegated_frame_host_) |
970 // TODO(tansell): Hook this up. | 924 return; |
971 } | |
972 | 925 |
973 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() { | 926 delegated_frame_host_->DestroyDelegatedContent(); |
974 RemoveLayers(); | |
975 if (!surface_id_.is_null()) { | |
976 DCHECK(surface_factory_.get()); | |
977 surface_factory_->Destroy(surface_id_); | |
978 surface_id_ = cc::SurfaceId(); | |
979 } | |
980 layer_ = NULL; | |
981 } | 927 } |
982 | 928 |
983 void RenderWidgetHostViewAndroid::CheckOutputSurfaceChanged( | 929 void RenderWidgetHostViewAndroid::CheckOutputSurfaceChanged( |
984 uint32_t output_surface_id) { | 930 uint32_t output_surface_id) { |
985 if (output_surface_id == last_output_surface_id_) | 931 if (output_surface_id == last_output_surface_id_) |
986 return; | 932 return; |
987 DestroyDelegatedContent(); | 933 |
988 surface_factory_.reset(); | 934 delegated_frame_host_.reset(); |
989 if (!surface_returned_resources_.empty()) | 935 if (!surface_returned_resources_.empty()) |
990 SendReturnedDelegatedResources(last_output_surface_id_); | 936 SendReturnedDelegatedResources(last_output_surface_id_); |
991 | 937 |
938 delegated_frame_host_.reset(new DelegatedFrameHostAndroid( | |
939 CompositorImpl::GetSurfaceManager(), | |
940 CompositorImpl::CreateSurfaceIdAllocator(), this)); | |
941 | |
992 last_output_surface_id_ = output_surface_id; | 942 last_output_surface_id_ = output_surface_id; |
993 } | 943 } |
994 | 944 |
995 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( | |
996 cc::CompositorFrame frame) { | |
997 cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager(); | |
998 if (!surface_factory_) { | |
999 surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this)); | |
1000 } | |
1001 if (surface_id_.is_null() || | |
1002 texture_size_in_layer_ != current_surface_size_ || | |
1003 location_bar_content_translation_ != | |
1004 frame.metadata.location_bar_content_translation || | |
1005 current_viewport_selection_ != frame.metadata.selection) { | |
1006 RemoveLayers(); | |
1007 if (!surface_id_.is_null()) | |
1008 surface_factory_->Destroy(surface_id_); | |
1009 surface_id_ = id_allocator_->GenerateId(); | |
1010 surface_factory_->Create(surface_id_); | |
1011 layer_ = CreateSurfaceLayer(surface_id_, texture_size_in_layer_); | |
1012 | |
1013 DCHECK(layer_); | |
1014 | |
1015 current_surface_size_ = texture_size_in_layer_; | |
1016 location_bar_content_translation_ = | |
1017 frame.metadata.location_bar_content_translation; | |
1018 current_viewport_selection_ = frame.metadata.selection; | |
1019 AttachLayers(); | |
1020 } | |
1021 | |
1022 cc::SurfaceFactory::DrawCallback ack_callback = | |
1023 base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks, | |
1024 weak_ptr_factory_.GetWeakPtr()); | |
1025 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), | |
1026 ack_callback); | |
1027 } | |
1028 | |
1029 void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame( | 945 void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame( |
1030 uint32_t output_surface_id, | 946 uint32_t output_surface_id, |
1031 cc::CompositorFrame frame) { | 947 cc::CompositorFrame frame) { |
1032 last_scroll_offset_ = frame.metadata.root_scroll_offset; | 948 last_scroll_offset_ = frame.metadata.root_scroll_offset; |
1033 DCHECK(frame.delegated_frame_data); | 949 DCHECK(frame.delegated_frame_data); |
1034 DCHECK(CompositorImpl::GetSurfaceManager()); | 950 DCHECK(CompositorImpl::GetSurfaceManager()); |
1035 | 951 |
1036 if (locks_on_frame_count_ > 0) { | 952 if (locks_on_frame_count_ > 0) { |
1037 DCHECK(HasValidFrame()); | 953 DCHECK(HasValidFrame()); |
1038 RetainFrame(output_surface_id, std::move(frame)); | 954 RetainFrame(output_surface_id, std::move(frame)); |
1039 return; | 955 return; |
1040 } | 956 } |
1041 | 957 |
1042 DCHECK(!frame.delegated_frame_data->render_pass_list.empty()); | 958 DCHECK(!frame.delegated_frame_data->render_pass_list.empty()); |
1043 | 959 |
1044 cc::RenderPass* root_pass = | 960 cc::RenderPass* root_pass = |
1045 frame.delegated_frame_data->render_pass_list.back().get(); | 961 frame.delegated_frame_data->render_pass_list.back().get(); |
1046 texture_size_in_layer_ = root_pass->output_rect.size(); | 962 texture_size_in_layer_ = root_pass->output_rect.size(); |
1047 | 963 |
1048 cc::CompositorFrameMetadata metadata = frame.metadata.Clone(); | 964 cc::CompositorFrameMetadata metadata = frame.metadata.Clone(); |
1049 | 965 |
1050 CheckOutputSurfaceChanged(output_surface_id); | 966 CheckOutputSurfaceChanged(output_surface_id); |
967 DCHECK(delegated_frame_host_); | |
968 | |
1051 bool has_content = !texture_size_in_layer_.IsEmpty(); | 969 bool has_content = !texture_size_in_layer_.IsEmpty(); |
1052 | 970 |
1053 base::Closure ack_callback = | 971 base::Closure ack_callback = |
1054 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck, | 972 base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck, |
1055 weak_ptr_factory_.GetWeakPtr(), | 973 weak_ptr_factory_.GetWeakPtr(), |
1056 output_surface_id); | 974 output_surface_id); |
1057 | 975 |
1058 ack_callbacks_.push(ack_callback); | 976 ack_callbacks_.push(ack_callback); |
1059 | 977 |
1060 if (!has_content) { | 978 if (!has_content) { |
1061 DestroyDelegatedContent(); | 979 DestroyDelegatedContent(); |
1062 } else { | 980 } else { |
1063 SubmitCompositorFrame(std::move(frame)); | 981 delegated_frame_host_->SubmitCompositorFrame( |
982 std::move(frame), | |
983 base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks, | |
984 weak_ptr_factory_.GetWeakPtr())); | |
985 DCHECK(layer_); | |
986 | |
1064 layer_->SetIsDrawable(true); | 987 layer_->SetIsDrawable(true); |
1065 layer_->SetContentsOpaque(true); | 988 layer_->SetContentsOpaque(true); |
1066 layer_->SetBounds(texture_size_in_layer_); | 989 layer_->SetBounds(texture_size_in_layer_); |
1067 } | 990 } |
1068 | 991 |
1069 if (host_->is_hidden()) | 992 if (host_->is_hidden()) |
1070 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); | 993 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); |
1071 frame_evictor_->SwappedFrame(!host_->is_hidden()); | 994 frame_evictor_->SwappedFrame(!host_->is_hidden()); |
1072 | 995 |
1073 // As the metadata update may trigger view invalidation, always call it after | 996 // As the metadata update may trigger view invalidation, always call it after |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1187 return PopupTouchHandleDrawable::Create(content_view_core_); | 1110 return PopupTouchHandleDrawable::Create(content_view_core_); |
1188 | 1111 |
1189 return std::unique_ptr< | 1112 return std::unique_ptr< |
1190 ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable( | 1113 ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable( |
1191 content_view_core_->GetLayer().get(), content_view_core_->GetDpiScale(), | 1114 content_view_core_->GetLayer().get(), content_view_core_->GetDpiScale(), |
1192 // Use the activity context (instead of the application context) to ensure | 1115 // Use the activity context (instead of the application context) to ensure |
1193 // proper handle theming. | 1116 // proper handle theming. |
1194 content_view_core_->GetContext().obj())); | 1117 content_view_core_->GetContext().obj())); |
1195 } | 1118 } |
1196 | 1119 |
1120 void RenderWidgetHostViewAndroid::AttachSurfaceLayer( | |
Khushal
2016/07/12 02:02:25
I was looking at removing the Attach and Detach Su
| |
1121 scoped_refptr<cc::SurfaceLayer> layer) { | |
1122 layer_ = std::move(layer); | |
1123 AttachLayers(); | |
1124 } | |
1125 | |
1126 void RenderWidgetHostViewAndroid::DetachSurfaceLayer() { | |
1127 RemoveLayers(); | |
1128 layer_ = nullptr; | |
1129 } | |
1130 | |
1197 void RenderWidgetHostViewAndroid::SynchronousCopyContents( | 1131 void RenderWidgetHostViewAndroid::SynchronousCopyContents( |
1198 const gfx::Rect& src_subrect_in_pixel, | 1132 const gfx::Rect& src_subrect_in_pixel, |
1199 const gfx::Size& dst_size_in_pixel, | 1133 const gfx::Size& dst_size_in_pixel, |
1200 const ReadbackRequestCallback& callback, | 1134 const ReadbackRequestCallback& callback, |
1201 const SkColorType color_type) { | 1135 const SkColorType color_type) { |
1202 gfx::Size input_size_in_pixel; | 1136 gfx::Size input_size_in_pixel; |
1203 if (src_subrect_in_pixel.IsEmpty()) | 1137 if (src_subrect_in_pixel.IsEmpty()) |
1204 input_size_in_pixel = texture_size_in_layer_; | 1138 input_size_in_pixel = texture_size_in_layer_; |
1205 else | 1139 else |
1206 input_size_in_pixel = src_subrect_in_pixel.size(); | 1140 input_size_in_pixel = src_subrect_in_pixel.size(); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1448 } | 1382 } |
1449 | 1383 |
1450 void RenderWidgetHostViewAndroid::RequestDisallowInterceptTouchEvent() { | 1384 void RenderWidgetHostViewAndroid::RequestDisallowInterceptTouchEvent() { |
1451 if (content_view_core_) | 1385 if (content_view_core_) |
1452 content_view_core_->RequestDisallowInterceptTouchEvent(); | 1386 content_view_core_->RequestDisallowInterceptTouchEvent(); |
1453 } | 1387 } |
1454 | 1388 |
1455 void RenderWidgetHostViewAndroid::EvictDelegatedFrame() { | 1389 void RenderWidgetHostViewAndroid::EvictDelegatedFrame() { |
1456 DCHECK_EQ(locks_on_frame_count_, 0u); | 1390 DCHECK_EQ(locks_on_frame_count_, 0u); |
1457 frame_evictor_->DiscardedFrame(); | 1391 frame_evictor_->DiscardedFrame(); |
1458 if (layer_.get()) | 1392 DestroyDelegatedContent(); |
1459 DestroyDelegatedContent(); | |
1460 } | 1393 } |
1461 | 1394 |
1462 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( | 1395 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( |
1463 const gfx::Size& desired_size) { | 1396 const gfx::Size& desired_size) { |
1464 NOTREACHED(); | 1397 NOTREACHED(); |
1465 return false; | 1398 return false; |
1466 } | 1399 } |
1467 | 1400 |
1468 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* result) { | 1401 void RenderWidgetHostViewAndroid::GetScreenInfo(blink::WebScreenInfo* result) { |
1469 // ScreenInfo isn't tied to the widget on Android. Always return the default. | 1402 // ScreenInfo isn't tied to the widget on Android. Always return the default. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1672 if (overscroll_controller_) | 1605 if (overscroll_controller_) |
1673 overscroll_controller_->OnOverscrolled(params); | 1606 overscroll_controller_->OnOverscrolled(params); |
1674 } | 1607 } |
1675 | 1608 |
1676 void RenderWidgetHostViewAndroid::DidStopFlinging() { | 1609 void RenderWidgetHostViewAndroid::DidStopFlinging() { |
1677 if (content_view_core_) | 1610 if (content_view_core_) |
1678 content_view_core_->DidStopFlinging(); | 1611 content_view_core_->DidStopFlinging(); |
1679 } | 1612 } |
1680 | 1613 |
1681 uint32_t RenderWidgetHostViewAndroid::GetSurfaceIdNamespace() { | 1614 uint32_t RenderWidgetHostViewAndroid::GetSurfaceIdNamespace() { |
1682 if (id_allocator_) | 1615 if (!delegated_frame_host_) |
1683 return id_allocator_->id_namespace(); | 1616 return 0; |
1684 return 0; | 1617 |
1618 return delegated_frame_host_->GetSurfaceIdNamespace(); | |
1685 } | 1619 } |
1686 | 1620 |
1687 void RenderWidgetHostViewAndroid::SetContentViewCore( | 1621 void RenderWidgetHostViewAndroid::SetContentViewCore( |
1688 ContentViewCoreImpl* content_view_core) { | 1622 ContentViewCoreImpl* content_view_core) { |
1689 DCHECK(!content_view_core || !content_view_core_ || | 1623 DCHECK(!content_view_core || !content_view_core_ || |
1690 (content_view_core_ == content_view_core)); | 1624 (content_view_core_ == content_view_core)); |
1691 RemoveLayers(); | 1625 RemoveLayers(); |
1692 StopObservingRootWindow(); | 1626 StopObservingRootWindow(); |
1693 | 1627 |
1694 bool resize = false; | 1628 bool resize = false; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1852 | 1786 |
1853 void RenderWidgetHostViewAndroid::OnActivityStarted() { | 1787 void RenderWidgetHostViewAndroid::OnActivityStarted() { |
1854 TRACE_EVENT0("browser", "RenderWidgetHostViewAndroid::OnActivityStarted"); | 1788 TRACE_EVENT0("browser", "RenderWidgetHostViewAndroid::OnActivityStarted"); |
1855 DCHECK(observing_root_window_); | 1789 DCHECK(observing_root_window_); |
1856 is_window_activity_started_ = true; | 1790 is_window_activity_started_ = true; |
1857 ShowInternal(); | 1791 ShowInternal(); |
1858 } | 1792 } |
1859 | 1793 |
1860 void RenderWidgetHostViewAndroid::OnLostResources() { | 1794 void RenderWidgetHostViewAndroid::OnLostResources() { |
1861 ReleaseLocksOnSurface(); | 1795 ReleaseLocksOnSurface(); |
1862 if (layer_.get()) | 1796 DestroyDelegatedContent(); |
1863 DestroyDelegatedContent(); | |
1864 DCHECK(ack_callbacks_.empty()); | 1797 DCHECK(ack_callbacks_.empty()); |
1865 } | 1798 } |
1866 | 1799 |
1867 // TODO(wjmaclean): There is significant overlap between | 1800 // TODO(wjmaclean): There is significant overlap between |
1868 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in | 1801 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in |
1869 // this file, and the versions in surface_utils.cc. They should | 1802 // this file, and the versions in surface_utils.cc. They should |
1870 // be merged. See https://crbug.com/582955 | 1803 // be merged. See https://crbug.com/582955 |
1871 | 1804 |
1872 // static | 1805 // static |
1873 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( | 1806 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1990 case ui::MotionEvent::ACTION_UP: | 1923 case ui::MotionEvent::ACTION_UP: |
1991 case ui::MotionEvent::ACTION_POINTER_UP: | 1924 case ui::MotionEvent::ACTION_POINTER_UP: |
1992 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 1925 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
1993 delta.InMicroseconds(), 1, 1000000, 50); | 1926 delta.InMicroseconds(), 1, 1000000, 50); |
1994 default: | 1927 default: |
1995 return; | 1928 return; |
1996 } | 1929 } |
1997 } | 1930 } |
1998 | 1931 |
1999 } // namespace content | 1932 } // namespace content |
OLD | NEW |