| 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 20 matching lines...) Expand all Loading... |
| 31 #include "ui/compositor/test/in_process_context_provider.h" | 31 #include "ui/compositor/test/in_process_context_provider.h" |
| 32 #include "ui/gl/gl_implementation.h" | 32 #include "ui/gl/gl_implementation.h" |
| 33 #include "ui/gl/test/gl_surface_test_support.h" | 33 #include "ui/gl/test/gl_surface_test_support.h" |
| 34 | 34 |
| 35 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW) | 35 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW) |
| 36 #include "gpu/ipc/common/gpu_surface_tracker.h" | 36 #include "gpu/ipc/common/gpu_surface_tracker.h" |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 namespace ui { | 39 namespace ui { |
| 40 namespace { | 40 namespace { |
| 41 // The client_id used here should not conflict with the client_id generated |
| 42 // from RenderWidgetHostImpl. |
| 43 constexpr uint32_t kDefaultClientId = 0u; |
| 41 | 44 |
| 42 class FakeReflector : public Reflector { | 45 class FakeReflector : public Reflector { |
| 43 public: | 46 public: |
| 44 FakeReflector() {} | 47 FakeReflector() {} |
| 45 ~FakeReflector() override {} | 48 ~FakeReflector() override {} |
| 46 void OnMirroringCompositorResized() override {} | 49 void OnMirroringCompositorResized() override {} |
| 47 void AddMirroringLayer(Layer* layer) override {} | 50 void AddMirroringLayer(Layer* layer) override {} |
| 48 void RemoveMirroringLayer(Layer* layer) override {} | 51 void RemoveMirroringLayer(Layer* layer) override {} |
| 49 }; | 52 }; |
| 50 | 53 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 125 |
| 123 struct InProcessContextFactory::PerCompositorData { | 126 struct InProcessContextFactory::PerCompositorData { |
| 124 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle; | 127 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle; |
| 125 std::unique_ptr<cc::BeginFrameSource> begin_frame_source; | 128 std::unique_ptr<cc::BeginFrameSource> begin_frame_source; |
| 126 std::unique_ptr<cc::Display> display; | 129 std::unique_ptr<cc::Display> display; |
| 127 }; | 130 }; |
| 128 | 131 |
| 129 InProcessContextFactory::InProcessContextFactory( | 132 InProcessContextFactory::InProcessContextFactory( |
| 130 bool context_factory_for_test, | 133 bool context_factory_for_test, |
| 131 cc::SurfaceManager* surface_manager) | 134 cc::SurfaceManager* surface_manager) |
| 132 : next_surface_sink_id_(1u), | 135 : frame_sink_id_allocator_(kDefaultClientId), |
| 133 use_test_surface_(true), | 136 use_test_surface_(true), |
| 134 context_factory_for_test_(context_factory_for_test), | 137 context_factory_for_test_(context_factory_for_test), |
| 135 surface_manager_(surface_manager) { | 138 surface_manager_(surface_manager) { |
| 136 DCHECK(surface_manager); | 139 DCHECK(surface_manager); |
| 137 DCHECK_NE(gl::GetGLImplementation(), gl::kGLImplementationNone) | 140 DCHECK_NE(gl::GetGLImplementation(), gl::kGLImplementationNone) |
| 138 << "If running tests, ensure that main() is calling " | 141 << "If running tests, ensure that main() is calling " |
| 139 << "gl::GLSurfaceTestSupport::InitializeOneOff()"; | 142 << "gl::GLSurfaceTestSupport::InitializeOneOff()"; |
| 140 } | 143 } |
| 141 | 144 |
| 142 InProcessContextFactory::~InProcessContextFactory() { | 145 InProcessContextFactory::~InProcessContextFactory() { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 gpu::GpuMemoryBufferManager* | 281 gpu::GpuMemoryBufferManager* |
| 279 InProcessContextFactory::GetGpuMemoryBufferManager() { | 282 InProcessContextFactory::GetGpuMemoryBufferManager() { |
| 280 return &gpu_memory_buffer_manager_; | 283 return &gpu_memory_buffer_manager_; |
| 281 } | 284 } |
| 282 | 285 |
| 283 cc::TaskGraphRunner* InProcessContextFactory::GetTaskGraphRunner() { | 286 cc::TaskGraphRunner* InProcessContextFactory::GetTaskGraphRunner() { |
| 284 return &task_graph_runner_; | 287 return &task_graph_runner_; |
| 285 } | 288 } |
| 286 | 289 |
| 287 cc::FrameSinkId InProcessContextFactory::AllocateFrameSinkId() { | 290 cc::FrameSinkId InProcessContextFactory::AllocateFrameSinkId() { |
| 288 // The FrameSinkId generated here must be unique with | 291 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 } | 292 } |
| 295 | 293 |
| 296 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() { | 294 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() { |
| 297 return surface_manager_; | 295 return surface_manager_; |
| 298 } | 296 } |
| 299 | 297 |
| 300 void InProcessContextFactory::SetDisplayVisible(ui::Compositor* compositor, | 298 void InProcessContextFactory::SetDisplayVisible(ui::Compositor* compositor, |
| 301 bool visible) { | 299 bool visible) { |
| 302 if (!per_compositor_data_.count(compositor)) | 300 if (!per_compositor_data_.count(compositor)) |
| 303 return; | 301 return; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 data->surface_handle = tracker->AddSurfaceForNativeWidget(widget); | 334 data->surface_handle = tracker->AddSurfaceForNativeWidget(widget); |
| 337 #endif | 335 #endif |
| 338 } | 336 } |
| 339 | 337 |
| 340 PerCompositorData* return_ptr = data.get(); | 338 PerCompositorData* return_ptr = data.get(); |
| 341 per_compositor_data_[compositor] = std::move(data); | 339 per_compositor_data_[compositor] = std::move(data); |
| 342 return return_ptr; | 340 return return_ptr; |
| 343 } | 341 } |
| 344 | 342 |
| 345 } // namespace ui | 343 } // namespace ui |
| OLD | NEW |