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

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

Issue 2629633003: Refactor GL bindings so there is no global GLApi or DriverGL. (Closed)
Patch Set: rebase 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_initializer_mac.cc ('k') | ui/gl/init/gl_initializer_win.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_initializer.h" 5 #include "ui/gl/init/gl_initializer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/gl/gl_bindings.h" 8 #include "ui/gl/gl_bindings.h"
9 #include "ui/gl/gl_egl_api_implementation.h" 9 #include "ui/gl/gl_egl_api_implementation.h"
10 #include "ui/gl/gl_gl_api_implementation.h" 10 #include "ui/gl/gl_gl_api_implementation.h"
(...skipping 29 matching lines...) Expand all
40 switch (GetGLImplementation()) { 40 switch (GetGLImplementation()) {
41 case kGLImplementationEGLGLES2: 41 case kGLImplementationEGLGLES2:
42 if (!GLSurfaceEGL::InitializeOneOff( 42 if (!GLSurfaceEGL::InitializeOneOff(
43 GetSurfaceFactoryOzone()->GetNativeDisplay())) { 43 GetSurfaceFactoryOzone()->GetNativeDisplay())) {
44 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; 44 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
45 return false; 45 return false;
46 } 46 }
47 return true; 47 return true;
48 case kGLImplementationOSMesaGL: 48 case kGLImplementationOSMesaGL:
49 case kGLImplementationMockGL: 49 case kGLImplementationMockGL:
50 case kGLImplementationStubGL:
50 return true; 51 return true;
51 default: 52 default:
52 return false; 53 return false;
53 } 54 }
54 } 55 }
55 56
56 bool InitializeStaticGLBindings(GLImplementation implementation) { 57 bool InitializeStaticGLBindings(GLImplementation implementation) {
57 // Prevent reinitialization with a different implementation. Once the gpu 58 // Prevent reinitialization with a different implementation. Once the gpu
58 // unit tests have initialized with kGLImplementationMock, we don't want to 59 // unit tests have initialized with kGLImplementationMock, we don't want to
59 // later switch to another GL implementation. 60 // later switch to another GL implementation.
60 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); 61 DCHECK_EQ(kGLImplementationNone, GetGLImplementation());
61 62
62 if (HasGLOzone(implementation)) { 63 if (HasGLOzone(implementation)) {
63 return GetGLOzone(implementation) 64 return GetGLOzone(implementation)
64 ->InitializeStaticGLBindings(implementation); 65 ->InitializeStaticGLBindings(implementation);
65 } 66 }
66 67
67 switch (implementation) { 68 switch (implementation) {
68 case kGLImplementationOSMesaGL: 69 case kGLImplementationOSMesaGL:
69 return InitializeStaticGLBindingsOSMesaGL(); 70 return InitializeStaticGLBindingsOSMesaGL();
70 case kGLImplementationEGLGLES2: 71 case kGLImplementationEGLGLES2:
71 return InitializeStaticEGLInternal(); 72 return InitializeStaticEGLInternal();
72 case kGLImplementationMockGL: 73 case kGLImplementationMockGL:
73 SetGLImplementation(kGLImplementationMockGL); 74 case kGLImplementationStubGL:
75 SetGLImplementation(implementation);
74 InitializeStaticGLBindingsGL(); 76 InitializeStaticGLBindingsGL();
75 return true; 77 return true;
76 default: 78 default:
77 NOTREACHED(); 79 NOTREACHED();
78 } 80 }
79 81
80 return false; 82 return false;
81 } 83 }
82 84
83 void InitializeDebugGLBindings() { 85 void InitializeDebugGLBindings() {
(...skipping 14 matching lines...) Expand all
98 return; 100 return;
99 } 101 }
100 102
101 ClearBindingsEGL(); 103 ClearBindingsEGL();
102 ClearBindingsGL(); 104 ClearBindingsGL();
103 ClearBindingsOSMESA(); 105 ClearBindingsOSMESA();
104 } 106 }
105 107
106 } // namespace init 108 } // namespace init
107 } // namespace gl 109 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/init/gl_initializer_mac.cc ('k') | ui/gl/init/gl_initializer_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698