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

Side by Side Diff: services/ui/gpu/gpu_service_internal.h

Issue 2289553002: gpu: Introduce GpuInit. (Closed)
Patch Set: . 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
« no previous file with comments | « services/ui/gpu/gpu_main.cc ('k') | services/ui/gpu/gpu_service_internal.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 #ifndef SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_ 5 #ifndef SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_
6 #define SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_ 6 #define SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/threading/non_thread_safe.h" 10 #include "base/threading/non_thread_safe.h"
11 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "gpu/command_buffer/service/gpu_preferences.h" 13 #include "gpu/command_buffer/service/gpu_preferences.h"
14 #include "gpu/config/gpu_info.h" 14 #include "gpu/config/gpu_info.h"
15 #include "gpu/ipc/common/surface_handle.h" 15 #include "gpu/ipc/common/surface_handle.h"
16 #include "gpu/ipc/service/gpu_channel.h" 16 #include "gpu/ipc/service/gpu_channel.h"
17 #include "gpu/ipc/service/gpu_channel_manager.h" 17 #include "gpu/ipc/service/gpu_channel_manager.h"
18 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" 18 #include "gpu/ipc/service/gpu_channel_manager_delegate.h"
19 #include "gpu/ipc/service/gpu_config.h" 19 #include "gpu/ipc/service/gpu_config.h"
20 #include "gpu/ipc/service/x_util.h" 20 #include "gpu/ipc/service/x_util.h"
21 #include "mojo/public/cpp/bindings/binding.h" 21 #include "mojo/public/cpp/bindings/binding.h"
22 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" 22 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h"
23 #include "ui/gfx/native_widget_types.h" 23 #include "ui/gfx/native_widget_types.h"
24 24
25 namespace base {
26 template <typename T>
27 struct DefaultSingletonTraits;
28 }
29
30 namespace gpu { 25 namespace gpu {
31 class GpuChannelHost; 26 class GpuChannelHost;
32 class GpuMemoryBufferFactory; 27 class GpuMemoryBufferFactory;
33 class GpuWatchdogThread; 28 class GpuWatchdogThread;
34 class SyncPointManager; 29 class SyncPointManager;
35 } 30 }
36 31
37 namespace media { 32 namespace media {
38 class MediaService; 33 class MediaService;
39 } 34 }
40 35
41 namespace ui { 36 namespace ui {
42 37
38 class GpuMain;
39
43 // This runs in the GPU process, and communicates with the gpu host (which is 40 // This runs in the GPU process, and communicates with the gpu host (which is
44 // the window server) over the mojom APIs. This is responsible for setting up 41 // the window server) over the mojom APIs. This is responsible for setting up
45 // the connection to clients, allocating/free'ing gpu memory etc. 42 // the connection to clients, allocating/free'ing gpu memory etc.
46 class GpuServiceInternal : public gpu::GpuChannelManagerDelegate, 43 class GpuServiceInternal : public gpu::GpuChannelManagerDelegate,
47 public mojom::GpuServiceInternal, 44 public mojom::GpuServiceInternal,
48 public base::NonThreadSafe { 45 public base::NonThreadSafe {
49 public: 46 public:
47 ~GpuServiceInternal() override;
48
50 void Add(mojom::GpuServiceInternalRequest request); 49 void Add(mojom::GpuServiceInternalRequest request);
51 50
52 // TODO(sad): This should not be a singleton.
53 static GpuServiceInternal* GetInstance();
54
55 gpu::GpuChannelManager* gpu_channel_manager() const { 51 gpu::GpuChannelManager* gpu_channel_manager() const {
56 return gpu_channel_manager_.get(); 52 return gpu_channel_manager_.get();
57 } 53 }
58 54
59 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory() const { 55 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory() const {
60 return gpu_memory_buffer_factory_.get(); 56 return gpu_memory_buffer_factory_;
61 } 57 }
62 58
63 // TODO(sad): These should be mojom API. 59 // TODO(sad): These should be mojom API.
64 gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( 60 gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer(
65 gfx::GpuMemoryBufferId id, 61 gfx::GpuMemoryBufferId id,
66 const gfx::Size& size, 62 const gfx::Size& size,
67 gfx::BufferFormat format, 63 gfx::BufferFormat format,
68 gfx::BufferUsage usage, 64 gfx::BufferUsage usage,
69 int client_id, 65 int client_id,
70 gpu::SurfaceHandle surface_handle); 66 gpu::SurfaceHandle surface_handle);
71 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, 67 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
72 int client_id, 68 int client_id,
73 const gpu::SyncToken& sync_token); 69 const gpu::SyncToken& sync_token);
74 70
75 private: 71 private:
76 friend struct base::DefaultSingletonTraits<GpuServiceInternal>; 72 friend class GpuMain;
77 73
78 GpuServiceInternal(); 74 GpuServiceInternal(gpu::GpuWatchdogThread* watchdog,
79 ~GpuServiceInternal() override; 75 gpu::GpuMemoryBufferFactory* memory_buffer_factory);
80 76
81 void EstablishGpuChannelInternal(int32_t client_id, 77 void EstablishGpuChannelInternal(int32_t client_id,
82 uint64_t client_tracing_id, 78 uint64_t client_tracing_id,
83 bool preempts, 79 bool preempts,
84 bool allow_view_command_buffers, 80 bool allow_view_command_buffers,
85 bool allow_real_time_streams, 81 bool allow_real_time_streams,
86 const EstablishGpuChannelCallback& callback); 82 const EstablishGpuChannelCallback& callback);
87 gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferFromeHandle( 83 gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferFromeHandle(
88 gfx::GpuMemoryBufferHandle buffer_handle, 84 gfx::GpuMemoryBufferHandle buffer_handle,
89 gfx::GpuMemoryBufferId id, 85 gfx::GpuMemoryBufferId id,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 127
132 // An event that will be signalled when we shutdown. 128 // An event that will be signalled when we shutdown.
133 base::WaitableEvent shutdown_event_; 129 base::WaitableEvent shutdown_event_;
134 130
135 // The main thread for GpuService. 131 // The main thread for GpuService.
136 base::Thread gpu_thread_; 132 base::Thread gpu_thread_;
137 133
138 // The thread that handles IO events for GpuService. 134 // The thread that handles IO events for GpuService.
139 base::Thread io_thread_; 135 base::Thread io_thread_;
140 136
141 scoped_refptr<gpu::GpuWatchdogThread> watchdog_thread_; 137 gpu::GpuWatchdogThread* watchdog_thread_;
142 138
143 std::unique_ptr<gpu::SyncPointManager> owned_sync_point_manager_; 139 std::unique_ptr<gpu::SyncPointManager> owned_sync_point_manager_;
144 140
145 std::unique_ptr<gpu::GpuChannelManager> gpu_channel_manager_; 141 std::unique_ptr<gpu::GpuChannelManager> gpu_channel_manager_;
146 142
147 std::unique_ptr<media::MediaService> media_service_; 143 std::unique_ptr<media::MediaService> media_service_;
148 144
149 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory_; 145 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory_;
150 146
151 gpu::GpuPreferences gpu_preferences_; 147 gpu::GpuPreferences gpu_preferences_;
152 148
153 // Information about the GPU, such as device and vendor ID. 149 // Information about the GPU, such as device and vendor ID.
154 gpu::GPUInfo gpu_info_; 150 gpu::GPUInfo gpu_info_;
155 151
156 mojo::Binding<mojom::GpuServiceInternal> binding_; 152 mojo::Binding<mojom::GpuServiceInternal> binding_;
157 153
158 DISALLOW_COPY_AND_ASSIGN(GpuServiceInternal); 154 DISALLOW_COPY_AND_ASSIGN(GpuServiceInternal);
159 }; 155 };
160 156
161 } // namespace ui 157 } // namespace ui
162 158
163 #endif // SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_ 159 #endif // SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_
OLDNEW
« no previous file with comments | « services/ui/gpu/gpu_main.cc ('k') | services/ui/gpu/gpu_service_internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698