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

Side by Side Diff: services/ui/ws/gpu_host.cc

Issue 2610783003: mus: Make sure window parenting happens in the window server. (Closed)
Patch Set: . 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
« no previous file with comments | « services/ui/ws/gpu_host.h ('k') | services/ui/ws/platform_display.h » ('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/ws/gpu_host.h" 5 #include "services/ui/ws/gpu_host.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "gpu/ipc/client/gpu_channel_host.h" 12 #include "gpu/ipc/client/gpu_channel_host.h"
13 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" 13 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h"
14 #include "mojo/public/cpp/bindings/strong_binding.h" 14 #include "mojo/public/cpp/bindings/strong_binding.h"
15 #include "mojo/public/cpp/system/buffer.h" 15 #include "mojo/public/cpp/system/buffer.h"
16 #include "mojo/public/cpp/system/platform_handle.h" 16 #include "mojo/public/cpp/system/platform_handle.h"
17 #include "services/service_manager/public/cpp/connection.h" 17 #include "services/service_manager/public/cpp/connection.h"
18 #include "services/ui/common/server_gpu_memory_buffer_manager.h" 18 #include "services/ui/common/server_gpu_memory_buffer_manager.h"
19 #include "services/ui/ws/gpu_host_delegate.h" 19 #include "services/ui/ws/gpu_host_delegate.h"
20 #include "ui/gfx/buffer_format_util.h" 20 #include "ui/gfx/buffer_format_util.h"
21 21
22 #if defined(OS_WIN)
23 #include "ui/gfx/win/rendering_window_manager.h"
24 #endif
25
22 namespace ui { 26 namespace ui {
23 namespace ws { 27 namespace ws {
24 28
25 namespace { 29 namespace {
26 30
27 // The client Id 1 is reserved for the display compositor. 31 // The client Id 1 is reserved for the display compositor.
28 const int32_t kInternalGpuChannelClientId = 2; 32 const int32_t kInternalGpuChannelClientId = 2;
29 33
30 // The implementation that relays requests from clients to the real 34 // The implementation that relays requests from clients to the real
31 // service implementation in the GPU process over mojom.GpuService. 35 // service implementation in the GPU process over mojom.GpuService.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 DISALLOW_COPY_AND_ASSIGN(GpuClient); 96 DISALLOW_COPY_AND_ASSIGN(GpuClient);
93 }; 97 };
94 98
95 } // namespace 99 } // namespace
96 100
97 GpuHost::GpuHost(GpuHostDelegate* delegate) 101 GpuHost::GpuHost(GpuHostDelegate* delegate)
98 : delegate_(delegate), 102 : delegate_(delegate),
99 next_client_id_(kInternalGpuChannelClientId + 1), 103 next_client_id_(kInternalGpuChannelClientId + 1),
100 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), 104 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
101 gpu_host_binding_(this) { 105 gpu_host_binding_(this) {
106 // TODO(sad): Once GPU process is split, this would look like:
107 // connector->ConnectToInterface("gpu", &gpu_main_);
102 gpu_main_impl_ = base::MakeUnique<GpuMain>(MakeRequest(&gpu_main_)); 108 gpu_main_impl_ = base::MakeUnique<GpuMain>(MakeRequest(&gpu_main_));
103 gpu_main_impl_->OnStart(); 109 gpu_main_impl_->OnStart();
104 // TODO(sad): Once GPU process is split, this would look like:
105 // connector->ConnectToInterface("gpu", &gpu_main_);
106 gpu_main_->CreateGpuService(MakeRequest(&gpu_service_), 110 gpu_main_->CreateGpuService(MakeRequest(&gpu_service_),
107 gpu_host_binding_.CreateInterfacePtrAndBind()); 111 gpu_host_binding_.CreateInterfacePtrAndBind());
108 gpu_memory_buffer_manager_ = base::MakeUnique<ServerGpuMemoryBufferManager>( 112 gpu_memory_buffer_manager_ = base::MakeUnique<ServerGpuMemoryBufferManager>(
109 gpu_service_.get(), next_client_id_++); 113 gpu_service_.get(), next_client_id_++);
110 } 114 }
111 115
112 GpuHost::~GpuHost() {} 116 GpuHost::~GpuHost() {}
113 117
114 void GpuHost::Add(mojom::GpuRequest request) { 118 void GpuHost::Add(mojom::GpuRequest request) {
115 mojo::MakeStrongBinding( 119 mojo::MakeStrongBinding(
116 base::MakeUnique<GpuClient>(next_client_id_++, &gpu_info_, 120 base::MakeUnique<GpuClient>(next_client_id_++, &gpu_info_,
117 gpu_memory_buffer_manager_.get(), 121 gpu_memory_buffer_manager_.get(),
118 gpu_service_.get()), 122 gpu_service_.get()),
119 std::move(request)); 123 std::move(request));
120 } 124 }
121 125
126 void GpuHost::OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) {
127 #if defined(OS_WIN)
128 gfx::RenderingWindowManager::GetInstance()->RegisterParent(widget);
129 #endif
130 }
131
132 void GpuHost::OnAcceleratedWidgetDestroyed(gfx::AcceleratedWidget widget) {
133 #if defined(OS_WIN)
134 gfx::RenderingWindowManager::GetInstance()->UnregisterParent(widget);
135 #endif
136 }
137
122 void GpuHost::CreateDisplayCompositor( 138 void GpuHost::CreateDisplayCompositor(
123 cc::mojom::DisplayCompositorRequest request, 139 cc::mojom::DisplayCompositorRequest request,
124 cc::mojom::DisplayCompositorClientPtr client) { 140 cc::mojom::DisplayCompositorClientPtr client) {
125 gpu_main_->CreateDisplayCompositor(std::move(request), std::move(client)); 141 gpu_main_->CreateDisplayCompositor(std::move(request), std::move(client));
126 } 142 }
127 143
144 void GpuHost::OnBadMessageFromGpu() {
145 // TODO(sad): Received some unexpected message from the gpu process. We
146 // should kill the process and restart it.
147 NOTIMPLEMENTED();
148 }
149
128 void GpuHost::DidInitialize(const gpu::GPUInfo& gpu_info) { 150 void GpuHost::DidInitialize(const gpu::GPUInfo& gpu_info) {
129 gpu_info_ = gpu_info; 151 gpu_info_ = gpu_info;
130 delegate_->OnGpuServiceInitialized(); 152 delegate_->OnGpuServiceInitialized();
131 } 153 }
132 154
133 void GpuHost::DidCreateOffscreenContext(const GURL& url) {} 155 void GpuHost::DidCreateOffscreenContext(const GURL& url) {}
134 156
135 void GpuHost::DidDestroyOffscreenContext(const GURL& url) {} 157 void GpuHost::DidDestroyOffscreenContext(const GURL& url) {}
136 158
137 void GpuHost::DidDestroyChannel(int32_t client_id) {} 159 void GpuHost::DidDestroyChannel(int32_t client_id) {}
138 160
139 void GpuHost::DidLoseContext(bool offscreen, 161 void GpuHost::DidLoseContext(bool offscreen,
140 gpu::error::ContextLostReason reason, 162 gpu::error::ContextLostReason reason,
141 const GURL& active_url) {} 163 const GURL& active_url) {}
142 164
165 void GpuHost::SetChildSurface(gpu::SurfaceHandle parent,
166 gpu::SurfaceHandle child) {
167 #if defined(OS_WIN)
168 // Verify that |parent| was created by the window server.
169 DWORD process_id = 0;
170 DWORD thread_id = GetWindowThreadProcessId(parent, &process_id);
171 if (!thread_id || process_id != ::GetCurrentProcessId()) {
172 OnBadMessageFromGpu();
173 return;
174 }
175
176 // TODO(sad): Also verify that |child| was created by the mus-gpu process.
177
178 if (!gfx::RenderingWindowManager::GetInstance()->RegisterChild(parent,
179 child)) {
180 OnBadMessageFromGpu();
181 }
182 #else
183 NOTREACHED();
184 #endif
185 }
186
143 void GpuHost::StoreShaderToDisk(int32_t client_id, 187 void GpuHost::StoreShaderToDisk(int32_t client_id,
144 const std::string& key, 188 const std::string& key,
145 const std::string& shader) {} 189 const std::string& shader) {}
146 190
147 } // namespace ws 191 } // namespace ws
148 } // namespace ui 192 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/gpu_host.h ('k') | services/ui/ws/platform_display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698