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

Unified Diff: src/gpu/gl/GrGLAssembleInterface.cpp

Issue 254713006: Common GrGLInterface OpenGL setup function. (Closed) Base URL: https://skia.googlesource.com/skia.git@grgl
Patch Set: Address additional comment Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLAssembleInterface.h ('k') | src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLAssembleInterface.cpp
diff --git a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp b/src/gpu/gl/GrGLAssembleInterface.cpp
similarity index 75%
copy from src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp
copy to src/gpu/gl/GrGLAssembleInterface.cpp
index 5dd1c6cab96d1876bc021616e86aa1e2786fedd9..11355b8991d65dd5a159599619ce83274ff8123b 100644
--- a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp
+++ b/src/gpu/gl/GrGLAssembleInterface.cpp
@@ -1,58 +1,55 @@
/*
- * Copyright 2011 Google Inc.
+ * Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gl/GrGLInterface.h"
-#include "../GrGLUtil.h"
+#include "GrGLAssembleInterface.h"
+#include "GrGLUtil.h"
-#include <GL/glx.h>
-#include <GL/gl.h>
-#include <GL/glext.h>
-#include <GL/glu.h>
+#define GET_PROC(F) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F)
+#define GET_PROC_SUFFIX(F, S) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F #S)
+#define GET_PROC_LOCAL(F) GrGL ## F ## Proc F = (GrGL ## F ## Proc) get(ctx, "gl" #F)
-#define GET_PROC(F) interface->fFunctions.f ## F = (GrGL ## F ## Proc) \
- glXGetProcAddress(reinterpret_cast<const GLubyte*>("gl" #F));
-#define GET_PROC_SUFFIX(F, S) interface->fFunctions.f ## F = (GrGL ## F ## Proc) \
- glXGetProcAddress(reinterpret_cast<const GLubyte*>("gl" #F #S));
+const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
+ GET_PROC_LOCAL(GetString);
+ GET_PROC_LOCAL(GetStringi);
+ GET_PROC_LOCAL(GetIntegerv);
-const GrGLInterface* GrGLCreateNativeInterface() {
- if (NULL == glXGetCurrentContext()) {
+ // GetStringi may be NULL depending on the GL version.
+ if (NULL == GetString || NULL == GetIntegerv) {
return NULL;
}
- const char* versionString = (const char*) glGetString(GL_VERSION);
+ const char* versionString = (const char*) GetString(GR_GL_VERSION);
GrGLVersion glVer = GrGLGetVersionFromString(versionString);
- // This may or may not succeed depending on the gl version.
- GrGLGetStringiProc glGetStringi =
- (GrGLGetStringiProc) glXGetProcAddress(reinterpret_cast<const GLubyte*>("glGetStringi"));
-
- GrGLExtensions extensions;
- if (!extensions.init(kGL_GrGLStandard, glGetString, glGetStringi, glGetIntegerv)) {
+ if (glVer < GR_GL_VER(1,5)) {
+ // We must have array and element_array buffer objects.
return NULL;
}
- if (glVer < GR_GL_VER(1,5)) {
- // We must have array and element_array buffer objects.
+ GrGLExtensions extensions;
+ if (!extensions.init(kGL_GrGLStandard, GetString, GetStringi, GetIntegerv)) {
return NULL;
}
GrGLInterface* interface = SkNEW(GrGLInterface());
GrGLInterface::Functions* functions = &interface->fFunctions;
- functions->fActiveTexture = glActiveTexture;
+ GET_PROC(ActiveTexture);
GET_PROC(AttachShader);
GET_PROC(BindAttribLocation);
GET_PROC(BindBuffer);
- GET_PROC(BindFragDataLocation);
+ if (glVer >= GR_GL_VER(3,0)) {
+ GET_PROC(BindFragDataLocation);
+ }
GET_PROC(BeginQuery);
- functions->fBindTexture = glBindTexture;
- functions->fBlendFunc = glBlendFunc;
+ GET_PROC(BindTexture);
+ GET_PROC(BlendFunc);
if (glVer >= GR_GL_VER(1,4) ||
extensions.has("GL_ARB_imaging") ||
@@ -62,39 +59,39 @@ const GrGLInterface* GrGLCreateNativeInterface() {
GET_PROC(BufferData);
GET_PROC(BufferSubData);
- functions->fClear = glClear;
- functions->fClearColor = glClearColor;
- functions->fClearStencil = glClearStencil;
- functions->fColorMask = glColorMask;
+ GET_PROC(Clear);
+ GET_PROC(ClearColor);
+ GET_PROC(ClearStencil);
+ GET_PROC(ColorMask);
GET_PROC(CompileShader);
- functions->fCompressedTexImage2D = glCompressedTexImage2D;
- functions->fCopyTexSubImage2D = glCopyTexSubImage2D;
+ GET_PROC(CompressedTexImage2D);
+ GET_PROC(CopyTexSubImage2D);
GET_PROC(CreateProgram);
GET_PROC(CreateShader);
- functions->fCullFace = glCullFace;
+ GET_PROC(CullFace);
GET_PROC(DeleteBuffers);
GET_PROC(DeleteProgram);
GET_PROC(DeleteQueries);
GET_PROC(DeleteShader);
- functions->fDeleteTextures = glDeleteTextures;
- functions->fDepthMask = glDepthMask;
- functions->fDisable = glDisable;
+ GET_PROC(DeleteTextures);
+ GET_PROC(DepthMask);
+ GET_PROC(Disable);
GET_PROC(DisableVertexAttribArray);
- functions->fDrawArrays = glDrawArrays;
- functions->fDrawBuffer = glDrawBuffer;
+ GET_PROC(DrawArrays);
+ GET_PROC(DrawBuffer);
GET_PROC(DrawBuffers);
- functions->fDrawElements = glDrawElements;
- functions->fEnable = glEnable;
+ GET_PROC(DrawElements);
+ GET_PROC(Enable);
GET_PROC(EnableVertexAttribArray);
GET_PROC(EndQuery);
- functions->fFinish = glFinish;
- functions->fFlush = glFlush;
- functions->fFrontFace = glFrontFace;
+ GET_PROC(Finish);
+ GET_PROC(Flush);
+ GET_PROC(FrontFace);
GET_PROC(GenBuffers);
GET_PROC(GenerateMipmap);
GET_PROC(GetBufferParameteriv);
- functions->fGetError = glGetError;
- functions->fGetIntegerv = glGetIntegerv;
+ GET_PROC(GetError);
+ GET_PROC(GetIntegerv);
GET_PROC(GetQueryObjectiv);
GET_PROC(GetQueryObjectuiv);
if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) {
@@ -110,39 +107,39 @@ const GrGLInterface* GrGLCreateNativeInterface() {
GET_PROC(GetProgramiv);
GET_PROC(GetShaderInfoLog);
GET_PROC(GetShaderiv);
- functions->fGetString = glGetString;
+ GET_PROC(GetString);
GET_PROC(GetStringi);
- functions->fGetTexLevelParameteriv = glGetTexLevelParameteriv;
+ GET_PROC(GetTexLevelParameteriv);
GET_PROC(GenQueries);
- functions->fGenTextures = glGenTextures;
+ GET_PROC(GenTextures);
GET_PROC(GetUniformLocation);
- functions->fLineWidth = glLineWidth;
+ GET_PROC(LineWidth);
GET_PROC(LinkProgram);
GET_PROC(MapBuffer);
if (extensions.has("GL_EXT_direct_state_access")) {
GET_PROC_SUFFIX(MatrixLoadf, EXT);
GET_PROC_SUFFIX(MatrixLoadIdentity, EXT);
}
- functions->fPixelStorei = glPixelStorei;
- functions->fReadBuffer = glReadBuffer;
- functions->fReadPixels = glReadPixels;
- functions->fScissor = glScissor;
+ GET_PROC(PixelStorei);
+ GET_PROC(ReadBuffer);
+ GET_PROC(ReadPixels);
+ GET_PROC(Scissor);
GET_PROC(ShaderSource);
- functions->fStencilFunc = glStencilFunc;
+ GET_PROC(StencilFunc);
GET_PROC(StencilFuncSeparate);
- functions->fStencilMask = glStencilMask;
+ GET_PROC(StencilMask);
GET_PROC(StencilMaskSeparate);
- functions->fStencilOp = glStencilOp;
+ GET_PROC(StencilOp);
GET_PROC(StencilOpSeparate);
- functions->fTexImage2D = glTexImage2D;
- functions->fTexParameteri = glTexParameteri;
- functions->fTexParameteriv = glTexParameteriv;
+ GET_PROC(TexImage2D);
+ GET_PROC(TexParameteri);
+ GET_PROC(TexParameteriv);
if (glVer >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) {
GET_PROC(TexStorage2D);
} else if (extensions.has("GL_EXT_texture_storage")) {
GET_PROC_SUFFIX(TexStorage2D, EXT);
}
- functions->fTexSubImage2D = glTexSubImage2D;
+ GET_PROC(TexSubImage2D);
GET_PROC(Uniform1f);
GET_PROC(Uniform1i);
GET_PROC(Uniform1fv);
@@ -166,7 +163,7 @@ const GrGLInterface* GrGLCreateNativeInterface() {
GET_PROC(UseProgram);
GET_PROC(VertexAttrib4fv);
GET_PROC(VertexAttribPointer);
- functions->fViewport = glViewport;
+ GET_PROC(Viewport);
GET_PROC(BindFragDataLocationIndexed);
if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) {
« no previous file with comments | « src/gpu/gl/GrGLAssembleInterface.h ('k') | src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698