OLD | NEW |
---|---|
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 } | 92 } |
93 | 93 |
94 private: | 94 private: |
95 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; | 95 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; |
96 | 96 |
97 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); | 97 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); |
98 }; | 98 }; |
99 | 99 |
100 } // namespace | 100 } // namespace |
101 | 101 |
102 struct InProcessContextFactory::PerCompositorData { | |
103 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; | |
104 std::unique_ptr<cc::Display> display; | |
105 }; | |
106 | |
102 InProcessContextFactory::InProcessContextFactory( | 107 InProcessContextFactory::InProcessContextFactory( |
103 bool context_factory_for_test, | 108 bool context_factory_for_test, |
104 cc::SurfaceManager* surface_manager) | 109 cc::SurfaceManager* surface_manager) |
105 : next_surface_client_id_(1u), | 110 : next_surface_client_id_(1u), |
106 use_test_surface_(true), | 111 use_test_surface_(true), |
107 context_factory_for_test_(context_factory_for_test), | 112 context_factory_for_test_(context_factory_for_test), |
108 surface_manager_(surface_manager) { | 113 surface_manager_(surface_manager) { |
109 DCHECK_NE(gl::GetGLImplementation(), gl::kGLImplementationNone) | 114 DCHECK_NE(gl::GetGLImplementation(), gl::kGLImplementationNone) |
110 << "If running tests, ensure that main() is calling " | 115 << "If running tests, ensure that main() is calling " |
111 << "gl::GLSurfaceTestSupport::InitializeOneOff()"; | 116 << "gl::GLSurfaceTestSupport::InitializeOneOff()"; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 bool flipped_output_surface = false; | 166 bool flipped_output_surface = false; |
162 display_output_surface = base::MakeUnique<cc::PixelTestOutputSurface>( | 167 display_output_surface = base::MakeUnique<cc::PixelTestOutputSurface>( |
163 context_provider, shared_worker_context_provider_, | 168 context_provider, shared_worker_context_provider_, |
164 flipped_output_surface); | 169 flipped_output_surface); |
165 } else { | 170 } else { |
166 display_output_surface = base::MakeUnique<DirectOutputSurface>( | 171 display_output_surface = base::MakeUnique<DirectOutputSurface>( |
167 context_provider, shared_worker_context_provider_); | 172 context_provider, shared_worker_context_provider_); |
168 } | 173 } |
169 | 174 |
170 if (surface_manager_) { | 175 if (surface_manager_) { |
171 std::unique_ptr<cc::DelayBasedBeginFrameSource> begin_frame_source( | 176 auto data = base::MakeUnique<PerCompositorData>(); |
172 new cc::DelayBasedBeginFrameSource( | 177 data->begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( |
danakj
2016/08/30 01:10:56
it works here cuz you're making a new |data|. mayb
enne (OOO)
2016/08/30 20:17:28
I don't think this one needs a comment. I think i
| |
173 base::MakeUnique<cc::DelayBasedTimeSource>( | 178 base::MakeUnique<cc::DelayBasedTimeSource>( |
174 compositor->task_runner().get()))); | 179 compositor->task_runner().get()))); |
175 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 180 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
176 begin_frame_source.get(), compositor->task_runner().get(), | 181 data->begin_frame_source.get(), compositor->task_runner().get(), |
177 display_output_surface->capabilities().max_frames_pending)); | 182 display_output_surface->capabilities().max_frames_pending)); |
178 per_compositor_data_[compositor.get()] = base::MakeUnique<cc::Display>( | 183 data->display = base::MakeUnique<cc::Display>( |
179 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), | 184 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), |
180 compositor->GetRendererSettings(), std::move(begin_frame_source), | 185 compositor->GetRendererSettings(), data->begin_frame_source.get(), |
181 std::move(display_output_surface), std::move(scheduler), | 186 std::move(display_output_surface), std::move(scheduler), |
182 base::MakeUnique<cc::TextureMailboxDeleter>( | 187 base::MakeUnique<cc::TextureMailboxDeleter>( |
183 compositor->task_runner().get())); | 188 compositor->task_runner().get())); |
184 | |
185 auto* display = per_compositor_data_[compositor.get()].get(); | |
186 std::unique_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( | 189 std::unique_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( |
187 new cc::SurfaceDisplayOutputSurface( | 190 new cc::SurfaceDisplayOutputSurface( |
188 surface_manager_, compositor->surface_id_allocator(), display, | 191 surface_manager_, compositor->surface_id_allocator(), |
189 context_provider, shared_worker_context_provider_)); | 192 data->display.get(), context_provider, |
193 shared_worker_context_provider_)); | |
194 | |
195 per_compositor_data_[compositor.get()] = std::move(data); | |
190 compositor->SetOutputSurface(std::move(surface_output_surface)); | 196 compositor->SetOutputSurface(std::move(surface_output_surface)); |
191 } else { | 197 } else { |
192 compositor->SetOutputSurface(std::move(display_output_surface)); | 198 compositor->SetOutputSurface(std::move(display_output_surface)); |
193 } | 199 } |
194 } | 200 } |
195 | 201 |
196 std::unique_ptr<Reflector> InProcessContextFactory::CreateReflector( | 202 std::unique_ptr<Reflector> InProcessContextFactory::CreateReflector( |
197 Compositor* mirrored_compositor, | 203 Compositor* mirrored_compositor, |
198 Layer* mirroring_layer) { | 204 Layer* mirroring_layer) { |
199 return base::WrapUnique(new FakeReflector); | 205 return base::WrapUnique(new FakeReflector); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 } | 258 } |
253 | 259 |
254 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() { | 260 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() { |
255 return surface_manager_; | 261 return surface_manager_; |
256 } | 262 } |
257 | 263 |
258 void InProcessContextFactory::SetDisplayVisible(ui::Compositor* compositor, | 264 void InProcessContextFactory::SetDisplayVisible(ui::Compositor* compositor, |
259 bool visible) { | 265 bool visible) { |
260 if (!per_compositor_data_.count(compositor)) | 266 if (!per_compositor_data_.count(compositor)) |
261 return; | 267 return; |
262 per_compositor_data_[compositor]->SetVisible(visible); | 268 per_compositor_data_[compositor]->display->SetVisible(visible); |
263 } | 269 } |
264 | 270 |
265 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, | 271 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, |
266 const gfx::Size& size) { | 272 const gfx::Size& size) { |
267 if (!per_compositor_data_.count(compositor)) | 273 if (!per_compositor_data_.count(compositor)) |
268 return; | 274 return; |
269 per_compositor_data_[compositor]->Resize(size); | 275 per_compositor_data_[compositor]->display->Resize(size); |
270 } | 276 } |
271 | 277 |
272 void InProcessContextFactory::AddObserver(ContextFactoryObserver* observer) { | 278 void InProcessContextFactory::AddObserver(ContextFactoryObserver* observer) { |
273 observer_list_.AddObserver(observer); | 279 observer_list_.AddObserver(observer); |
274 } | 280 } |
275 | 281 |
276 void InProcessContextFactory::RemoveObserver(ContextFactoryObserver* observer) { | 282 void InProcessContextFactory::RemoveObserver(ContextFactoryObserver* observer) { |
277 observer_list_.RemoveObserver(observer); | 283 observer_list_.RemoveObserver(observer); |
278 } | 284 } |
279 | 285 |
280 } // namespace ui | 286 } // namespace ui |
OLD | NEW |