Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Side by Side Diff: ui/gl/init/gl_factory.cc

Issue 2690113010: Abstract OSMesa from the Layout tests (Closed)
Patch Set: Renamed "Renderer" to "GL" Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/init/gl_factory.h ('k') | ui/gl/test/gl_surface_test_support.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/init/gl_factory.h" 5 #include "ui/gl/init/gl_factory.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 11 matching lines...) Expand all
22 22
23 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); 23 DCHECK_EQ(kGLImplementationNone, GetGLImplementation());
24 24
25 std::vector<GLImplementation> allowed_impls = GetAllowedGLImplementations(); 25 std::vector<GLImplementation> allowed_impls = GetAllowedGLImplementations();
26 DCHECK(!allowed_impls.empty()); 26 DCHECK(!allowed_impls.empty());
27 27
28 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); 28 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
29 29
30 // The default implementation is always the first one in list. 30 // The default implementation is always the first one in list.
31 GLImplementation impl = allowed_impls[0]; 31 GLImplementation impl = allowed_impls[0];
32 bool fallback_to_osmesa = false; 32 bool fallback_to_software_gl = false;
33 if (cmd->HasSwitch(switches::kOverrideUseGLWithOSMesaForTests)) { 33 if (cmd->HasSwitch(switches::kOverrideUseSoftwareGLForTests)) {
34 impl = kGLImplementationOSMesaGL; 34 impl = GetSoftwareGLImplementation();
35 } else if (cmd->HasSwitch(switches::kUseGL)) { 35 } else if (cmd->HasSwitch(switches::kUseGL)) {
36 std::string requested_implementation_name = 36 std::string requested_implementation_name =
37 cmd->GetSwitchValueASCII(switches::kUseGL); 37 cmd->GetSwitchValueASCII(switches::kUseGL);
38 if (requested_implementation_name == "any") { 38 if (requested_implementation_name == "any") {
39 fallback_to_osmesa = true; 39 fallback_to_software_gl = true;
40 } else if (requested_implementation_name == 40 } else if (requested_implementation_name ==
41 kGLImplementationSwiftShaderName) { 41 kGLImplementationSwiftShaderName) {
42 impl = kGLImplementationSwiftShaderGL; 42 impl = kGLImplementationSwiftShaderGL;
43 } else if (requested_implementation_name == 43 } else if (requested_implementation_name ==
44 kGLImplementationSwiftShaderForWebGLName || 44 kGLImplementationSwiftShaderForWebGLName ||
45 requested_implementation_name == kGLImplementationANGLEName) { 45 requested_implementation_name == kGLImplementationANGLEName) {
46 impl = kGLImplementationEGLGLES2; 46 impl = kGLImplementationEGLGLES2;
47 } else { 47 } else {
48 impl = GetNamedGLImplementation(requested_implementation_name); 48 impl = GetNamedGLImplementation(requested_implementation_name);
49 if (!base::ContainsValue(allowed_impls, impl)) { 49 if (!base::ContainsValue(allowed_impls, impl)) {
50 LOG(ERROR) << "Requested GL implementation is not available."; 50 LOG(ERROR) << "Requested GL implementation is not available.";
51 return false; 51 return false;
52 } 52 }
53 } 53 }
54 } 54 }
55 55
56 bool gpu_service_logging = cmd->HasSwitch(switches::kEnableGPUServiceLogging); 56 bool gpu_service_logging = cmd->HasSwitch(switches::kEnableGPUServiceLogging);
57 bool disable_gl_drawing = cmd->HasSwitch(switches::kDisableGLDrawingForTests); 57 bool disable_gl_drawing = cmd->HasSwitch(switches::kDisableGLDrawingForTests);
58 58
59 return InitializeGLOneOffImplementation( 59 return InitializeGLOneOffImplementation(
60 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing); 60 impl, fallback_to_software_gl, gpu_service_logging, disable_gl_drawing);
61 } 61 }
62 62
63 bool InitializeGLOneOffImplementation(GLImplementation impl, 63 bool InitializeGLOneOffImplementation(GLImplementation impl,
64 bool fallback_to_osmesa, 64 bool fallback_to_software_gl,
65 bool gpu_service_logging, 65 bool gpu_service_logging,
66 bool disable_gl_drawing) { 66 bool disable_gl_drawing) {
67 bool initialized = 67 bool initialized =
68 InitializeStaticGLBindings(impl) && InitializeGLOneOffPlatform(); 68 InitializeStaticGLBindings(impl) && InitializeGLOneOffPlatform();
69 if (!initialized && fallback_to_osmesa) { 69 if (!initialized && fallback_to_software_gl) {
70 ShutdownGL(); 70 ShutdownGL();
71 initialized = InitializeStaticGLBindings(kGLImplementationOSMesaGL) && 71 initialized = InitializeStaticGLBindings(GetSoftwareGLImplementation()) &&
72 InitializeGLOneOffPlatform(); 72 InitializeGLOneOffPlatform();
73 } 73 }
74 if (!initialized) 74 if (!initialized)
75 ShutdownGL(); 75 ShutdownGL();
76 76
77 if (initialized) { 77 if (initialized) {
78 DVLOG(1) << "Using " << GetGLImplementationName(GetGLImplementation()) 78 DVLOG(1) << "Using " << GetGLImplementationName(GetGLImplementation())
79 << " GL implementation."; 79 << " GL implementation.";
80 if (gpu_service_logging) 80 if (gpu_service_logging)
81 InitializeDebugGLBindings(); 81 InitializeDebugGLBindings();
82 if (disable_gl_drawing) 82 if (disable_gl_drawing)
83 InitializeNullDrawGLBindings(); 83 InitializeNullDrawGLBindings();
84 } 84 }
85 return initialized; 85 return initialized;
86 } 86 }
87 87
88 void ShutdownGL() { 88 void ShutdownGL() {
89 ShutdownGLPlatform(); 89 ShutdownGLPlatform();
90 90
91 SetGLImplementation(kGLImplementationNone); 91 SetGLImplementation(kGLImplementationNone);
92 UnloadGLNativeLibraries(); 92 UnloadGLNativeLibraries();
93 } 93 }
94 94
95 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) { 95 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) {
96 return CreateOffscreenGLSurfaceWithFormat(size, GLSurfaceFormat()); 96 return CreateOffscreenGLSurfaceWithFormat(size, GLSurfaceFormat());
97 } 97 }
98 98
99 } // namespace init 99 } // namespace init
100 } // namespace gl 100 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/init/gl_factory.h ('k') | ui/gl/test/gl_surface_test_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698