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

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

Issue 2559113002: mus/gpu: Introduce the GpuServiceHost mojom interface. (Closed)
Patch Set: . 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_service_internal.h ('k') | services/ui/gpu/interfaces/BUILD.gn » ('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 #include "services/ui/gpu/gpu_service_internal.h" 5 #include "services/ui/gpu/gpu_service_internal.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 gpu_channel_manager_.reset(); 54 gpu_channel_manager_.reset();
55 owned_sync_point_manager_.reset(); 55 owned_sync_point_manager_.reset();
56 56
57 // Signal this event before destroying the child process. That way all 57 // Signal this event before destroying the child process. That way all
58 // background threads can cleanup. 58 // background threads can cleanup.
59 // For example, in the renderer the RenderThread instances will be able to 59 // For example, in the renderer the RenderThread instances will be able to
60 // notice shutdown before the render process begins waiting for them to exit. 60 // notice shutdown before the render process begins waiting for them to exit.
61 shutdown_event_.Signal(); 61 shutdown_event_.Signal();
62 } 62 }
63 63
64 void GpuServiceInternal::InitializeWithHost(mojom::GpuServiceHostPtr gpu_host) {
65 DCHECK(CalledOnValidThread());
66 DCHECK(!gpu_host_);
67 gpu_host_ = std::move(gpu_host);
68 gpu_info_.video_decode_accelerator_capabilities =
69 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_);
70 gpu_info_.video_encode_accelerator_supported_profiles =
71 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences_);
72 gpu_info_.jpeg_decode_accelerator_supported =
73 media::GpuJpegDecodeAccelerator::IsSupported();
74 gpu_host_->DidInitialize(gpu_info_);
75
76 DCHECK(!owned_sync_point_manager_);
77 const bool allow_threaded_wait = false;
78 owned_sync_point_manager_.reset(
79 new gpu::SyncPointManager(allow_threaded_wait));
80
81 // Defer creation of the render thread. This is to prevent it from handling
82 // IPC messages before the sandbox has been enabled and all other necessary
83 // initialization has succeeded.
84 gpu_channel_manager_.reset(new gpu::GpuChannelManager(
85 gpu_preferences_, this, watchdog_thread_.get(),
86 base::ThreadTaskRunnerHandle::Get().get(), io_runner_.get(),
87 &shutdown_event_, owned_sync_point_manager_.get(),
88 gpu_memory_buffer_factory_));
89
90 media_gpu_channel_manager_.reset(
91 new media::MediaGpuChannelManager(gpu_channel_manager_.get()));
92 }
93
64 void GpuServiceInternal::Bind(mojom::GpuServiceInternalRequest request) { 94 void GpuServiceInternal::Bind(mojom::GpuServiceInternalRequest request) {
65 bindings_.AddBinding(this, std::move(request)); 95 bindings_.AddBinding(this, std::move(request));
66 } 96 }
67 97
68 void GpuServiceInternal::CreateGpuMemoryBuffer( 98 void GpuServiceInternal::CreateGpuMemoryBuffer(
69 gfx::GpuMemoryBufferId id, 99 gfx::GpuMemoryBufferId id,
70 const gfx::Size& size, 100 const gfx::Size& size,
71 gfx::BufferFormat format, 101 gfx::BufferFormat format,
72 gfx::BufferUsage usage, 102 gfx::BufferUsage usage,
73 int client_id, 103 int client_id,
74 gpu::SurfaceHandle surface_handle, 104 gpu::SurfaceHandle surface_handle,
75 const CreateGpuMemoryBufferCallback& callback) { 105 const CreateGpuMemoryBufferCallback& callback) {
76 DCHECK(CalledOnValidThread()); 106 DCHECK(CalledOnValidThread());
77 callback.Run(gpu_memory_buffer_factory_->CreateGpuMemoryBuffer( 107 callback.Run(gpu_memory_buffer_factory_->CreateGpuMemoryBuffer(
78 id, size, format, usage, client_id, surface_handle)); 108 id, size, format, usage, client_id, surface_handle));
79 } 109 }
80 110
81 void GpuServiceInternal::DestroyGpuMemoryBuffer( 111 void GpuServiceInternal::DestroyGpuMemoryBuffer(
82 gfx::GpuMemoryBufferId id, 112 gfx::GpuMemoryBufferId id,
83 int client_id, 113 int client_id,
84 const gpu::SyncToken& sync_token) { 114 const gpu::SyncToken& sync_token) {
85 DCHECK(CalledOnValidThread()); 115 DCHECK(CalledOnValidThread());
86 if (gpu_channel_manager_) 116 if (gpu_channel_manager_)
87 gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token); 117 gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token);
88 } 118 }
89 119
90 void GpuServiceInternal::DidCreateOffscreenContext(const GURL& active_url) { 120 void GpuServiceInternal::DidCreateOffscreenContext(const GURL& active_url) {
91 NOTIMPLEMENTED(); 121 gpu_host_->DidCreateOffscreenContext(active_url);
92 } 122 }
93 123
94 void GpuServiceInternal::DidDestroyChannel(int client_id) { 124 void GpuServiceInternal::DidDestroyChannel(int client_id) {
95 media_gpu_channel_manager_->RemoveChannel(client_id); 125 media_gpu_channel_manager_->RemoveChannel(client_id);
96 NOTIMPLEMENTED(); 126 gpu_host_->DidDestroyChannel(client_id);
97 } 127 }
98 128
99 void GpuServiceInternal::DidDestroyOffscreenContext(const GURL& active_url) { 129 void GpuServiceInternal::DidDestroyOffscreenContext(const GURL& active_url) {
100 NOTIMPLEMENTED(); 130 gpu_host_->DidDestroyOffscreenContext(active_url);
101 } 131 }
102 132
103 void GpuServiceInternal::DidLoseContext(bool offscreen, 133 void GpuServiceInternal::DidLoseContext(bool offscreen,
104 gpu::error::ContextLostReason reason, 134 gpu::error::ContextLostReason reason,
105 const GURL& active_url) { 135 const GURL& active_url) {
106 NOTIMPLEMENTED(); 136 gpu_host_->DidLoseContext(offscreen, reason, active_url);
107 } 137 }
108 138
109 void GpuServiceInternal::StoreShaderToDisk(int client_id, 139 void GpuServiceInternal::StoreShaderToDisk(int client_id,
110 const std::string& key, 140 const std::string& key,
111 const std::string& shader) { 141 const std::string& shader) {
112 NOTIMPLEMENTED(); 142 gpu_host_->StoreShaderToDisk(client_id, key, shader);
113 } 143 }
114 144
115 #if defined(OS_WIN) 145 #if defined(OS_WIN)
116 void GpuServiceInternal::SendAcceleratedSurfaceCreatedChildWindow( 146 void GpuServiceInternal::SendAcceleratedSurfaceCreatedChildWindow(
117 gpu::SurfaceHandle parent_window, 147 gpu::SurfaceHandle parent_window,
118 gpu::SurfaceHandle child_window) { 148 gpu::SurfaceHandle child_window) {
119 ::SetParent(child_window, parent_window); 149 ::SetParent(child_window, parent_window);
120 } 150 }
121 #endif 151 #endif
122 152
123 void GpuServiceInternal::SetActiveURL(const GURL& url) { 153 void GpuServiceInternal::SetActiveURL(const GURL& url) {
124 // TODO(penghuang): implement this function. 154 // TODO(penghuang): implement this function.
125 } 155 }
126 156
127 void GpuServiceInternal::Initialize() {
128 DCHECK(CalledOnValidThread());
129 gpu_info_.video_decode_accelerator_capabilities =
130 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_);
131 gpu_info_.video_encode_accelerator_supported_profiles =
132 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences_);
133 gpu_info_.jpeg_decode_accelerator_supported =
134 media::GpuJpegDecodeAccelerator::IsSupported();
135
136 DCHECK(!owned_sync_point_manager_);
137 const bool allow_threaded_wait = false;
138 owned_sync_point_manager_.reset(
139 new gpu::SyncPointManager(allow_threaded_wait));
140
141 // Defer creation of the render thread. This is to prevent it from handling
142 // IPC messages before the sandbox has been enabled and all other necessary
143 // initialization has succeeded.
144 gpu_channel_manager_.reset(new gpu::GpuChannelManager(
145 gpu_preferences_, this, watchdog_thread_.get(),
146 base::ThreadTaskRunnerHandle::Get().get(), io_runner_.get(),
147 &shutdown_event_, owned_sync_point_manager_.get(),
148 gpu_memory_buffer_factory_));
149
150 media_gpu_channel_manager_.reset(
151 new media::MediaGpuChannelManager(gpu_channel_manager_.get()));
152 }
153
154 void GpuServiceInternal::EstablishGpuChannel( 157 void GpuServiceInternal::EstablishGpuChannel(
155 int32_t client_id, 158 int32_t client_id,
156 uint64_t client_tracing_id, 159 uint64_t client_tracing_id,
157 bool is_gpu_host, 160 bool is_gpu_host,
158 const EstablishGpuChannelCallback& callback) { 161 const EstablishGpuChannelCallback& callback) {
159 DCHECK(CalledOnValidThread()); 162 DCHECK(CalledOnValidThread());
160 163
161 if (!gpu_channel_manager_) { 164 if (!gpu_channel_manager_) {
162 callback.Run(mojo::ScopedMessagePipeHandle()); 165 callback.Run(mojo::ScopedMessagePipeHandle());
163 return; 166 return;
164 } 167 }
165 168
166 const bool preempts = is_gpu_host; 169 const bool preempts = is_gpu_host;
167 const bool allow_view_command_buffers = is_gpu_host; 170 const bool allow_view_command_buffers = is_gpu_host;
168 const bool allow_real_time_streams = is_gpu_host; 171 const bool allow_real_time_streams = is_gpu_host;
169 mojo::ScopedMessagePipeHandle channel_handle; 172 mojo::ScopedMessagePipeHandle channel_handle;
170 IPC::ChannelHandle handle = gpu_channel_manager_->EstablishChannel( 173 IPC::ChannelHandle handle = gpu_channel_manager_->EstablishChannel(
171 client_id, client_tracing_id, preempts, allow_view_command_buffers, 174 client_id, client_tracing_id, preempts, allow_view_command_buffers,
172 allow_real_time_streams); 175 allow_real_time_streams);
173 channel_handle.reset(handle.mojo_handle); 176 channel_handle.reset(handle.mojo_handle);
174 media_gpu_channel_manager_->AddChannel(client_id); 177 media_gpu_channel_manager_->AddChannel(client_id);
175 callback.Run(std::move(channel_handle)); 178 callback.Run(std::move(channel_handle));
176 } 179 }
177 180
178 } // namespace ui 181 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/gpu/gpu_service_internal.h ('k') | services/ui/gpu/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698