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

Side by Side Diff: services/ui/public/cpp/gles2_context.cc

Issue 2286873003: Provide TaskRunner to ContextCacheController (Closed)
Patch Set: fix unittests Created 4 years, 3 months 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/public/cpp/gles2_context.h" 5 #include "services/ui/public/cpp/gles2_context.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
11 11
12 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 12 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
13 #include "gpu/command_buffer/client/shared_memory_limits.h" 13 #include "gpu/command_buffer/client/shared_memory_limits.h"
14 #include "gpu/command_buffer/client/transfer_buffer.h" 14 #include "gpu/command_buffer/client/transfer_buffer.h"
15 #include "gpu/ipc/client/command_buffer_proxy_impl.h" 15 #include "gpu/ipc/client/command_buffer_proxy_impl.h"
16 #include "gpu/ipc/client/gpu_channel_host.h" 16 #include "gpu/ipc/client/gpu_channel_host.h"
17 #include "mojo/public/cpp/system/core.h" 17 #include "mojo/public/cpp/system/core.h"
18 #include "services/ui/public/cpp/gpu_service.h" 18 #include "services/ui/public/cpp/gpu_service.h"
19 #include "services/ui/public/interfaces/gpu_service.mojom.h" 19 #include "services/ui/public/interfaces/gpu_service.mojom.h"
20 #include "url/gurl.h" 20 #include "url/gurl.h"
21 21
22 namespace ui { 22 namespace ui {
23 23
24 GLES2Context::GLES2Context() {} 24 GLES2Context::GLES2Context() {}
25 25
26 GLES2Context::~GLES2Context() {} 26 GLES2Context::~GLES2Context() {}
27 27
28 bool GLES2Context::Initialize( 28 bool GLES2Context::Initialize(
29 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) { 29 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
30 scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
30 DCHECK(gpu_channel_host); 31 DCHECK(gpu_channel_host);
31 gpu::SurfaceHandle surface_handle = gfx::kNullAcceleratedWidget; 32 gpu::SurfaceHandle surface_handle = gfx::kNullAcceleratedWidget;
32 // TODO(penghuang): support shared group. 33 // TODO(penghuang): support shared group.
33 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; 34 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr;
34 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; 35 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT;
35 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; 36 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL;
36 gpu::gles2::ContextCreationAttribHelper attributes; 37 gpu::gles2::ContextCreationAttribHelper attributes;
37 // TODO(penghuang): figure a useful active_url. 38 // TODO(penghuang): figure a useful active_url.
38 GURL active_url; 39 GURL active_url;
39 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
40 base::ThreadTaskRunnerHandle::Get();
41 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( 40 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create(
42 std::move(gpu_channel_host), surface_handle, shared_command_buffer, 41 std::move(gpu_channel_host), surface_handle, shared_command_buffer,
43 stream_id, stream_priority, attributes, active_url, 42 stream_id, stream_priority, attributes, active_url,
44 std::move(task_runner)); 43 std::move(task_runner));
45 if (!command_buffer_proxy_impl_) 44 if (!command_buffer_proxy_impl_)
46 return false; 45 return false;
47 gpu::CommandBuffer* command_buffer = command_buffer_proxy_impl_.get(); 46 gpu::CommandBuffer* command_buffer = command_buffer_proxy_impl_.get();
48 gpu::GpuControl* gpu_control = command_buffer_proxy_impl_.get(); 47 gpu::GpuControl* gpu_control = command_buffer_proxy_impl_.get();
49 48
50 constexpr gpu::SharedMemoryLimits default_limits; 49 constexpr gpu::SharedMemoryLimits default_limits;
(...skipping 16 matching lines...) Expand all
67 if (!implementation_->Initialize(default_limits.start_transfer_buffer_size, 66 if (!implementation_->Initialize(default_limits.start_transfer_buffer_size,
68 default_limits.min_transfer_buffer_size, 67 default_limits.min_transfer_buffer_size,
69 default_limits.max_transfer_buffer_size, 68 default_limits.max_transfer_buffer_size,
70 default_limits.mapped_memory_reclaim_limit)) 69 default_limits.mapped_memory_reclaim_limit))
71 return false; 70 return false;
72 return true; 71 return true;
73 } 72 }
74 73
75 // static 74 // static
76 std::unique_ptr<GLES2Context> GLES2Context::CreateOffscreenContext( 75 std::unique_ptr<GLES2Context> GLES2Context::CreateOffscreenContext(
77 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) { 76 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
77 scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
78 if (!gpu_channel_host) 78 if (!gpu_channel_host)
79 return nullptr; 79 return nullptr;
80 80
81 // Return the GLES2Context only if it is successfully initialized. If 81 // Return the GLES2Context only if it is successfully initialized. If
82 // initialization fails, then return null. 82 // initialization fails, then return null.
83 std::unique_ptr<GLES2Context> gles2_context(new GLES2Context); 83 std::unique_ptr<GLES2Context> gles2_context(new GLES2Context);
84 if (!gles2_context->Initialize(std::move(gpu_channel_host))) 84 if (!gles2_context->Initialize(std::move(gpu_channel_host),
85 std::move(task_runner)))
85 gles2_context.reset(); 86 gles2_context.reset();
86 return gles2_context; 87 return gles2_context;
87 } 88 }
88 89
89 } // namespace ui 90 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698