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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 } | 441 } |
442 | 442 |
443 cc::TaskGraphRunner* GpuProcessTransportFactory::GetTaskGraphRunner() { | 443 cc::TaskGraphRunner* GpuProcessTransportFactory::GetTaskGraphRunner() { |
444 return task_graph_runner_.get(); | 444 return task_graph_runner_.get(); |
445 } | 445 } |
446 | 446 |
447 ui::ContextFactory* GpuProcessTransportFactory::GetContextFactory() { | 447 ui::ContextFactory* GpuProcessTransportFactory::GetContextFactory() { |
448 return this; | 448 return this; |
449 } | 449 } |
450 | 450 |
451 gfx::GLSurfaceHandle GpuProcessTransportFactory::GetSharedSurfaceHandle() { | |
452 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( | |
453 gfx::kNullPluginWindow, gfx::NULL_TRANSPORT); | |
454 handle.parent_client_id = | |
455 BrowserGpuChannelHostFactory::instance()->GetGpuChannelId(); | |
456 return handle; | |
457 } | |
458 | |
459 scoped_ptr<cc::SurfaceIdAllocator> | 451 scoped_ptr<cc::SurfaceIdAllocator> |
460 GpuProcessTransportFactory::CreateSurfaceIdAllocator() { | 452 GpuProcessTransportFactory::CreateSurfaceIdAllocator() { |
461 scoped_ptr<cc::SurfaceIdAllocator> allocator = | 453 scoped_ptr<cc::SurfaceIdAllocator> allocator = |
462 make_scoped_ptr(new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); | 454 make_scoped_ptr(new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); |
463 if (GetSurfaceManager()) | 455 if (GetSurfaceManager()) |
464 allocator->RegisterSurfaceIdNamespace(GetSurfaceManager()); | 456 allocator->RegisterSurfaceIdNamespace(GetSurfaceManager()); |
465 return allocator; | 457 return allocator; |
466 } | 458 } |
467 | 459 |
468 void GpuProcessTransportFactory::ResizeDisplay(ui::Compositor* compositor, | 460 void GpuProcessTransportFactory::ResizeDisplay(ui::Compositor* compositor, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 DCHECK(!per_compositor_data_[compositor]); | 555 DCHECK(!per_compositor_data_[compositor]); |
564 | 556 |
565 gfx::AcceleratedWidget widget = compositor->widget(); | 557 gfx::AcceleratedWidget widget = compositor->widget(); |
566 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); | 558 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); |
567 | 559 |
568 PerCompositorData* data = new PerCompositorData; | 560 PerCompositorData* data = new PerCompositorData; |
569 if (compositor->widget() == gfx::kNullAcceleratedWidget) { | 561 if (compositor->widget() == gfx::kNullAcceleratedWidget) { |
570 data->surface_id = 0; | 562 data->surface_id = 0; |
571 } else { | 563 } else { |
572 data->surface_id = tracker->AddSurfaceForNativeWidget(widget); | 564 data->surface_id = tracker->AddSurfaceForNativeWidget(widget); |
| 565 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 566 // On Mac and Android, we can't pass the AcceleratedWidget, which is |
| 567 // process-local, so instead we pass the surface_id, so that we can look up |
| 568 // the AcceleratedWidget on the GPU side or when we receive |
| 569 // GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params. |
| 570 gfx::PluginWindowHandle handle = data->surface_id; |
| 571 #else |
| 572 gfx::PluginWindowHandle handle = widget; |
| 573 #endif |
573 tracker->SetSurfaceHandle(data->surface_id, | 574 tracker->SetSurfaceHandle(data->surface_id, |
574 gfx::GLSurfaceHandle(widget, gfx::NATIVE_DIRECT)); | 575 gfx::GLSurfaceHandle(handle, gfx::NATIVE_DIRECT)); |
575 } | 576 } |
576 | 577 |
577 per_compositor_data_[compositor] = data; | 578 per_compositor_data_[compositor] = data; |
578 | 579 |
579 return data; | 580 return data; |
580 } | 581 } |
581 | 582 |
582 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 583 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
583 GpuProcessTransportFactory::CreateContextCommon( | 584 GpuProcessTransportFactory::CreateContextCommon( |
584 scoped_refptr<GpuChannelHost> gpu_channel_host, | 585 scoped_refptr<GpuChannelHost> gpu_channel_host, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 633 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
633 observer_list_, | 634 observer_list_, |
634 OnLostResources()); | 635 OnLostResources()); |
635 | 636 |
636 // Kill things that use the shared context before killing the shared context. | 637 // Kill things that use the shared context before killing the shared context. |
637 lost_gl_helper.reset(); | 638 lost_gl_helper.reset(); |
638 lost_shared_main_thread_contexts = NULL; | 639 lost_shared_main_thread_contexts = NULL; |
639 } | 640 } |
640 | 641 |
641 } // namespace content | 642 } // namespace content |
OLD | NEW |