Chromium Code Reviews| 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 "base/android/sys_utils.h" | 9 #include "base/android/sys_utils.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 return; | 628 return; |
| 629 } | 629 } |
| 630 | 630 |
| 631 std::string utf8_selection = base::UTF16ToUTF8(text.substr(pos, n)); | 631 std::string utf8_selection = base::UTF16ToUTF8(text.substr(pos, n)); |
| 632 | 632 |
| 633 content_view_core_->OnSelectionChanged(utf8_selection); | 633 content_view_core_->OnSelectionChanged(utf8_selection); |
| 634 } | 634 } |
| 635 | 635 |
| 636 void RenderWidgetHostViewAndroid::SelectionBoundsChanged( | 636 void RenderWidgetHostViewAndroid::SelectionBoundsChanged( |
| 637 const ViewHostMsg_SelectionBounds_Params& params) { | 637 const ViewHostMsg_SelectionBounds_Params& params) { |
| 638 if (content_view_core_) { | 638 NOTREACHED() << "Selection bounds should be routed through the compositor."; |
| 639 content_view_core_->OnSelectionBoundsChanged(params); | |
| 640 } | |
| 641 } | 639 } |
| 642 | 640 |
| 643 void RenderWidgetHostViewAndroid::ScrollOffsetChanged() { | 641 void RenderWidgetHostViewAndroid::ScrollOffsetChanged() { |
| 644 } | 642 } |
| 645 | 643 |
| 646 void RenderWidgetHostViewAndroid::SetBackgroundOpaque(bool opaque) { | 644 void RenderWidgetHostViewAndroid::SetBackgroundOpaque(bool opaque) { |
| 647 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque); | 645 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque); |
| 648 host_->SetBackgroundOpaque(opaque); | 646 host_->SetBackgroundOpaque(opaque); |
| 649 } | 647 } |
| 650 | 648 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 887 | 885 |
| 888 DCHECK(!frame->delegated_frame_data->render_pass_list.empty()); | 886 DCHECK(!frame->delegated_frame_data->render_pass_list.empty()); |
| 889 | 887 |
| 890 cc::RenderPass* root_pass = | 888 cc::RenderPass* root_pass = |
| 891 frame->delegated_frame_data->render_pass_list.back(); | 889 frame->delegated_frame_data->render_pass_list.back(); |
| 892 texture_size_in_layer_ = root_pass->output_rect.size(); | 890 texture_size_in_layer_ = root_pass->output_rect.size(); |
| 893 ComputeContentsSize(frame->metadata); | 891 ComputeContentsSize(frame->metadata); |
| 894 | 892 |
| 895 SwapDelegatedFrame(output_surface_id, frame->delegated_frame_data.Pass()); | 893 SwapDelegatedFrame(output_surface_id, frame->delegated_frame_data.Pass()); |
| 896 frame_evictor_->SwappedFrame(!host_->is_hidden()); | 894 frame_evictor_->SwappedFrame(!host_->is_hidden()); |
| 895 | |
| 896 // As the selection bound updates may trigger view invalidation, always call | |
| 897 // it after any potential compositor scheduling. | |
| 898 UpdateSelectionBounds(frame->metadata); | |
| 897 } | 899 } |
| 898 | 900 |
| 899 void RenderWidgetHostViewAndroid::OnSwapCompositorFrame( | 901 void RenderWidgetHostViewAndroid::OnSwapCompositorFrame( |
| 900 uint32 output_surface_id, | 902 uint32 output_surface_id, |
| 901 scoped_ptr<cc::CompositorFrame> frame) { | 903 scoped_ptr<cc::CompositorFrame> frame) { |
| 902 InternalSwapCompositorFrame(output_surface_id, frame.Pass()); | 904 InternalSwapCompositorFrame(output_surface_id, frame.Pass()); |
| 903 } | 905 } |
| 904 | 906 |
| 905 void RenderWidgetHostViewAndroid::RetainFrame( | 907 void RenderWidgetHostViewAndroid::RetainFrame( |
| 906 uint32 output_surface_id, | 908 uint32 output_surface_id, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 922 | 924 |
| 923 last_frame_info_.reset(new LastFrameInfo(output_surface_id, frame.Pass())); | 925 last_frame_info_.reset(new LastFrameInfo(output_surface_id, frame.Pass())); |
| 924 } | 926 } |
| 925 | 927 |
| 926 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( | 928 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( |
| 927 const cc::CompositorFrameMetadata& frame_metadata) { | 929 const cc::CompositorFrameMetadata& frame_metadata) { |
| 928 // This is a subset of OnSwapCompositorFrame() used in the synchronous | 930 // This is a subset of OnSwapCompositorFrame() used in the synchronous |
| 929 // compositor flow. | 931 // compositor flow. |
| 930 OnFrameMetadataUpdated(frame_metadata); | 932 OnFrameMetadataUpdated(frame_metadata); |
| 931 ComputeContentsSize(frame_metadata); | 933 ComputeContentsSize(frame_metadata); |
| 934 UpdateSelectionBounds(frame_metadata); | |
| 932 | 935 |
| 933 // DevTools ScreenCast support for Android WebView. | 936 // DevTools ScreenCast support for Android WebView. |
| 934 if (DevToolsAgentHost::HasFor(RenderViewHost::From(GetRenderWidgetHost()))) { | 937 if (DevToolsAgentHost::HasFor(RenderViewHost::From(GetRenderWidgetHost()))) { |
| 935 scoped_refptr<DevToolsAgentHost> dtah = | 938 scoped_refptr<DevToolsAgentHost> dtah = |
| 936 DevToolsAgentHost::GetOrCreateFor( | 939 DevToolsAgentHost::GetOrCreateFor( |
| 937 RenderViewHost::From(GetRenderWidgetHost())); | 940 RenderViewHost::From(GetRenderWidgetHost())); |
| 938 // Unblock the compositor. | 941 // Unblock the compositor. |
| 939 BrowserThread::PostTask( | 942 BrowserThread::PostTask( |
| 940 BrowserThread::UI, FROM_HERE, | 943 BrowserThread::UI, FROM_HERE, |
| 941 base::Bind(&RenderViewDevToolsAgentHost::SynchronousSwapCompositorFrame, | 944 base::Bind(&RenderViewDevToolsAgentHost::SynchronousSwapCompositorFrame, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 993 content_view_core_->UpdateFrameInfo( | 996 content_view_core_->UpdateFrameInfo( |
| 994 frame_metadata.root_scroll_offset, | 997 frame_metadata.root_scroll_offset, |
| 995 frame_metadata.page_scale_factor, | 998 frame_metadata.page_scale_factor, |
| 996 gfx::Vector2dF(frame_metadata.min_page_scale_factor, | 999 gfx::Vector2dF(frame_metadata.min_page_scale_factor, |
| 997 frame_metadata.max_page_scale_factor), | 1000 frame_metadata.max_page_scale_factor), |
| 998 frame_metadata.root_layer_size, | 1001 frame_metadata.root_layer_size, |
| 999 frame_metadata.viewport_size, | 1002 frame_metadata.viewport_size, |
| 1000 frame_metadata.location_bar_offset, | 1003 frame_metadata.location_bar_offset, |
| 1001 frame_metadata.location_bar_content_translation, | 1004 frame_metadata.location_bar_content_translation, |
| 1002 frame_metadata.overdraw_bottom_height); | 1005 frame_metadata.overdraw_bottom_height); |
| 1006 | |
|
aelias_OOO_until_Jul13
2014/06/12 06:22:42
nit: unnecessary newline
jdduke (slow)
2014/06/12 18:32:44
Done.
| |
| 1003 #if defined(VIDEO_HOLE) | 1007 #if defined(VIDEO_HOLE) |
| 1004 if (host_ && host_->IsRenderView()) { | 1008 if (host_ && host_->IsRenderView()) { |
| 1005 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | 1009 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
| 1006 RenderViewHost::From(host_)); | 1010 RenderViewHost::From(host_)); |
| 1007 rvhi->media_web_contents_observer()->OnFrameInfoUpdated(); | 1011 rvhi->media_web_contents_observer()->OnFrameInfoUpdated(); |
| 1008 } | 1012 } |
| 1009 #endif // defined(VIDEO_HOLE) | 1013 #endif // defined(VIDEO_HOLE) |
| 1010 } | 1014 } |
| 1011 | 1015 |
| 1016 void RenderWidgetHostViewAndroid::UpdateSelectionBounds( | |
| 1017 const cc::CompositorFrameMetadata& frame_metadata) { | |
| 1018 if (!content_view_core_) | |
| 1019 return; | |
| 1020 | |
| 1021 const cc::SelectionBound& anchor = frame_metadata.selection_anchor; | |
| 1022 const cc::SelectionBound& focus = frame_metadata.selection_focus; | |
| 1023 | |
| 1024 if (cached_selection_anchor_ == anchor && cached_selection_focus_ == focus) | |
| 1025 return; | |
| 1026 | |
| 1027 TRACE_EVENT0("input", "RenderWidgetHostViewAndroid::UpdateSelectionBounds"); | |
| 1028 | |
| 1029 cached_selection_anchor_ = anchor; | |
| 1030 cached_selection_focus_ = focus; | |
| 1031 | |
| 1032 content_view_core_->OnSelectionBoundsChanged( | |
| 1033 anchor.viewport_rect.bottom_left(), | |
| 1034 focus.viewport_rect.bottom_left(), | |
| 1035 anchor.type == cc::SELECTION_BOUND_RIGHT | |
| 1036 ? blink::WebTextDirectionRightToLeft | |
| 1037 : blink::WebTextDirectionDefault, | |
| 1038 focus.type == cc::SELECTION_BOUND_LEFT | |
| 1039 ? blink::WebTextDirectionRightToLeft | |
| 1040 : blink::WebTextDirectionDefault, | |
| 1041 anchor.visible, | |
| 1042 focus.visible); | |
| 1043 } | |
| 1044 | |
| 1012 void RenderWidgetHostViewAndroid::AcceleratedSurfaceInitialized(int host_id, | 1045 void RenderWidgetHostViewAndroid::AcceleratedSurfaceInitialized(int host_id, |
| 1013 int route_id) { | 1046 int route_id) { |
| 1014 accelerated_surface_route_id_ = route_id; | 1047 accelerated_surface_route_id_ = route_id; |
| 1015 } | 1048 } |
| 1016 | 1049 |
| 1017 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( | 1050 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( |
| 1018 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | 1051 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| 1019 int gpu_host_id) { | 1052 int gpu_host_id) { |
| 1020 NOTREACHED() << "Need --composite-to-mailbox or --enable-delegated-renderer"; | 1053 NOTREACHED() << "Need --composite-to-mailbox or --enable-delegated-renderer"; |
| 1021 } | 1054 } |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1449 results->availableRect = display.work_area(); | 1482 results->availableRect = display.work_area(); |
| 1450 results->deviceScaleFactor = display.device_scale_factor(); | 1483 results->deviceScaleFactor = display.device_scale_factor(); |
| 1451 results->orientationAngle = display.RotationAsDegree(); | 1484 results->orientationAngle = display.RotationAsDegree(); |
| 1452 gfx::DeviceDisplayInfo info; | 1485 gfx::DeviceDisplayInfo info; |
| 1453 results->depth = info.GetBitsPerPixel(); | 1486 results->depth = info.GetBitsPerPixel(); |
| 1454 results->depthPerComponent = info.GetBitsPerComponent(); | 1487 results->depthPerComponent = info.GetBitsPerComponent(); |
| 1455 results->isMonochrome = (results->depthPerComponent == 0); | 1488 results->isMonochrome = (results->depthPerComponent == 0); |
| 1456 } | 1489 } |
| 1457 | 1490 |
| 1458 } // namespace content | 1491 } // namespace content |
| OLD | NEW |