| 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/build_info.h" | 9 #include "base/android/build_info.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "content/browser/android/overscroll_controller_android.h" | 37 #include "content/browser/android/overscroll_controller_android.h" |
| 38 #include "content/browser/devtools/render_view_devtools_agent_host.h" | 38 #include "content/browser/devtools/render_view_devtools_agent_host.h" |
| 39 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 39 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 40 #include "content/browser/gpu/compositor_util.h" | 40 #include "content/browser/gpu/compositor_util.h" |
| 41 #include "content/browser/gpu/gpu_data_manager_impl.h" | 41 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 42 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 42 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 43 #include "content/browser/gpu/gpu_surface_tracker.h" | 43 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 44 #include "content/browser/media/media_web_contents_observer.h" | 44 #include "content/browser/media/media_web_contents_observer.h" |
| 45 #include "content/browser/renderer_host/compositor_impl_android.h" | 45 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 46 #include "content/browser/renderer_host/dip_util.h" | 46 #include "content/browser/renderer_host/dip_util.h" |
| 47 #include "content/browser/renderer_host/frame_metadata_util.h" |
| 47 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h
" | 48 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h
" |
| 48 #include "content/browser/renderer_host/input/web_input_event_builders_android.h
" | 49 #include "content/browser/renderer_host/input/web_input_event_builders_android.h
" |
| 49 #include "content/browser/renderer_host/input/web_input_event_util.h" | 50 #include "content/browser/renderer_host/input/web_input_event_util.h" |
| 50 #include "content/browser/renderer_host/render_process_host_impl.h" | 51 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 51 #include "content/browser/renderer_host/render_view_host_impl.h" | 52 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 52 #include "content/browser/renderer_host/render_widget_host_impl.h" | 53 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 53 #include "content/common/gpu/client/gl_helper.h" | 54 #include "content/common/gpu/client/gl_helper.h" |
| 54 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 55 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 55 #include "content/common/gpu/gpu_messages.h" | 56 #include "content/common/gpu/gpu_messages.h" |
| 56 #include "content/common/gpu/gpu_process_launch_causes.h" | 57 #include "content/common/gpu/gpu_process_launch_causes.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 81 #include "ui/gfx/geometry/size_conversions.h" | 82 #include "ui/gfx/geometry/size_conversions.h" |
| 82 #include "ui/gfx/screen.h" | 83 #include "ui/gfx/screen.h" |
| 83 #include "ui/touch_selection/touch_selection_controller.h" | 84 #include "ui/touch_selection/touch_selection_controller.h" |
| 84 | 85 |
| 85 namespace content { | 86 namespace content { |
| 86 | 87 |
| 87 namespace { | 88 namespace { |
| 88 | 89 |
| 89 const int kUndefinedOutputSurfaceId = -1; | 90 const int kUndefinedOutputSurfaceId = -1; |
| 90 | 91 |
| 91 // Used to accomodate finite precision when comparing scaled viewport and | |
| 92 // content widths. While this value may seem large, width=device-width on an N7 | |
| 93 // V1 saw errors of ~0.065 between computed window and content widths. | |
| 94 const float kMobileViewportWidthEpsilon = 0.15f; | |
| 95 | |
| 96 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; | 92 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; |
| 97 | 93 |
| 98 // Sends an acknowledgement to the renderer of a processed IME event. | 94 // Sends an acknowledgement to the renderer of a processed IME event. |
| 99 void SendImeEventAck(RenderWidgetHostImpl* host) { | 95 void SendImeEventAck(RenderWidgetHostImpl* host) { |
| 100 host->Send(new ViewMsg_ImeEventAck(host->GetRoutingID())); | 96 host->Send(new ViewMsg_ImeEventAck(host->GetRoutingID())); |
| 101 } | 97 } |
| 102 | 98 |
| 103 class GLHelperHolder | 99 class GLHelperHolder |
| 104 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 100 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
| 105 public: | 101 public: |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 282 |
| 287 ui::GestureProvider::Config CreateGestureProviderConfig() { | 283 ui::GestureProvider::Config CreateGestureProviderConfig() { |
| 288 ui::GestureProvider::Config config = ui::GetGestureProviderConfig( | 284 ui::GestureProvider::Config config = ui::GetGestureProviderConfig( |
| 289 ui::GestureProviderConfigType::CURRENT_PLATFORM); | 285 ui::GestureProviderConfigType::CURRENT_PLATFORM); |
| 290 config.disable_click_delay = | 286 config.disable_click_delay = |
| 291 base::CommandLine::ForCurrentProcess()->HasSwitch( | 287 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 292 switches::kDisableClickDelay); | 288 switches::kDisableClickDelay); |
| 293 return config; | 289 return config; |
| 294 } | 290 } |
| 295 | 291 |
| 296 bool HasFixedPageScale(const cc::CompositorFrameMetadata& frame_metadata) { | |
| 297 return frame_metadata.min_page_scale_factor == | |
| 298 frame_metadata.max_page_scale_factor; | |
| 299 } | |
| 300 | |
| 301 bool HasMobileViewport(const cc::CompositorFrameMetadata& frame_metadata) { | |
| 302 float window_width_dip = | |
| 303 frame_metadata.page_scale_factor * | |
| 304 frame_metadata.scrollable_viewport_size.width(); | |
| 305 float content_width_css = frame_metadata.root_layer_size.width(); | |
| 306 return content_width_css <= window_width_dip + kMobileViewportWidthEpsilon; | |
| 307 } | |
| 308 | |
| 309 } // anonymous namespace | 292 } // anonymous namespace |
| 310 | 293 |
| 311 ReadbackRequest::ReadbackRequest(float scale, | 294 ReadbackRequest::ReadbackRequest(float scale, |
| 312 SkColorType color_type, | 295 SkColorType color_type, |
| 313 gfx::Rect src_subrect, | 296 gfx::Rect src_subrect, |
| 314 ReadbackRequestCallback& result_callback) | 297 ReadbackRequestCallback& result_callback) |
| 315 : scale_(scale), | 298 : scale_(scale), |
| 316 color_type_(color_type), | 299 color_type_(color_type), |
| 317 src_subrect_(src_subrect), | 300 src_subrect_(src_subrect), |
| 318 result_callback_(result_callback) { | 301 result_callback_(result_callback) { |
| (...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 SkCanvas canvas(bitmap); | 1303 SkCanvas canvas(bitmap); |
| 1321 canvas.scale( | 1304 canvas.scale( |
| 1322 (float)output_width / (float)input_size_in_pixel.width(), | 1305 (float)output_width / (float)input_size_in_pixel.width(), |
| 1323 (float)output_height / (float)input_size_in_pixel.height()); | 1306 (float)output_height / (float)input_size_in_pixel.height()); |
| 1324 compositor->DemandDrawSw(&canvas); | 1307 compositor->DemandDrawSw(&canvas); |
| 1325 callback.Run(bitmap, READBACK_SUCCESS); | 1308 callback.Run(bitmap, READBACK_SUCCESS); |
| 1326 } | 1309 } |
| 1327 | 1310 |
| 1328 void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated( | 1311 void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated( |
| 1329 const cc::CompositorFrameMetadata& frame_metadata) { | 1312 const cc::CompositorFrameMetadata& frame_metadata) { |
| 1330 | |
| 1331 // Disable double tap zoom for pages that have a width=device-width or | |
| 1332 // narrower viewport (indicating that this is a mobile-optimized or responsive | |
| 1333 // web design, so text will be legible without zooming). Also disable | |
| 1334 // double tap and pinch for pages that prevent zooming in or out. | |
| 1335 bool has_mobile_viewport = HasMobileViewport(frame_metadata); | |
| 1336 bool has_fixed_page_scale = HasFixedPageScale(frame_metadata); | |
| 1337 gesture_provider_.SetDoubleTapSupportForPageEnabled( | 1313 gesture_provider_.SetDoubleTapSupportForPageEnabled( |
| 1338 !has_fixed_page_scale && !has_mobile_viewport); | 1314 !IsMobileOptimizedFrame(frame_metadata)); |
| 1339 | 1315 |
| 1340 if (!content_view_core_) | 1316 if (!content_view_core_) |
| 1341 return; | 1317 return; |
| 1342 | 1318 |
| 1343 if (overscroll_controller_) | 1319 if (overscroll_controller_) |
| 1344 overscroll_controller_->OnFrameMetadataUpdated(frame_metadata); | 1320 overscroll_controller_->OnFrameMetadataUpdated(frame_metadata); |
| 1345 | 1321 |
| 1346 if (selection_controller_) { | 1322 if (selection_controller_) { |
| 1347 selection_controller_->OnSelectionBoundsChanged( | 1323 selection_controller_->OnSelectionBoundsChanged( |
| 1348 ui::SelectionBound(frame_metadata.selection_start), | 1324 ui::SelectionBound(frame_metadata.selection_start), |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 results->orientationAngle = display.RotationAsDegree(); | 1911 results->orientationAngle = display.RotationAsDegree(); |
| 1936 results->orientationType = | 1912 results->orientationType = |
| 1937 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 1913 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
| 1938 gfx::DeviceDisplayInfo info; | 1914 gfx::DeviceDisplayInfo info; |
| 1939 results->depth = info.GetBitsPerPixel(); | 1915 results->depth = info.GetBitsPerPixel(); |
| 1940 results->depthPerComponent = info.GetBitsPerComponent(); | 1916 results->depthPerComponent = info.GetBitsPerComponent(); |
| 1941 results->isMonochrome = (results->depthPerComponent == 0); | 1917 results->isMonochrome = (results->depthPerComponent == 0); |
| 1942 } | 1918 } |
| 1943 | 1919 |
| 1944 } // namespace content | 1920 } // namespace content |
| OLD | NEW |