OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/compositor/gpu_process_transport_factory.h" | 5 #include "content/browser/compositor/gpu_process_transport_factory.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, | 180 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, |
181 data->surface_id), | 181 data->surface_id), |
182 "Compositor"); | 182 "Compositor"); |
183 } | 183 } |
184 | 184 |
185 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", | 185 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", |
186 !!context_provider.get()); | 186 !!context_provider.get()); |
187 | 187 |
188 if (context_provider.get()) { | 188 if (context_provider.get()) { |
189 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_task_runner = | 189 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_task_runner = |
190 GetCompositorMessageLoop(); | 190 base::MessageLoopProxy::current(); |
191 if (!compositor_thread_task_runner.get()) | |
192 compositor_thread_task_runner = base::MessageLoopProxy::current(); | |
193 | 191 |
194 // Here we know the GpuProcessHost has been set up, because we created a | 192 // Here we know the GpuProcessHost has been set up, because we created a |
195 // context. | 193 // context. |
196 output_surface_proxy_->ConnectToGpuProcessHost( | 194 output_surface_proxy_->ConnectToGpuProcessHost( |
197 compositor_thread_task_runner.get()); | 195 compositor_thread_task_runner.get()); |
198 } | 196 } |
199 | 197 |
200 if (UseSurfacesEnabled()) { | 198 if (UseSurfacesEnabled()) { |
201 // This gets a bit confusing. Here we have a ContextProvider configured to | 199 // This gets a bit confusing. Here we have a ContextProvider configured to |
202 // render directly to this widget. We need to make an OnscreenDisplayClient | 200 // render directly to this widget. We need to make an OnscreenDisplayClient |
(...skipping 28 matching lines...) Expand all Loading... | |
231 manager, compositor->surface_id_allocator(), context_provider)); | 229 manager, compositor->surface_id_allocator(), context_provider)); |
232 display_client->set_surface_output_surface(output_surface.get()); | 230 display_client->set_surface_output_surface(output_surface.get()); |
233 output_surface->set_display_client(display_client.get()); | 231 output_surface->set_display_client(display_client.get()); |
234 display_client->display()->Resize(compositor->size()); | 232 display_client->display()->Resize(compositor->size()); |
235 data->display_client = display_client.Pass(); | 233 data->display_client = display_client.Pass(); |
236 compositor->SetOutputSurface(output_surface.Pass()); | 234 compositor->SetOutputSurface(output_surface.Pass()); |
237 return; | 235 return; |
238 } | 236 } |
239 | 237 |
240 if (!context_provider.get()) { | 238 if (!context_provider.get()) { |
241 if (compositor_thread_.get()) { | 239 #if defined(OS_CHROMEOS) |
242 LOG(FATAL) << "Failed to create UI context, but can't use software" | 240 NOTREACHED() << "Shouldn't use software compositing on ChromeOS."; |
no sievers
2015/02/20 02:14:31
So with threaded compositing we would get crash re
danakj
2015/02/20 03:32:08
ya we did because of those tests which I just fixe
| |
243 " compositing with browser threaded compositing. Aborting."; | 241 #endif |
244 } | |
245 | 242 |
246 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface( | 243 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface( |
247 new SoftwareBrowserCompositorOutputSurface( | 244 new SoftwareBrowserCompositorOutputSurface( |
248 output_surface_proxy_, | 245 output_surface_proxy_, |
249 CreateSoftwareOutputDevice(compositor.get()), | 246 CreateSoftwareOutputDevice(compositor.get()), |
250 data->surface_id, | 247 data->surface_id, |
251 &output_surface_map_, | 248 &output_surface_map_, |
252 compositor->vsync_manager())); | 249 compositor->vsync_manager())); |
253 compositor->SetOutputSurface(surface.Pass()); | 250 compositor->SetOutputSurface(surface.Pass()); |
254 return; | 251 return; |
255 } | 252 } |
256 | 253 |
257 scoped_ptr<BrowserCompositorOutputSurface> surface; | 254 scoped_ptr<BrowserCompositorOutputSurface> surface; |
258 #if defined(USE_OZONE) | 255 #if defined(USE_OZONE) |
259 if (ui::SurfaceFactoryOzone::GetInstance()->CanShowPrimaryPlaneAsOverlay()) { | 256 if (ui::SurfaceFactoryOzone::GetInstance()->CanShowPrimaryPlaneAsOverlay()) { |
260 surface.reset(new GpuSurfacelessBrowserCompositorOutputSurface( | 257 surface.reset(new GpuSurfacelessBrowserCompositorOutputSurface( |
261 context_provider, data->surface_id, &output_surface_map_, | 258 context_provider, data->surface_id, &output_surface_map_, |
262 compositor->vsync_manager(), | 259 compositor->vsync_manager(), |
263 CreateOverlayCandidateValidator(compositor->widget()), GL_RGB, | 260 CreateOverlayCandidateValidator(compositor->widget()), GL_RGB, |
264 compositor_thread_ != nullptr, | |
265 BrowserGpuMemoryBufferManager::current())); | 261 BrowserGpuMemoryBufferManager::current())); |
266 } | 262 } |
267 #endif | 263 #endif |
268 if (!surface) | 264 if (!surface) |
269 surface.reset(new GpuBrowserCompositorOutputSurface( | 265 surface.reset(new GpuBrowserCompositorOutputSurface( |
270 context_provider, | 266 context_provider, |
271 data->surface_id, | 267 data->surface_id, |
272 &output_surface_map_, | 268 &output_surface_map_, |
273 compositor->vsync_manager(), | 269 compositor->vsync_manager(), |
274 CreateOverlayCandidateValidator(compositor->widget()))); | 270 CreateOverlayCandidateValidator(compositor->widget()))); |
275 | 271 |
276 if (data->reflector.get()) | 272 if (data->reflector.get()) |
277 data->reflector->ReattachToOutputSurfaceFromMainThread(surface.get()); | 273 data->reflector->ReattachToOutputSurfaceFromMainThread(surface.get()); |
278 | 274 |
279 compositor->SetOutputSurface(surface.Pass()); | 275 compositor->SetOutputSurface(surface.Pass()); |
280 } | 276 } |
281 | 277 |
282 scoped_refptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( | 278 scoped_refptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( |
283 ui::Compositor* source, | 279 ui::Compositor* source, |
284 ui::Layer* target) { | 280 ui::Layer* target) { |
285 PerCompositorData* data = per_compositor_data_[source]; | 281 PerCompositorData* data = per_compositor_data_[source]; |
286 DCHECK(data); | 282 DCHECK(data); |
287 | 283 |
288 data->reflector = new ReflectorImpl(source, | 284 data->reflector = new ReflectorImpl(source, target, &output_surface_map_, |
289 target, | 285 nullptr, // Compositor message loop. |
290 &output_surface_map_, | |
291 GetCompositorMessageLoop(), | |
292 data->surface_id); | 286 data->surface_id); |
293 return data->reflector; | 287 return data->reflector; |
294 } | 288 } |
295 | 289 |
296 void GpuProcessTransportFactory::RemoveReflector( | 290 void GpuProcessTransportFactory::RemoveReflector( |
297 scoped_refptr<ui::Reflector> reflector) { | 291 scoped_refptr<ui::Reflector> reflector) { |
298 ReflectorImpl* reflector_impl = | 292 ReflectorImpl* reflector_impl = |
299 static_cast<ReflectorImpl*>(reflector.get()); | 293 static_cast<ReflectorImpl*>(reflector.get()); |
300 PerCompositorData* data = | 294 PerCompositorData* data = |
301 per_compositor_data_[reflector_impl->mirrored_compositor()]; | 295 per_compositor_data_[reflector_impl->mirrored_compositor()]; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 | 334 |
341 gpu::GpuMemoryBufferManager* | 335 gpu::GpuMemoryBufferManager* |
342 GpuProcessTransportFactory::GetGpuMemoryBufferManager() { | 336 GpuProcessTransportFactory::GetGpuMemoryBufferManager() { |
343 return BrowserGpuMemoryBufferManager::current(); | 337 return BrowserGpuMemoryBufferManager::current(); |
344 } | 338 } |
345 | 339 |
346 ui::ContextFactory* GpuProcessTransportFactory::GetContextFactory() { | 340 ui::ContextFactory* GpuProcessTransportFactory::GetContextFactory() { |
347 return this; | 341 return this; |
348 } | 342 } |
349 | 343 |
350 base::MessageLoopProxy* GpuProcessTransportFactory::GetCompositorMessageLoop() { | |
351 if (!compositor_thread_) | |
352 return NULL; | |
353 return compositor_thread_->message_loop_proxy().get(); | |
354 } | |
355 | |
356 gfx::GLSurfaceHandle GpuProcessTransportFactory::GetSharedSurfaceHandle() { | 344 gfx::GLSurfaceHandle GpuProcessTransportFactory::GetSharedSurfaceHandle() { |
357 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( | 345 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( |
358 gfx::kNullPluginWindow, gfx::NULL_TRANSPORT); | 346 gfx::kNullPluginWindow, gfx::NULL_TRANSPORT); |
359 handle.parent_client_id = | 347 handle.parent_client_id = |
360 BrowserGpuChannelHostFactory::instance()->GetGpuChannelId(); | 348 BrowserGpuChannelHostFactory::instance()->GetGpuChannelId(); |
361 return handle; | 349 return handle; |
362 } | 350 } |
363 | 351 |
364 scoped_ptr<cc::SurfaceIdAllocator> | 352 scoped_ptr<cc::SurfaceIdAllocator> |
365 GpuProcessTransportFactory::CreateSurfaceIdAllocator() { | 353 GpuProcessTransportFactory::CreateSurfaceIdAllocator() { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 518 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
531 observer_list_, | 519 observer_list_, |
532 OnLostResources()); | 520 OnLostResources()); |
533 | 521 |
534 // Kill things that use the shared context before killing the shared context. | 522 // Kill things that use the shared context before killing the shared context. |
535 lost_gl_helper.reset(); | 523 lost_gl_helper.reset(); |
536 lost_shared_main_thread_contexts = NULL; | 524 lost_shared_main_thread_contexts = NULL; |
537 } | 525 } |
538 | 526 |
539 } // namespace content | 527 } // namespace content |
OLD | NEW |