| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 157 } |
| 158 #endif | 158 #endif |
| 159 | 159 |
| 160 } // namespace | 160 } // namespace |
| 161 | 161 |
| 162 namespace content { | 162 namespace content { |
| 163 | 163 |
| 164 struct GpuProcessTransportFactory::PerCompositorData { | 164 struct GpuProcessTransportFactory::PerCompositorData { |
| 165 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle; | 165 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle; |
| 166 BrowserCompositorOutputSurface* display_output_surface = nullptr; | 166 BrowserCompositorOutputSurface* display_output_surface = nullptr; |
| 167 cc::SyntheticBeginFrameSource* begin_frame_source = nullptr; | 167 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; |
| 168 ReflectorImpl* reflector = nullptr; | 168 ReflectorImpl* reflector = nullptr; |
| 169 std::unique_ptr<cc::Display> display; | 169 std::unique_ptr<cc::Display> display; |
| 170 bool output_is_secure = false; | 170 bool output_is_secure = false; |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 GpuProcessTransportFactory::GpuProcessTransportFactory() | 173 GpuProcessTransportFactory::GpuProcessTransportFactory() |
| 174 : task_graph_runner_(new cc::SingleThreadTaskGraphRunner), | 174 : task_graph_runner_(new cc::SingleThreadTaskGraphRunner), |
| 175 callback_factory_(this) { | 175 callback_factory_(this) { |
| 176 cc::SetClientNameForMetrics("Browser"); | 176 cc::SetClientNameForMetrics("Browser"); |
| 177 | 177 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 return GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor(); | 276 return GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor(); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void GpuProcessTransportFactory::CreateCompositorFrameSink( | 279 void GpuProcessTransportFactory::CreateCompositorFrameSink( |
| 280 base::WeakPtr<ui::Compositor> compositor) { | 280 base::WeakPtr<ui::Compositor> compositor) { |
| 281 DCHECK(!!compositor); | 281 DCHECK(!!compositor); |
| 282 PerCompositorData* data = per_compositor_data_[compositor.get()].get(); | 282 PerCompositorData* data = per_compositor_data_[compositor.get()].get(); |
| 283 if (!data) { | 283 if (!data) { |
| 284 data = CreatePerCompositorData(compositor.get()); | 284 data = CreatePerCompositorData(compositor.get()); |
| 285 } else { | 285 } else { |
| 286 // TODO(danakj): We can destroy the |data->display| here when the compositor | 286 // TODO(danakj): We can destroy the |data->display| and |
| 287 // destroys its CompositorFrameSink before calling back here. | 287 // |data->begin_frame_source| here when the compositor destroys its |
| 288 // CompositorFrameSink before calling back here. |
| 288 data->display_output_surface = nullptr; | 289 data->display_output_surface = nullptr; |
| 289 data->begin_frame_source = nullptr; | |
| 290 } | 290 } |
| 291 | 291 |
| 292 #if defined(OS_WIN) | 292 #if defined(OS_WIN) |
| 293 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( | 293 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( |
| 294 compositor->widget()); | 294 compositor->widget()); |
| 295 #endif | 295 #endif |
| 296 | 296 |
| 297 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); | 297 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); |
| 298 const bool create_gpu_output_surface = | 298 const bool create_gpu_output_surface = |
| 299 ShouldCreateGpuCompositorFrameSink(compositor.get()); | 299 ShouldCreateGpuCompositorFrameSink(compositor.get()); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 } | 530 } |
| 531 #else | 531 #else |
| 532 NOTREACHED(); | 532 NOTREACHED(); |
| 533 #endif | 533 #endif |
| 534 } | 534 } |
| 535 } | 535 } |
| 536 } | 536 } |
| 537 } | 537 } |
| 538 | 538 |
| 539 data->display_output_surface = display_output_surface.get(); | 539 data->display_output_surface = display_output_surface.get(); |
| 540 data->begin_frame_source = begin_frame_source.get(); | |
| 541 if (data->reflector) | 540 if (data->reflector) |
| 542 data->reflector->OnSourceSurfaceReady(data->display_output_surface); | 541 data->reflector->OnSourceSurfaceReady(data->display_output_surface); |
| 543 | 542 |
| 544 #if defined(OS_WIN) | 543 #if defined(OS_WIN) |
| 545 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild( | 544 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild( |
| 546 compositor->widget()); | 545 compositor->widget()); |
| 547 #endif | 546 #endif |
| 548 | 547 |
| 549 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 548 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
| 550 begin_frame_source.get(), compositor->task_runner().get(), | 549 compositor->task_runner().get(), |
| 551 display_output_surface->capabilities().max_frames_pending)); | 550 display_output_surface->capabilities().max_frames_pending)); |
| 552 | 551 |
| 553 // The Display owns and uses the |display_output_surface| created above. | 552 // The Display owns and uses the |display_output_surface| created above. |
| 554 data->display = base::MakeUnique<cc::Display>( | 553 data->display = base::MakeUnique<cc::Display>( |
| 555 HostSharedBitmapManager::current(), GetGpuMemoryBufferManager(), | 554 HostSharedBitmapManager::current(), GetGpuMemoryBufferManager(), |
| 556 compositor->GetRendererSettings(), compositor->frame_sink_id(), | 555 compositor->GetRendererSettings(), compositor->frame_sink_id(), |
| 557 std::move(begin_frame_source), std::move(display_output_surface), | 556 begin_frame_source.get(), std::move(display_output_surface), |
| 558 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>( | 557 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>( |
| 559 compositor->task_runner().get())); | 558 compositor->task_runner().get())); |
| 559 data->begin_frame_source = std::move(begin_frame_source); |
| 560 | 560 |
| 561 // The |delegated_output_surface| is given back to the compositor, it | 561 // The |delegated_output_surface| is given back to the compositor, it |
| 562 // delegates to the Display as its root surface. Importantly, it shares the | 562 // delegates to the Display as its root surface. Importantly, it shares the |
| 563 // same ContextProvider as the Display's output surface. | 563 // same ContextProvider as the Display's output surface. |
| 564 auto compositor_frame_sink = | 564 auto compositor_frame_sink = |
| 565 vulkan_context_provider | 565 vulkan_context_provider |
| 566 ? base::MakeUnique<cc::DirectCompositorFrameSink>( | 566 ? base::MakeUnique<cc::DirectCompositorFrameSink>( |
| 567 compositor->frame_sink_id(), surface_manager_.get(), | 567 compositor->frame_sink_id(), surface_manager_.get(), |
| 568 data->display.get(), | 568 data->display.get(), |
| 569 static_cast<scoped_refptr<cc::VulkanContextProvider>>( | 569 static_cast<scoped_refptr<cc::VulkanContextProvider>>( |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 shared_vulkan_context_provider_ = | 880 shared_vulkan_context_provider_ = |
| 881 cc::VulkanInProcessContextProvider::Create(); | 881 cc::VulkanInProcessContextProvider::Create(); |
| 882 } | 882 } |
| 883 | 883 |
| 884 shared_vulkan_context_provider_initialized_ = true; | 884 shared_vulkan_context_provider_initialized_ = true; |
| 885 } | 885 } |
| 886 return shared_vulkan_context_provider_; | 886 return shared_vulkan_context_provider_; |
| 887 } | 887 } |
| 888 | 888 |
| 889 } // namespace content | 889 } // namespace content |
| OLD | NEW |