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

Side by Side Diff: ui/compositor/test/in_process_context_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
« no previous file with comments | « services/ui/surfaces/gpu_compositor_frame_sink.cc ('k') | no next file » | 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 "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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 cc::OutputSurfaceClient* client_ = nullptr; 112 cc::OutputSurfaceClient* client_ = nullptr;
113 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; 113 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_;
114 114
115 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); 115 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface);
116 }; 116 };
117 117
118 } // namespace 118 } // namespace
119 119
120 struct InProcessContextFactory::PerCompositorData { 120 struct InProcessContextFactory::PerCompositorData {
121 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle; 121 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle;
122 std::unique_ptr<cc::BeginFrameSource> begin_frame_source;
122 std::unique_ptr<cc::Display> display; 123 std::unique_ptr<cc::Display> display;
123 }; 124 };
124 125
125 InProcessContextFactory::InProcessContextFactory( 126 InProcessContextFactory::InProcessContextFactory(
126 bool context_factory_for_test, 127 bool context_factory_for_test,
127 cc::SurfaceManager* surface_manager) 128 cc::SurfaceManager* surface_manager)
128 : next_surface_client_id_(1u), 129 : next_surface_client_id_(1u),
129 use_test_surface_(true), 130 use_test_surface_(true),
130 context_factory_for_test_(context_factory_for_test), 131 context_factory_for_test_(context_factory_for_test),
131 surface_manager_(surface_manager) { 132 surface_manager_(surface_manager) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } else { 194 } else {
194 display_output_surface = 195 display_output_surface =
195 base::MakeUnique<DirectOutputSurface>(context_provider); 196 base::MakeUnique<DirectOutputSurface>(context_provider);
196 } 197 }
197 198
198 std::unique_ptr<cc::DelayBasedBeginFrameSource> begin_frame_source( 199 std::unique_ptr<cc::DelayBasedBeginFrameSource> begin_frame_source(
199 new cc::DelayBasedBeginFrameSource( 200 new cc::DelayBasedBeginFrameSource(
200 base::MakeUnique<cc::DelayBasedTimeSource>( 201 base::MakeUnique<cc::DelayBasedTimeSource>(
201 compositor->task_runner().get()))); 202 compositor->task_runner().get())));
202 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( 203 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler(
203 begin_frame_source.get(), compositor->task_runner().get(), 204 compositor->task_runner().get(),
204 display_output_surface->capabilities().max_frames_pending)); 205 display_output_surface->capabilities().max_frames_pending));
205 206
206 data->display = base::MakeUnique<cc::Display>( 207 data->display = base::MakeUnique<cc::Display>(
207 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, 208 &shared_bitmap_manager_, &gpu_memory_buffer_manager_,
208 compositor->GetRendererSettings(), compositor->frame_sink_id(), 209 compositor->GetRendererSettings(), compositor->frame_sink_id(),
209 std::move(begin_frame_source), std::move(display_output_surface), 210 begin_frame_source.get(), std::move(display_output_surface),
210 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>( 211 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>(
211 compositor->task_runner().get())); 212 compositor->task_runner().get()));
213 // Note that we are careful not to destroy a prior |data->begin_frame_source|
214 // until we have reset |data->display|.
215 data->begin_frame_source = std::move(begin_frame_source);
212 216
213 auto* display = per_compositor_data_[compositor.get()]->display.get(); 217 auto* display = per_compositor_data_[compositor.get()]->display.get();
214 auto compositor_frame_sink = base::MakeUnique<cc::DirectCompositorFrameSink>( 218 auto compositor_frame_sink = base::MakeUnique<cc::DirectCompositorFrameSink>(
215 compositor->frame_sink_id(), surface_manager_, display, context_provider, 219 compositor->frame_sink_id(), surface_manager_, display, context_provider,
216 shared_worker_context_provider_, &gpu_memory_buffer_manager_, 220 shared_worker_context_provider_, &gpu_memory_buffer_manager_,
217 &shared_bitmap_manager_); 221 &shared_bitmap_manager_);
218 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); 222 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink));
219 } 223 }
220 224
221 std::unique_ptr<Reflector> InProcessContextFactory::CreateReflector( 225 std::unique_ptr<Reflector> InProcessContextFactory::CreateReflector(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 data->surface_handle = tracker->AddSurfaceForNativeWidget(widget); 326 data->surface_handle = tracker->AddSurfaceForNativeWidget(widget);
323 #endif 327 #endif
324 } 328 }
325 329
326 PerCompositorData* return_ptr = data.get(); 330 PerCompositorData* return_ptr = data.get();
327 per_compositor_data_[compositor] = std::move(data); 331 per_compositor_data_[compositor] = std::move(data);
328 return return_ptr; 332 return return_ptr;
329 } 333 }
330 334
331 } // namespace ui 335 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/surfaces/gpu_compositor_frame_sink.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698