Chromium Code Reviews| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; | 80 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); | 82 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 } // namespace | 85 } // namespace |
| 86 | 86 |
| 87 InProcessContextFactory::InProcessContextFactory( | 87 InProcessContextFactory::InProcessContextFactory( |
| 88 bool context_factory_for_test, | 88 bool context_factory_for_test) |
| 89 cc::SurfaceManager* surface_manager) | |
| 90 : next_surface_id_namespace_(1u), | 89 : next_surface_id_namespace_(1u), |
| 91 use_test_surface_(true), | 90 use_test_surface_(true), |
| 92 context_factory_for_test_(context_factory_for_test), | 91 context_factory_for_test_(context_factory_for_test), |
| 93 surface_manager_(surface_manager) { | 92 surface_manager_(new cc::SurfaceManager()) { |
| 94 DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone) | 93 DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone) |
| 95 << "If running tests, ensure that main() is calling " | 94 << "If running tests, ensure that main() is calling " |
| 96 << "gfx::GLSurfaceTestSupport::InitializeOneOff()"; | 95 << "gfx::GLSurfaceTestSupport::InitializeOneOff()"; |
| 97 } | 96 } |
| 98 | 97 |
| 99 InProcessContextFactory::~InProcessContextFactory() { | 98 InProcessContextFactory::~InProcessContextFactory() { |
| 100 DCHECK(per_compositor_data_.empty()); | 99 DCHECK(per_compositor_data_.empty()); |
| 101 } | 100 } |
| 102 | 101 |
| 103 void InProcessContextFactory::CreateOutputSurface( | 102 void InProcessContextFactory::CreateOutputSurface( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 if (use_test_surface_) { | 143 if (use_test_surface_) { |
| 145 bool flipped_output_surface = false; | 144 bool flipped_output_surface = false; |
| 146 real_output_surface = make_scoped_ptr(new cc::PixelTestOutputSurface( | 145 real_output_surface = make_scoped_ptr(new cc::PixelTestOutputSurface( |
| 147 context_provider, shared_worker_context_provider_, | 146 context_provider, shared_worker_context_provider_, |
| 148 flipped_output_surface)); | 147 flipped_output_surface)); |
| 149 } else { | 148 } else { |
| 150 real_output_surface = make_scoped_ptr(new DirectOutputSurface( | 149 real_output_surface = make_scoped_ptr(new DirectOutputSurface( |
| 151 context_provider, shared_worker_context_provider_)); | 150 context_provider, shared_worker_context_provider_)); |
| 152 } | 151 } |
| 153 | 152 |
| 154 if (surface_manager_) { | 153 scoped_ptr<cc::OnscreenDisplayClient> display_client( |
| 155 scoped_ptr<cc::OnscreenDisplayClient> display_client( | 154 new cc::OnscreenDisplayClient( |
| 156 new cc::OnscreenDisplayClient( | 155 std::move(real_output_surface), surface_manager_.get(), |
| 157 std::move(real_output_surface), surface_manager_, | 156 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), |
| 158 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), | 157 compositor->GetRendererSettings(), compositor->task_runner())); |
| 159 compositor->GetRendererSettings(), compositor->task_runner())); | 158 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( |
| 160 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( | 159 new cc::SurfaceDisplayOutputSurface( |
| 161 new cc::SurfaceDisplayOutputSurface( | 160 surface_manager_.get(), compositor->surface_id_allocator(), |
| 162 surface_manager_, compositor->surface_id_allocator(), | 161 context_provider, shared_worker_context_provider_)); |
| 163 context_provider, shared_worker_context_provider_)); | 162 display_client->set_surface_output_surface(surface_output_surface.get()); |
| 164 display_client->set_surface_output_surface(surface_output_surface.get()); | 163 surface_output_surface->set_display_client(display_client.get()); |
| 165 surface_output_surface->set_display_client(display_client.get()); | |
| 166 | 164 |
| 167 compositor->SetOutputSurface(std::move(surface_output_surface)); | 165 compositor->SetOutputSurface(std::move(surface_output_surface)); |
| 168 | 166 |
| 169 delete per_compositor_data_[compositor.get()]; | 167 delete per_compositor_data_[compositor.get()]; |
| 170 per_compositor_data_[compositor.get()] = display_client.release(); | 168 per_compositor_data_[compositor.get()] = display_client.release(); |
| 171 } else { | 169 |
| 172 compositor->SetOutputSurface(std::move(real_output_surface)); | 170 // In tests, the OnscreenDisplayClient doesn't exist yet and so the resize |
| 173 } | 171 // message is missed. Instead of recording it for later, just resize now. |
| 172 ResizeDisplay(compositor.get(), compositor->size()); | |
|
enne (OOO)
2016/03/19 01:31:32
This was needed because when switching to surfaces
| |
| 174 } | 173 } |
| 175 | 174 |
| 176 scoped_ptr<Reflector> InProcessContextFactory::CreateReflector( | 175 scoped_ptr<Reflector> InProcessContextFactory::CreateReflector( |
| 177 Compositor* mirrored_compositor, | 176 Compositor* mirrored_compositor, |
| 178 Layer* mirroring_layer) { | 177 Layer* mirroring_layer) { |
| 179 return make_scoped_ptr(new FakeReflector); | 178 return make_scoped_ptr(new FakeReflector); |
| 180 } | 179 } |
| 181 | 180 |
| 182 void InProcessContextFactory::RemoveReflector(Reflector* reflector) { | 181 void InProcessContextFactory::RemoveReflector(Reflector* reflector) { |
| 183 } | 182 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 | 220 |
| 222 gpu::GpuMemoryBufferManager* | 221 gpu::GpuMemoryBufferManager* |
| 223 InProcessContextFactory::GetGpuMemoryBufferManager() { | 222 InProcessContextFactory::GetGpuMemoryBufferManager() { |
| 224 return &gpu_memory_buffer_manager_; | 223 return &gpu_memory_buffer_manager_; |
| 225 } | 224 } |
| 226 | 225 |
| 227 cc::TaskGraphRunner* InProcessContextFactory::GetTaskGraphRunner() { | 226 cc::TaskGraphRunner* InProcessContextFactory::GetTaskGraphRunner() { |
| 228 return &task_graph_runner_; | 227 return &task_graph_runner_; |
| 229 } | 228 } |
| 230 | 229 |
| 230 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() { | |
| 231 return surface_manager_.get(); | |
| 232 } | |
| 233 | |
| 231 scoped_ptr<cc::SurfaceIdAllocator> | 234 scoped_ptr<cc::SurfaceIdAllocator> |
| 232 InProcessContextFactory::CreateSurfaceIdAllocator() { | 235 InProcessContextFactory::CreateSurfaceIdAllocator() { |
| 233 scoped_ptr<cc::SurfaceIdAllocator> allocator( | 236 scoped_ptr<cc::SurfaceIdAllocator> allocator( |
| 234 new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); | 237 new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); |
| 235 if (surface_manager_) | 238 allocator->RegisterSurfaceIdNamespace(surface_manager_.get()); |
| 236 allocator->RegisterSurfaceIdNamespace(surface_manager_); | |
| 237 return allocator; | 239 return allocator; |
| 238 } | 240 } |
| 239 | 241 |
| 240 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, | 242 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, |
| 241 const gfx::Size& size) { | 243 const gfx::Size& size) { |
| 244 // If it doesn't exist yet, this will be called again later. | |
| 242 if (!per_compositor_data_.count(compositor)) | 245 if (!per_compositor_data_.count(compositor)) |
| 243 return; | 246 return; |
| 244 per_compositor_data_[compositor]->display()->Resize(size); | 247 per_compositor_data_[compositor]->display()->Resize(size); |
| 245 } | 248 } |
| 246 | 249 |
| 247 } // namespace ui | 250 } // namespace ui |
| OLD | NEW |