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

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

Issue 2559183003: mus: More gpu-related renames. (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
(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 #include "services/ui/gpu/gpu_service_internal.h"
6
7 #include "base/bind.h"
8 #include "base/memory/shared_memory.h"
9 #include "base/threading/thread_task_runner_handle.h"
10 #include "build/build_config.h"
11 #include "cc/output/in_process_context_provider.h"
12 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
13 #include "gpu/command_buffer/service/gpu_switches.h"
14 #include "gpu/command_buffer/service/sync_point_manager.h"
15 #include "gpu/config/gpu_info_collector.h"
16 #include "gpu/config/gpu_switches.h"
17 #include "gpu/config/gpu_util.h"
18 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
19 #include "gpu/ipc/common/memory_stats.h"
20 #include "gpu/ipc/gpu_in_process_thread_service.h"
21 #include "gpu/ipc/service/gpu_channel_manager.h"
22 #include "gpu/ipc/service/gpu_memory_buffer_factory.h"
23 #include "gpu/ipc/service/gpu_watchdog_thread.h"
24 #include "ipc/ipc_channel_handle.h"
25 #include "ipc/ipc_sync_message_filter.h"
26 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h"
27 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h"
28 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h"
29 #include "media/gpu/ipc/service/media_gpu_channel_manager.h"
30 #include "mojo/public/cpp/bindings/strong_binding.h"
31 #include "ui/gl/gl_implementation.h"
32 #include "ui/gl/gl_switches.h"
33 #include "ui/gl/gpu_switching_manager.h"
34 #include "ui/gl/init/gl_factory.h"
35 #include "url/gurl.h"
36
37 namespace ui {
38
39 GpuServiceInternal::GpuServiceInternal(
40 const gpu::GPUInfo& gpu_info,
41 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread,
42 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory,
43 scoped_refptr<base::SingleThreadTaskRunner> io_runner)
44 : io_runner_(std::move(io_runner)),
45 shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL,
46 base::WaitableEvent::InitialState::NOT_SIGNALED),
47 watchdog_thread_(std::move(watchdog_thread)),
48 gpu_memory_buffer_factory_(gpu_memory_buffer_factory),
49 gpu_info_(gpu_info) {}
50
51 GpuServiceInternal::~GpuServiceInternal() {
52 bindings_.CloseAllBindings();
53 media_gpu_channel_manager_.reset();
54 gpu_channel_manager_.reset();
55 owned_sync_point_manager_.reset();
56
57 // Signal this event before destroying the child process. That way all
58 // background threads can cleanup.
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.
61 shutdown_event_.Signal();
62 }
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
94 void GpuServiceInternal::Bind(mojom::GpuServiceInternalRequest request) {
95 bindings_.AddBinding(this, std::move(request));
96 }
97
98 void GpuServiceInternal::CreateGpuMemoryBuffer(
99 gfx::GpuMemoryBufferId id,
100 const gfx::Size& size,
101 gfx::BufferFormat format,
102 gfx::BufferUsage usage,
103 int client_id,
104 gpu::SurfaceHandle surface_handle,
105 const CreateGpuMemoryBufferCallback& callback) {
106 DCHECK(CalledOnValidThread());
107 callback.Run(gpu_memory_buffer_factory_->CreateGpuMemoryBuffer(
108 id, size, format, usage, client_id, surface_handle));
109 }
110
111 void GpuServiceInternal::DestroyGpuMemoryBuffer(
112 gfx::GpuMemoryBufferId id,
113 int client_id,
114 const gpu::SyncToken& sync_token) {
115 DCHECK(CalledOnValidThread());
116 if (gpu_channel_manager_)
117 gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token);
118 }
119
120 void GpuServiceInternal::DidCreateOffscreenContext(const GURL& active_url) {
121 gpu_host_->DidCreateOffscreenContext(active_url);
122 }
123
124 void GpuServiceInternal::DidDestroyChannel(int client_id) {
125 media_gpu_channel_manager_->RemoveChannel(client_id);
126 gpu_host_->DidDestroyChannel(client_id);
127 }
128
129 void GpuServiceInternal::DidDestroyOffscreenContext(const GURL& active_url) {
130 gpu_host_->DidDestroyOffscreenContext(active_url);
131 }
132
133 void GpuServiceInternal::DidLoseContext(bool offscreen,
134 gpu::error::ContextLostReason reason,
135 const GURL& active_url) {
136 gpu_host_->DidLoseContext(offscreen, reason, active_url);
137 }
138
139 void GpuServiceInternal::StoreShaderToDisk(int client_id,
140 const std::string& key,
141 const std::string& shader) {
142 gpu_host_->StoreShaderToDisk(client_id, key, shader);
143 }
144
145 #if defined(OS_WIN)
146 void GpuServiceInternal::SendAcceleratedSurfaceCreatedChildWindow(
147 gpu::SurfaceHandle parent_window,
148 gpu::SurfaceHandle child_window) {
149 ::SetParent(child_window, parent_window);
150 }
151 #endif
152
153 void GpuServiceInternal::SetActiveURL(const GURL& url) {
154 // TODO(penghuang): implement this function.
155 }
156
157 void GpuServiceInternal::EstablishGpuChannel(
158 int32_t client_id,
159 uint64_t client_tracing_id,
160 bool is_gpu_host,
161 const EstablishGpuChannelCallback& callback) {
162 DCHECK(CalledOnValidThread());
163
164 if (!gpu_channel_manager_) {
165 callback.Run(mojo::ScopedMessagePipeHandle());
166 return;
167 }
168
169 const bool preempts = is_gpu_host;
170 const bool allow_view_command_buffers = is_gpu_host;
171 const bool allow_real_time_streams = is_gpu_host;
172 mojo::ScopedMessagePipeHandle channel_handle;
173 IPC::ChannelHandle handle = gpu_channel_manager_->EstablishChannel(
174 client_id, client_tracing_id, preempts, allow_view_command_buffers,
175 allow_real_time_streams);
176 channel_handle.reset(handle.mojo_handle);
177 media_gpu_channel_manager_->AddChannel(client_id);
178 callback.Run(std::move(channel_handle));
179 }
180
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