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

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

Issue 2691363002: Centralize FrameSinkId allocation in one place (Closed)
Patch Set: explicit Created 3 years, 10 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
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 #if defined(ENABLE_VULKAN) 96 #if defined(ENABLE_VULKAN)
97 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h" 97 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h"
98 #endif 98 #endif
99 99
100 using cc::ContextProvider; 100 using cc::ContextProvider;
101 using gpu::gles2::GLES2Interface; 101 using gpu::gles2::GLES2Interface;
102 102
103 namespace { 103 namespace {
104 104
105 const int kNumRetriesBeforeSoftwareFallback = 4; 105 const int kNumRetriesBeforeSoftwareFallback = 4;
106 // The client_id used here should not conflict with the client_id generated
107 // from RenderWidgetHostImpl.
108 constexpr uint32_t kDefaultClientId = 0u;
106 109
107 bool IsUsingMus() { 110 bool IsUsingMus() {
108 return service_manager::ServiceManagerIsRemote(); 111 return service_manager::ServiceManagerIsRemote();
109 } 112 }
110 113
111 scoped_refptr<ui::ContextProviderCommandBuffer> CreateContextCommon( 114 scoped_refptr<ui::ContextProviderCommandBuffer> CreateContextCommon(
112 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, 115 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
113 gpu::SurfaceHandle surface_handle, 116 gpu::SurfaceHandle surface_handle,
114 bool need_alpha_channel, 117 bool need_alpha_channel,
115 bool need_stencil_bits, 118 bool need_stencil_bits,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 struct GpuProcessTransportFactory::PerCompositorData { 171 struct GpuProcessTransportFactory::PerCompositorData {
169 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle; 172 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle;
170 BrowserCompositorOutputSurface* display_output_surface = nullptr; 173 BrowserCompositorOutputSurface* display_output_surface = nullptr;
171 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; 174 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source;
172 ReflectorImpl* reflector = nullptr; 175 ReflectorImpl* reflector = nullptr;
173 std::unique_ptr<cc::Display> display; 176 std::unique_ptr<cc::Display> display;
174 bool output_is_secure = false; 177 bool output_is_secure = false;
175 }; 178 };
176 179
177 GpuProcessTransportFactory::GpuProcessTransportFactory() 180 GpuProcessTransportFactory::GpuProcessTransportFactory()
178 : task_graph_runner_(new cc::SingleThreadTaskGraphRunner), 181 : frame_sink_id_allocator_(kDefaultClientId),
182 task_graph_runner_(new cc::SingleThreadTaskGraphRunner),
179 callback_factory_(this) { 183 callback_factory_(this) {
180 cc::SetClientNameForMetrics("Browser"); 184 cc::SetClientNameForMetrics("Browser");
181 185
182 surface_manager_ = base::WrapUnique(new cc::SurfaceManager); 186 surface_manager_ = base::WrapUnique(new cc::SurfaceManager);
183 187
184 task_graph_runner_->Start("CompositorTileWorker1", 188 task_graph_runner_->Start("CompositorTileWorker1",
185 base::SimpleThread::Options()); 189 base::SimpleThread::Options());
186 #if defined(OS_WIN) 190 #if defined(OS_WIN)
187 software_backing_.reset(new OutputDeviceBacking); 191 software_backing_.reset(new OutputDeviceBacking);
188 #endif 192 #endif
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 ui::ContextFactory* GpuProcessTransportFactory::GetContextFactory() { 686 ui::ContextFactory* GpuProcessTransportFactory::GetContextFactory() {
683 return this; 687 return this;
684 } 688 }
685 689
686 ui::ContextFactoryPrivate* 690 ui::ContextFactoryPrivate*
687 GpuProcessTransportFactory::GetContextFactoryPrivate() { 691 GpuProcessTransportFactory::GetContextFactoryPrivate() {
688 return this; 692 return this;
689 } 693 }
690 694
691 cc::FrameSinkId GpuProcessTransportFactory::AllocateFrameSinkId() { 695 cc::FrameSinkId GpuProcessTransportFactory::AllocateFrameSinkId() {
692 // The FrameSinkId generated here must be unique with 696 return frame_sink_id_allocator_.NextFrameSinkId();
693 // RenderWidgetHostViewAura's
694 // and RenderWidgetHostViewMac's FrameSinkId allocation.
695 // TODO(crbug.com/685777): Centralize allocation in one place for easier
696 // maintenance.
697 return cc::FrameSinkId(0, next_sink_id_++);
698 } 697 }
699 698
700 void GpuProcessTransportFactory::SetDisplayVisible(ui::Compositor* compositor, 699 void GpuProcessTransportFactory::SetDisplayVisible(ui::Compositor* compositor,
701 bool visible) { 700 bool visible) {
702 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor); 701 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor);
703 if (it == per_compositor_data_.end()) 702 if (it == per_compositor_data_.end())
704 return; 703 return;
705 PerCompositorData* data = it->second.get(); 704 PerCompositorData* data = it->second.get();
706 DCHECK(data); 705 DCHECK(data);
707 // The compositor will always SetVisible on the Display once it is set up, so 706 // The compositor will always SetVisible on the Display once it is set up, so
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 shared_vulkan_context_provider_ = 913 shared_vulkan_context_provider_ =
915 cc::VulkanInProcessContextProvider::Create(); 914 cc::VulkanInProcessContextProvider::Create();
916 } 915 }
917 916
918 shared_vulkan_context_provider_initialized_ = true; 917 shared_vulkan_context_provider_initialized_ = true;
919 } 918 }
920 return shared_vulkan_context_provider_; 919 return shared_vulkan_context_provider_;
921 } 920 }
922 921
923 } // namespace content 922 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698