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

Side by Side Diff: src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp

Issue 500153002: Remove reliance on linked in GL functions for assembling GLES interfaces (Closed) Base URL: https://skia.googlesource.com/skia.git@gmcfg
Patch Set: cleanup Created 6 years, 3 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "gl/GrGLInterface.h" 10 #include "gl/GrGLInterface.h"
11 #include "gl/GrGLAssembleInterface.h"
11 12
12 #ifndef GL_GLEXT_PROTOTYPES 13 #define WIN32_LEAN_AND_MEAN
13 #define GL_GLEXT_PROTOTYPES 14 #include <windows.h>
14 #endif
15
16 #include "GLES2/gl2.h"
17 #include "GLES2/gl2ext.h"
18 #include "EGL/egl.h" 15 #include "EGL/egl.h"
19 16
20 #define GET_PROC(name) \ 17 static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) {
21 interface->fFunctions.f ## name = (GrGL ## name ## Proc) GetProcAddress(ghAN GLELib, "gl" #name); 18 GrGLFuncPtr proc = (GrGLFuncPtr) GetProcAddress((HMODULE)ctx, name);
19 if (NULL != proc) {
20 return proc;
21 }
22 return eglGetProcAddress(name);
23 }
22 24
23 const GrGLInterface* GrGLCreateANGLEInterface() { 25 const GrGLInterface* GrGLCreateANGLEInterface() {
24 26
25 static HMODULE ghANGLELib = NULL; 27 static HMODULE ghANGLELib = NULL;
26 28
27 if (NULL == ghANGLELib) { 29 if (NULL == ghANGLELib) {
28 // We load the ANGLE library and never let it go 30 // We load the ANGLE library and never let it go
29 ghANGLELib = LoadLibrary("libGLESv2.dll"); 31 ghANGLELib = LoadLibrary("libGLESv2.dll");
30 } 32 }
31 if (NULL == ghANGLELib) { 33 if (NULL == ghANGLELib) {
32 // We can't setup the interface correctly w/o the DLL 34 // We can't setup the interface correctly w/o the DLL
33 return NULL; 35 return NULL;
34 } 36 }
35 37
36 GrGLInterface* interface = SkNEW(GrGLInterface); 38 return GrGLAssembleGLESInterface(ghANGLELib, angle_get_gl_proc);
37 interface->fStandard = kGLES_GrGLStandard;
38
39 GrGLInterface::Functions* functions = &interface->fFunctions;
40
41 GET_PROC(ActiveTexture);
42 GET_PROC(AttachShader);
43 GET_PROC(BindAttribLocation);
44 GET_PROC(BindBuffer);
45 GET_PROC(BindTexture);
46 functions->fBindVertexArray =
47 (GrGLBindVertexArrayProc) eglGetProcAddress("glBindVertexArrayOES");
48 GET_PROC(BlendColor);
49 GET_PROC(BlendFunc);
50 GET_PROC(BufferData);
51 GET_PROC(BufferSubData);
52 GET_PROC(Clear);
53 GET_PROC(ClearColor);
54 GET_PROC(ClearStencil);
55 GET_PROC(ColorMask);
56 GET_PROC(CompileShader);
57 GET_PROC(CompressedTexImage2D);
58 GET_PROC(CompressedTexSubImage2D);
59 GET_PROC(CopyTexSubImage2D);
60 GET_PROC(CreateProgram);
61 GET_PROC(CreateShader);
62 GET_PROC(CullFace);
63 GET_PROC(DeleteBuffers);
64 GET_PROC(DeleteProgram);
65 GET_PROC(DeleteShader);
66 GET_PROC(DeleteTextures);
67 functions->fDeleteVertexArrays =
68 (GrGLDeleteVertexArraysProc) eglGetProcAddress("glDeleteVertexArraysOES" );
69 GET_PROC(DepthMask);
70 GET_PROC(Disable);
71 GET_PROC(DisableVertexAttribArray);
72 GET_PROC(DrawArrays);
73 GET_PROC(DrawElements);
74 GET_PROC(Enable);
75 GET_PROC(EnableVertexAttribArray);
76 GET_PROC(Finish);
77 GET_PROC(Flush);
78 GET_PROC(FrontFace);
79 GET_PROC(GenBuffers);
80 GET_PROC(GenerateMipmap);
81 GET_PROC(GenTextures);
82 functions->fGenVertexArrays =
83 (GrGLGenVertexArraysProc) eglGetProcAddress("glGenVertexArraysOES");
84 GET_PROC(GetBufferParameteriv);
85 GET_PROC(GetError);
86 GET_PROC(GetIntegerv);
87 GET_PROC(GetProgramInfoLog);
88 GET_PROC(GetProgramiv);
89 GET_PROC(GetShaderInfoLog);
90 GET_PROC(GetShaderiv);
91 GET_PROC(GetString);
92 GET_PROC(GetStringi);
93 GET_PROC(GetUniformLocation);
94 GET_PROC(LineWidth);
95 GET_PROC(LinkProgram);
96 GET_PROC(PixelStorei);
97 GET_PROC(ReadPixels);
98 GET_PROC(Scissor);
99 GET_PROC(ShaderSource);
100 GET_PROC(StencilFunc);
101 GET_PROC(StencilFuncSeparate);
102 GET_PROC(StencilMask);
103 GET_PROC(StencilMaskSeparate);
104 GET_PROC(StencilOp);
105 GET_PROC(StencilOpSeparate);
106 GET_PROC(TexImage2D);
107 GET_PROC(TexParameteri);
108 GET_PROC(TexParameteriv);
109 GET_PROC(TexSubImage2D);
110 #if GL_ARB_texture_storage
111 GET_PROC(TexStorage2D);
112 #elif GL_EXT_texture_storage
113 functions->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexSt orage2DEXT");
114 #endif
115 GET_PROC(Uniform1f);
116 GET_PROC(Uniform1i);
117 GET_PROC(Uniform1fv);
118 GET_PROC(Uniform1iv);
119
120 GET_PROC(Uniform2f);
121 GET_PROC(Uniform2i);
122 GET_PROC(Uniform2fv);
123 GET_PROC(Uniform2iv);
124
125 GET_PROC(Uniform3f);
126 GET_PROC(Uniform3i);
127 GET_PROC(Uniform3fv);
128 GET_PROC(Uniform3iv);
129
130 GET_PROC(Uniform4f);
131 GET_PROC(Uniform4i);
132 GET_PROC(Uniform4fv);
133 GET_PROC(Uniform4iv);
134
135 GET_PROC(UniformMatrix2fv);
136 GET_PROC(UniformMatrix3fv);
137 GET_PROC(UniformMatrix4fv);
138 GET_PROC(UseProgram);
139 GET_PROC(VertexAttrib4fv);
140 GET_PROC(VertexAttribPointer);
141 GET_PROC(Viewport);
142 GET_PROC(BindFramebuffer);
143 GET_PROC(BindRenderbuffer);
144 GET_PROC(CheckFramebufferStatus);
145 GET_PROC(DeleteFramebuffers);
146 GET_PROC(DeleteRenderbuffers);
147 GET_PROC(FramebufferRenderbuffer);
148 GET_PROC(FramebufferTexture2D);
149 GET_PROC(GenFramebuffers);
150 GET_PROC(GenRenderbuffers);
151 GET_PROC(GetFramebufferAttachmentParameteriv);
152 GET_PROC(GetRenderbufferParameteriv);
153 GET_PROC(RenderbufferStorage);
154
155 functions->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOE S");
156 functions->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBu fferOES");
157
158 #if GL_ES_VERSION_3_0
159 functions->fMapBufferRange = GET_PROC(glMapBufferRange);
160 functions->fFlushMappedBufferRange = GET_PROC(glFlushMappedBufferRange);
161 #else
162 functions->fMapBufferRange = (GrGLMapBufferRangeProc) eglGetProcAddress("glM apBufferRange");
163 functions->fFlushMappedBufferRange = (GrGLFlushMappedBufferRangeProc) eglGet ProcAddress("glFlushMappedBufferRange");
164 #endif
165
166 functions->fInsertEventMarker = (GrGLInsertEventMarkerProc) eglGetProcAddres s("glInsertEventMarkerEXT");
167 functions->fPushGroupMarker = (GrGLInsertEventMarkerProc) eglGetProcAddress( "glPushGroupMarkerEXT");
168 functions->fPopGroupMarker = (GrGLPopGroupMarkerProc) eglGetProcAddress("glP opGroupMarkerEXT");
169
170 #if GL_ES_VERSION_3_0
171 GET_PROC(InvalidateFramebuffer);
172 GET_PROC(InvalidateSubFramebuffer);
173 #else
174 functions->fInvalidateFramebuffer = (GrGLInvalidateFramebufferProc) eglGetPr ocAddress("glInvalidateFramebuffer");
175 functions->fInvalidateSubFramebuffer = (GrGLInvalidateSubFramebufferProc) eg lGetProcAddress("glInvalidateSubFramebuffer");
176 #endif
177 functions->fInvalidateBufferData = (GrGLInvalidateBufferDataProc) eglGetProc Address("glInvalidateBufferData");
178 functions->fInvalidateBufferSubData = (GrGLInvalidateBufferSubDataProc) eglG etProcAddress("glInvalidateBufferSubData");
179 functions->fInvalidateTexImage = (GrGLInvalidateTexImageProc) eglGetProcAddr ess("glInvalidateTexImage");
180 functions->fInvalidateTexSubImage = (GrGLInvalidateTexSubImageProc) eglGetPr ocAddress("glInvalidateTexSubImage");
181
182 interface->fExtensions.init(kGLES_GrGLStandard,
183 functions->fGetString,
184 functions->fGetStringi,
185 functions->fGetIntegerv);
186 return interface;
187 } 39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698