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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 if (!host_ || host_->is_hidden() || !IsSurfaceAvailableForCopy()) { | 554 if (!host_ || host_->is_hidden() || !IsSurfaceAvailableForCopy()) { |
555 result_callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); | 555 result_callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); |
556 return; | 556 return; |
557 } | 557 } |
558 gfx::Size bounds = current_surface_size_; | 558 gfx::Size bounds = current_surface_size_; |
559 if (src_subrect.IsEmpty()) | 559 if (src_subrect.IsEmpty()) |
560 src_subrect = gfx::Rect(bounds); | 560 src_subrect = gfx::Rect(bounds); |
561 DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width()); | 561 DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width()); |
562 DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height()); | 562 DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height()); |
563 const display::Display& display = | 563 const display::Display& display = |
564 display::Screen::GetScreen()->GetPrimaryDisplay(); | 564 display::Screen::GetScreen()->GetDisplayNearestWindow(GetNativeView()); |
565 float device_scale_factor = display.device_scale_factor(); | 565 float device_scale_factor = display.device_scale_factor(); |
566 DCHECK_GT(device_scale_factor, 0); | 566 DCHECK_GT(device_scale_factor, 0); |
567 gfx::Size dst_size( | 567 gfx::Size dst_size( |
568 gfx::ScaleToCeiledSize(src_subrect.size(), scale / device_scale_factor)); | 568 gfx::ScaleToCeiledSize(src_subrect.size(), scale / device_scale_factor)); |
569 src_subrect = gfx::ConvertRectToDIP(device_scale_factor, src_subrect); | 569 src_subrect = gfx::ConvertRectToDIP(device_scale_factor, src_subrect); |
570 | 570 |
571 CopyFromCompositingSurface(src_subrect, dst_size, result_callback, | 571 CopyFromCompositingSurface(src_subrect, dst_size, result_callback, |
572 preferred_color_type); | 572 preferred_color_type); |
573 } | 573 } |
574 | 574 |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); | 990 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); |
991 return; | 991 return; |
992 } | 992 } |
993 if (!(view_.GetWindowAndroid())) { | 993 if (!(view_.GetWindowAndroid())) { |
994 callback.Run(SkBitmap(), READBACK_FAILED); | 994 callback.Run(SkBitmap(), READBACK_FAILED); |
995 return; | 995 return; |
996 } | 996 } |
997 | 997 |
998 base::TimeTicks start_time = base::TimeTicks::Now(); | 998 base::TimeTicks start_time = base::TimeTicks::Now(); |
999 const display::Display& display = | 999 const display::Display& display = |
1000 display::Screen::GetScreen()->GetPrimaryDisplay(); | 1000 display::Screen::GetScreen()->GetDisplayNearestWindow(GetNativeView()); |
1001 float device_scale_factor = display.device_scale_factor(); | 1001 float device_scale_factor = display.device_scale_factor(); |
1002 gfx::Size dst_size_in_pixel = | 1002 gfx::Size dst_size_in_pixel = |
1003 gfx::ConvertRectToPixel(device_scale_factor, gfx::Rect(dst_size)).size(); | 1003 gfx::ConvertRectToPixel(device_scale_factor, gfx::Rect(dst_size)).size(); |
1004 gfx::Rect src_subrect_in_pixel = | 1004 gfx::Rect src_subrect_in_pixel = |
1005 gfx::ConvertRectToPixel(device_scale_factor, src_subrect); | 1005 gfx::ConvertRectToPixel(device_scale_factor, src_subrect); |
1006 | 1006 |
1007 if (!using_browser_compositor_) { | 1007 if (!using_browser_compositor_) { |
1008 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback, | 1008 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback, |
1009 preferred_color_type); | 1009 preferred_color_type); |
1010 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", | 1010 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 case ui::MotionEvent::ACTION_UP: | 1990 case ui::MotionEvent::ACTION_UP: |
1991 case ui::MotionEvent::ACTION_POINTER_UP: | 1991 case ui::MotionEvent::ACTION_POINTER_UP: |
1992 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 1992 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
1993 delta.InMicroseconds(), 1, 1000000, 50); | 1993 delta.InMicroseconds(), 1, 1000000, 50); |
1994 default: | 1994 default: |
1995 return; | 1995 return; |
1996 } | 1996 } |
1997 } | 1997 } |
1998 | 1998 |
1999 } // namespace content | 1999 } // namespace content |
OLD | NEW |