| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 attribs.stencil_size = 0; | 105 attribs.stencil_size = 0; |
| 106 attribs.samples = 0; | 106 attribs.samples = 0; |
| 107 attribs.sample_buffers = 0; | 107 attribs.sample_buffers = 0; |
| 108 attribs.fail_if_major_perf_caveat = false; | 108 attribs.fail_if_major_perf_caveat = false; |
| 109 attribs.bind_generates_resource = false; | 109 attribs.bind_generates_resource = false; |
| 110 | 110 |
| 111 scoped_refptr<InProcessContextProvider> context_provider = | 111 scoped_refptr<InProcessContextProvider> context_provider = |
| 112 InProcessContextProvider::Create(attribs, &gpu_memory_buffer_manager_, | 112 InProcessContextProvider::Create(attribs, &gpu_memory_buffer_manager_, |
| 113 &image_factory_, | 113 &image_factory_, |
| 114 compositor->widget(), "UICompositor"); | 114 compositor->widget(), "UICompositor"); |
| 115 | 115 scoped_refptr<InProcessContextProvider> worker_context_provider = |
| 116 // Try to reuse existing shared worker context provider. | 116 InProcessContextProvider::CreateOffscreen(&gpu_memory_buffer_manager_, |
| 117 bool shared_worker_context_provider_lost = false; | 117 &image_factory_); |
| 118 if (shared_worker_context_provider_) { | |
| 119 // Note: If context is lost, delete reference after releasing the lock. | |
| 120 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); | |
| 121 if (shared_worker_context_provider_->ContextGL() | |
| 122 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | |
| 123 shared_worker_context_provider_lost = true; | |
| 124 } | |
| 125 } | |
| 126 if (!shared_worker_context_provider_ || shared_worker_context_provider_lost) { | |
| 127 shared_worker_context_provider_ = InProcessContextProvider::CreateOffscreen( | |
| 128 &gpu_memory_buffer_manager_, &image_factory_); | |
| 129 if (shared_worker_context_provider_ && | |
| 130 !shared_worker_context_provider_->BindToCurrentThread()) | |
| 131 shared_worker_context_provider_ = nullptr; | |
| 132 if (shared_worker_context_provider_) | |
| 133 shared_worker_context_provider_->SetupLock(); | |
| 134 } | |
| 135 | 118 |
| 136 scoped_ptr<cc::OutputSurface> real_output_surface; | 119 scoped_ptr<cc::OutputSurface> real_output_surface; |
| 137 | 120 |
| 138 if (use_test_surface_) { | 121 if (use_test_surface_) { |
| 139 bool flipped_output_surface = false; | 122 bool flipped_output_surface = false; |
| 140 real_output_surface = make_scoped_ptr(new cc::PixelTestOutputSurface( | 123 real_output_surface = make_scoped_ptr(new cc::PixelTestOutputSurface( |
| 141 context_provider, shared_worker_context_provider_, | 124 context_provider, worker_context_provider, flipped_output_surface)); |
| 142 flipped_output_surface)); | |
| 143 } else { | 125 } else { |
| 144 real_output_surface = make_scoped_ptr(new DirectOutputSurface( | 126 real_output_surface = make_scoped_ptr( |
| 145 context_provider, shared_worker_context_provider_)); | 127 new DirectOutputSurface(context_provider, worker_context_provider)); |
| 146 } | 128 } |
| 147 | 129 |
| 148 if (surface_manager_) { | 130 if (surface_manager_) { |
| 149 scoped_ptr<cc::OnscreenDisplayClient> display_client( | 131 scoped_ptr<cc::OnscreenDisplayClient> display_client( |
| 150 new cc::OnscreenDisplayClient( | 132 new cc::OnscreenDisplayClient( |
| 151 real_output_surface.Pass(), surface_manager_, | 133 real_output_surface.Pass(), surface_manager_, |
| 152 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), | 134 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), |
| 153 compositor->GetRendererSettings(), compositor->task_runner())); | 135 compositor->GetRendererSettings(), compositor->task_runner())); |
| 154 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( | 136 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( |
| 155 new cc::SurfaceDisplayOutputSurface( | 137 new cc::SurfaceDisplayOutputSurface( |
| 156 surface_manager_, compositor->surface_id_allocator(), | 138 surface_manager_, compositor->surface_id_allocator(), |
| 157 context_provider, shared_worker_context_provider_)); | 139 context_provider, worker_context_provider)); |
| 158 display_client->set_surface_output_surface(surface_output_surface.get()); | 140 display_client->set_surface_output_surface(surface_output_surface.get()); |
| 159 surface_output_surface->set_display_client(display_client.get()); | 141 surface_output_surface->set_display_client(display_client.get()); |
| 160 | 142 |
| 161 compositor->SetOutputSurface(surface_output_surface.Pass()); | 143 compositor->SetOutputSurface(surface_output_surface.Pass()); |
| 162 | 144 |
| 163 delete per_compositor_data_[compositor.get()]; | 145 delete per_compositor_data_[compositor.get()]; |
| 164 per_compositor_data_[compositor.get()] = display_client.release(); | 146 per_compositor_data_[compositor.get()] = display_client.release(); |
| 165 } else { | 147 } else { |
| 166 compositor->SetOutputSurface(real_output_surface.Pass()); | 148 compositor->SetOutputSurface(real_output_surface.Pass()); |
| 167 } | 149 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 212 } |
| 231 | 213 |
| 232 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, | 214 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, |
| 233 const gfx::Size& size) { | 215 const gfx::Size& size) { |
| 234 if (!per_compositor_data_.count(compositor)) | 216 if (!per_compositor_data_.count(compositor)) |
| 235 return; | 217 return; |
| 236 per_compositor_data_[compositor]->display()->Resize(size); | 218 per_compositor_data_[compositor]->display()->Resize(size); |
| 237 } | 219 } |
| 238 | 220 |
| 239 } // namespace ui | 221 } // namespace ui |
| OLD | NEW |