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

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

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

Powered by Google App Engine
This is Rietveld 408576698