| 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/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 13 #include "cc/output/compositor_frame.h" | 14 #include "cc/output/compositor_frame.h" |
| 14 #include "cc/output/context_provider.h" | 15 #include "cc/output/context_provider.h" |
| 15 #include "cc/output/output_surface_client.h" | 16 #include "cc/output/output_surface_client.h" |
| 16 #include "cc/surfaces/onscreen_display_client.h" | 17 #include "cc/surfaces/onscreen_display_client.h" |
| 17 #include "cc/surfaces/surface_display_output_surface.h" | 18 #include "cc/surfaces/surface_display_output_surface.h" |
| 18 #include "cc/surfaces/surface_id_allocator.h" | 19 #include "cc/surfaces/surface_id_allocator.h" |
| 19 #include "cc/test/pixel_test_output_surface.h" | 20 #include "cc/test/pixel_test_output_surface.h" |
| 20 #include "cc/test/test_shared_bitmap_manager.h" | 21 #include "cc/test/test_shared_bitmap_manager.h" |
| 21 #include "gpu/command_buffer/client/context_support.h" | 22 #include "gpu/command_buffer/client/context_support.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 attribs.samples = 0; | 133 attribs.samples = 0; |
| 133 attribs.sample_buffers = 0; | 134 attribs.sample_buffers = 0; |
| 134 attribs.fail_if_major_perf_caveat = false; | 135 attribs.fail_if_major_perf_caveat = false; |
| 135 attribs.bind_generates_resource = false; | 136 attribs.bind_generates_resource = false; |
| 136 scoped_refptr<InProcessContextProvider> context_provider = | 137 scoped_refptr<InProcessContextProvider> context_provider = |
| 137 InProcessContextProvider::Create( | 138 InProcessContextProvider::Create( |
| 138 attribs, shared_worker_context_provider_.get(), | 139 attribs, shared_worker_context_provider_.get(), |
| 139 &gpu_memory_buffer_manager_, &image_factory_, compositor->widget(), | 140 &gpu_memory_buffer_manager_, &image_factory_, compositor->widget(), |
| 140 "UICompositor"); | 141 "UICompositor"); |
| 141 | 142 |
| 142 scoped_ptr<cc::OutputSurface> real_output_surface; | 143 std::unique_ptr<cc::OutputSurface> real_output_surface; |
| 143 | 144 |
| 144 if (use_test_surface_) { | 145 if (use_test_surface_) { |
| 145 bool flipped_output_surface = false; | 146 bool flipped_output_surface = false; |
| 146 real_output_surface = make_scoped_ptr(new cc::PixelTestOutputSurface( | 147 real_output_surface = base::WrapUnique(new cc::PixelTestOutputSurface( |
| 147 context_provider, shared_worker_context_provider_, | 148 context_provider, shared_worker_context_provider_, |
| 148 flipped_output_surface)); | 149 flipped_output_surface)); |
| 149 } else { | 150 } else { |
| 150 real_output_surface = make_scoped_ptr(new DirectOutputSurface( | 151 real_output_surface = base::WrapUnique(new DirectOutputSurface( |
| 151 context_provider, shared_worker_context_provider_)); | 152 context_provider, shared_worker_context_provider_)); |
| 152 } | 153 } |
| 153 | 154 |
| 154 if (surface_manager_) { | 155 if (surface_manager_) { |
| 155 scoped_ptr<cc::OnscreenDisplayClient> display_client( | 156 std::unique_ptr<cc::OnscreenDisplayClient> display_client( |
| 156 new cc::OnscreenDisplayClient( | 157 new cc::OnscreenDisplayClient( |
| 157 std::move(real_output_surface), surface_manager_, | 158 std::move(real_output_surface), surface_manager_, |
| 158 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), | 159 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), |
| 159 compositor->GetRendererSettings(), compositor->task_runner())); | 160 compositor->GetRendererSettings(), compositor->task_runner())); |
| 160 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( | 161 std::unique_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( |
| 161 new cc::SurfaceDisplayOutputSurface( | 162 new cc::SurfaceDisplayOutputSurface( |
| 162 surface_manager_, compositor->surface_id_allocator(), | 163 surface_manager_, compositor->surface_id_allocator(), |
| 163 context_provider, shared_worker_context_provider_)); | 164 context_provider, shared_worker_context_provider_)); |
| 164 display_client->set_surface_output_surface(surface_output_surface.get()); | 165 display_client->set_surface_output_surface(surface_output_surface.get()); |
| 165 surface_output_surface->set_display_client(display_client.get()); | 166 surface_output_surface->set_display_client(display_client.get()); |
| 166 | 167 |
| 167 compositor->SetOutputSurface(std::move(surface_output_surface)); | 168 compositor->SetOutputSurface(std::move(surface_output_surface)); |
| 168 | 169 |
| 169 delete per_compositor_data_[compositor.get()]; | 170 delete per_compositor_data_[compositor.get()]; |
| 170 per_compositor_data_[compositor.get()] = display_client.release(); | 171 per_compositor_data_[compositor.get()] = display_client.release(); |
| 171 } else { | 172 } else { |
| 172 compositor->SetOutputSurface(std::move(real_output_surface)); | 173 compositor->SetOutputSurface(std::move(real_output_surface)); |
| 173 } | 174 } |
| 174 } | 175 } |
| 175 | 176 |
| 176 scoped_ptr<Reflector> InProcessContextFactory::CreateReflector( | 177 std::unique_ptr<Reflector> InProcessContextFactory::CreateReflector( |
| 177 Compositor* mirrored_compositor, | 178 Compositor* mirrored_compositor, |
| 178 Layer* mirroring_layer) { | 179 Layer* mirroring_layer) { |
| 179 return make_scoped_ptr(new FakeReflector); | 180 return base::WrapUnique(new FakeReflector); |
| 180 } | 181 } |
| 181 | 182 |
| 182 void InProcessContextFactory::RemoveReflector(Reflector* reflector) { | 183 void InProcessContextFactory::RemoveReflector(Reflector* reflector) { |
| 183 } | 184 } |
| 184 | 185 |
| 185 scoped_refptr<cc::ContextProvider> | 186 scoped_refptr<cc::ContextProvider> |
| 186 InProcessContextFactory::SharedMainThreadContextProvider() { | 187 InProcessContextFactory::SharedMainThreadContextProvider() { |
| 187 if (shared_main_thread_contexts_ && | 188 if (shared_main_thread_contexts_ && |
| 188 shared_main_thread_contexts_->ContextGL()->GetGraphicsResetStatusKHR() == | 189 shared_main_thread_contexts_->ContextGL()->GetGraphicsResetStatusKHR() == |
| 189 GL_NO_ERROR) | 190 GL_NO_ERROR) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 222 |
| 222 gpu::GpuMemoryBufferManager* | 223 gpu::GpuMemoryBufferManager* |
| 223 InProcessContextFactory::GetGpuMemoryBufferManager() { | 224 InProcessContextFactory::GetGpuMemoryBufferManager() { |
| 224 return &gpu_memory_buffer_manager_; | 225 return &gpu_memory_buffer_manager_; |
| 225 } | 226 } |
| 226 | 227 |
| 227 cc::TaskGraphRunner* InProcessContextFactory::GetTaskGraphRunner() { | 228 cc::TaskGraphRunner* InProcessContextFactory::GetTaskGraphRunner() { |
| 228 return &task_graph_runner_; | 229 return &task_graph_runner_; |
| 229 } | 230 } |
| 230 | 231 |
| 231 scoped_ptr<cc::SurfaceIdAllocator> | 232 std::unique_ptr<cc::SurfaceIdAllocator> |
| 232 InProcessContextFactory::CreateSurfaceIdAllocator() { | 233 InProcessContextFactory::CreateSurfaceIdAllocator() { |
| 233 scoped_ptr<cc::SurfaceIdAllocator> allocator( | 234 std::unique_ptr<cc::SurfaceIdAllocator> allocator( |
| 234 new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); | 235 new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); |
| 235 if (surface_manager_) | 236 if (surface_manager_) |
| 236 allocator->RegisterSurfaceIdNamespace(surface_manager_); | 237 allocator->RegisterSurfaceIdNamespace(surface_manager_); |
| 237 return allocator; | 238 return allocator; |
| 238 } | 239 } |
| 239 | 240 |
| 240 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, | 241 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, |
| 241 const gfx::Size& size) { | 242 const gfx::Size& size) { |
| 242 if (!per_compositor_data_.count(compositor)) | 243 if (!per_compositor_data_.count(compositor)) |
| 243 return; | 244 return; |
| 244 per_compositor_data_[compositor]->display()->Resize(size); | 245 per_compositor_data_[compositor]->display()->Resize(size); |
| 245 } | 246 } |
| 246 | 247 |
| 247 } // namespace ui | 248 } // namespace ui |
| OLD | NEW |