| 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 "content/browser/compositor/gpu_process_transport_factory.h" | 5 #include "content/browser/compositor/gpu_process_transport_factory.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 NOTREACHED(); | 173 NOTREACHED(); |
| 174 return scoped_ptr<cc::SoftwareOutputDevice>(); | 174 return scoped_ptr<cc::SoftwareOutputDevice>(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 scoped_ptr<cc::OutputSurface> GpuProcessTransportFactory::CreateOutputSurface( | 177 scoped_ptr<cc::OutputSurface> GpuProcessTransportFactory::CreateOutputSurface( |
| 178 ui::Compositor* compositor, bool software_fallback) { | 178 ui::Compositor* compositor, bool software_fallback) { |
| 179 PerCompositorData* data = per_compositor_data_[compositor]; | 179 PerCompositorData* data = per_compositor_data_[compositor]; |
| 180 if (!data) | 180 if (!data) |
| 181 data = CreatePerCompositorData(compositor); | 181 data = CreatePerCompositorData(compositor); |
| 182 | 182 |
| 183 bool force_software_renderer = false; | 183 bool create_software_renderer = software_fallback; |
| 184 #if defined(OS_WIN) | 184 #if defined(OS_CHROMEOS) |
| 185 // Software fallback does not happen on Chrome OS. |
| 186 create_software_renderer = false; |
| 187 #elif defined(OS_WIN) |
| 185 if (::GetProp(compositor->widget(), kForceSoftwareCompositor)) { | 188 if (::GetProp(compositor->widget(), kForceSoftwareCompositor)) { |
| 186 force_software_renderer = reinterpret_cast<bool>( | 189 if (::RemoveProp(compositor->widget(), kForceSoftwareCompositor)) |
| 187 ::RemoveProp(compositor->widget(), kForceSoftwareCompositor)); | 190 create_software_renderer = true; |
| 188 } | 191 } |
| 189 #endif | 192 #endif |
| 190 | 193 |
| 191 scoped_refptr<ContextProviderCommandBuffer> context_provider; | 194 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
| 192 | 195 if (!create_software_renderer) { |
| 193 // Software fallback does not happen on Chrome OS. | |
| 194 #if defined(OS_CHROMEOS) | |
| 195 software_fallback = false; | |
| 196 #endif | |
| 197 | |
| 198 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 199 if (!command_line->HasSwitch(switches::kUIEnableSoftwareCompositing) && | |
| 200 !force_software_renderer && !software_fallback) { | |
| 201 context_provider = ContextProviderCommandBuffer::Create( | 196 context_provider = ContextProviderCommandBuffer::Create( |
| 202 GpuProcessTransportFactory::CreateContextCommon(data->surface_id), | 197 GpuProcessTransportFactory::CreateContextCommon(data->surface_id), |
| 203 "Compositor"); | 198 "Compositor"); |
| 204 } | 199 } |
| 205 | 200 |
| 206 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", !!context_provider); | 201 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", !!context_provider); |
| 207 | 202 |
| 208 if (!context_provider.get()) { | 203 if (!context_provider.get()) { |
| 209 if (ui::Compositor::WasInitializedWithThread()) { | 204 if (ui::Compositor::WasInitializedWithThread()) { |
| 210 LOG(FATAL) << "Failed to create UI context, but can't use software" | 205 LOG(FATAL) << "Failed to create UI context, but can't use software" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 observer_list_, | 467 observer_list_, |
| 473 OnLostResources()); | 468 OnLostResources()); |
| 474 | 469 |
| 475 // Kill things that use the shared context before killing the shared context. | 470 // Kill things that use the shared context before killing the shared context. |
| 476 lost_gl_helper.reset(); | 471 lost_gl_helper.reset(); |
| 477 lost_offscreen_compositor_contexts = NULL; | 472 lost_offscreen_compositor_contexts = NULL; |
| 478 lost_shared_main_thread_contexts = NULL; | 473 lost_shared_main_thread_contexts = NULL; |
| 479 } | 474 } |
| 480 | 475 |
| 481 } // namespace content | 476 } // namespace content |
| OLD | NEW |