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

Side by Side Diff: src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.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 2011 Google Inc. 3 * Copyright 2014 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 #include "gl/GrGLInterface.h" 9 #include "gl/GrGLInterface.h"
10 #include "gl/GrGLAssembleInterface.h"
11 #include <dlfcn.h>
10 12
11 #import <OpenGLES/ES2/gl.h> 13 class GLLoader {
12 #import <OpenGLES/ES2/glext.h> 14 public:
15 GLLoader() {
16 fLibrary = dlopen(
17 "/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/li bGL.dylib",
18 RTLD_LAZY);
19 }
20
21 ~GLLoader() {
22 if (NULL != fLibrary) {
23 dlclose(fLibrary);
24 }
25 }
26
27 void* handle() const {
28 return NULL == fLibrary ? RTLD_DEFAULT : fLibrary;
29 }
30
31 private:
32 void* fLibrary;
33 };
34
35 class GLProcGetter {
36 public:
37 GLProcGetter() {}
38
39 GrGLFuncPtr getProc(const char name[]) const {
40 return (GrGLFuncPtr) dlsym(fLoader.handle(), name);
41 }
42
43 private:
44 GLLoader fLoader;
45 };
46
47 static GrGLFuncPtr ios_get_gl_proc(void* ctx, const char name[]) {
48 SkASSERT(NULL != ctx);
49 const GLProcGetter* getter = (const GLProcGetter*) ctx;
50 return getter->getProc(name);
51 }
13 52
14 const GrGLInterface* GrGLCreateNativeInterface() { 53 const GrGLInterface* GrGLCreateNativeInterface() {
15 GrGLInterface* interface = SkNEW(GrGLInterface); 54 GLProcGetter getter;
16 55 return GrGLAssembleGLESInterface(&getter, ios_get_gl_proc);
17 GrGLInterface::Functions* functions = &interface->fFunctions;
18
19 functions->fActiveTexture = glActiveTexture;
20 functions->fAttachShader = glAttachShader;
21 functions->fBindAttribLocation = glBindAttribLocation;
22 functions->fBindBuffer = glBindBuffer;
23 functions->fBindTexture = glBindTexture;
24 functions->fBlendColor = glBlendColor;
25 functions->fBlendFunc = glBlendFunc;
26 functions->fBufferData = (GrGLBufferDataProc)glBufferData;
27 functions->fBufferSubData = (GrGLBufferSubDataProc)glBufferSubData;
28 functions->fClear = glClear;
29 functions->fClearColor = glClearColor;
30 functions->fClearStencil = glClearStencil;
31 functions->fColorMask = glColorMask;
32 functions->fCompileShader = glCompileShader;
33 functions->fCompressedTexImage2D = glCompressedTexImage2D;
34 functions->fCompressedTexSubImage2D = glCompressedTexSubImage2D;
35 functions->fCopyTexSubImage2D = glCopyTexSubImage2D;
36 functions->fCreateProgram = glCreateProgram;
37 functions->fCreateShader = glCreateShader;
38 functions->fCullFace = glCullFace;
39 functions->fDeleteBuffers = glDeleteBuffers;
40 functions->fDeleteProgram = glDeleteProgram;
41 functions->fDeleteShader = glDeleteShader;
42 functions->fDeleteTextures = glDeleteTextures;
43 functions->fDepthMask = glDepthMask;
44 functions->fDisable = glDisable;
45 functions->fDisableVertexAttribArray = glDisableVertexAttribArray;
46 functions->fDrawArrays = glDrawArrays;
47 functions->fDrawBuffer = NULL;
48 functions->fDrawBuffers = NULL;
49 functions->fDrawElements = glDrawElements;
50 functions->fEnable = glEnable;
51 functions->fEnableVertexAttribArray = glEnableVertexAttribArray;
52 functions->fFinish = glFinish;
53 functions->fFlush = glFlush;
54 functions->fFrontFace = glFrontFace;
55 functions->fGenBuffers = glGenBuffers;
56 functions->fGenerateMipmap = glGenerateMipmap;
57 functions->fGetBufferParameteriv = glGetBufferParameteriv;
58 functions->fGetError = glGetError;
59 functions->fGetIntegerv = glGetIntegerv;
60 functions->fGetProgramInfoLog = glGetProgramInfoLog;
61 functions->fGetProgramiv = glGetProgramiv;
62 functions->fGetShaderInfoLog = glGetShaderInfoLog;
63 functions->fGetShaderiv = glGetShaderiv;
64 functions->fGetString = glGetString;
65 functions->fGenTextures = glGenTextures;
66 functions->fGetUniformLocation = glGetUniformLocation;
67 functions->fLineWidth = glLineWidth;
68 functions->fLinkProgram = glLinkProgram;
69 functions->fPixelStorei = glPixelStorei;
70 functions->fReadBuffer = NULL;
71 functions->fReadPixels = glReadPixels;
72 functions->fScissor = glScissor;
73 functions->fShaderSource = (GrGLShaderSourceProc) glShaderSource;
74 functions->fStencilFunc = glStencilFunc;
75 functions->fStencilFuncSeparate = glStencilFuncSeparate;
76 functions->fStencilMask = glStencilMask;
77 functions->fStencilMaskSeparate = glStencilMaskSeparate;
78 functions->fStencilOp = glStencilOp;
79 functions->fStencilOpSeparate = glStencilOpSeparate;
80 // mac uses GLenum for internalFormat param (non-standard)
81 // amounts to int vs. uint.
82 functions->fTexImage2D = (GrGLTexImage2DProc)glTexImage2D;
83 #if GL_ARB_texture_storage
84 functions->fTexStorage2D = glTexStorage2D;
85 #elif GL_EXT_texture_storage
86 functions->fTexStorage2D = glTexStorage2DEXT;
87 #endif
88 #if GL_EXT_discard_framebuffer
89 functions->fDiscardFramebuffer = glDiscardFramebufferEXT;
90 #endif
91 functions->fTexParameteri = glTexParameteri;
92 functions->fTexParameteriv = glTexParameteriv;
93 functions->fTexSubImage2D = glTexSubImage2D;
94 functions->fUniform1f = glUniform1f;
95 functions->fUniform1i = glUniform1i;
96 functions->fUniform1fv = glUniform1fv;
97 functions->fUniform1iv = glUniform1iv;
98 functions->fUniform2f = glUniform2f;
99 functions->fUniform2i = glUniform2i;
100 functions->fUniform2fv = glUniform2fv;
101 functions->fUniform2iv = glUniform2iv;
102 functions->fUniform3f = glUniform3f;
103 functions->fUniform3i = glUniform3i;
104 functions->fUniform3fv = glUniform3fv;
105 functions->fUniform3iv = glUniform3iv;
106 functions->fUniform4f = glUniform4f;
107 functions->fUniform4i = glUniform4i;
108 functions->fUniform4fv = glUniform4fv;
109 functions->fUniform4iv = glUniform4iv;
110 functions->fUniform4fv = glUniform4fv;
111 functions->fUniformMatrix2fv = glUniformMatrix2fv;
112 functions->fUniformMatrix3fv = glUniformMatrix3fv;
113 functions->fUniformMatrix4fv = glUniformMatrix4fv;
114 functions->fUseProgram = glUseProgram;
115 functions->fVertexAttrib4fv = glVertexAttrib4fv;
116 functions->fVertexAttribPointer = glVertexAttribPointer;
117 functions->fViewport = glViewport;
118 functions->fGenFramebuffers = glGenFramebuffers;
119 functions->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachment Parameteriv;
120 functions->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
121 functions->fBindFramebuffer = glBindFramebuffer;
122 functions->fFramebufferTexture2D = glFramebufferTexture2D;
123 functions->fCheckFramebufferStatus = glCheckFramebufferStatus;
124 functions->fDeleteFramebuffers = glDeleteFramebuffers;
125 functions->fRenderbufferStorage = glRenderbufferStorage;
126 functions->fGenRenderbuffers = glGenRenderbuffers;
127 functions->fDeleteRenderbuffers = glDeleteRenderbuffers;
128 functions->fFramebufferRenderbuffer = glFramebufferRenderbuffer;
129 functions->fBindRenderbuffer = glBindRenderbuffer;
130
131 #if GL_OES_mapbuffer
132 functions->fMapBuffer = glMapBufferOES;
133 functions->fUnmapBuffer = glUnmapBufferOES;
134 #endif
135
136 #if GL_EXT_map_buffer_range || GL_ES_VERSION_3_0
137 functions->fMapBufferRange = glMapBufferRangeEXT;
138 functions->fFlushMappedBufferRange = glFlushMappedBufferRangeEXT;
139 #endif
140
141 #if GL_APPLE_framebuffer_multisample
142 functions->fRenderbufferStorageMultisampleES2APPLE = glRenderbufferStorageMu ltisampleAPPLE;
143 functions->fResolveMultisampleFramebuffer = glResolveMultisampleFramebufferA PPLE;
144 #endif
145
146 #if GL_OES_vertex_array_object
147 functions->fBindVertexArray = glBindVertexArrayOES;
148 functions->fDeleteVertexArrays = glDeleteVertexArraysOES;
149 functions->fGenVertexArrays = glGenVertexArraysOES;
150 #endif
151
152 #if GL_EXT_debug_marker
153 functions->fInsertEventMarker = glInsertEventMarkerEXT;
154 functions->fPushGroupMarker = glPushGroupMarkerEXT;
155 functions->fPopGroupMarker = glPopGroupMarkerEXT;
156 #endif
157
158 #if GL_ES_VERSION_3_0 || GL_ARB_invalidate_subdata
159 functions->fInvalidateFramebuffer = glInvalidateFramebuffer;
160 functions->fInvalidateSubFramebuffer = glInvalidateSubFramebuffer;
161 #endif
162
163 #if GL_ARB_invalidate_subdata
164 functions->fInvalidateBufferData = glInvalidateBufferData;
165 functions->fInvalidateBufferSubData = glInvalidateBufferSubData;
166 functions->fInvalidateTexImage = glInvalidateTexImage;
167 functions->fInvalidateTexSubImage = glInvalidateTexSubImage;
168 #endif
169
170 interface->fStandard = kGLES_GrGLStandard;
171 interface->fExtensions.init(kGLES_GrGLStandard, glGetString, NULL, glGetInte gerv);
172
173 return interface;
174 } 56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698