| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 #include "ui/android/window_android_compositor.h" | 82 #include "ui/android/window_android_compositor.h" |
| 83 #include "ui/base/layout.h" | 83 #include "ui/base/layout.h" |
| 84 #include "ui/display/display.h" | 84 #include "ui/display/display.h" |
| 85 #include "ui/display/screen.h" | 85 #include "ui/display/screen.h" |
| 86 #include "ui/events/base_event_utils.h" | 86 #include "ui/events/base_event_utils.h" |
| 87 #include "ui/events/blink/blink_event_util.h" | 87 #include "ui/events/blink/blink_event_util.h" |
| 88 #include "ui/events/blink/did_overscroll_params.h" | 88 #include "ui/events/blink/did_overscroll_params.h" |
| 89 #include "ui/events/blink/web_input_event_traits.h" | 89 #include "ui/events/blink/web_input_event_traits.h" |
| 90 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" | 90 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
| 91 #include "ui/events/gesture_detection/motion_event.h" | 91 #include "ui/events/gesture_detection/motion_event.h" |
| 92 #include "ui/gfx/android/device_display_info.h" | |
| 93 #include "ui/gfx/android/java_bitmap.h" | 92 #include "ui/gfx/android/java_bitmap.h" |
| 94 #include "ui/gfx/android/view_configuration.h" | 93 #include "ui/gfx/android/view_configuration.h" |
| 95 #include "ui/gfx/geometry/dip_util.h" | 94 #include "ui/gfx/geometry/dip_util.h" |
| 96 #include "ui/gfx/geometry/size_conversions.h" | 95 #include "ui/gfx/geometry/size_conversions.h" |
| 97 #include "ui/touch_selection/touch_selection_controller.h" | 96 #include "ui/touch_selection/touch_selection_controller.h" |
| 98 | 97 |
| 99 namespace content { | 98 namespace content { |
| 100 | 99 |
| 101 namespace { | 100 namespace { |
| 102 | 101 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // This is for an offscreen context, so we don't need the default framebuffer | 181 // This is for an offscreen context, so we don't need the default framebuffer |
| 183 // to have alpha, stencil, depth, antialiasing. | 182 // to have alpha, stencil, depth, antialiasing. |
| 184 gpu::gles2::ContextCreationAttribHelper attributes; | 183 gpu::gles2::ContextCreationAttribHelper attributes; |
| 185 attributes.alpha_size = -1; | 184 attributes.alpha_size = -1; |
| 186 attributes.stencil_size = 0; | 185 attributes.stencil_size = 0; |
| 187 attributes.depth_size = 0; | 186 attributes.depth_size = 0; |
| 188 attributes.samples = 0; | 187 attributes.samples = 0; |
| 189 attributes.sample_buffers = 0; | 188 attributes.sample_buffers = 0; |
| 190 attributes.bind_generates_resource = false; | 189 attributes.bind_generates_resource = false; |
| 191 | 190 |
| 192 constexpr size_t kBytesPerPixel = 4; | |
| 193 size_t full_screen_texture_size_in_bytes = | |
| 194 gfx::DeviceDisplayInfo().GetDisplayHeight() * | |
| 195 gfx::DeviceDisplayInfo().GetDisplayWidth() * kBytesPerPixel; | |
| 196 | |
| 197 gpu::SharedMemoryLimits limits; | 191 gpu::SharedMemoryLimits limits; |
| 198 // The GLHelper context doesn't do a lot of stuff, so we don't expect it to | 192 // The GLHelper context doesn't do a lot of stuff, so we don't expect it to |
| 199 // need a lot of space for commands. | 193 // need a lot of space for commands. |
| 200 limits.command_buffer_size = 1024; | 194 limits.command_buffer_size = 1024; |
| 201 // The transfer buffer is used for shaders among other things, so give some | 195 // The transfer buffer is used for shaders among other things, so give some |
| 202 // reasonable but small limit. | 196 // reasonable but small limit. |
| 203 limits.start_transfer_buffer_size = 4 * 1024; | 197 limits.start_transfer_buffer_size = 4 * 1024; |
| 204 limits.min_transfer_buffer_size = 4 * 1024; | 198 limits.min_transfer_buffer_size = 4 * 1024; |
| 205 limits.max_transfer_buffer_size = full_screen_texture_size_in_bytes; | 199 |
| 200 // Use the largest available display size as the max texture size. |
| 201 constexpr size_t kBytesPerPixel = 4; |
| 202 size_t max_screen_texture_size_in_bytes = limits.min_transfer_buffer_size; |
| 203 for (auto& display : display::Screen::GetScreen()->GetAllDisplays()) { |
| 204 gfx::Size size = display.GetSizeInPixel(); |
| 205 size_t display_size_in_bytes = |
| 206 kBytesPerPixel * size.width() * size.height(); |
| 207 if (display_size_in_bytes > max_screen_texture_size_in_bytes) |
| 208 max_screen_texture_size_in_bytes = display_size_in_bytes; |
| 209 } |
| 210 |
| 211 limits.max_transfer_buffer_size = max_screen_texture_size_in_bytes; |
| 206 // This context is used for doing async readbacks, so allow at least a full | 212 // This context is used for doing async readbacks, so allow at least a full |
| 207 // screen readback to be mapped. | 213 // screen readback to be mapped. |
| 208 limits.mapped_memory_reclaim_limit = full_screen_texture_size_in_bytes; | 214 limits.mapped_memory_reclaim_limit = max_screen_texture_size_in_bytes; |
| 209 | 215 |
| 210 constexpr bool automatic_flushes = false; | 216 constexpr bool automatic_flushes = false; |
| 211 constexpr bool support_locking = false; | 217 constexpr bool support_locking = false; |
| 212 const GURL url("chrome://gpu/RenderWidgetHostViewAndroid"); | 218 const GURL url("chrome://gpu/RenderWidgetHostViewAndroid"); |
| 213 | 219 |
| 214 provider_ = new ui::ContextProviderCommandBuffer( | 220 provider_ = new ui::ContextProviderCommandBuffer( |
| 215 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, | 221 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, |
| 216 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, url, | 222 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, url, |
| 217 automatic_flushes, support_locking, limits, attributes, nullptr, | 223 automatic_flushes, support_locking, limits, attributes, nullptr, |
| 218 ui::command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); | 224 ui::command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); |
| (...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 if (!compositor) | 2078 if (!compositor) |
| 2073 return; | 2079 return; |
| 2074 | 2080 |
| 2075 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2081 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| 2076 overscroll_refresh_handler, compositor, | 2082 overscroll_refresh_handler, compositor, |
| 2077 ui::GetScaleFactorForNativeView(GetNativeView())); | 2083 ui::GetScaleFactorForNativeView(GetNativeView())); |
| 2078 is_showing_overscroll_glow_ = true; | 2084 is_showing_overscroll_glow_ = true; |
| 2079 } | 2085 } |
| 2080 | 2086 |
| 2081 } // namespace content | 2087 } // namespace content |
| OLD | NEW |