Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/test/gl_surface_test_support.h" | 5 #include "ui/gl/test/gl_surface_test_support.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 | 27 |
| 28 // static | 28 // static |
| 29 void GLSurfaceTestSupport::InitializeOneOff() { | 29 void GLSurfaceTestSupport::InitializeOneOff() { |
| 30 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); | 30 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); |
| 31 | 31 |
| 32 #if defined(USE_X11) | 32 #if defined(USE_X11) |
| 33 XInitThreads(); | 33 XInitThreads(); |
| 34 #endif | 34 #endif |
| 35 ui::test::EnableTestConfigForPlatformWindows(); | 35 ui::test::EnableTestConfigForPlatformWindows(); |
| 36 | 36 |
| 37 bool use_osmesa = true; | 37 bool use_software_renderer = true; |
|
Ken Russell (switch to Gerrit)
2017/02/15 02:32:15
Similar here.
| |
| 38 | 38 |
| 39 // We usually use OSMesa as this works on all bots. The command line can | 39 // We usually use a software renderer as this works on all bots. The |
| 40 // override this behaviour to use hardware GL. | 40 // command line can override this behaviour to use hardware GL. |
| 41 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 41 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 42 switches::kUseGpuInTests)) { | 42 switches::kUseGpuInTests)) { |
| 43 use_osmesa = false; | 43 use_software_renderer = false; |
| 44 } | 44 } |
| 45 | 45 |
| 46 #if defined(OS_ANDROID) | 46 #if defined(OS_ANDROID) |
| 47 // On Android we always use hardware GL. | 47 // On Android we always use hardware GL. |
| 48 use_osmesa = false; | 48 use_software_renderer = false; |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 std::vector<GLImplementation> allowed_impls = | 51 std::vector<GLImplementation> allowed_impls = |
| 52 init::GetAllowedGLImplementations(); | 52 init::GetAllowedGLImplementations(); |
| 53 DCHECK(!allowed_impls.empty()); | 53 DCHECK(!allowed_impls.empty()); |
| 54 | 54 |
| 55 GLImplementation impl = allowed_impls[0]; | 55 GLImplementation impl = allowed_impls[0]; |
| 56 if (use_osmesa) | 56 if (use_software_renderer) |
| 57 impl = kGLImplementationOSMesaGL; | 57 impl = gl::GetSoftwareGLImplementation(); |
| 58 | 58 |
| 59 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) | 59 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) |
| 60 << "kUseGL has not effect in tests"; | 60 << "kUseGL has not effect in tests"; |
| 61 | 61 |
| 62 bool fallback_to_osmesa = false; | 62 bool fallback_to_software_rendering = false; |
| 63 bool gpu_service_logging = false; | 63 bool gpu_service_logging = false; |
| 64 bool disable_gl_drawing = true; | 64 bool disable_gl_drawing = true; |
| 65 | 65 |
| 66 CHECK(init::InitializeGLOneOffImplementation( | 66 CHECK(init::InitializeGLOneOffImplementation( |
| 67 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing)); | 67 impl, fallback_to_software_rendering, gpu_service_logging, |
| 68 disable_gl_drawing)); | |
| 68 } | 69 } |
| 69 | 70 |
| 70 // static | 71 // static |
| 71 void GLSurfaceTestSupport::InitializeOneOffImplementation( | 72 void GLSurfaceTestSupport::InitializeOneOffImplementation( |
| 72 GLImplementation impl, | 73 GLImplementation impl, |
| 73 bool fallback_to_osmesa) { | 74 bool fallback_to_software_rendering) { |
| 74 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) | 75 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) |
| 75 << "kUseGL has not effect in tests"; | 76 << "kUseGL has not effect in tests"; |
| 76 | 77 |
| 77 // This method may be called multiple times in the same process to set up | 78 // This method may be called multiple times in the same process to set up |
| 78 // bindings in different ways. | 79 // bindings in different ways. |
| 79 init::ShutdownGL(); | 80 init::ShutdownGL(); |
| 80 | 81 |
| 81 bool gpu_service_logging = false; | 82 bool gpu_service_logging = false; |
| 82 bool disable_gl_drawing = false; | 83 bool disable_gl_drawing = false; |
| 83 | 84 |
| 84 CHECK(init::InitializeGLOneOffImplementation( | 85 CHECK(init::InitializeGLOneOffImplementation( |
| 85 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing)); | 86 impl, fallback_to_software_rendering, gpu_service_logging, |
| 87 disable_gl_drawing)); | |
| 86 } | 88 } |
| 87 | 89 |
| 88 // static | 90 // static |
| 89 void GLSurfaceTestSupport::InitializeOneOffWithMockBindings() { | 91 void GLSurfaceTestSupport::InitializeOneOffWithMockBindings() { |
| 90 #if defined(USE_OZONE) | 92 #if defined(USE_OZONE) |
| 91 // This function skips where Ozone is otherwise initialized. | 93 // This function skips where Ozone is otherwise initialized. |
| 92 ui::OzonePlatform::InitializeForGPU(); | 94 ui::OzonePlatform::InitializeForGPU(); |
| 93 #endif | 95 #endif |
| 94 InitializeOneOffImplementation(kGLImplementationMockGL, false); | 96 InitializeOneOffImplementation(kGLImplementationMockGL, false); |
| 95 } | 97 } |
| 96 | 98 |
| 97 void GLSurfaceTestSupport::InitializeOneOffWithStubBindings() { | 99 void GLSurfaceTestSupport::InitializeOneOffWithStubBindings() { |
| 98 #if defined(USE_OZONE) | 100 #if defined(USE_OZONE) |
| 99 // This function skips where Ozone is otherwise initialized. | 101 // This function skips where Ozone is otherwise initialized. |
| 100 ui::OzonePlatform::InitializeForGPU(); | 102 ui::OzonePlatform::InitializeForGPU(); |
| 101 #endif | 103 #endif |
| 102 InitializeOneOffImplementation(kGLImplementationStubGL, false); | 104 InitializeOneOffImplementation(kGLImplementationStubGL, false); |
| 103 } | 105 } |
| 104 | 106 |
| 105 } // namespace gl | 107 } // namespace gl |
| OLD | NEW |