Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 2734043003: Fix Android tab navigation "stretch" regression. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 default_bounds_ = gfx::Rect(default_bounds_.origin(), size); 532 default_bounds_ = gfx::Rect(default_bounds_.origin(), size);
533 } 533 }
534 534
535 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { 535 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) {
536 default_bounds_ = rect; 536 default_bounds_ = rect;
537 } 537 }
538 538
539 void RenderWidgetHostViewAndroid::GetScaledContentBitmap( 539 void RenderWidgetHostViewAndroid::GetScaledContentBitmap(
540 float scale, 540 float scale,
541 SkColorType preferred_color_type, 541 SkColorType preferred_color_type,
542 gfx::Rect src_subrect, 542 gfx::Rect src_subrect_in_pixel,
aelias_OOO_until_Jul13 2017/03/07 21:08:01 It looks like this is always called with empty rec
miu 2017/03/08 01:42:04 Yeah, I noticed this. Wasn't going to expand the s
543 const ReadbackRequestCallback& result_callback) { 543 const ReadbackRequestCallback& result_callback) {
544 if (!host_ || host_->is_hidden() || !IsSurfaceAvailableForCopy()) { 544 if (!host_ || host_->is_hidden() || !IsSurfaceAvailableForCopy()) {
545 result_callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); 545 result_callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE);
546 return; 546 return;
547 } 547 }
548 gfx::Size bounds = current_surface_size_; 548
549 if (src_subrect.IsEmpty()) 549 gfx::Rect src_subrect;
550 src_subrect = gfx::Rect(bounds); 550 gfx::Size dst_size;
551 DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width()); 551 if (src_subrect_in_pixel.IsEmpty()) {
552 DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height()); 552 src_subrect = gfx::Rect(GetVisibleViewportSize());
553 const display::Display& display = 553 dst_size = gfx::ScaleToCeiledSize(src_subrect.size(), scale);
554 display::Screen::GetScreen()->GetDisplayNearestWindow(GetNativeView()); 554 } else {
555 float device_scale_factor = display.device_scale_factor(); 555 const display::Display& display =
556 DCHECK_GT(device_scale_factor, 0); 556 display::Screen::GetScreen()->GetDisplayNearestWindow(GetNativeView());
557 gfx::Size dst_size( 557 float device_scale_factor = display.device_scale_factor();
558 gfx::ScaleToCeiledSize(src_subrect.size(), scale / device_scale_factor)); 558 DCHECK_GT(device_scale_factor, 0);
559 src_subrect = gfx::ConvertRectToDIP(device_scale_factor, src_subrect); 559 src_subrect =
560 gfx::ConvertRectToDIP(device_scale_factor, src_subrect_in_pixel);
561 dst_size = gfx::ScaleToCeiledSize(src_subrect_in_pixel.size(),
562 scale / device_scale_factor);
563 }
560 564
561 CopyFromSurface(src_subrect, dst_size, result_callback, preferred_color_type); 565 CopyFromSurface(src_subrect, dst_size, result_callback, preferred_color_type);
562 } 566 }
563 567
564 bool RenderWidgetHostViewAndroid::HasValidFrame() const { 568 bool RenderWidgetHostViewAndroid::HasValidFrame() const {
565 if (!content_view_core_) 569 if (!content_view_core_)
566 return false; 570 return false;
567 571
568 if (current_surface_size_.IsEmpty()) 572 if (current_surface_size_.IsEmpty())
569 return false; 573 return false;
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 callback.Run(SkBitmap(), READBACK_FAILED); 939 callback.Run(SkBitmap(), READBACK_FAILED);
936 return; 940 return;
937 } 941 }
938 942
939 base::TimeTicks start_time = base::TimeTicks::Now(); 943 base::TimeTicks start_time = base::TimeTicks::Now();
940 const display::Display& display = 944 const display::Display& display =
941 display::Screen::GetScreen()->GetDisplayNearestWindow(GetNativeView()); 945 display::Screen::GetScreen()->GetDisplayNearestWindow(GetNativeView());
942 float device_scale_factor = display.device_scale_factor(); 946 float device_scale_factor = display.device_scale_factor();
943 gfx::Size dst_size_in_pixel = 947 gfx::Size dst_size_in_pixel =
944 gfx::ConvertRectToPixel(device_scale_factor, gfx::Rect(dst_size)).size(); 948 gfx::ConvertRectToPixel(device_scale_factor, gfx::Rect(dst_size)).size();
945 gfx::Rect src_subrect_in_pixel = 949 // Note: When |src_subrect| is empty, a conversion from the view size must be
946 gfx::ConvertRectToPixel(device_scale_factor, src_subrect); 950 // made instead of using |current_frame_size_|. The latter sometimes also
951 // includes extra height for the toolbar UI, which is not intended for
952 // capture.
953 gfx::Rect src_subrect_in_pixel = gfx::ConvertRectToPixel(
aelias_OOO_until_Jul13 2017/03/07 21:08:01 I don't think making a change here is necessary at
miu 2017/03/08 01:42:04 Actually, this is necessary. This method is the An
954 device_scale_factor, src_subrect.IsEmpty()
955 ? gfx::Rect(GetVisibleViewportSize())
956 : src_subrect);
947 957
948 if (!using_browser_compositor_) { 958 if (!using_browser_compositor_) {
949 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback, 959 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback,
950 preferred_color_type); 960 preferred_color_type);
951 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", 961 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous",
952 base::TimeTicks::Now() - start_time); 962 base::TimeTicks::Now() - start_time);
953 return; 963 return;
954 } 964 }
955 965
956 ui::WindowAndroidCompositor* compositor = 966 ui::WindowAndroidCompositor* compositor =
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 // context) to ensure proper handle theming. 1195 // context) to ensure proper handle theming.
1186 activityContext.is_null() ? base::android::GetApplicationContext() 1196 activityContext.is_null() ? base::android::GetApplicationContext()
1187 : activityContext)); 1197 : activityContext));
1188 } 1198 }
1189 1199
1190 void RenderWidgetHostViewAndroid::SynchronousCopyContents( 1200 void RenderWidgetHostViewAndroid::SynchronousCopyContents(
1191 const gfx::Rect& src_subrect_in_pixel, 1201 const gfx::Rect& src_subrect_in_pixel,
1192 const gfx::Size& dst_size_in_pixel, 1202 const gfx::Size& dst_size_in_pixel,
1193 const ReadbackRequestCallback& callback, 1203 const ReadbackRequestCallback& callback,
1194 const SkColorType color_type) { 1204 const SkColorType color_type) {
1195 gfx::Size input_size_in_pixel; 1205 // Current implementation does not support read-back of regions that do not
1196 if (src_subrect_in_pixel.IsEmpty()) 1206 // originate at (0,0). http://crbug.com/698974
1197 input_size_in_pixel = current_surface_size_; 1207 if (src_subrect_in_pixel.origin() != gfx::Point(0, 0)) {
1198 else 1208 callback.Run(SkBitmap(), READBACK_FAILED);
aelias_OOO_until_Jul13 2017/03/07 21:08:01 Hmm, this is just replacing one bug by another fro
miu 2017/03/08 01:42:04 Done.
1199 input_size_in_pixel = src_subrect_in_pixel.size(); 1209 }
1210 const gfx::Size& input_size_in_pixel = src_subrect_in_pixel.size();
1211 DCHECK(!input_size_in_pixel.IsEmpty());
1200 1212
1201 gfx::Size output_size_in_pixel; 1213 gfx::Size output_size_in_pixel;
1202 if (dst_size_in_pixel.IsEmpty()) 1214 if (dst_size_in_pixel.IsEmpty())
1203 output_size_in_pixel = input_size_in_pixel; 1215 output_size_in_pixel = input_size_in_pixel;
1204 else 1216 else
1205 output_size_in_pixel = dst_size_in_pixel; 1217 output_size_in_pixel = dst_size_in_pixel;
1206 int output_width = output_size_in_pixel.width(); 1218 int output_width = output_size_in_pixel.width();
1207 int output_height = output_size_in_pixel.height(); 1219 int output_height = output_size_in_pixel.height();
1208 1220
1209 if (!sync_compositor_) { 1221 if (!sync_compositor_) {
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); 1985 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor();
1974 if (!compositor) 1986 if (!compositor)
1975 return; 1987 return;
1976 1988
1977 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( 1989 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>(
1978 overscroll_refresh_handler, compositor, 1990 overscroll_refresh_handler, compositor,
1979 ui::GetScaleFactorForNativeView(GetNativeView())); 1991 ui::GetScaleFactorForNativeView(GetNativeView()));
1980 } 1992 }
1981 1993
1982 } // namespace content 1994 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698