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

Side by Side Diff: components/mus/gpu/gpu_service_mus.h

Issue 2119963002: Move mus to //services/ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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
« no previous file with comments | « components/mus/gpu/gpu_service_impl.cc ('k') | components/mus/gpu/gpu_service_mus.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_MUS_GPU_GPU_SERVICE_MUS_H_
6 #define COMPONENTS_MUS_GPU_GPU_SERVICE_MUS_H_
7
8 #include "base/callback.h"
9 #include "base/synchronization/waitable_event.h"
10 #include "base/threading/non_thread_safe.h"
11 #include "base/threading/thread.h"
12 #include "build/build_config.h"
13 #include "gpu/command_buffer/service/gpu_preferences.h"
14 #include "gpu/config/gpu_info.h"
15 #include "gpu/ipc/client/gpu_channel_host.h"
16 #include "gpu/ipc/common/surface_handle.h"
17 #include "gpu/ipc/service/gpu_channel.h"
18 #include "gpu/ipc/service/gpu_channel_manager.h"
19 #include "gpu/ipc/service/gpu_channel_manager_delegate.h"
20 #include "gpu/ipc/service/gpu_config.h"
21 #include "gpu/ipc/service/x_util.h"
22 #include "ui/gfx/native_widget_types.h"
23
24 namespace base {
25 template <typename T>
26 struct DefaultSingletonTraits;
27 }
28
29 namespace IPC {
30 struct ChannelHandle;
31 }
32
33 namespace gpu {
34 class GpuChannelHost;
35 class GpuMemoryBufferFactory;
36 class SyncPointManager;
37 }
38
39 namespace media {
40 class MediaService;
41 }
42
43 namespace mus {
44
45 class MusGpuMemoryBufferManager;
46
47 // TODO(fsamuel): GpuServiceMus is intended to be the Gpu thread within Mus.
48 // Similar to GpuChildThread, it is a GpuChannelManagerDelegate and will have a
49 // GpuChannelManager.
50 class GpuServiceMus : public gpu::GpuChannelManagerDelegate,
51 public gpu::GpuChannelHostFactory,
52 public base::NonThreadSafe {
53 public:
54 typedef base::Callback<void(int client_id, const IPC::ChannelHandle&)>
55 EstablishGpuChannelCallback;
56 void EstablishGpuChannel(uint64_t client_tracing_id,
57 bool preempts,
58 bool allow_view_command_buffers,
59 bool allow_real_time_streams,
60 const EstablishGpuChannelCallback& callback);
61 gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer(
62 gfx::GpuMemoryBufferId id,
63 const gfx::Size& size,
64 gfx::BufferFormat format,
65 gfx::BufferUsage usage,
66 int client_id,
67 gpu::SurfaceHandle surface_handle);
68 gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferFromeHandle(
69 gfx::GpuMemoryBufferHandle buffer_handle,
70 gfx::GpuMemoryBufferId id,
71 const gfx::Size& size,
72 gfx::BufferFormat format,
73 int client_id);
74 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
75 int client_id,
76 const gpu::SyncToken& sync_token);
77
78 gpu::GpuChannelManager* gpu_channel_manager() const {
79 return gpu_channel_manager_.get();
80 }
81
82 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory() const {
83 return gpu_memory_buffer_factory_.get();
84 }
85
86 scoped_refptr<gpu::GpuChannelHost> gpu_channel_local() const {
87 return gpu_channel_local_;
88 }
89
90 const gpu::GPUInfo& gpu_info() const { return gpu_info_; }
91
92 // GpuChannelManagerDelegate overrides:
93 void DidCreateOffscreenContext(const GURL& active_url) override;
94 void DidDestroyChannel(int client_id) override;
95 void DidDestroyOffscreenContext(const GURL& active_url) override;
96 void DidLoseContext(bool offscreen,
97 gpu::error::ContextLostReason reason,
98 const GURL& active_url) override;
99 void GpuMemoryUmaStats(const gpu::GPUMemoryUmaStats& params) override;
100 void StoreShaderToDisk(int client_id,
101 const std::string& key,
102 const std::string& shader) override;
103 #if defined(OS_WIN)
104 void SendAcceleratedSurfaceCreatedChildWindow(
105 gpu::SurfaceHandle parent_window,
106 gpu::SurfaceHandle child_window) override;
107 #endif
108 void SetActiveURL(const GURL& url) override;
109
110 // GpuChannelHostFactory overrides:
111 bool IsMainThread() override;
112 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override;
113 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(
114 size_t size) override;
115
116 static GpuServiceMus* GetInstance();
117
118 private:
119 friend struct base::DefaultSingletonTraits<GpuServiceMus>;
120
121 GpuServiceMus();
122 ~GpuServiceMus() override;
123
124 void Initialize();
125 void InitializeOnGpuThread(IPC::ChannelHandle* channel_handle,
126 base::WaitableEvent* event);
127 void EstablishGpuChannelOnGpuThread(int client_id,
128 uint64_t client_tracing_id,
129 bool preempts,
130 bool allow_view_command_buffers,
131 bool allow_real_time_streams,
132 IPC::ChannelHandle* channel_handle);
133
134 // The next client id.
135 int next_client_id_;
136
137 // The main thread task runner.
138 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
139
140 // An event that will be signalled when we shutdown.
141 base::WaitableEvent shutdown_event_;
142
143 // The main thread for GpuService.
144 base::Thread gpu_thread_;
145
146 // The thread that handles IO events for GpuService.
147 base::Thread io_thread_;
148
149 std::unique_ptr<gpu::SyncPointManager> owned_sync_point_manager_;
150
151 std::unique_ptr<gpu::GpuChannelManager> gpu_channel_manager_;
152
153 std::unique_ptr<media::MediaService> media_service_;
154
155 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory_;
156
157 // A GPU memory buffer manager used locally.
158 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager_local_;
159
160 // A GPU channel used locally.
161 scoped_refptr<gpu::GpuChannelHost> gpu_channel_local_;
162
163 gpu::GpuPreferences gpu_preferences_;
164
165 // Information about the GPU, such as device and vendor ID.
166 gpu::GPUInfo gpu_info_;
167
168 DISALLOW_COPY_AND_ASSIGN(GpuServiceMus);
169 };
170
171 } // namespace mus
172
173 #endif // COMPONENTS_MUS_GPU_GPU_SERVICE_MUS_H_
OLDNEW
« no previous file with comments | « components/mus/gpu/gpu_service_impl.cc ('k') | components/mus/gpu/gpu_service_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698