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

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

Issue 2539893002: Mus: Implement GpuMain mojo interface (Closed)
Patch Set: Addressed Sadrul's comments Created 4 years 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/client/gpu_memory_buffer_manager.h"
13 #include "gpu/command_buffer/service/gpu_preferences.h" 14 #include "gpu/command_buffer/service/gpu_preferences.h"
14 #include "gpu/config/gpu_info.h" 15 #include "gpu/config/gpu_info.h"
15 #include "gpu/ipc/common/surface_handle.h" 16 #include "gpu/ipc/common/surface_handle.h"
16 #include "gpu/ipc/service/gpu_channel.h" 17 #include "gpu/ipc/service/gpu_channel.h"
17 #include "gpu/ipc/service/gpu_channel_manager.h" 18 #include "gpu/ipc/service/gpu_channel_manager.h"
18 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" 19 #include "gpu/ipc/service/gpu_channel_manager_delegate.h"
19 #include "gpu/ipc/service/gpu_config.h" 20 #include "gpu/ipc/service/gpu_config.h"
20 #include "gpu/ipc/service/x_util.h" 21 #include "gpu/ipc/service/x_util.h"
21 #include "mojo/public/cpp/bindings/binding.h" 22 #include "mojo/public/cpp/bindings/binding.h"
22 #include "mojo/public/cpp/bindings/binding_set.h" 23 #include "mojo/public/cpp/bindings/binding_set.h"
23 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" 24 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h"
24 #include "services/ui/surfaces/display_compositor.h"
25 #include "ui/gfx/native_widget_types.h" 25 #include "ui/gfx/native_widget_types.h"
26 26
27 namespace gpu { 27 namespace gpu {
28 class GpuChannelHost; 28 class GpuChannelHost;
29 class GpuMemoryBufferFactory; 29 class GpuMemoryBufferFactory;
30 class GpuWatchdogThread; 30 class GpuWatchdogThread;
31 class SyncPointManager; 31 class SyncPointManager;
32 } 32 }
33 33
34 namespace media { 34 namespace media {
35 class MediaGpuChannelManager; 35 class MediaGpuChannelManager;
36 } 36 }
37 37
38 namespace ui { 38 namespace ui {
39 39
40 class GpuMain; 40 class GpuMain;
41 41
42 // This runs in the GPU process, and communicates with the gpu host (which is 42 // This runs in the GPU process, and communicates with the gpu host (which is
43 // the window server) over the mojom APIs. This is responsible for setting up 43 // the window server) over the mojom APIs. This is responsible for setting up
44 // the connection to clients, allocating/free'ing gpu memory etc. 44 // the connection to clients, allocating/free'ing gpu memory etc.
45 class GpuServiceInternal : public gpu::GpuChannelManagerDelegate, 45 class GpuServiceInternal : public gpu::GpuChannelManagerDelegate,
46 public mojom::GpuServiceInternal, 46 public mojom::GpuServiceInternal,
47 public base::NonThreadSafe { 47 public base::NonThreadSafe {
48 public: 48 public:
49 GpuServiceInternal(const gpu::GPUInfo& gpu_info,
50 std::unique_ptr<gpu::GpuWatchdogThread> watchdog,
51 gpu::GpuMemoryBufferFactory* memory_buffer_factory,
52 scoped_refptr<base::SingleThreadTaskRunner> io_runner);
53
49 ~GpuServiceInternal() override; 54 ~GpuServiceInternal() override;
50 55
51 void Add(mojom::GpuServiceInternalRequest request); 56 void Bind(mojom::GpuServiceInternalRequest request);
52
53 void DestroyDisplayCompositor();
54 57
55 private: 58 private:
56 friend class GpuMain; 59 friend class GpuMain;
57 60
58 GpuServiceInternal(
59 const gpu::GPUInfo& gpu_info,
60 std::unique_ptr<gpu::GpuWatchdogThread> watchdog,
61 gpu::GpuMemoryBufferFactory* memory_buffer_factory,
62 scoped_refptr<base::SingleThreadTaskRunner> io_runner,
63 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner);
64
65 gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferFromeHandle( 61 gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferFromeHandle(
66 gfx::GpuMemoryBufferHandle buffer_handle, 62 gfx::GpuMemoryBufferHandle buffer_handle,
67 gfx::GpuMemoryBufferId id, 63 gfx::GpuMemoryBufferId id,
68 const gfx::Size& size, 64 const gfx::Size& size,
69 gfx::BufferFormat format, 65 gfx::BufferFormat format,
70 int client_id); 66 int client_id);
71 67
68 gpu::SyncPointManager* sync_point_manager() {
69 return owned_sync_point_manager_.get();
70 }
71
72 gpu::gles2::MailboxManager* mailbox_manager() {
73 return gpu_channel_manager_->mailbox_manager();
74 }
75
76 gl::GLShareGroup* share_group() {
77 return gpu_channel_manager_->share_group();
78 }
79
80 const gpu::GPUInfo& gpu_info() const { return gpu_info_; }
81
72 // gpu::GpuChannelManagerDelegate: 82 // gpu::GpuChannelManagerDelegate:
73 void DidCreateOffscreenContext(const GURL& active_url) override; 83 void DidCreateOffscreenContext(const GURL& active_url) override;
74 void DidDestroyChannel(int client_id) override; 84 void DidDestroyChannel(int client_id) override;
75 void DidDestroyOffscreenContext(const GURL& active_url) override; 85 void DidDestroyOffscreenContext(const GURL& active_url) override;
76 void DidLoseContext(bool offscreen, 86 void DidLoseContext(bool offscreen,
77 gpu::error::ContextLostReason reason, 87 gpu::error::ContextLostReason reason,
78 const GURL& active_url) override; 88 const GURL& active_url) override;
79 void StoreShaderToDisk(int client_id, 89 void StoreShaderToDisk(int client_id,
80 const std::string& key, 90 const std::string& key,
81 const std::string& shader) override; 91 const std::string& shader) override;
82 #if defined(OS_WIN) 92 #if defined(OS_WIN)
83 void SendAcceleratedSurfaceCreatedChildWindow( 93 void SendAcceleratedSurfaceCreatedChildWindow(
84 gpu::SurfaceHandle parent_window, 94 gpu::SurfaceHandle parent_window,
85 gpu::SurfaceHandle child_window) override; 95 gpu::SurfaceHandle child_window) override;
86 #endif 96 #endif
87 void SetActiveURL(const GURL& url) override; 97 void SetActiveURL(const GURL& url) override;
98 void Initialize();
88 99
89 // mojom::GpuServiceInternal: 100 // mojom::GpuServiceInternal:
90 void Initialize(const InitializeCallback& callback) override;
91 void EstablishGpuChannel( 101 void EstablishGpuChannel(
92 int32_t client_id, 102 int32_t client_id,
93 uint64_t client_tracing_id, 103 uint64_t client_tracing_id,
94 bool is_gpu_host, 104 bool is_gpu_host,
95 const EstablishGpuChannelCallback& callback) override; 105 const EstablishGpuChannelCallback& callback) override;
96 void CreateGpuMemoryBuffer( 106 void CreateGpuMemoryBuffer(
97 gfx::GpuMemoryBufferId id, 107 gfx::GpuMemoryBufferId id,
98 const gfx::Size& size, 108 const gfx::Size& size,
99 gfx::BufferFormat format, 109 gfx::BufferFormat format,
100 gfx::BufferUsage usage, 110 gfx::BufferUsage usage,
101 int client_id, 111 int client_id,
102 gpu::SurfaceHandle surface_handle, 112 gpu::SurfaceHandle surface_handle,
103 const CreateGpuMemoryBufferCallback& callback) override; 113 const CreateGpuMemoryBufferCallback& callback) override;
104 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, 114 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
105 int client_id, 115 int client_id,
106 const gpu::SyncToken& sync_token) override; 116 const gpu::SyncToken& sync_token) override;
107 void CreateDisplayCompositor(
108 cc::mojom::DisplayCompositorRequest request,
109 cc::mojom::DisplayCompositorClientPtr client) override;
110
111 void CreateDisplayCompositorOnCompositorThread(
112 mojom::GpuServiceInternalPtrInfo gpu_service_info,
113 cc::mojom::DisplayCompositorRequest request,
114 cc::mojom::DisplayCompositorClientPtrInfo client_info);
115
116 void DestroyDisplayCompositorOnCompositorThread();
117 117
118 scoped_refptr<base::SingleThreadTaskRunner> io_runner_; 118 scoped_refptr<base::SingleThreadTaskRunner> io_runner_;
119 scoped_refptr<base::SingleThreadTaskRunner> compositor_runner_;
120 119
121 // An event that will be signalled when we shutdown. 120 // An event that will be signalled when we shutdown.
122 base::WaitableEvent shutdown_event_; 121 base::WaitableEvent shutdown_event_;
123 122
124 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread_; 123 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread_;
125 124
126 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory_; 125 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory_;
127 126
128 gpu::GpuPreferences gpu_preferences_; 127 gpu::GpuPreferences gpu_preferences_;
129 128
130 // Information about the GPU, such as device and vendor ID. 129 // Information about the GPU, such as device and vendor ID.
131 gpu::GPUInfo gpu_info_; 130 gpu::GPUInfo gpu_info_;
132 131
133 std::unique_ptr<ui::DisplayCompositor> display_compositor_;
134
135 // The message-pipe used by the DisplayCompositor to request gpu memory
136 // buffers.
137 mojom::GpuServiceInternalPtr gpu_internal_;
138
139 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_command_service_;
140 std::unique_ptr<gpu::SyncPointManager> owned_sync_point_manager_; 132 std::unique_ptr<gpu::SyncPointManager> owned_sync_point_manager_;
141 std::unique_ptr<gpu::GpuChannelManager> gpu_channel_manager_; 133 std::unique_ptr<gpu::GpuChannelManager> gpu_channel_manager_;
142 std::unique_ptr<media::MediaGpuChannelManager> media_gpu_channel_manager_; 134 std::unique_ptr<media::MediaGpuChannelManager> media_gpu_channel_manager_;
143 mojo::BindingSet<mojom::GpuServiceInternal> bindings_; 135 mojo::BindingSet<mojom::GpuServiceInternal> bindings_;
144 136
145 DISALLOW_COPY_AND_ASSIGN(GpuServiceInternal); 137 DISALLOW_COPY_AND_ASSIGN(GpuServiceInternal);
146 }; 138 };
147 139
148 } // namespace ui 140 } // namespace ui
149 141
150 #endif // SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_ 142 #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