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

Side by Side Diff: services/ui/surfaces/surfaces_context_provider.cc

Issue 2431753002: Mus experiment in content shell on Android.
Patch Set: Fix mac bot Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "services/ui/surfaces/surfaces_context_provider.h" 5 #include "services/ui/surfaces/surfaces_context_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "cc/output/context_cache_controller.h" 16 #include "cc/output/context_cache_controller.h"
17 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 17 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
18 #include "gpu/command_buffer/client/gles2_implementation.h" 18 #include "gpu/command_buffer/client/gles2_implementation.h"
19 #include "gpu/command_buffer/client/shared_memory_limits.h" 19 #include "gpu/command_buffer/client/shared_memory_limits.h"
20 #include "gpu/command_buffer/client/transfer_buffer.h" 20 #include "gpu/command_buffer/client/transfer_buffer.h"
21 #include "gpu/ipc/client/command_buffer_proxy_impl.h" 21 #include "gpu/ipc/client/command_buffer_proxy_impl.h"
22 #include "gpu/ipc/client/gpu_channel_host.h" 22 #include "gpu/ipc/client/gpu_channel_host.h"
23 #include "gpu/ipc/common/gpu_surface_tracker.h"
23 #include "services/ui/common/switches.h" 24 #include "services/ui/common/switches.h"
24 #include "services/ui/surfaces/surfaces_context_provider_delegate.h" 25 #include "services/ui/surfaces/surfaces_context_provider_delegate.h"
25 #include "ui/gl/gpu_preference.h" 26 #include "ui/gl/gpu_preference.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
27 28
28 namespace ui { 29 namespace ui {
29 30
30 SurfacesContextProvider::SurfacesContextProvider( 31 SurfacesContextProvider::SurfacesContextProvider(
31 gfx::AcceleratedWidget widget, 32 gfx::AcceleratedWidget widget,
32 scoped_refptr<gpu::GpuChannelHost> gpu_channel) 33 scoped_refptr<gpu::GpuChannelHost> gpu_channel)
33 : delegate_(nullptr), 34 : delegate_(nullptr),
34 widget_(widget), 35 widget_(widget),
35 task_runner_(base::ThreadTaskRunnerHandle::Get()) { 36 task_runner_(base::ThreadTaskRunnerHandle::Get()) {
36 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; 37 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr;
37 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; 38 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT;
38 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; 39 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL;
39 gpu::gles2::ContextCreationAttribHelper attributes; 40 gpu::gles2::ContextCreationAttribHelper attributes;
40 attributes.alpha_size = -1; 41 attributes.alpha_size = -1;
41 attributes.depth_size = 0; 42 attributes.depth_size = 0;
42 attributes.stencil_size = 0; 43 attributes.stencil_size = 0;
43 attributes.samples = 0; 44 attributes.samples = 0;
44 attributes.sample_buffers = 0; 45 attributes.sample_buffers = 0;
45 attributes.bind_generates_resource = false; 46 attributes.bind_generates_resource = false;
46 attributes.lose_context_when_out_of_memory = true; 47 attributes.lose_context_when_out_of_memory = true;
47 GURL active_url; 48 GURL active_url;
49
50 gpu::SurfaceHandle surface_handle;
51 #if defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW)
52 surface_handle = widget;
53 #else
54 surface_handle =
55 gpu::GpuSurfaceTracker::Get()->AddSurfaceForNativeWidget(widget);
56 #endif
57
48 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( 58 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create(
49 std::move(gpu_channel), widget, shared_command_buffer, stream_id, 59 std::move(gpu_channel), surface_handle, shared_command_buffer, stream_id,
50 stream_priority, attributes, active_url, task_runner_); 60 stream_priority, attributes, active_url, task_runner_);
51 CHECK(command_buffer_proxy_impl_); 61 CHECK(command_buffer_proxy_impl_);
52 command_buffer_proxy_impl_->SetSwapBuffersCompletionCallback( 62 command_buffer_proxy_impl_->SetSwapBuffersCompletionCallback(
53 base::Bind(&SurfacesContextProvider::OnGpuSwapBuffersCompleted, 63 base::Bind(&SurfacesContextProvider::OnGpuSwapBuffersCompleted,
54 base::Unretained(this))); 64 base::Unretained(this)));
55 command_buffer_proxy_impl_->SetUpdateVSyncParametersCallback( 65 command_buffer_proxy_impl_->SetUpdateVSyncParametersCallback(
56 base::Bind(&SurfacesContextProvider::OnUpdateVSyncParameters, 66 base::Bind(&SurfacesContextProvider::OnUpdateVSyncParameters,
57 base::Unretained(this))); 67 base::Unretained(this)));
58 } 68 }
59 69
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (delegate_) 170 if (delegate_)
161 delegate_->OnVSyncParametersUpdated(timebase, interval); 171 delegate_->OnVSyncParametersUpdated(timebase, interval);
162 } 172 }
163 173
164 void SurfacesContextProvider::SetSwapBuffersCompletionCallback( 174 void SurfacesContextProvider::SetSwapBuffersCompletionCallback(
165 gl::GLSurface::SwapCompletionCallback callback) { 175 gl::GLSurface::SwapCompletionCallback callback) {
166 swap_buffers_completion_callback_ = callback; 176 swap_buffers_completion_callback_ = callback;
167 } 177 }
168 178
169 } // namespace ui 179 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/surfaces/BUILD.gn ('k') | ui/platform_window/android/java/src/org/chromium/ui/PlatformWindowAndroid.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698