• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Modified from chromium/src/webkit/glue/gl_bindings_skia_cmd_buffer.cc
2 
3 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style license that can be
5 // found in the LICENSE file.
6 
7 #include "gl/GrGLInterface.h"
8 
9 #ifndef GL_GLEXT_PROTOTYPES
10 #define GL_GLEXT_PROTOTYPES
11 #endif
12 
13 #include <GLES2/gl2.h>
14 #include <GLES2/gl2ext.h>
15 
16 #include <EGL/egl.h>
17 
GrGLCreateNativeInterface()18 const GrGLInterface* GrGLCreateNativeInterface() {
19     static SkAutoTUnref<GrGLInterface> glInterface;
20     if (!glInterface.get()) {
21         GrGLInterface* interface = new GrGLInterface;
22         glInterface.reset(interface);
23         interface->fBindingsExported = kES2_GrGLBinding;
24         interface->fActiveTexture = glActiveTexture;
25         interface->fAttachShader = glAttachShader;
26         interface->fBindAttribLocation = glBindAttribLocation;
27         interface->fBindBuffer = glBindBuffer;
28         interface->fBindTexture = glBindTexture;
29         interface->fBlendColor = glBlendColor;
30         interface->fBlendFunc = glBlendFunc;
31         interface->fBufferData = glBufferData;
32         interface->fBufferSubData = glBufferSubData;
33         interface->fClear = glClear;
34         interface->fClearColor = glClearColor;
35         interface->fClearStencil = glClearStencil;
36         interface->fColorMask = glColorMask;
37         interface->fCompileShader = glCompileShader;
38         interface->fCompressedTexImage2D = glCompressedTexImage2D;
39         interface->fCreateProgram = glCreateProgram;
40         interface->fCreateShader = glCreateShader;
41         interface->fCullFace = glCullFace;
42         interface->fDeleteBuffers = glDeleteBuffers;
43         interface->fDeleteProgram = glDeleteProgram;
44         interface->fDeleteShader = glDeleteShader;
45         interface->fDeleteTextures = glDeleteTextures;
46         interface->fDepthMask = glDepthMask;
47         interface->fDisable = glDisable;
48         interface->fDisableVertexAttribArray = glDisableVertexAttribArray;
49         interface->fDrawArrays = glDrawArrays;
50         interface->fDrawElements = glDrawElements;
51         interface->fEnable = glEnable;
52         interface->fEnableVertexAttribArray = glEnableVertexAttribArray;
53         interface->fFinish = glFinish;
54         interface->fFlush = glFlush;
55         interface->fFrontFace = glFrontFace;
56         interface->fGenBuffers = glGenBuffers;
57         interface->fGenTextures = glGenTextures;
58         interface->fGetBufferParameteriv = glGetBufferParameteriv;
59         interface->fGetError = glGetError;
60         interface->fGetIntegerv = glGetIntegerv;
61         interface->fGetProgramInfoLog = glGetProgramInfoLog;
62         interface->fGetProgramiv = glGetProgramiv;
63         interface->fGetShaderInfoLog = glGetShaderInfoLog;
64         interface->fGetShaderiv = glGetShaderiv;
65         interface->fGetString = glGetString;
66         interface->fGetUniformLocation = glGetUniformLocation;
67         interface->fLineWidth = glLineWidth;
68         interface->fLinkProgram = glLinkProgram;
69         interface->fPixelStorei = glPixelStorei;
70         interface->fReadPixels = glReadPixels;
71         interface->fScissor = glScissor;
72 #if GR_USE_NEW_GL_SHADER_SOURCE_SIGNATURE
73         interface->fShaderSource = (GrGLShaderSourceProc) glShaderSource;
74 #else
75         interface->fShaderSource = glShaderSource;
76 #endif
77         interface->fStencilFunc = glStencilFunc;
78         interface->fStencilFuncSeparate = glStencilFuncSeparate;
79         interface->fStencilMask = glStencilMask;
80         interface->fStencilMaskSeparate = glStencilMaskSeparate;
81         interface->fStencilOp = glStencilOp;
82         interface->fStencilOpSeparate = glStencilOpSeparate;
83         interface->fTexImage2D = glTexImage2D;
84         interface->fTexParameteri = glTexParameteri;
85         interface->fTexParameteriv = glTexParameteriv;
86         interface->fTexSubImage2D = glTexSubImage2D;
87 #if GL_ARB_texture_storage
88         interface->fTexStorage2D = glTexStorage2D;
89 #elif GL_EXT_texture_storage
90         interface->fTexStorage2D = glTexStorage2DEXT;
91 #else
92         interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2DEXT");
93 #endif
94         interface->fUniform1f = glUniform1f;
95         interface->fUniform1i = glUniform1i;
96         interface->fUniform1fv = glUniform1fv;
97         interface->fUniform1iv = glUniform1iv;
98         interface->fUniform2f = glUniform2f;
99         interface->fUniform2i = glUniform2i;
100         interface->fUniform2fv = glUniform2fv;
101         interface->fUniform2iv = glUniform2iv;
102         interface->fUniform3f = glUniform3f;
103         interface->fUniform3i = glUniform3i;
104         interface->fUniform3fv = glUniform3fv;
105         interface->fUniform3iv = glUniform3iv;
106         interface->fUniform4f = glUniform4f;
107         interface->fUniform4i = glUniform4i;
108         interface->fUniform4fv = glUniform4fv;
109         interface->fUniform4iv = glUniform4iv;
110         interface->fUniformMatrix2fv = glUniformMatrix2fv;
111         interface->fUniformMatrix3fv = glUniformMatrix3fv;
112         interface->fUniformMatrix4fv = glUniformMatrix4fv;
113         interface->fUseProgram = glUseProgram;
114         interface->fVertexAttrib4fv = glVertexAttrib4fv;
115         interface->fVertexAttribPointer = glVertexAttribPointer;
116         interface->fViewport = glViewport;
117         interface->fBindFramebuffer = glBindFramebuffer;
118         interface->fBindRenderbuffer = glBindRenderbuffer;
119         interface->fCheckFramebufferStatus = glCheckFramebufferStatus;
120         interface->fDeleteFramebuffers = glDeleteFramebuffers;
121         interface->fDeleteRenderbuffers = glDeleteRenderbuffers;
122         interface->fFramebufferRenderbuffer = glFramebufferRenderbuffer;
123         interface->fFramebufferTexture2D = glFramebufferTexture2D;
124         interface->fGenFramebuffers = glGenFramebuffers;
125         interface->fGenRenderbuffers = glGenRenderbuffers;
126         interface->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
127         interface->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
128         interface->fRenderbufferStorage = glRenderbufferStorage;
129 #if GL_OES_mapbuffer
130         interface->fMapBuffer = glMapBufferOES;
131         interface->fUnmapBuffer = glUnmapBufferOES;
132 #else
133         interface->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOES");
134         interface->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBufferOES");
135 #endif
136     }
137     glInterface.get()->ref();
138     return glInterface.get();
139 }
140