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

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

Issue 2691363002: Centralize FrameSinkId allocation in one place (Closed)
Patch Set: android 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 : use_test_surface_(true),
133 use_test_surface_(true),
134 context_factory_for_test_(context_factory_for_test), 133 context_factory_for_test_(context_factory_for_test),
135 surface_manager_(surface_manager) { 134 surface_manager_(surface_manager) {
136 DCHECK(surface_manager); 135 DCHECK(surface_manager);
137 DCHECK_NE(gl::GetGLImplementation(), gl::kGLImplementationNone) 136 DCHECK_NE(gl::GetGLImplementation(), gl::kGLImplementationNone)
138 << "If running tests, ensure that main() is calling " 137 << "If running tests, ensure that main() is calling "
139 << "gl::GLSurfaceTestSupport::InitializeOneOff()"; 138 << "gl::GLSurfaceTestSupport::InitializeOneOff()";
140 } 139 }
141 140
142 InProcessContextFactory::~InProcessContextFactory() { 141 InProcessContextFactory::~InProcessContextFactory() {
143 DCHECK(per_compositor_data_.empty()); 142 DCHECK(per_compositor_data_.empty());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 gpu::GpuMemoryBufferManager* 277 gpu::GpuMemoryBufferManager*
279 InProcessContextFactory::GetGpuMemoryBufferManager() { 278 InProcessContextFactory::GetGpuMemoryBufferManager() {
280 return &gpu_memory_buffer_manager_; 279 return &gpu_memory_buffer_manager_;
281 } 280 }
282 281
283 cc::TaskGraphRunner* InProcessContextFactory::GetTaskGraphRunner() { 282 cc::TaskGraphRunner* InProcessContextFactory::GetTaskGraphRunner() {
284 return &task_graph_runner_; 283 return &task_graph_runner_;
285 } 284 }
286 285
287 cc::FrameSinkId InProcessContextFactory::AllocateFrameSinkId() { 286 cc::FrameSinkId InProcessContextFactory::AllocateFrameSinkId() {
288 // The FrameSinkId generated here must be unique with 287 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 } 288 }
295 289
296 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() { 290 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() {
297 return surface_manager_; 291 return surface_manager_;
298 } 292 }
299 293
300 void InProcessContextFactory::SetDisplayVisible(ui::Compositor* compositor, 294 void InProcessContextFactory::SetDisplayVisible(ui::Compositor* compositor,
301 bool visible) { 295 bool visible) {
302 if (!per_compositor_data_.count(compositor)) 296 if (!per_compositor_data_.count(compositor))
303 return; 297 return;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 data->surface_handle = tracker->AddSurfaceForNativeWidget(widget); 330 data->surface_handle = tracker->AddSurfaceForNativeWidget(widget);
337 #endif 331 #endif
338 } 332 }
339 333
340 PerCompositorData* return_ptr = data.get(); 334 PerCompositorData* return_ptr = data.get();
341 per_compositor_data_[compositor] = std::move(data); 335 per_compositor_data_[compositor] = std::move(data);
342 return return_ptr; 336 return return_ptr;
343 } 337 }
344 338
345 } // namespace ui 339 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698