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

Side by Side Diff: ui/compositor/test/in_process_context_factory.cc

Issue 2691363002: Centralize FrameSinkId allocation in one place (Closed)
Patch Set: fix based on comment 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 "ui/compositor/test/in_process_context_factory.h" 5 #include "ui/compositor/test/in_process_context_factory.h"
6 6
7 #include <utility> 7 #include <utility>
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 struct InProcessContextFactory::PerCompositorData { 123 struct InProcessContextFactory::PerCompositorData {
124 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle; 124 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle;
125 std::unique_ptr<cc::BeginFrameSource> begin_frame_source; 125 std::unique_ptr<cc::BeginFrameSource> begin_frame_source;
126 std::unique_ptr<cc::Display> display; 126 std::unique_ptr<cc::Display> display;
127 }; 127 };
128 128
129 InProcessContextFactory::InProcessContextFactory( 129 InProcessContextFactory::InProcessContextFactory(
130 bool context_factory_for_test, 130 bool context_factory_for_test,
131 cc::SurfaceManager* surface_manager) 131 cc::SurfaceManager* surface_manager)
132 : next_surface_sink_id_(1u), 132 : frame_sink_id_allocator_(
133 0 /* client_id, not to conflict with the client_id
134 generated from RenderWidgetHostImpl */),
133 use_test_surface_(true), 135 use_test_surface_(true),
134 context_factory_for_test_(context_factory_for_test), 136 context_factory_for_test_(context_factory_for_test),
135 surface_manager_(surface_manager) { 137 surface_manager_(surface_manager) {
136 DCHECK(surface_manager); 138 DCHECK(surface_manager);
137 DCHECK_NE(gl::GetGLImplementation(), gl::kGLImplementationNone) 139 DCHECK_NE(gl::GetGLImplementation(), gl::kGLImplementationNone)
138 << "If running tests, ensure that main() is calling " 140 << "If running tests, ensure that main() is calling "
139 << "gl::GLSurfaceTestSupport::InitializeOneOff()"; 141 << "gl::GLSurfaceTestSupport::InitializeOneOff()";
140 } 142 }
141 143
142 InProcessContextFactory::~InProcessContextFactory() { 144 InProcessContextFactory::~InProcessContextFactory() {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 gpu::GpuMemoryBufferManager* 280 gpu::GpuMemoryBufferManager*
279 InProcessContextFactory::GetGpuMemoryBufferManager() { 281 InProcessContextFactory::GetGpuMemoryBufferManager() {
280 return &gpu_memory_buffer_manager_; 282 return &gpu_memory_buffer_manager_;
281 } 283 }
282 284
283 cc::TaskGraphRunner* InProcessContextFactory::GetTaskGraphRunner() { 285 cc::TaskGraphRunner* InProcessContextFactory::GetTaskGraphRunner() {
284 return &task_graph_runner_; 286 return &task_graph_runner_;
285 } 287 }
286 288
287 cc::FrameSinkId InProcessContextFactory::AllocateFrameSinkId() { 289 cc::FrameSinkId InProcessContextFactory::AllocateFrameSinkId() {
288 // The FrameSinkId generated here must be unique with 290 return frame_sink_id_allocator_.NextFrameSinkId();
289 // RenderWidgetHostViewAura's
290 // and RenderWidgetHostViewMac's FrameSinkId allocation.
291 // TODO(crbug.com/685777): Centralize allocation in one place for easier
292 // maintenance.
293 return cc::FrameSinkId(0, next_surface_sink_id_++);
294 } 291 }
295 292
296 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() { 293 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() {
297 return surface_manager_; 294 return surface_manager_;
298 } 295 }
299 296
300 void InProcessContextFactory::SetDisplayVisible(ui::Compositor* compositor, 297 void InProcessContextFactory::SetDisplayVisible(ui::Compositor* compositor,
301 bool visible) { 298 bool visible) {
302 if (!per_compositor_data_.count(compositor)) 299 if (!per_compositor_data_.count(compositor))
303 return; 300 return;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 data->surface_handle = tracker->AddSurfaceForNativeWidget(widget); 333 data->surface_handle = tracker->AddSurfaceForNativeWidget(widget);
337 #endif 334 #endif
338 } 335 }
339 336
340 PerCompositorData* return_ptr = data.get(); 337 PerCompositorData* return_ptr = data.get();
341 per_compositor_data_[compositor] = std::move(data); 338 per_compositor_data_[compositor] = std::move(data);
342 return return_ptr; 339 return return_ptr;
343 } 340 }
344 341
345 } // namespace ui 342 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698