| 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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width()); | 543 DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width()); |
| 544 DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height()); | 544 DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height()); |
| 545 const display::Display& display = | 545 const display::Display& display = |
| 546 display::Screen::GetScreen()->GetDisplayNearestWindow(GetNativeView()); | 546 display::Screen::GetScreen()->GetDisplayNearestWindow(GetNativeView()); |
| 547 float device_scale_factor = display.device_scale_factor(); | 547 float device_scale_factor = display.device_scale_factor(); |
| 548 DCHECK_GT(device_scale_factor, 0); | 548 DCHECK_GT(device_scale_factor, 0); |
| 549 gfx::Size dst_size( | 549 gfx::Size dst_size( |
| 550 gfx::ScaleToCeiledSize(src_subrect.size(), scale / device_scale_factor)); | 550 gfx::ScaleToCeiledSize(src_subrect.size(), scale / device_scale_factor)); |
| 551 src_subrect = gfx::ConvertRectToDIP(device_scale_factor, src_subrect); | 551 src_subrect = gfx::ConvertRectToDIP(device_scale_factor, src_subrect); |
| 552 | 552 |
| 553 CopyFromCompositingSurface(src_subrect, dst_size, result_callback, | 553 CopyFromSurface(src_subrect, dst_size, result_callback, preferred_color_type); |
| 554 preferred_color_type); | |
| 555 } | 554 } |
| 556 | 555 |
| 557 bool RenderWidgetHostViewAndroid::HasValidFrame() const { | 556 bool RenderWidgetHostViewAndroid::HasValidFrame() const { |
| 558 if (!content_view_core_) | 557 if (!content_view_core_) |
| 559 return false; | 558 return false; |
| 560 | 559 |
| 561 if (current_surface_size_.IsEmpty()) | 560 if (current_surface_size_.IsEmpty()) |
| 562 return false; | 561 return false; |
| 563 // This tell us whether a valid frame has arrived or not. | 562 // This tell us whether a valid frame has arrived or not. |
| 564 if (!frame_evictor_->HasFrame()) | 563 if (!frame_evictor_->HasFrame()) |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 const base::string16& tooltip_text) { | 911 const base::string16& tooltip_text) { |
| 913 // Tooltips don't makes sense on Android. | 912 // Tooltips don't makes sense on Android. |
| 914 } | 913 } |
| 915 | 914 |
| 916 void RenderWidgetHostViewAndroid::SetBackgroundColor(SkColor color) { | 915 void RenderWidgetHostViewAndroid::SetBackgroundColor(SkColor color) { |
| 917 RenderWidgetHostViewBase::SetBackgroundColor(color); | 916 RenderWidgetHostViewBase::SetBackgroundColor(color); |
| 918 host_->SetBackgroundOpaque(GetBackgroundOpaque()); | 917 host_->SetBackgroundOpaque(GetBackgroundOpaque()); |
| 919 UpdateBackgroundColor(color); | 918 UpdateBackgroundColor(color); |
| 920 } | 919 } |
| 921 | 920 |
| 922 void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( | 921 void RenderWidgetHostViewAndroid::CopyFromSurface( |
| 923 const gfx::Rect& src_subrect, | 922 const gfx::Rect& src_subrect, |
| 924 const gfx::Size& dst_size, | 923 const gfx::Size& dst_size, |
| 925 const ReadbackRequestCallback& callback, | 924 const ReadbackRequestCallback& callback, |
| 926 const SkColorType preferred_color_type) { | 925 const SkColorType preferred_color_type) { |
| 927 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurface"); | 926 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::CopyFromSurface"); |
| 928 if (!host_ || !IsSurfaceAvailableForCopy()) { | 927 if (!host_ || !IsSurfaceAvailableForCopy()) { |
| 929 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); | 928 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); |
| 930 return; | 929 return; |
| 931 } | 930 } |
| 932 if (!(view_.GetWindowAndroid())) { | 931 if (!(view_.GetWindowAndroid())) { |
| 933 callback.Run(SkBitmap(), READBACK_FAILED); | 932 callback.Run(SkBitmap(), READBACK_FAILED); |
| 934 return; | 933 return; |
| 935 } | 934 } |
| 936 | 935 |
| 937 base::TimeTicks start_time = base::TimeTicks::Now(); | 936 base::TimeTicks start_time = base::TimeTicks::Now(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 957 DCHECK(delegated_frame_host_); | 956 DCHECK(delegated_frame_host_); |
| 958 scoped_refptr<PendingReadbackLock> readback_lock( | 957 scoped_refptr<PendingReadbackLock> readback_lock( |
| 959 g_pending_readback_lock ? g_pending_readback_lock | 958 g_pending_readback_lock ? g_pending_readback_lock |
| 960 : new PendingReadbackLock); | 959 : new PendingReadbackLock); |
| 961 delegated_frame_host_->RequestCopyOfSurface( | 960 delegated_frame_host_->RequestCopyOfSurface( |
| 962 compositor, src_subrect_in_pixel, | 961 compositor, src_subrect_in_pixel, |
| 963 base::Bind(&PrepareTextureCopyOutputResult, dst_size_in_pixel, | 962 base::Bind(&PrepareTextureCopyOutputResult, dst_size_in_pixel, |
| 964 preferred_color_type, start_time, callback, readback_lock)); | 963 preferred_color_type, start_time, callback, readback_lock)); |
| 965 } | 964 } |
| 966 | 965 |
| 967 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( | |
| 968 const gfx::Rect& src_subrect, | |
| 969 const scoped_refptr<media::VideoFrame>& target, | |
| 970 const base::Callback<void(const gfx::Rect&, bool)>& callback) { | |
| 971 NOTIMPLEMENTED(); | |
| 972 callback.Run(gfx::Rect(), false); | |
| 973 } | |
| 974 | |
| 975 bool RenderWidgetHostViewAndroid::CanCopyToVideoFrame() const { | |
| 976 return false; | |
| 977 } | |
| 978 | |
| 979 void RenderWidgetHostViewAndroid::ShowDisambiguationPopup( | 966 void RenderWidgetHostViewAndroid::ShowDisambiguationPopup( |
| 980 const gfx::Rect& rect_pixels, const SkBitmap& zoomed_bitmap) { | 967 const gfx::Rect& rect_pixels, const SkBitmap& zoomed_bitmap) { |
| 981 if (!content_view_core_) | 968 if (!content_view_core_) |
| 982 return; | 969 return; |
| 983 | 970 |
| 984 content_view_core_->ShowDisambiguationPopup(rect_pixels, zoomed_bitmap); | 971 content_view_core_->ShowDisambiguationPopup(rect_pixels, zoomed_bitmap); |
| 985 } | 972 } |
| 986 | 973 |
| 987 std::unique_ptr<SyntheticGestureTarget> | 974 std::unique_ptr<SyntheticGestureTarget> |
| 988 RenderWidgetHostViewAndroid::CreateSyntheticGestureTarget() { | 975 RenderWidgetHostViewAndroid::CreateSyntheticGestureTarget() { |
| (...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1986 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 1973 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
| 1987 if (!compositor) | 1974 if (!compositor) |
| 1988 return; | 1975 return; |
| 1989 | 1976 |
| 1990 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 1977 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| 1991 overscroll_refresh_handler, compositor, | 1978 overscroll_refresh_handler, compositor, |
| 1992 ui::GetScaleFactorForNativeView(GetNativeView())); | 1979 ui::GetScaleFactorForNativeView(GetNativeView())); |
| 1993 } | 1980 } |
| 1994 | 1981 |
| 1995 } // namespace content | 1982 } // namespace content |
| OLD | NEW |