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

Side by Side Diff: ui/gl/gl_implementation_ozone.cc

Issue 94963003: Take GL version and extensions correctly into account when binding functions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Improve Windows initialization and renderBufferMultisample explanation Created 7 years 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/gl_implementation_mac.cc ('k') | ui/gl/gl_implementation_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "ui/gfx/ozone/surface_factory_ozone.h" 6 #include "ui/gfx/ozone/surface_factory_ozone.h"
7 #include "ui/gl/gl_bindings.h" 7 #include "ui/gl/gl_bindings.h"
8 #include "ui/gl/gl_context_stub_with_extensions.h"
8 #include "ui/gl/gl_egl_api_implementation.h" 9 #include "ui/gl/gl_egl_api_implementation.h"
9 #include "ui/gl/gl_gl_api_implementation.h" 10 #include "ui/gl/gl_gl_api_implementation.h"
10 #include "ui/gl/gl_implementation.h" 11 #include "ui/gl/gl_implementation.h"
11 #include "ui/gl/gl_implementation_linux.h" 12 #include "ui/gl/gl_implementation_linux.h"
12 #include "ui/gl/gl_osmesa_api_implementation.h" 13 #include "ui/gl/gl_osmesa_api_implementation.h"
13 #include "ui/ozone/ozone_platform.h" 14 #include "ui/ozone/ozone_platform.h"
14 15
15 namespace gfx { 16 namespace gfx {
16 17
17 namespace { 18 namespace {
18 19
19 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) { 20 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) {
20 glClearDepthf(static_cast<GLclampf>(depth)); 21 glClearDepthf(static_cast<GLclampf>(depth));
21 } 22 }
22 23
23 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near, 24 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near,
24 GLclampd z_far) { 25 GLclampd z_far) {
25 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far)); 26 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far));
26 } 27 }
27 28
28 } // namespace 29 } // namespace
29 30
30 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { 31 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
31 impls->push_back(kGLImplementationEGLGLES2); 32 impls->push_back(kGLImplementationEGLGLES2);
32 impls->push_back(kGLImplementationOSMesaGL); 33 impls->push_back(kGLImplementationOSMesaGL);
33 } 34 }
34 35
35 bool InitializeGLBindings(GLImplementation implementation) { 36 bool InitializeStaticGLBindings(GLImplementation implementation) {
36 // Prevent reinitialization with a different implementation. Once the gpu 37 // Prevent reinitialization with a different implementation. Once the gpu
37 // unit tests have initialized with kGLImplementationMock, we don't want to 38 // unit tests have initialized with kGLImplementationMock, we don't want to
38 // later switch to another GL implementation. 39 // later switch to another GL implementation.
39 if (GetGLImplementation() != kGLImplementationNone) 40 if (GetGLImplementation() != kGLImplementationNone)
40 return true; 41 return true;
41 42
42 switch (implementation) { 43 switch (implementation) {
43 case kGLImplementationOSMesaGL: 44 case kGLImplementationOSMesaGL:
44 return InitializeGLBindingsOSMesaGL(); 45 return InitializeStaticGLBindingsOSMesaGL();
45 case kGLImplementationEGLGLES2: 46 case kGLImplementationEGLGLES2:
46 ui::OzonePlatform::Initialize(); 47 ui::OzonePlatform::Initialize();
47 if (!gfx::SurfaceFactoryOzone::GetInstance()->LoadEGLGLES2Bindings( 48 if (!gfx::SurfaceFactoryOzone::GetInstance()->LoadEGLGLES2Bindings(
48 base::Bind(&AddGLNativeLibrary), 49 base::Bind(&AddGLNativeLibrary),
49 base::Bind(&SetGLGetProcAddressProc))) 50 base::Bind(&SetGLGetProcAddressProc)))
50 return false; 51 return false;
51 SetGLImplementation(kGLImplementationEGLGLES2); 52 SetGLImplementation(kGLImplementationEGLGLES2);
52 InitializeGLBindingsGL(); 53 InitializeStaticGLBindingsGL();
53 InitializeGLBindingsEGL(); 54 InitializeStaticGLBindingsEGL();
54 55
55 // These two functions take single precision float rather than double 56 // These two functions take single precision float rather than double
56 // precision float parameters in GLES. 57 // precision float parameters in GLES.
57 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf; 58 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf;
58 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef; 59 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef;
59 break; 60 break;
60 case kGLImplementationMockGL: { 61 case kGLImplementationMockGL: {
61 SetGLGetProcAddressProc(GetMockGLProcAddress); 62 SetGLGetProcAddressProc(GetMockGLProcAddress);
62 SetGLImplementation(kGLImplementationMockGL); 63 SetGLImplementation(kGLImplementationMockGL);
63 InitializeGLBindingsGL(); 64 InitializeStaticGLBindingsGL();
64 break; 65 break;
65 } 66 }
66 default: 67 default:
67 NOTIMPLEMENTED() 68 NOTIMPLEMENTED()
68 << "Unsupported GL type for Ozone surface implementation"; 69 << "Unsupported GL type for Ozone surface implementation";
69 return false; 70 return false;
70 } 71 }
71 72
72 return true; 73 return true;
73 } 74 }
74 75
75 bool InitializeGLExtensionBindings(GLImplementation implementation, 76 bool InitializeDynamicGLBindings(GLImplementation implementation,
76 GLContext* context) { 77 GLContext* context) {
77 switch (implementation) { 78 switch (implementation) {
78 case kGLImplementationOSMesaGL: 79 case kGLImplementationOSMesaGL:
79 InitializeGLExtensionBindingsGL(context); 80 InitializeDynamicGLBindingsGL(context);
80 InitializeGLExtensionBindingsOSMESA(context); 81 InitializeDynamicGLBindingsOSMESA(context);
81 break; 82 break;
82 case kGLImplementationEGLGLES2: 83 case kGLImplementationEGLGLES2:
83 InitializeGLExtensionBindingsGL(context); 84 InitializeDynamicGLBindingsGL(context);
84 InitializeGLExtensionBindingsEGL(context); 85 InitializeDynamicGLBindingsEGL(context);
85 break; 86 break;
86 case kGLImplementationMockGL: 87 case kGLImplementationMockGL:
87 InitializeGLExtensionBindingsGL(context); 88 if (!context) {
89 scoped_refptr<GLContextStubWithExtensions> mock_context(
90 new GLContextStubWithExtensions());
91 mock_context->SetGLVersionString("3.0");
92 InitializeDynamicGLBindingsGL(mock_context.get());
93 } else
94 InitializeDynamicGLBindingsGL(context);
88 break; 95 break;
89 default: 96 default:
90 return false; 97 return false;
91 } 98 }
92 99
93 return true; 100 return true;
94 } 101 }
95 102
96 void InitializeDebugGLBindings() { 103 void InitializeDebugGLBindings() {
97 } 104 }
98 105
99 void ClearGLBindings() { 106 void ClearGLBindings() {
100 ClearGLBindingsEGL(); 107 ClearGLBindingsEGL();
101 ClearGLBindingsGL(); 108 ClearGLBindingsGL();
102 SetGLImplementation(kGLImplementationNone); 109 SetGLImplementation(kGLImplementationNone);
103 UnloadGLNativeLibraries(); 110 UnloadGLNativeLibraries();
104 } 111 }
105 112
106 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { 113 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
107 switch (GetGLImplementation()) { 114 switch (GetGLImplementation()) {
108 case kGLImplementationEGLGLES2: 115 case kGLImplementationEGLGLES2:
109 return GetGLWindowSystemBindingInfoEGL(info); 116 return GetGLWindowSystemBindingInfoEGL(info);
110 default: 117 default:
111 return false; 118 return false;
112 } 119 }
113 return false; 120 return false;
114 } 121 }
115 122
116 } // namespace gfx 123 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_implementation_mac.cc ('k') | ui/gl/gl_implementation_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698