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" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "cc/output/context_provider.h" | 14 #include "cc/output/context_provider.h" |
15 #include "cc/output/output_surface_client.h" | 15 #include "cc/output/output_surface_client.h" |
16 #include "cc/output/output_surface_frame.h" | 16 #include "cc/output/output_surface_frame.h" |
17 #include "cc/output/texture_mailbox_deleter.h" | 17 #include "cc/output/texture_mailbox_deleter.h" |
18 #include "cc/scheduler/begin_frame_source.h" | 18 #include "cc/scheduler/begin_frame_source.h" |
19 #include "cc/scheduler/delay_based_time_source.h" | 19 #include "cc/scheduler/delay_based_time_source.h" |
20 #include "cc/surfaces/direct_compositor_frame_sink.h" | 20 #include "cc/surfaces/direct_compositor_frame_sink.h" |
21 #include "cc/surfaces/display.h" | 21 #include "cc/surfaces/display.h" |
22 #include "cc/surfaces/display_scheduler.h" | 22 #include "cc/surfaces/display_scheduler.h" |
23 #include "cc/surfaces/surface_id_allocator.h" | 23 #include "cc/surfaces/surface_id_allocator.h" |
24 #include "cc/test/pixel_test_output_surface.h" | 24 #include "cc/test/pixel_test_output_surface.h" |
| 25 #include "components/display_compositor/display_compositor.h" |
25 #include "gpu/command_buffer/client/context_support.h" | 26 #include "gpu/command_buffer/client/context_support.h" |
26 #include "gpu/command_buffer/client/gles2_interface.h" | 27 #include "gpu/command_buffer/client/gles2_interface.h" |
27 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 28 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
28 #include "ui/compositor/compositor_switches.h" | 29 #include "ui/compositor/compositor_switches.h" |
29 #include "ui/compositor/layer.h" | 30 #include "ui/compositor/layer.h" |
30 #include "ui/compositor/reflector.h" | 31 #include "ui/compositor/reflector.h" |
31 #include "ui/compositor/test/in_process_context_provider.h" | 32 #include "ui/compositor/test/in_process_context_provider.h" |
32 #include "ui/gl/gl_implementation.h" | 33 #include "ui/gl/gl_implementation.h" |
33 #include "ui/gl/test/gl_surface_test_support.h" | 34 #include "ui/gl/test/gl_surface_test_support.h" |
34 | 35 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } // namespace | 122 } // namespace |
122 | 123 |
123 struct InProcessContextFactory::PerCompositorData { | 124 struct InProcessContextFactory::PerCompositorData { |
124 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle; | 125 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle; |
125 std::unique_ptr<cc::BeginFrameSource> begin_frame_source; | 126 std::unique_ptr<cc::BeginFrameSource> begin_frame_source; |
126 std::unique_ptr<cc::Display> display; | 127 std::unique_ptr<cc::Display> display; |
127 }; | 128 }; |
128 | 129 |
129 InProcessContextFactory::InProcessContextFactory( | 130 InProcessContextFactory::InProcessContextFactory( |
130 bool context_factory_for_test, | 131 bool context_factory_for_test, |
131 cc::SurfaceManager* surface_manager) | 132 display_compositor::DisplayCompositor* display_compositor) |
132 : next_surface_sink_id_(1u), | 133 : next_surface_sink_id_(1u), |
133 use_test_surface_(true), | 134 use_test_surface_(true), |
134 context_factory_for_test_(context_factory_for_test), | 135 context_factory_for_test_(context_factory_for_test), |
135 surface_manager_(surface_manager) { | 136 display_compositor_(display_compositor) { |
136 DCHECK(surface_manager); | 137 DCHECK(display_compositor); |
137 DCHECK_NE(gl::GetGLImplementation(), gl::kGLImplementationNone) | 138 DCHECK_NE(gl::GetGLImplementation(), gl::kGLImplementationNone) |
138 << "If running tests, ensure that main() is calling " | 139 << "If running tests, ensure that main() is calling " |
139 << "gl::GLSurfaceTestSupport::InitializeOneOff()"; | 140 << "gl::GLSurfaceTestSupport::InitializeOneOff()"; |
140 } | 141 } |
141 | 142 |
142 InProcessContextFactory::~InProcessContextFactory() { | 143 InProcessContextFactory::~InProcessContextFactory() { |
143 DCHECK(per_compositor_data_.empty()); | 144 DCHECK(per_compositor_data_.empty()); |
144 } | 145 } |
145 | 146 |
146 void InProcessContextFactory::SendOnLostResources() { | 147 void InProcessContextFactory::SendOnLostResources() { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 compositor->GetRendererSettings(), compositor->frame_sink_id(), | 213 compositor->GetRendererSettings(), compositor->frame_sink_id(), |
213 begin_frame_source.get(), std::move(display_output_surface), | 214 begin_frame_source.get(), std::move(display_output_surface), |
214 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>( | 215 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>( |
215 compositor->task_runner().get())); | 216 compositor->task_runner().get())); |
216 // Note that we are careful not to destroy a prior |data->begin_frame_source| | 217 // Note that we are careful not to destroy a prior |data->begin_frame_source| |
217 // until we have reset |data->display|. | 218 // until we have reset |data->display|. |
218 data->begin_frame_source = std::move(begin_frame_source); | 219 data->begin_frame_source = std::move(begin_frame_source); |
219 | 220 |
220 auto* display = per_compositor_data_[compositor.get()]->display.get(); | 221 auto* display = per_compositor_data_[compositor.get()]->display.get(); |
221 auto compositor_frame_sink = base::MakeUnique<cc::DirectCompositorFrameSink>( | 222 auto compositor_frame_sink = base::MakeUnique<cc::DirectCompositorFrameSink>( |
222 compositor->frame_sink_id(), surface_manager_, display, context_provider, | 223 compositor->frame_sink_id(), display_compositor_->surface_manager(), |
223 shared_worker_context_provider_, &gpu_memory_buffer_manager_, | 224 display, context_provider, shared_worker_context_provider_, |
224 &shared_bitmap_manager_); | 225 &gpu_memory_buffer_manager_, &shared_bitmap_manager_); |
225 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 226 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
226 | 227 |
227 data->display->Resize(compositor->size()); | 228 data->display->Resize(compositor->size()); |
228 } | 229 } |
229 | 230 |
230 std::unique_ptr<Reflector> InProcessContextFactory::CreateReflector( | 231 std::unique_ptr<Reflector> InProcessContextFactory::CreateReflector( |
231 Compositor* mirrored_compositor, | 232 Compositor* mirrored_compositor, |
232 Layer* mirroring_layer) { | 233 Layer* mirroring_layer) { |
233 return base::WrapUnique(new FakeReflector); | 234 return base::WrapUnique(new FakeReflector); |
234 } | 235 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 cc::FrameSinkId InProcessContextFactory::AllocateFrameSinkId() { | 288 cc::FrameSinkId InProcessContextFactory::AllocateFrameSinkId() { |
288 // The FrameSinkId generated here must be unique with | 289 // The FrameSinkId generated here must be unique with |
289 // RenderWidgetHostViewAura's | 290 // RenderWidgetHostViewAura's |
290 // and RenderWidgetHostViewMac's FrameSinkId allocation. | 291 // and RenderWidgetHostViewMac's FrameSinkId allocation. |
291 // TODO(crbug.com/685777): Centralize allocation in one place for easier | 292 // TODO(crbug.com/685777): Centralize allocation in one place for easier |
292 // maintenance. | 293 // maintenance. |
293 return cc::FrameSinkId(0, next_surface_sink_id_++); | 294 return cc::FrameSinkId(0, next_surface_sink_id_++); |
294 } | 295 } |
295 | 296 |
296 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() { | 297 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() { |
297 return surface_manager_; | 298 return display_compositor_->surface_manager(); |
| 299 } |
| 300 |
| 301 display_compositor::DisplayCompositor* |
| 302 InProcessContextFactory::GetDisplayCompositor() { |
| 303 return display_compositor_; |
298 } | 304 } |
299 | 305 |
300 void InProcessContextFactory::SetDisplayVisible(ui::Compositor* compositor, | 306 void InProcessContextFactory::SetDisplayVisible(ui::Compositor* compositor, |
301 bool visible) { | 307 bool visible) { |
302 if (!per_compositor_data_.count(compositor)) | 308 if (!per_compositor_data_.count(compositor)) |
303 return; | 309 return; |
304 per_compositor_data_[compositor]->display->SetVisible(visible); | 310 per_compositor_data_[compositor]->display->SetVisible(visible); |
305 } | 311 } |
306 | 312 |
307 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, | 313 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, |
(...skipping 28 matching lines...) Expand all Loading... |
336 data->surface_handle = tracker->AddSurfaceForNativeWidget(widget); | 342 data->surface_handle = tracker->AddSurfaceForNativeWidget(widget); |
337 #endif | 343 #endif |
338 } | 344 } |
339 | 345 |
340 PerCompositorData* return_ptr = data.get(); | 346 PerCompositorData* return_ptr = data.get(); |
341 per_compositor_data_[compositor] = std::move(data); | 347 per_compositor_data_[compositor] = std::move(data); |
342 return return_ptr; | 348 return return_ptr; |
343 } | 349 } |
344 | 350 |
345 } // namespace ui | 351 } // namespace ui |
OLD | NEW |