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

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

Issue 1936773002: Move attributes and context type out to ContextProviderCommandBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rmwgc3d
Patch Set: attributes: rebase Created 4 years, 7 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 | « components/test_runner/test_plugin.cc ('k') | content/browser/gpu/gpu_ipc_browsertests.cc » ('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 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h" 88 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h"
89 #endif 89 #endif
90 90
91 using cc::ContextProvider; 91 using cc::ContextProvider;
92 using gpu::gles2::GLES2Interface; 92 using gpu::gles2::GLES2Interface;
93 93
94 namespace { 94 namespace {
95 95
96 const int kNumRetriesBeforeSoftwareFallback = 4; 96 const int kNumRetriesBeforeSoftwareFallback = 4;
97 97
98 std::unique_ptr<content::WebGraphicsContext3DCommandBufferImpl> 98 scoped_refptr<content::ContextProviderCommandBuffer> CreateContextCommon(
99 CreateContextCommon(scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, 99 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
100 gpu::SurfaceHandle surface_handle) { 100 gpu::SurfaceHandle surface_handle,
101 content::ContextProviderCommandBuffer* shared_context_provider,
102 content::command_buffer_metrics::ContextType type) {
101 DCHECK( 103 DCHECK(
102 content::GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()); 104 content::GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor());
103 DCHECK(gpu_channel_host); 105 DCHECK(gpu_channel_host);
104 106
105 // This is called from a few places to create different contexts: 107 // This is called from a few places to create different contexts:
106 // - The shared main thread context (offscreen). 108 // - The shared main thread context (offscreen).
107 // - The compositor context, which is used by the browser compositor 109 // - The compositor context, which is used by the browser compositor
108 // (offscreen) for synchronization mostly, and by the display compositor 110 // (offscreen) for synchronization mostly, and by the display compositor
109 // (onscreen) for actual GL drawing. 111 // (onscreen) for actual GL drawing.
110 // - The compositor worker context (offscreen) used for GPU raster. 112 // - The compositor worker context (offscreen) used for GPU raster.
111 // So ask for capabilities needed by any of these cases (we can optimize by 113 // So ask for capabilities needed by any of these cases (we can optimize by
112 // branching on |surface_handle| being null if these needs diverge). 114 // branching on |surface_handle| being null if these needs diverge).
113 // 115 //
114 // The default framebuffer for an offscreen context is not used, so it does 116 // The default framebuffer for an offscreen context is not used, so it does
115 // not need alpha, stencil, depth, antialiasing. The display compositor does 117 // not need alpha, stencil, depth, antialiasing. The display compositor does
116 // not use these things either, so we can request nothing here. 118 // not use these things either, so we can request nothing here.
117 gpu::gles2::ContextCreationAttribHelper attributes; 119 gpu::gles2::ContextCreationAttribHelper attributes;
118 attributes.alpha_size = -1; 120 attributes.alpha_size = -1;
119 attributes.depth_size = 0; 121 attributes.depth_size = 0;
120 attributes.stencil_size = 0; 122 attributes.stencil_size = 0;
121 attributes.samples = 0; 123 attributes.samples = 0;
122 attributes.sample_buffers = 0; 124 attributes.sample_buffers = 0;
123 attributes.bind_generates_resource = false; 125 attributes.bind_generates_resource = false;
124 attributes.lose_context_when_out_of_memory = true; 126 attributes.lose_context_when_out_of_memory = true;
125 127
126 bool automatic_flushes = false; 128 bool automatic_flushes = false;
127 129
128 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); 130 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon");
129 return base::WrapUnique(new content::WebGraphicsContext3DCommandBufferImpl( 131 return make_scoped_refptr(new content::ContextProviderCommandBuffer(
130 surface_handle, url, gpu_channel_host.get(), attributes, 132 base::WrapUnique(new content::WebGraphicsContext3DCommandBufferImpl(
131 gfx::PreferIntegratedGpu, automatic_flushes)); 133 surface_handle, url, gpu_channel_host.get(), gfx::PreferIntegratedGpu,
134 automatic_flushes)),
135 gpu::SharedMemoryLimits(), attributes, shared_context_provider, type));
132 } 136 }
133 137
134 #if defined(OS_MACOSX) 138 #if defined(OS_MACOSX)
135 bool IsCALayersDisabledFromCommandLine() { 139 bool IsCALayersDisabledFromCommandLine() {
136 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 140 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
137 return command_line->HasSwitch(switches::kDisableMacOverlays); 141 return command_line->HasSwitch(switches::kDisableMacOverlays);
138 } 142 }
139 #endif 143 #endif
140 144
141 } // namespace 145 } // namespace
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 // We attempted to do EstablishGpuChannel already, so we just use 355 // We attempted to do EstablishGpuChannel already, so we just use
352 // GetGpuChannel() instead of EstablishGpuChannelSync(). 356 // GetGpuChannel() instead of EstablishGpuChannelSync().
353 gpu_channel_host = 357 gpu_channel_host =
354 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); 358 BrowserGpuChannelHostFactory::instance()->GetGpuChannel();
355 } 359 }
356 360
357 if (!gpu_channel_host) { 361 if (!gpu_channel_host) {
358 shared_worker_context_provider_ = nullptr; 362 shared_worker_context_provider_ = nullptr;
359 } else { 363 } else {
360 if (!shared_worker_context_provider_) { 364 if (!shared_worker_context_provider_) {
361 shared_worker_context_provider_ = new ContextProviderCommandBuffer( 365 shared_worker_context_provider_ = CreateContextCommon(
362 CreateContextCommon(gpu_channel_host, gpu::kNullSurfaceHandle), 366 gpu_channel_host, gpu::kNullSurfaceHandle, nullptr,
363 gpu::SharedMemoryLimits(), nullptr, BROWSER_WORKER_CONTEXT); 367 command_buffer_metrics::BROWSER_WORKER_CONTEXT);
364 if (shared_worker_context_provider_->BindToCurrentThread()) 368 if (shared_worker_context_provider_->BindToCurrentThread())
365 shared_worker_context_provider_->SetupLock(); 369 shared_worker_context_provider_->SetupLock();
366 else 370 else
367 shared_worker_context_provider_ = nullptr; 371 shared_worker_context_provider_ = nullptr;
368 } 372 }
369 373
370 // The |context_provider| is used for both the browser compositor and the 374 // The |context_provider| is used for both the browser compositor and the
371 // display compositor. It shares resources with the worker context, so if 375 // display compositor. It shares resources with the worker context, so if
372 // we failed to make a worker context, just start over and try again. 376 // we failed to make a worker context, just start over and try again.
373 if (shared_worker_context_provider_) { 377 if (shared_worker_context_provider_) {
374 context_provider = new ContextProviderCommandBuffer( 378 context_provider = CreateContextCommon(
375 CreateContextCommon(std::move(gpu_channel_host), 379 std::move(gpu_channel_host), data->surface_handle,
376 data->surface_handle), 380 shared_worker_context_provider_.get(),
377 gpu::SharedMemoryLimits(), shared_worker_context_provider_.get(), 381 command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT);
378 DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT);
379 if (!context_provider->BindToCurrentThread()) 382 if (!context_provider->BindToCurrentThread())
380 context_provider = nullptr; 383 context_provider = nullptr;
381 } 384 }
382 } 385 }
383 386
384 bool created_gpu_browser_compositor = 387 bool created_gpu_browser_compositor =
385 !!context_provider && !!shared_worker_context_provider_; 388 !!context_provider && !!shared_worker_context_provider_;
386 389
387 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", 390 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor",
388 created_gpu_browser_compositor); 391 created_gpu_browser_compositor);
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 return nullptr; 679 return nullptr;
677 CauseForGpuLaunch cause = 680 CauseForGpuLaunch cause =
678 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; 681 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
679 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( 682 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(
680 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause)); 683 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause));
681 if (!gpu_channel_host) 684 if (!gpu_channel_host)
682 return nullptr; 685 return nullptr;
683 686
684 // We need a separate context from the compositor's so that skia and gl_helper 687 // We need a separate context from the compositor's so that skia and gl_helper
685 // don't step on each other. 688 // don't step on each other.
686 shared_main_thread_contexts_ = new ContextProviderCommandBuffer( 689 shared_main_thread_contexts_ = CreateContextCommon(
687 CreateContextCommon(std::move(gpu_channel_host), gpu::kNullSurfaceHandle), 690 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, nullptr,
688 gpu::SharedMemoryLimits(), nullptr, BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); 691 command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT);
689 shared_main_thread_contexts_->SetLostContextCallback(base::Bind( 692 shared_main_thread_contexts_->SetLostContextCallback(base::Bind(
690 &GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback, 693 &GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback,
691 callback_factory_.GetWeakPtr())); 694 callback_factory_.GetWeakPtr()));
692 if (!shared_main_thread_contexts_->BindToCurrentThread()) 695 if (!shared_main_thread_contexts_->BindToCurrentThread())
693 shared_main_thread_contexts_ = nullptr; 696 shared_main_thread_contexts_ = nullptr;
694 return shared_main_thread_contexts_; 697 return shared_main_thread_contexts_;
695 } 698 }
696 699
697 GpuProcessTransportFactory::PerCompositorData* 700 GpuProcessTransportFactory::PerCompositorData*
698 GpuProcessTransportFactory::CreatePerCompositorData( 701 GpuProcessTransportFactory::CreatePerCompositorData(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 shared_vulkan_context_provider_ = 759 shared_vulkan_context_provider_ =
757 cc::VulkanInProcessContextProvider::Create(); 760 cc::VulkanInProcessContextProvider::Create();
758 } 761 }
759 762
760 shared_vulkan_context_provider_initialized_ = true; 763 shared_vulkan_context_provider_initialized_ = true;
761 } 764 }
762 return shared_vulkan_context_provider_; 765 return shared_vulkan_context_provider_;
763 } 766 }
764 767
765 } // namespace content 768 } // namespace content
OLDNEW
« no previous file with comments | « components/test_runner/test_plugin.cc ('k') | content/browser/gpu/gpu_ipc_browsertests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698