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

Side by Side Diff: content/gpu/gpu_child_thread.h

Issue 2612623002: gpu: Use mus gpu interface in non-mus chrome. (Closed)
Patch Set: more cleanup Created 3 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_GPU_GPU_CHILD_THREAD_H_ 5 #ifndef CONTENT_GPU_GPU_CHILD_THREAD_H_
6 #define CONTENT_GPU_GPU_CHILD_THREAD_H_ 6 #define CONTENT_GPU_GPU_CHILD_THREAD_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <queue> 11 #include <queue>
12 #include <string> 12 #include <string>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/metrics/field_trial.h" 18 #include "base/metrics/field_trial.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "build/build_config.h" 20 #include "build/build_config.h"
21 #include "content/child/child_thread_impl.h" 21 #include "content/child/child_thread_impl.h"
22 #include "content/common/associated_interface_registry_impl.h"
22 #include "gpu/command_buffer/service/gpu_preferences.h" 23 #include "gpu/command_buffer/service/gpu_preferences.h"
23 #include "gpu/config/gpu_info.h" 24 #include "gpu/config/gpu_info.h"
24 #include "gpu/ipc/service/gpu_channel.h" 25 #include "gpu/ipc/service/gpu_channel.h"
25 #include "gpu/ipc/service/gpu_channel_manager.h" 26 #include "gpu/ipc/service/gpu_channel_manager.h"
26 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" 27 #include "gpu/ipc/service/gpu_channel_manager_delegate.h"
27 #include "gpu/ipc/service/gpu_config.h" 28 #include "gpu/ipc/service/gpu_config.h"
28 #include "gpu/ipc/service/x_util.h" 29 #include "gpu/ipc/service/x_util.h"
30 #include "mojo/public/cpp/bindings/associated_binding_set.h"
29 #include "mojo/public/cpp/bindings/binding_set.h" 31 #include "mojo/public/cpp/bindings/binding_set.h"
30 #include "services/service_manager/public/interfaces/service_factory.mojom.h" 32 #include "services/service_manager/public/interfaces/service_factory.mojom.h"
33 #include "services/ui/gpu/gpu_service.h"
31 #include "services/ui/gpu/interfaces/gpu_main.mojom.h" 34 #include "services/ui/gpu/interfaces/gpu_main.mojom.h"
32 #include "ui/gfx/native_widget_types.h" 35 #include "ui/gfx/native_widget_types.h"
33 36
34 namespace gpu { 37 namespace gpu {
35 class GpuMemoryBufferFactory; 38 class GpuMemoryBufferFactory;
36 class GpuWatchdogThread; 39 class GpuWatchdogThread;
37 class SyncPointManager;
38 }
39
40 namespace media {
41 class MediaGpuChannelManager;
42 } 40 }
43 41
44 namespace sandbox { 42 namespace sandbox {
45 class TargetServices; 43 class TargetServices;
46 } 44 }
47 45
48 namespace content { 46 namespace content {
49 class GpuServiceFactory; 47 class GpuServiceFactory;
50 struct EstablishChannelParams; 48 struct EstablishChannelParams;
51 49
52 // The main thread of the GPU child process. There will only ever be one of 50 // The main thread of the GPU child process. There will only ever be one of
53 // these per process. It does process initialization and shutdown. It forwards 51 // these per process. It does process initialization and shutdown. It forwards
54 // IPC messages to gpu::GpuChannelManager, which is responsible for issuing 52 // IPC messages to gpu::GpuChannelManager, which is responsible for issuing
55 // rendering commands to the GPU. 53 // rendering commands to the GPU.
56 class GpuChildThread : public ChildThreadImpl, 54 class GpuChildThread : public ChildThreadImpl,
57 public gpu::GpuChannelManagerDelegate, 55 public ui::mojom::GpuMain,
58 public base::FieldTrialList::Observer { 56 public base::FieldTrialList::Observer {
59 public: 57 public:
60 struct LogMessage { 58 struct LogMessage {
61 int severity; 59 int severity;
62 std::string header; 60 std::string header;
63 std::string message; 61 std::string message;
64 }; 62 };
65 typedef std::queue<LogMessage> DeferredMessages; 63 typedef std::queue<LogMessage> DeferredMessages;
66 64
67 GpuChildThread(std::unique_ptr<gpu::GpuWatchdogThread> gpu_watchdog_thread, 65 GpuChildThread(std::unique_ptr<gpu::GpuWatchdogThread> gpu_watchdog_thread,
68 bool dead_on_arrival, 66 bool dead_on_arrival,
69 const gpu::GPUInfo& gpu_info, 67 const gpu::GPUInfo& gpu_info,
70 const DeferredMessages& deferred_messages, 68 const DeferredMessages& deferred_messages,
71 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory); 69 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory);
72 70
73 GpuChildThread(const InProcessChildThreadParams& params, 71 GpuChildThread(const InProcessChildThreadParams& params,
74 const gpu::GPUInfo& gpu_info, 72 const gpu::GPUInfo& gpu_info,
75 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory); 73 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory);
76 74
77 ~GpuChildThread() override; 75 ~GpuChildThread() override;
78 76
79 void Shutdown() override; 77 void Shutdown() override;
80 78
81 void Init(const base::Time& process_start_time); 79 void Init(const base::Time& process_start_time);
82 80
83 gpu::GpuWatchdogThread* watchdog_thread() { return watchdog_thread_.get(); } 81 gpu::GpuWatchdogThread* watchdog_thread() {
82 return gpu_service_->watchdog_thread();
83 }
84 84
85 private: 85 private:
86 void CreateGpuMainService(ui::mojom::GpuMainAssociatedRequest request); 86 void CreateGpuMainService(ui::mojom::GpuMainAssociatedRequest request);
87 87
88 // ChildThreadImpl:. 88 // ChildThreadImpl:.
89 bool Send(IPC::Message* msg) override; 89 bool Send(IPC::Message* msg) override;
90 bool OnControlMessageReceived(const IPC::Message& msg) override; 90 bool OnControlMessageReceived(const IPC::Message& msg) override;
91 bool OnMessageReceived(const IPC::Message& msg) override; 91 bool OnMessageReceived(const IPC::Message& msg) override;
92 92
93 // gpu::GpuChannelManagerDelegate: 93 // IPC::Listener implementation via ChildThreadImpl:
94 void SetActiveURL(const GURL& url) override; 94 void OnAssociatedInterfaceRequest(
95 void DidCreateOffscreenContext(const GURL& active_url) override; 95 const std::string& name,
96 void DidDestroyChannel(int client_id) override; 96 mojo::ScopedInterfaceEndpointHandle handle) override;
97 void DidDestroyOffscreenContext(const GURL& active_url) override; 97
98 void DidLoseContext(bool offscreen, 98 // ui::mojom::GpuMain:
99 gpu::error::ContextLostReason reason, 99 void CreateGpuService(ui::mojom::GpuServiceRequest request,
100 const GURL& active_url) override; 100 ui::mojom::GpuHostPtr gpu_host,
101 #if defined(OS_WIN) 101 const gpu::GpuPreferences& preferences) override;
102 void SendAcceleratedSurfaceCreatedChildWindow( 102 void CreateDisplayCompositor(
103 gpu::SurfaceHandle parent_window, 103 cc::mojom::DisplayCompositorRequest request,
104 gpu::SurfaceHandle child_window) override; 104 cc::mojom::DisplayCompositorClientPtr client) override;
105 #endif
106 void StoreShaderToDisk(int32_t client_id,
107 const std::string& key,
108 const std::string& shader) override;
109 105
110 // base::FieldTrialList::Observer: 106 // base::FieldTrialList::Observer:
111 void OnFieldTrialGroupFinalized(const std::string& trial_name, 107 void OnFieldTrialGroupFinalized(const std::string& trial_name,
112 const std::string& group_name) override; 108 const std::string& group_name) override;
113 109
114 // Message handlers. 110 // Message handlers.
115 void OnInitialize(const gpu::GpuPreferences& gpu_preferences);
116 void OnFinalize(); 111 void OnFinalize();
117 void OnCollectGraphicsInfo(); 112 void OnCollectGraphicsInfo();
118 void OnGetVideoMemoryUsageStats(); 113 void OnGetVideoMemoryUsageStats();
119 void OnSetVideoMemoryWindowCount(uint32_t window_count); 114 void OnSetVideoMemoryWindowCount(uint32_t window_count);
120 115
121 void OnClean(); 116 void OnClean();
122 void OnCrash(); 117 void OnCrash();
123 void OnHang(); 118 void OnHang();
124 void OnGpuSwitched(); 119 void OnGpuSwitched();
125 120
126 void OnEstablishChannel(const EstablishChannelParams& params); 121 void OnEstablishChannel(const EstablishChannelParams& params);
127 void OnCloseChannel(int32_t client_id); 122 void OnCloseChannel(int32_t client_id);
128 void OnLoadedShader(const std::string& shader); 123 void OnLoadedShader(const std::string& shader);
129 void OnDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, 124 void OnDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
130 int client_id, 125 int client_id,
131 const gpu::SyncToken& sync_token); 126 const gpu::SyncToken& sync_token);
132 #if defined(OS_ANDROID) 127 #if defined(OS_ANDROID)
133 void OnWakeUpGpu(); 128 void OnWakeUpGpu();
134 void OnDestroyingVideoSurface(int surface_id); 129 void OnDestroyingVideoSurface(int surface_id);
135 #endif 130 #endif
136 void OnLoseAllContexts();
137 131
138 void BindServiceFactoryRequest( 132 void BindServiceFactoryRequest(
139 service_manager::mojom::ServiceFactoryRequest request); 133 service_manager::mojom::ServiceFactoryRequest request);
140 134
135 gpu::GpuChannelManager* gpu_channel_manager() {
136 return gpu_service_->gpu_channel_manager();
137 }
138
141 // Set this flag to true if a fatal error occurred before we receive the 139 // Set this flag to true if a fatal error occurred before we receive the
142 // OnInitialize message, in which case we just declare ourselves DOA. 140 // OnInitialize message, in which case we just declare ourselves DOA.
143 const bool dead_on_arrival_; 141 const bool dead_on_arrival_;
144 base::Time process_start_time_; 142 base::Time process_start_time_;
145 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread_;
146 143
147 #if defined(OS_WIN) 144 #if defined(OS_WIN)
148 // Windows specific client sandbox interface. 145 // Windows specific client sandbox interface.
149 sandbox::TargetServices* target_services_; 146 sandbox::TargetServices* target_services_;
150 #endif 147 #endif
151 148
152 // Can be null if overridden by ContentGpuClient.
153 std::unique_ptr<gpu::SyncPointManager> owned_sync_point_manager_;
154
155 std::unique_ptr<gpu::GpuChannelManager> gpu_channel_manager_;
156
157 std::unique_ptr<media::MediaGpuChannelManager> media_gpu_channel_manager_;
158
159 // Information about the GPU, such as device and vendor ID. 149 // Information about the GPU, such as device and vendor ID.
160 gpu::GPUInfo gpu_info_; 150 gpu::GPUInfo gpu_info_;
161 151
162 // Error messages collected in gpu_main() before the thread is created. 152 // Error messages collected in gpu_main() before the thread is created.
163 DeferredMessages deferred_messages_; 153 DeferredMessages deferred_messages_;
164 154
165 // Whether the GPU thread is running in the browser process. 155 // Whether the GPU thread is running in the browser process.
166 bool in_browser_process_; 156 bool in_browser_process_;
167 157
168 // The gpu::GpuMemoryBufferFactory instance used to allocate GpuMemoryBuffers.
169 gpu::GpuMemoryBufferFactory* const gpu_memory_buffer_factory_;
170
171 // ServiceFactory for service_manager::Service hosting. 158 // ServiceFactory for service_manager::Service hosting.
172 std::unique_ptr<GpuServiceFactory> service_factory_; 159 std::unique_ptr<GpuServiceFactory> service_factory_;
173 160
174 // Bindings to the service_manager::mojom::ServiceFactory impl. 161 // Bindings to the service_manager::mojom::ServiceFactory impl.
175 mojo::BindingSet<service_manager::mojom::ServiceFactory> 162 mojo::BindingSet<service_manager::mojom::ServiceFactory>
176 service_factory_bindings_; 163 service_factory_bindings_;
177 164
165 AssociatedInterfaceRegistryImpl associated_interfaces_;
166 std::unique_ptr<ui::GpuService> gpu_service_;
167 mojo::AssociatedBinding<ui::mojom::GpuMain> gpu_main_binding_;
168
178 DISALLOW_COPY_AND_ASSIGN(GpuChildThread); 169 DISALLOW_COPY_AND_ASSIGN(GpuChildThread);
179 }; 170 };
180 171
181 } // namespace content 172 } // namespace content
182 173
183 #endif // CONTENT_GPU_GPU_CHILD_THREAD_H_ 174 #endif // CONTENT_GPU_GPU_CHILD_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698