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

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

Issue 1542013005: Add a new driver bug workaround SANDBOX_START_EARLY Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 2 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/init/gl_initializer.h » ('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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "ui/gl/gl_share_group.h" 13 #include "ui/gl/gl_share_group.h"
14 #include "ui/gl/gl_surface.h" 14 #include "ui/gl/gl_surface.h"
15 #include "ui/gl/init/gl_initializer.h" 15 #include "ui/gl/init/gl_initializer.h"
16 16
17 namespace gl { 17 namespace gl {
18 namespace init { 18 namespace init {
19 19
20 bool InitializeGLOneOff() { 20 bool InitializeGLOneOff() {
21 TRACE_EVENT0("gpu,startup", "gl::init::InitializeOneOff"); 21 TRACE_EVENT0("gpu,startup", "gl::init::InitializeOneOff");
22 22
23 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); 23 DCHECK_EQ(kGLImplementationNone, GetGLImplementation());
24 24
25 GLImplementation impl = kGLImplementationNone;
26 bool fallback_to_osmesa = false;
25 std::vector<GLImplementation> allowed_impls = GetAllowedGLImplementations(); 27 std::vector<GLImplementation> allowed_impls = GetAllowedGLImplementations();
26 DCHECK(!allowed_impls.empty()); 28 bool result =
29 SelectGLImplementation(allowed_impls, &impl, &fallback_to_osmesa);
30 if (!result)
31 return false;
27 32
28 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); 33 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
29
30 // The default implementation is always the first one in list.
31 GLImplementation impl = allowed_impls[0];
32 bool fallback_to_osmesa = false;
33 if (cmd->HasSwitch(switches::kOverrideUseGLWithOSMesaForTests)) {
34 impl = kGLImplementationOSMesaGL;
35 } else if (cmd->HasSwitch(switches::kUseGL)) {
36 std::string requested_implementation_name =
37 cmd->GetSwitchValueASCII(switches::kUseGL);
38 if (requested_implementation_name == "any") {
39 fallback_to_osmesa = true;
40 } else if (requested_implementation_name ==
41 kGLImplementationSwiftShaderName ||
42 requested_implementation_name == kGLImplementationANGLEName) {
43 impl = kGLImplementationEGLGLES2;
44 } else {
45 impl = GetNamedGLImplementation(requested_implementation_name);
46 if (!base::ContainsValue(allowed_impls, impl)) {
47 LOG(ERROR) << "Requested GL implementation is not available.";
48 return false;
49 }
50 }
51 }
52
53 bool gpu_service_logging = cmd->HasSwitch(switches::kEnableGPUServiceLogging); 34 bool gpu_service_logging = cmd->HasSwitch(switches::kEnableGPUServiceLogging);
54 bool disable_gl_drawing = cmd->HasSwitch(switches::kDisableGLDrawingForTests); 35 bool disable_gl_drawing = cmd->HasSwitch(switches::kDisableGLDrawingForTests);
55 36
56 return InitializeGLOneOffImplementation( 37 return InitializeGLOneOffImplementation(
57 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing); 38 impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing);
58 } 39 }
59 40
60 bool InitializeGLOneOffImplementation(GLImplementation impl, 41 bool InitializeGLOneOffImplementation(GLImplementation impl,
61 bool fallback_to_osmesa, 42 bool fallback_to_osmesa,
62 bool gpu_service_logging, 43 bool gpu_service_logging,
(...skipping 19 matching lines...) Expand all
82 return initialized; 63 return initialized;
83 } 64 }
84 65
85 void ClearGLBindings() { 66 void ClearGLBindings() {
86 ClearGLBindingsPlatform(); 67 ClearGLBindingsPlatform();
87 68
88 SetGLImplementation(kGLImplementationNone); 69 SetGLImplementation(kGLImplementationNone);
89 UnloadGLNativeLibraries(); 70 UnloadGLNativeLibraries();
90 } 71 }
91 72
73 #if !defined(OS_MACOSX)
74 bool GetNativeLibraryNamesFromGLImplementation(
75 GLImplementation impl,
76 std::vector<std::string>* required_libraries) {
77 return GetNativeLibraryNamesFromGLImplementationPlatform(impl,
78 required_libraries);
79 }
80 #endif
81
92 } // namespace init 82 } // namespace init
93 } // namespace gl 83 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/init/gl_factory.h ('k') | ui/gl/init/gl_initializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698