| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gl/gl_surface.h" | 5 #include "ui/gl/gl_surface.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // static | 30 // static |
| 31 bool GLSurface::InitializeOneOff() { | 31 bool GLSurface::InitializeOneOff() { |
| 32 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); | 32 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); |
| 33 | 33 |
| 34 TRACE_EVENT0("gpu", "GLSurface::InitializeOneOff"); | 34 TRACE_EVENT0("gpu", "GLSurface::InitializeOneOff"); |
| 35 | 35 |
| 36 std::vector<GLImplementation> allowed_impls; | 36 std::vector<GLImplementation> allowed_impls; |
| 37 GetAllowedGLImplementations(&allowed_impls); | 37 GetAllowedGLImplementations(&allowed_impls); |
| 38 DCHECK(!allowed_impls.empty()); | 38 DCHECK(!allowed_impls.empty()); |
| 39 | 39 |
| 40 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 40 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 41 | 41 |
| 42 // The default implementation is always the first one in list. | 42 // The default implementation is always the first one in list. |
| 43 GLImplementation impl = allowed_impls[0]; | 43 GLImplementation impl = allowed_impls[0]; |
| 44 bool fallback_to_osmesa = false; | 44 bool fallback_to_osmesa = false; |
| 45 if (cmd->HasSwitch(switches::kOverrideUseGLWithOSMesaForTests)) { | 45 if (cmd->HasSwitch(switches::kOverrideUseGLWithOSMesaForTests)) { |
| 46 impl = kGLImplementationOSMesaGL; | 46 impl = kGLImplementationOSMesaGL; |
| 47 } else if (cmd->HasSwitch(switches::kUseGL)) { | 47 } else if (cmd->HasSwitch(switches::kUseGL)) { |
| 48 std::string requested_implementation_name = | 48 std::string requested_implementation_name = |
| 49 cmd->GetSwitchValueASCII(switches::kUseGL); | 49 cmd->GetSwitchValueASCII(switches::kUseGL); |
| 50 if (requested_implementation_name == "any") { | 50 if (requested_implementation_name == "any") { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); | 101 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); |
| 102 | 102 |
| 103 #if defined(USE_X11) | 103 #if defined(USE_X11) |
| 104 XInitThreads(); | 104 XInitThreads(); |
| 105 #endif | 105 #endif |
| 106 | 106 |
| 107 bool use_osmesa = true; | 107 bool use_osmesa = true; |
| 108 | 108 |
| 109 // We usually use OSMesa as this works on all bots. The command line can | 109 // We usually use OSMesa as this works on all bots. The command line can |
| 110 // override this behaviour to use hardware GL. | 110 // override this behaviour to use hardware GL. |
| 111 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGpuInTests)) | 111 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 112 switches::kUseGpuInTests)) |
| 112 use_osmesa = false; | 113 use_osmesa = false; |
| 113 | 114 |
| 114 #if defined(OS_ANDROID) | 115 #if defined(OS_ANDROID) |
| 115 // On Android we always use hardware GL. | 116 // On Android we always use hardware GL. |
| 116 use_osmesa = false; | 117 use_osmesa = false; |
| 117 #endif | 118 #endif |
| 118 | 119 |
| 119 std::vector<GLImplementation> allowed_impls; | 120 std::vector<GLImplementation> allowed_impls; |
| 120 GetAllowedGLImplementations(&allowed_impls); | 121 GetAllowedGLImplementations(&allowed_impls); |
| 121 DCHECK(!allowed_impls.empty()); | 122 DCHECK(!allowed_impls.empty()); |
| 122 | 123 |
| 123 GLImplementation impl = allowed_impls[0]; | 124 GLImplementation impl = allowed_impls[0]; |
| 124 if (use_osmesa) | 125 if (use_osmesa) |
| 125 impl = kGLImplementationOSMesaGL; | 126 impl = kGLImplementationOSMesaGL; |
| 126 | 127 |
| 127 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) | 128 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) |
| 128 << "kUseGL has not effect in tests"; | 129 << "kUseGL has not effect in tests"; |
| 129 | 130 |
| 130 bool fallback_to_osmesa = false; | 131 bool fallback_to_osmesa = false; |
| 131 bool gpu_service_logging = false; | 132 bool gpu_service_logging = false; |
| 132 bool disable_gl_drawing = true; | 133 bool disable_gl_drawing = true; |
| 133 | 134 |
| 134 CHECK(InitializeOneOffImplementation( | 135 CHECK(InitializeOneOffImplementation( |
| 135 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing)); | 136 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing)); |
| 136 } | 137 } |
| 137 | 138 |
| 138 // static | 139 // static |
| 139 void GLSurface::InitializeOneOffWithMockBindingsForTests() { | 140 void GLSurface::InitializeOneOffWithMockBindingsForTests() { |
| 140 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) | 141 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) |
| 141 << "kUseGL has not effect in tests"; | 142 << "kUseGL has not effect in tests"; |
| 142 | 143 |
| 143 // This method may be called multiple times in the same process to set up | 144 // This method may be called multiple times in the same process to set up |
| 144 // mock bindings in different ways. | 145 // mock bindings in different ways. |
| 145 ClearGLBindings(); | 146 ClearGLBindings(); |
| 146 | 147 |
| 147 bool fallback_to_osmesa = false; | 148 bool fallback_to_osmesa = false; |
| 148 bool gpu_service_logging = false; | 149 bool gpu_service_logging = false; |
| 149 bool disable_gl_drawing = false; | 150 bool disable_gl_drawing = false; |
| 150 | 151 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 z_order, transform, image, bounds_rect, crop_rect); | 364 z_order, transform, image, bounds_rect, crop_rect); |
| 364 } | 365 } |
| 365 | 366 |
| 366 bool GLSurfaceAdapter::IsSurfaceless() const { | 367 bool GLSurfaceAdapter::IsSurfaceless() const { |
| 367 return surface_->IsSurfaceless(); | 368 return surface_->IsSurfaceless(); |
| 368 } | 369 } |
| 369 | 370 |
| 370 GLSurfaceAdapter::~GLSurfaceAdapter() {} | 371 GLSurfaceAdapter::~GLSurfaceAdapter() {} |
| 371 | 372 |
| 372 } // namespace gfx | 373 } // namespace gfx |
| OLD | NEW |