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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 << " GL implementation."; | 88 << " GL implementation."; |
89 if (gpu_service_logging) | 89 if (gpu_service_logging) |
90 InitializeDebugGLBindings(); | 90 InitializeDebugGLBindings(); |
91 if (disable_gl_drawing) | 91 if (disable_gl_drawing) |
92 InitializeNullDrawGLBindings(); | 92 InitializeNullDrawGLBindings(); |
93 } | 93 } |
94 return initialized; | 94 return initialized; |
95 } | 95 } |
96 | 96 |
97 // static | 97 // static |
98 void GLSurface::InitializeOneOffForTests() { | 98 void GLSurface::InitializeOneOffForTests(bool disable_drawing) { |
99 #if defined(USE_X11) | 99 #if defined(USE_X11) |
100 XInitThreads(); | 100 XInitThreads(); |
101 #endif | 101 #endif |
102 | 102 |
103 bool use_osmesa = true; | 103 bool use_osmesa = true; |
104 | 104 |
105 // We usually use OSMesa as this works on all bots. The command line can | 105 // We usually use OSMesa as this works on all bots. The command line can |
106 // override this behaviour to use hardware GL. | 106 // override this behaviour to use hardware GL. |
107 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGpuInTests)) | 107 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGpuInTests)) |
108 use_osmesa = false; | 108 use_osmesa = false; |
109 | 109 |
110 #if defined(OS_ANDROID) | 110 #if defined(OS_ANDROID) |
111 // On Android we always use hardware GL. | 111 // On Android we always use hardware GL. |
112 use_osmesa = false; | 112 use_osmesa = false; |
113 #endif | 113 #endif |
114 | 114 |
115 std::vector<GLImplementation> allowed_impls; | 115 std::vector<GLImplementation> allowed_impls; |
116 GetAllowedGLImplementations(&allowed_impls); | 116 GetAllowedGLImplementations(&allowed_impls); |
117 DCHECK(!allowed_impls.empty()); | 117 DCHECK(!allowed_impls.empty()); |
118 | 118 |
119 GLImplementation impl = allowed_impls[0]; | 119 GLImplementation impl = allowed_impls[0]; |
120 if (use_osmesa) | 120 if (use_osmesa) |
121 impl = kGLImplementationOSMesaGL; | 121 impl = kGLImplementationOSMesaGL; |
122 | 122 |
123 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) | 123 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) |
124 << "kUseGL has not effect in tests"; | 124 << "kUseGL has not effect in tests"; |
125 | 125 |
126 bool fallback_to_osmesa = false; | 126 bool fallback_to_osmesa = false; |
127 bool gpu_service_logging = false; | 127 bool gpu_service_logging = false; |
128 bool disable_gl_drawing = false; | 128 bool disable_gl_drawing = disable_drawing; |
129 // TODO(danakj): Unit tests do not produce pixel output by default. | 129 // TODO(danakj): Unit tests do not produce pixel output by default. |
130 // bool disable_gl_drawing = true; | 130 // bool disable_gl_drawing = true; |
131 | 131 |
132 CHECK(InitializeOneOffImplementation( | 132 CHECK(InitializeOneOffImplementation( |
133 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing)); | 133 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing)); |
134 } | 134 } |
135 | 135 |
136 // static | 136 // static |
137 void GLSurface::InitializeOneOffWithMockBindingsForTests() { | 137 void GLSurface::InitializeOneOffWithMockBindingsForTests() { |
138 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) | 138 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 return surface_->GetFormat(); | 338 return surface_->GetFormat(); |
339 } | 339 } |
340 | 340 |
341 VSyncProvider* GLSurfaceAdapter::GetVSyncProvider() { | 341 VSyncProvider* GLSurfaceAdapter::GetVSyncProvider() { |
342 return surface_->GetVSyncProvider(); | 342 return surface_->GetVSyncProvider(); |
343 } | 343 } |
344 | 344 |
345 GLSurfaceAdapter::~GLSurfaceAdapter() {} | 345 GLSurfaceAdapter::~GLSurfaceAdapter() {} |
346 | 346 |
347 } // namespace gfx | 347 } // namespace gfx |
OLD | NEW |