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 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 if (!content_view_core_) | 655 if (!content_view_core_) |
| 656 return default_bounds_.size(); | 656 return default_bounds_.size(); |
| 657 | 657 |
| 658 return content_view_core_->GetViewSize(); | 658 return content_view_core_->GetViewSize(); |
| 659 } | 659 } |
| 660 | 660 |
| 661 gfx::Size RenderWidgetHostViewAndroid::GetPhysicalBackingSize() const { | 661 gfx::Size RenderWidgetHostViewAndroid::GetPhysicalBackingSize() const { |
| 662 if (!content_view_core_) { | 662 if (!content_view_core_) { |
| 663 if (default_bounds_.IsEmpty()) return gfx::Size(); | 663 if (default_bounds_.IsEmpty()) return gfx::Size(); |
| 664 | 664 |
| 665 return gfx::Size(default_bounds_.right() | 665 float scale_factor = view_.GetDipScale(); |
| 666 * ui::GetScaleFactorForNativeView(GetNativeView()), | 666 return gfx::Size(default_bounds_.right() * scale_factor, |
|
boliu
2017/03/13 01:51:57
all other platforms are switching to GetScaleFacto
Jinsuk Kim
2017/03/13 01:58:21
ViewAndroid::GetDipScale() calls exactly that. I b
| |
| 667 default_bounds_.bottom() | 667 default_bounds_.bottom() * scale_factor); |
| 668 * ui::GetScaleFactorForNativeView(GetNativeView())); | |
| 669 } | 668 } |
| 670 | 669 |
| 671 return content_view_core_->GetPhysicalBackingSize(); | 670 return content_view_core_->GetPhysicalBackingSize(); |
| 672 } | 671 } |
| 673 | 672 |
| 674 bool RenderWidgetHostViewAndroid::DoBrowserControlsShrinkBlinkSize() const { | 673 bool RenderWidgetHostViewAndroid::DoBrowserControlsShrinkBlinkSize() const { |
| 675 // Whether or not Blink's viewport size should be shrunk by the height of the | 674 // Whether or not Blink's viewport size should be shrunk by the height of the |
| 676 // URL-bar. | 675 // URL-bar. |
| 677 return content_view_core_ && | 676 return content_view_core_ && |
| 678 content_view_core_->DoBrowserControlsShrinkBlinkSize(); | 677 content_view_core_->DoBrowserControlsShrinkBlinkSize(); |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1292 if (!using_browser_compositor_) { | 1291 if (!using_browser_compositor_) { |
| 1293 if (!sync_compositor_) | 1292 if (!sync_compositor_) |
| 1294 return nullptr; | 1293 return nullptr; |
| 1295 return std::unique_ptr<ui::TouchHandleDrawable>( | 1294 return std::unique_ptr<ui::TouchHandleDrawable>( |
| 1296 sync_compositor_->client()->CreateDrawable()); | 1295 sync_compositor_->client()->CreateDrawable()); |
| 1297 } | 1296 } |
| 1298 base::android::ScopedJavaLocalRef<jobject> activityContext = | 1297 base::android::ScopedJavaLocalRef<jobject> activityContext = |
| 1299 content_view_core_->GetContext(); | 1298 content_view_core_->GetContext(); |
| 1300 return std::unique_ptr<ui::TouchHandleDrawable>( | 1299 return std::unique_ptr<ui::TouchHandleDrawable>( |
| 1301 new CompositedTouchHandleDrawable( | 1300 new CompositedTouchHandleDrawable( |
| 1302 content_view_core_->GetViewAndroid()->GetLayer(), | 1301 content_view_core_->GetViewAndroid()->GetLayer(), view_.GetDipScale(), |
| 1303 ui::GetScaleFactorForNativeView(GetNativeView()), | |
| 1304 // Use the activity context where possible (instead of the application | 1302 // Use the activity context where possible (instead of the application |
| 1305 // context) to ensure proper handle theming. | 1303 // context) to ensure proper handle theming. |
| 1306 activityContext.is_null() ? base::android::GetApplicationContext() | 1304 activityContext.is_null() ? base::android::GetApplicationContext() |
| 1307 : activityContext)); | 1305 : activityContext)); |
| 1308 } | 1306 } |
| 1309 | 1307 |
| 1310 void RenderWidgetHostViewAndroid::SynchronousCopyContents( | 1308 void RenderWidgetHostViewAndroid::SynchronousCopyContents( |
| 1311 const gfx::Rect& src_subrect_in_pixel, | 1309 const gfx::Rect& src_subrect_in_pixel, |
| 1312 const gfx::Size& dst_size_in_pixel, | 1310 const gfx::Size& dst_size_in_pixel, |
| 1313 const ReadbackRequestCallback& callback, | 1311 const ReadbackRequestCallback& callback, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1368 selection_controller_->OnViewportChanged(viewport_rect); | 1366 selection_controller_->OnViewportChanged(viewport_rect); |
| 1369 } | 1367 } |
| 1370 | 1368 |
| 1371 UpdateBackgroundColor(is_transparent ? SK_ColorTRANSPARENT | 1369 UpdateBackgroundColor(is_transparent ? SK_ColorTRANSPARENT |
| 1372 : frame_metadata.root_background_color); | 1370 : frame_metadata.root_background_color); |
| 1373 | 1371 |
| 1374 view_.set_content_offset(gfx::Vector2dF(0.0f, | 1372 view_.set_content_offset(gfx::Vector2dF(0.0f, |
| 1375 frame_metadata.top_controls_height * | 1373 frame_metadata.top_controls_height * |
| 1376 frame_metadata.top_controls_shown_ratio)); | 1374 frame_metadata.top_controls_shown_ratio)); |
| 1377 | 1375 |
| 1378 float dip_scale = ui::GetScaleFactorForNativeView(GetNativeView()); | 1376 float dip_scale = view_.GetDipScale(); |
| 1379 float top_controls_pix = frame_metadata.top_controls_height * dip_scale; | 1377 float top_controls_pix = frame_metadata.top_controls_height * dip_scale; |
| 1380 float top_shown_pix = | 1378 float top_shown_pix = |
| 1381 top_controls_pix * frame_metadata.top_controls_shown_ratio; | 1379 top_controls_pix * frame_metadata.top_controls_shown_ratio; |
| 1382 bool top_changed = !FloatEquals(top_shown_pix, prev_top_shown_pix_); | 1380 bool top_changed = !FloatEquals(top_shown_pix, prev_top_shown_pix_); |
| 1383 | 1381 |
| 1384 float bottom_controls_pix = frame_metadata.bottom_controls_height * dip_scale; | 1382 float bottom_controls_pix = frame_metadata.bottom_controls_height * dip_scale; |
| 1385 float bottom_shown_pix = | 1383 float bottom_shown_pix = |
| 1386 bottom_controls_pix * frame_metadata.bottom_controls_shown_ratio; | 1384 bottom_controls_pix * frame_metadata.bottom_controls_shown_ratio; |
| 1387 bool bottom_changed = !FloatEquals(bottom_shown_pix, prev_bottom_shown_pix_); | 1385 bool bottom_changed = !FloatEquals(bottom_shown_pix, prev_bottom_shown_pix_); |
| 1388 | 1386 |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2127 // OverscrollController. | 2125 // OverscrollController. |
| 2128 ui::WindowAndroid* window_android = content_view_core_->GetWindowAndroid(); | 2126 ui::WindowAndroid* window_android = content_view_core_->GetWindowAndroid(); |
| 2129 if (!window_android) | 2127 if (!window_android) |
| 2130 return; | 2128 return; |
| 2131 | 2129 |
| 2132 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2130 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
| 2133 if (!compositor) | 2131 if (!compositor) |
| 2134 return; | 2132 return; |
| 2135 | 2133 |
| 2136 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2134 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| 2137 overscroll_refresh_handler, compositor, | 2135 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
| 2138 ui::GetScaleFactorForNativeView(GetNativeView())); | |
| 2139 } | 2136 } |
| 2140 | 2137 |
| 2141 } // namespace content | 2138 } // namespace content |
| OLD | NEW |