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 <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 619 } | 619 } |
| 620 | 620 |
| 621 float RenderWidgetHostViewAndroid::GetTopControlsHeight() const { | 621 float RenderWidgetHostViewAndroid::GetTopControlsHeight() const { |
| 622 if (!content_view_core_) | 622 if (!content_view_core_) |
| 623 return 0.f; | 623 return 0.f; |
| 624 | 624 |
| 625 // The height of the top controls. | 625 // The height of the top controls. |
| 626 return content_view_core_->GetTopControlsHeightDip(); | 626 return content_view_core_->GetTopControlsHeightDip(); |
| 627 } | 627 } |
| 628 | 628 |
| 629 float RenderWidgetHostViewAndroid::GetBottomControlsHeight() const { | |
| 630 if (!content_view_core_) | |
| 631 return 0.f; | |
| 632 | |
| 633 // The height of the top controls. | |
| 634 return content_view_core_->GetBottomControlsHeightDip(); | |
| 635 } | |
| 636 | |
| 629 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) { | 637 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) { |
| 630 // There are no cursors on Android. | 638 // There are no cursors on Android. |
| 631 } | 639 } |
| 632 | 640 |
| 633 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { | 641 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { |
| 634 // Do nothing. The UI notification is handled through ContentViewClient which | 642 // Do nothing. The UI notification is handled through ContentViewClient which |
| 635 // is TabContentsDelegate. | 643 // is TabContentsDelegate. |
| 636 } | 644 } |
| 637 | 645 |
| 638 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { | 646 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 985 | 993 |
| 986 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( | 994 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( |
| 987 cc::CompositorFrame frame) { | 995 cc::CompositorFrame frame) { |
| 988 cc::SurfaceManager* manager = | 996 cc::SurfaceManager* manager = |
| 989 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager(); | 997 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager(); |
| 990 if (!surface_factory_) { | 998 if (!surface_factory_) { |
| 991 surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this)); | 999 surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this)); |
| 992 } | 1000 } |
| 993 if (surface_id_.is_null() || | 1001 if (surface_id_.is_null() || |
| 994 texture_size_in_layer_ != current_surface_size_ || | 1002 texture_size_in_layer_ != current_surface_size_ || |
| 995 location_bar_content_translation_ != | 1003 top_bar_shown_ratio_ != frame.metadata.top_controls_shown_ratio || |
| 996 frame.metadata.location_bar_content_translation || | 1004 bottom_bar_shown_ratio_ != frame.metadata.bottom_controls_shown_ratio || |
|
no sievers
2016/08/16 20:29:16
This is for pixel-perfect scrolling where tearing
Ian Wen
2016/08/17 00:20:46
Done. I removed #1004, but kept #1017 as is.
| |
| 997 current_viewport_selection_ != frame.metadata.selection) { | 1005 current_viewport_selection_ != frame.metadata.selection) { |
| 998 RemoveLayers(); | 1006 RemoveLayers(); |
| 999 if (!surface_id_.is_null()) | 1007 if (!surface_id_.is_null()) |
| 1000 surface_factory_->Destroy(surface_id_); | 1008 surface_factory_->Destroy(surface_id_); |
| 1001 surface_id_ = id_allocator_->GenerateId(); | 1009 surface_id_ = id_allocator_->GenerateId(); |
| 1002 surface_factory_->Create(surface_id_); | 1010 surface_factory_->Create(surface_id_); |
| 1003 view_.SetLayer(CreateSurfaceLayer(surface_id_, texture_size_in_layer_)); | 1011 view_.SetLayer(CreateSurfaceLayer(surface_id_, texture_size_in_layer_)); |
| 1004 | 1012 |
| 1005 DCHECK(view_.GetLayer()); | 1013 DCHECK(view_.GetLayer()); |
| 1006 | 1014 |
| 1007 current_surface_size_ = texture_size_in_layer_; | 1015 current_surface_size_ = texture_size_in_layer_; |
| 1008 location_bar_content_translation_ = | 1016 top_bar_shown_ratio_ = frame.metadata.top_controls_shown_ratio; |
| 1009 frame.metadata.location_bar_content_translation; | 1017 bottom_bar_shown_ratio_ = frame.metadata.bottom_controls_shown_ratio; |
| 1010 current_viewport_selection_ = frame.metadata.selection; | 1018 current_viewport_selection_ = frame.metadata.selection; |
| 1011 AttachLayers(); | 1019 AttachLayers(); |
| 1012 } | 1020 } |
| 1013 | 1021 |
| 1014 cc::SurfaceFactory::DrawCallback ack_callback = | 1022 cc::SurfaceFactory::DrawCallback ack_callback = |
| 1015 base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks, | 1023 base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks, |
| 1016 weak_ptr_factory_.GetWeakPtr()); | 1024 weak_ptr_factory_.GetWeakPtr()); |
| 1017 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), | 1025 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), |
| 1018 ack_callback); | 1026 ack_callback); |
| 1019 } | 1027 } |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1239 selection_controller_->OnSelectionEditable( | 1247 selection_controller_->OnSelectionEditable( |
| 1240 frame_metadata.selection.is_editable); | 1248 frame_metadata.selection.is_editable); |
| 1241 selection_controller_->OnSelectionEmpty( | 1249 selection_controller_->OnSelectionEmpty( |
| 1242 frame_metadata.selection.is_empty_text_form_control); | 1250 frame_metadata.selection.is_empty_text_form_control); |
| 1243 selection_controller_->OnSelectionBoundsChanged( | 1251 selection_controller_->OnSelectionBoundsChanged( |
| 1244 frame_metadata.selection.start, frame_metadata.selection.end); | 1252 frame_metadata.selection.start, frame_metadata.selection.end); |
| 1245 | 1253 |
| 1246 // Set parameters for adaptive handle orientation. | 1254 // Set parameters for adaptive handle orientation. |
| 1247 gfx::SizeF viewport_size(frame_metadata.scrollable_viewport_size); | 1255 gfx::SizeF viewport_size(frame_metadata.scrollable_viewport_size); |
| 1248 viewport_size.Scale(frame_metadata.page_scale_factor); | 1256 viewport_size.Scale(frame_metadata.page_scale_factor); |
| 1249 gfx::RectF viewport_rect( | 1257 gfx::RectF viewport_rect(0.0f, frame_metadata.top_controls_height * |
| 1250 frame_metadata.location_bar_content_translation.x(), | 1258 frame_metadata.top_controls_shown_ratio, |
| 1251 frame_metadata.location_bar_content_translation.y(), | 1259 viewport_size.width(), viewport_size.height()); |
| 1252 viewport_size.width(), viewport_size.height()); | |
| 1253 selection_controller_->OnViewportChanged(viewport_rect); | 1260 selection_controller_->OnViewportChanged(viewport_rect); |
| 1254 } | 1261 } |
| 1255 | 1262 |
| 1256 UpdateBackgroundColor(frame_metadata.root_background_color); | 1263 UpdateBackgroundColor(frame_metadata.root_background_color); |
| 1257 | 1264 |
| 1258 // All offsets and sizes are in CSS pixels. | 1265 // All offsets and sizes are in CSS pixels. |
| 1259 content_view_core_->UpdateFrameInfo( | 1266 content_view_core_->UpdateFrameInfo( |
| 1260 frame_metadata.root_scroll_offset, | 1267 frame_metadata.root_scroll_offset, |
| 1261 frame_metadata.page_scale_factor, | 1268 frame_metadata.page_scale_factor, |
| 1262 gfx::Vector2dF(frame_metadata.min_page_scale_factor, | 1269 gfx::Vector2dF(frame_metadata.min_page_scale_factor, |
| 1263 frame_metadata.max_page_scale_factor), | 1270 frame_metadata.max_page_scale_factor), |
| 1264 frame_metadata.root_layer_size, | 1271 frame_metadata.root_layer_size, |
| 1265 frame_metadata.scrollable_viewport_size, | 1272 frame_metadata.scrollable_viewport_size, |
| 1266 frame_metadata.location_bar_offset, | 1273 frame_metadata.top_controls_height, |
| 1267 frame_metadata.location_bar_content_translation, | 1274 frame_metadata.top_controls_shown_ratio, |
| 1275 frame_metadata.bottom_controls_height, | |
| 1276 frame_metadata.bottom_controls_shown_ratio, | |
| 1268 is_mobile_optimized, | 1277 is_mobile_optimized, |
| 1269 frame_metadata.selection.start); | 1278 frame_metadata.selection.start); |
| 1270 #if defined(VIDEO_HOLE) | 1279 #if defined(VIDEO_HOLE) |
| 1271 if (host_) { | 1280 if (host_) { |
| 1272 WebContents* web_contents = | 1281 WebContents* web_contents = |
| 1273 WebContents::FromRenderViewHost(RenderViewHostImpl::From(host_)); | 1282 WebContents::FromRenderViewHost(RenderViewHostImpl::From(host_)); |
| 1274 if (web_contents) { | 1283 if (web_contents) { |
| 1275 MediaWebContentsObserverAndroid::FromWebContents(web_contents) | 1284 MediaWebContentsObserverAndroid::FromWebContents(web_contents) |
| 1276 ->OnFrameInfoUpdated(); | 1285 ->OnFrameInfoUpdated(); |
| 1277 } | 1286 } |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1993 case ui::MotionEvent::ACTION_UP: | 2002 case ui::MotionEvent::ACTION_UP: |
| 1994 case ui::MotionEvent::ACTION_POINTER_UP: | 2003 case ui::MotionEvent::ACTION_POINTER_UP: |
| 1995 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 2004 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
| 1996 delta.InMicroseconds(), 1, 1000000, 50); | 2005 delta.InMicroseconds(), 1, 1000000, 50); |
| 1997 default: | 2006 default: |
| 1998 return; | 2007 return; |
| 1999 } | 2008 } |
| 2000 } | 2009 } |
| 2001 | 2010 |
| 2002 } // namespace content | 2011 } // namespace content |
| OLD | NEW |