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
3 // found in the LICENSE file.
5 #include "ui/gl/test/gl_surface_test_support.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "ui/gl/gl_context.h"
10 #include "ui/gl/gl_implementation.h"
11 #include "ui/gl/gl_surface.h"
12 #include "ui/gl/gl_switches.h"
16 #include "ui/platform_window/x11/x11_window.h"
22 void GLSurfaceTestSupport::InitializeOneOff() {
23 DCHECK_EQ(kGLImplementationNone
, GetGLImplementation());
27 ui::test::SetUseOverrideRedirectWindowByDefault(true);
30 bool use_osmesa
= true;
32 // We usually use OSMesa as this works on all bots. The command line can
33 // override this behaviour to use hardware GL.
34 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
35 switches::kUseGpuInTests
)) {
39 #if defined(OS_ANDROID)
40 // On Android we always use hardware GL.
44 std::vector
<GLImplementation
> allowed_impls
;
45 GetAllowedGLImplementations(&allowed_impls
);
46 DCHECK(!allowed_impls
.empty());
48 GLImplementation impl
= allowed_impls
[0];
50 impl
= kGLImplementationOSMesaGL
;
52 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL
))
53 << "kUseGL has not effect in tests";
55 bool fallback_to_osmesa
= false;
56 bool gpu_service_logging
= false;
57 bool disable_gl_drawing
= true;
59 CHECK(GLSurface::InitializeOneOffImplementation(
60 impl
, fallback_to_osmesa
, gpu_service_logging
, disable_gl_drawing
));
64 void GLSurfaceTestSupport::InitializeOneOffWithMockBindings() {
65 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL
))
66 << "kUseGL has not effect in tests";
68 // This method may be called multiple times in the same process to set up
69 // mock bindings in different ways.
72 bool fallback_to_osmesa
= false;
73 bool gpu_service_logging
= false;
74 bool disable_gl_drawing
= false;
76 CHECK(GLSurface::InitializeOneOffImplementation(
77 kGLImplementationMockGL
, fallback_to_osmesa
, gpu_service_logging
,
82 void GLSurfaceTestSupport::InitializeDynamicMockBindings(GLContext
* context
) {
83 CHECK(InitializeDynamicGLBindings(kGLImplementationMockGL
, context
));