| 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" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "ui/gl/gl_context.h" | 12 #include "ui/gl/gl_context.h" |
| 13 #include "ui/gl/gl_implementation.h" | 13 #include "ui/gl/gl_implementation.h" |
| 14 #include "ui/gl/gl_switches.h" | 14 #include "ui/gl/gl_switches.h" |
| 15 #include "ui/gl/init/gl_factory.h" | 15 #include "ui/gl/init/gl_factory.h" |
| 16 | 16 |
| 17 #if defined(USE_X11) | 17 #if defined(USE_X11) |
| 18 #include <X11/Xlib.h> | 18 #include <X11/Xlib.h> |
| 19 #include "ui/platform_window/x11/x11_window.h" | 19 #include "ui/platform_window/x11/x11_window.h" |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 #if defined(USE_OZONE) |
| 23 #include "ui/ozone/public/ozone_platform.h" |
| 24 #endif |
| 25 |
| 22 namespace gl { | 26 namespace gl { |
| 23 | 27 |
| 24 // static | 28 // static |
| 25 void GLSurfaceTestSupport::InitializeOneOff() { | 29 void GLSurfaceTestSupport::InitializeOneOff() { |
| 26 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); | 30 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); |
| 27 | 31 |
| 28 #if defined(USE_X11) | 32 #if defined(USE_X11) |
| 29 XInitThreads(); | 33 XInitThreads(); |
| 30 ui::test::SetUseOverrideRedirectWindowByDefault(true); | 34 ui::test::SetUseOverrideRedirectWindowByDefault(true); |
| 31 #endif | 35 #endif |
| (...skipping 28 matching lines...) Expand all Loading... |
| 60 bool disable_gl_drawing = true; | 64 bool disable_gl_drawing = true; |
| 61 | 65 |
| 62 CHECK(init::InitializeGLOneOffImplementation( | 66 CHECK(init::InitializeGLOneOffImplementation( |
| 63 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing)); | 67 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing)); |
| 64 } | 68 } |
| 65 | 69 |
| 66 // static | 70 // static |
| 67 void GLSurfaceTestSupport::InitializeOneOffImplementation( | 71 void GLSurfaceTestSupport::InitializeOneOffImplementation( |
| 68 GLImplementation impl, | 72 GLImplementation impl, |
| 69 bool fallback_to_osmesa) { | 73 bool fallback_to_osmesa) { |
| 74 #if defined(USE_OZONE) |
| 75 // This function skips where Ozone is otherwise initialized in some tests. |
| 76 ui::OzonePlatform::InitializeForGPU(); |
| 77 #endif |
| 78 |
| 70 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) | 79 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) |
| 71 << "kUseGL has not effect in tests"; | 80 << "kUseGL has not effect in tests"; |
| 72 | 81 |
| 73 // This method may be called multiple times in the same process to set up | 82 // This method may be called multiple times in the same process to set up |
| 74 // bindings in different ways. | 83 // bindings in different ways. |
| 75 init::ClearGLBindings(); | 84 init::ClearGLBindings(); |
| 76 | 85 |
| 77 bool gpu_service_logging = false; | 86 bool gpu_service_logging = false; |
| 78 bool disable_gl_drawing = false; | 87 bool disable_gl_drawing = false; |
| 79 | 88 |
| 80 CHECK(init::InitializeGLOneOffImplementation( | 89 CHECK(init::InitializeGLOneOffImplementation( |
| 81 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing)); | 90 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing)); |
| 82 } | 91 } |
| 83 | 92 |
| 84 // static | 93 // static |
| 85 void GLSurfaceTestSupport::InitializeOneOffWithMockBindings() { | 94 void GLSurfaceTestSupport::InitializeOneOffWithMockBindings() { |
| 86 InitializeOneOffImplementation(kGLImplementationMockGL, false); | 95 InitializeOneOffImplementation(kGLImplementationMockGL, false); |
| 87 } | 96 } |
| 88 | 97 |
| 89 } // namespace gl | 98 } // namespace gl |
| OLD | NEW |