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

Side by Side Diff: content/browser/compositor/gpu_process_transport_factory.cc

Issue 2565783002: Moves ownership of the cc::Display's BeginFrameSource out of Display. (Closed)
Patch Set: rebase. 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
OLDNEW
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 #endif 159 #endif
160 160
161 } // namespace 161 } // namespace
162 162
163 namespace content { 163 namespace content {
164 164
165 struct GpuProcessTransportFactory::PerCompositorData { 165 struct GpuProcessTransportFactory::PerCompositorData {
166 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle; 166 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle;
167 BrowserCompositorOutputSurface* display_output_surface = nullptr; 167 BrowserCompositorOutputSurface* display_output_surface = nullptr;
168 cc::SyntheticBeginFrameSource* begin_frame_source = nullptr; 168 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source;
169 ReflectorImpl* reflector = nullptr; 169 ReflectorImpl* reflector = nullptr;
170 std::unique_ptr<cc::Display> display; 170 std::unique_ptr<cc::Display> display;
171 bool output_is_secure = false; 171 bool output_is_secure = false;
172 }; 172 };
173 173
174 GpuProcessTransportFactory::GpuProcessTransportFactory() 174 GpuProcessTransportFactory::GpuProcessTransportFactory()
175 : task_graph_runner_(new cc::SingleThreadTaskGraphRunner), 175 : task_graph_runner_(new cc::SingleThreadTaskGraphRunner),
176 callback_factory_(this) { 176 callback_factory_(this) {
177 cc::SetClientNameForMetrics("Browser"); 177 cc::SetClientNameForMetrics("Browser");
178 178
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 return GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor(); 285 return GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor();
286 } 286 }
287 287
288 void GpuProcessTransportFactory::CreateCompositorFrameSink( 288 void GpuProcessTransportFactory::CreateCompositorFrameSink(
289 base::WeakPtr<ui::Compositor> compositor) { 289 base::WeakPtr<ui::Compositor> compositor) {
290 DCHECK(!!compositor); 290 DCHECK(!!compositor);
291 PerCompositorData* data = per_compositor_data_[compositor.get()].get(); 291 PerCompositorData* data = per_compositor_data_[compositor.get()].get();
292 if (!data) { 292 if (!data) {
293 data = CreatePerCompositorData(compositor.get()); 293 data = CreatePerCompositorData(compositor.get());
294 } else { 294 } else {
295 // TODO(danakj): We can destroy the |data->display| here when the compositor 295 // TODO(danakj): We can destroy the |data->display| and
296 // destroys its CompositorFrameSink before calling back here. 296 // |data->begin_frame_source| here when the compositor destroys its
297 // CompositorFrameSink before calling back here.
297 data->display_output_surface = nullptr; 298 data->display_output_surface = nullptr;
298 data->begin_frame_source = nullptr;
299 } 299 }
300 300
301 #if defined(OS_WIN) 301 #if defined(OS_WIN)
302 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( 302 gfx::RenderingWindowManager::GetInstance()->UnregisterParent(
303 compositor->widget()); 303 compositor->widget());
304 #endif 304 #endif
305 305
306 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); 306 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider());
307 const bool create_gpu_output_surface = 307 const bool create_gpu_output_surface =
308 ShouldCreateGpuCompositorFrameSink(compositor.get()); 308 ShouldCreateGpuCompositorFrameSink(compositor.get());
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 } 539 }
540 #else 540 #else
541 NOTREACHED(); 541 NOTREACHED();
542 #endif 542 #endif
543 } 543 }
544 } 544 }
545 } 545 }
546 } 546 }
547 547
548 data->display_output_surface = display_output_surface.get(); 548 data->display_output_surface = display_output_surface.get();
549 data->begin_frame_source = begin_frame_source.get();
550 if (data->reflector) 549 if (data->reflector)
551 data->reflector->OnSourceSurfaceReady(data->display_output_surface); 550 data->reflector->OnSourceSurfaceReady(data->display_output_surface);
552 551
553 #if defined(OS_WIN) 552 #if defined(OS_WIN)
554 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild( 553 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild(
555 compositor->widget()); 554 compositor->widget());
556 #endif 555 #endif
557 556
558 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( 557 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler(
559 begin_frame_source.get(), compositor->task_runner().get(), 558 compositor->task_runner().get(),
560 display_output_surface->capabilities().max_frames_pending)); 559 display_output_surface->capabilities().max_frames_pending));
561 560
562 // The Display owns and uses the |display_output_surface| created above. 561 // The Display owns and uses the |display_output_surface| created above.
563 data->display = base::MakeUnique<cc::Display>( 562 data->display = base::MakeUnique<cc::Display>(
564 HostSharedBitmapManager::current(), GetGpuMemoryBufferManager(), 563 HostSharedBitmapManager::current(), GetGpuMemoryBufferManager(),
565 compositor->GetRendererSettings(), compositor->frame_sink_id(), 564 compositor->GetRendererSettings(), compositor->frame_sink_id(),
566 std::move(begin_frame_source), std::move(display_output_surface), 565 begin_frame_source.get(), std::move(display_output_surface),
567 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>( 566 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>(
568 compositor->task_runner().get())); 567 compositor->task_runner().get()));
568 // Note that we are careful not to destroy a prior |data->begin_frame_source|
569 // until we have reset |data->display|.
570 data->begin_frame_source = std::move(begin_frame_source);
569 571
570 // The |delegated_output_surface| is given back to the compositor, it 572 // The |delegated_output_surface| is given back to the compositor, it
571 // delegates to the Display as its root surface. Importantly, it shares the 573 // delegates to the Display as its root surface. Importantly, it shares the
572 // same ContextProvider as the Display's output surface. 574 // same ContextProvider as the Display's output surface.
573 auto compositor_frame_sink = 575 auto compositor_frame_sink =
574 vulkan_context_provider 576 vulkan_context_provider
575 ? base::MakeUnique<cc::DirectCompositorFrameSink>( 577 ? base::MakeUnique<cc::DirectCompositorFrameSink>(
576 compositor->frame_sink_id(), surface_manager_.get(), 578 compositor->frame_sink_id(), surface_manager_.get(),
577 data->display.get(), 579 data->display.get(),
578 static_cast<scoped_refptr<cc::VulkanContextProvider>>( 580 static_cast<scoped_refptr<cc::VulkanContextProvider>>(
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 shared_vulkan_context_provider_ = 896 shared_vulkan_context_provider_ =
895 cc::VulkanInProcessContextProvider::Create(); 897 cc::VulkanInProcessContextProvider::Create();
896 } 898 }
897 899
898 shared_vulkan_context_provider_initialized_ = true; 900 shared_vulkan_context_provider_initialized_ = true;
899 } 901 }
900 return shared_vulkan_context_provider_; 902 return shared_vulkan_context_provider_;
901 } 903 }
902 904
903 } // namespace content 905 } // namespace content
OLDNEW
« no previous file with comments | « components/exo/compositor_frame_sink.cc ('k') | content/browser/renderer_host/compositor_impl_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698