Bug 910754 - Add a bunch more required OpenGL functions for SkiaGL when using desktop OpenGL r=vlad
authorGeorge Wright <gw@gwright.org.uk>
Fri, 07 Jun 2013 23:11:58 -0400
changeset 169756 b739824ec95ca2cd9e2df3de6a2684f4259f6292
parent 169755 3f5e3a855a3d1afe36142b581637498bb5aeba39
child 169757 5c1a5d05a660601bffb8060255636ce1a7f0437f
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersvlad
bugs910754
milestone30.0a1
Bug 910754 - Add a bunch more required OpenGL functions for SkiaGL when using desktop OpenGL r=vlad
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/gl/GLContextSkia.cpp
gfx/gl/GLContextSymbols.h
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -494,16 +494,29 @@ GLContext::InitWithPrefix(const char *pr
             SymLoadStruct symbols_desktop[] = {
                 { (PRFuncPtr*) &mSymbols.fClearDepth, { "ClearDepth", nullptr } },
                 { (PRFuncPtr*) &mSymbols.fDepthRange, { "DepthRange", nullptr } },
                 { (PRFuncPtr*) &mSymbols.fReadBuffer, { "ReadBuffer", nullptr } },
                 { (PRFuncPtr*) &mSymbols.fMapBuffer, { "MapBuffer", nullptr } },
                 { (PRFuncPtr*) &mSymbols.fUnmapBuffer, { "UnmapBuffer", nullptr } },
                 { (PRFuncPtr*) &mSymbols.fPointParameterf, { "PointParameterf", nullptr } },
                 { (PRFuncPtr*) &mSymbols.fDrawBuffer, { "DrawBuffer", nullptr } },
+                    // These functions are only used by Skia/GL in desktop mode.
+                    // Other parts of Gecko should avoid using these
+                    { (PRFuncPtr*) &mSymbols.fDrawBuffers, { "DrawBuffers", nullptr } },
+                    { (PRFuncPtr*) &mSymbols.fClientActiveTexture, { "ClientActiveTexture", nullptr } },
+                    { (PRFuncPtr*) &mSymbols.fDisableClientState, { "DisableClientState", nullptr } },
+                    { (PRFuncPtr*) &mSymbols.fEnableClientState, { "EnableClientState", nullptr } },
+                    { (PRFuncPtr*) &mSymbols.fLoadIdentity, { "LoadIdentity", nullptr } },
+                    { (PRFuncPtr*) &mSymbols.fLoadMatrixf, { "LoadMatrixf", nullptr } },
+                    { (PRFuncPtr*) &mSymbols.fMatrixMode, { "MatrixMode", nullptr } },
+                    { (PRFuncPtr*) &mSymbols.fTexGeni, { "TexGeni", nullptr } },
+                    { (PRFuncPtr*) &mSymbols.fTexGenf, { "TexGenf", nullptr } },
+                    { (PRFuncPtr*) &mSymbols.fTexGenfv, { "TexGenfv", nullptr } },
+                    { (PRFuncPtr*) &mSymbols.fVertexPointer, { "VertexPointer", nullptr } },
                 { nullptr, { nullptr } },
             };
 
             if (!LoadSymbols(&symbols_desktop[0], trygl, prefix)) {
                 NS_ERROR("Desktop symbols failed to load.");
                 mInitialized = false;
             }
         }
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -857,16 +857,22 @@ public:
     }
 
     void fClearStencil(GLint s) {
         BEFORE_GL_CALL;
         mSymbols.fClearStencil(s);
         AFTER_GL_CALL;
     }
 
+    void fClientActiveTexture(GLenum texture) {
+        BEFORE_GL_CALL;
+        mSymbols.fClientActiveTexture(texture);
+        AFTER_GL_CALL;
+    }
+
     void fColorMask(realGLboolean red, realGLboolean green, realGLboolean blue, realGLboolean alpha) {
         BEFORE_GL_CALL;
         mSymbols.fColorMask(red, green, blue, alpha);
         AFTER_GL_CALL;
     }
 
     void fCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *pixels) {
         BEFORE_GL_CALL;
@@ -949,16 +955,22 @@ public:
     }
 
     void fDisable(GLenum capability) {
         BEFORE_GL_CALL;
         mSymbols.fDisable(capability);
         AFTER_GL_CALL;
     }
 
+    void fDisableClientState(GLenum capability) {
+        BEFORE_GL_CALL;
+        mSymbols.fDisableClientState(capability);
+        AFTER_GL_CALL;
+    }
+
     void fDisableVertexAttribArray(GLuint index) {
         BEFORE_GL_CALL;
         mSymbols.fDisableVertexAttribArray(index);
         AFTER_GL_CALL;
     }
 
     void fDrawBuffer(GLenum mode) {
         BEFORE_GL_CALL;
@@ -993,16 +1005,22 @@ public:
     }
 
     void fEnable(GLenum capability) {
         BEFORE_GL_CALL;
         mSymbols.fEnable(capability);
         AFTER_GL_CALL;
     }
 
+    void fEnableClientState(GLenum capability) {
+        BEFORE_GL_CALL;
+        mSymbols.fEnableClientState(capability);
+        AFTER_GL_CALL;
+    }
+
     void fEnableVertexAttribArray(GLuint index) {
         BEFORE_GL_CALL;
         mSymbols.fEnableVertexAttribArray(index);
         AFTER_GL_CALL;
     }
 
     void fEndQuery(GLenum target) {
         BEFORE_GL_CALL;
@@ -1338,16 +1356,34 @@ public:
 
     void fObjectPtrLabel(const GLvoid* ptr, GLsizei length, const GLchar* label) {
         BEFORE_GL_CALL;
         ASSERT_SYMBOL_PRESENT(fObjectPtrLabel);
         mSymbols.fObjectPtrLabel(ptr, length, label);
         AFTER_GL_CALL;
     }
 
+    void fLoadIdentity() {
+        BEFORE_GL_CALL;
+        mSymbols.fLoadIdentity();
+        AFTER_GL_CALL;
+    }
+
+    void fLoadMatrixf(const GLfloat *matrix) {
+        BEFORE_GL_CALL;
+        mSymbols.fLoadMatrixf(matrix);
+        AFTER_GL_CALL;
+    }
+
+    void fMatrixMode(GLenum mode) {
+        BEFORE_GL_CALL;
+        mSymbols.fMatrixMode(mode);
+        AFTER_GL_CALL;
+    }
+
     void fPixelStorei(GLenum pname, GLint param) {
         BEFORE_GL_CALL;
         mSymbols.fPixelStorei(pname, param);
         AFTER_GL_CALL;
     }
 
     void fTextureRangeAPPLE(GLenum target, GLsizei length, GLvoid *pointer) {
         BEFORE_GL_CALL;
@@ -1465,16 +1501,34 @@ public:
     }
 
     void fStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) {
         BEFORE_GL_CALL;
         mSymbols.fStencilOpSeparate(face, sfail, dpfail, dppass);
         AFTER_GL_CALL;
     }
 
+    void fTexGeni(GLenum coord, GLenum pname, GLint param) {
+        BEFORE_GL_CALL;
+        mSymbols.fTexGeni(coord, pname, param);
+        AFTER_GL_CALL;
+    }
+
+    void fTexGenf(GLenum coord, GLenum pname, GLfloat param) {
+        BEFORE_GL_CALL;
+        mSymbols.fTexGenf(coord, pname, param);
+        AFTER_GL_CALL;
+    }
+
+    void fTexGenfv(GLenum coord, GLenum pname, const GLfloat *params) {
+        BEFORE_GL_CALL;
+        mSymbols.fTexGenfv(coord, pname, params);
+        AFTER_GL_CALL;
+    }
+
 private:
     void raw_fTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {
         BEFORE_GL_CALL;
         mSymbols.fTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
         AFTER_GL_CALL;
     }
 
 public:
@@ -1671,16 +1725,22 @@ public:
     }
 
     void fVertexAttrib4fv(GLuint index, const GLfloat* v) {
         BEFORE_GL_CALL;
         mSymbols.fVertexAttrib4fv(index, v);
         AFTER_GL_CALL;
     }
 
+    void fVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) {
+        BEFORE_GL_CALL;
+        mSymbols.fVertexPointer(size, type, stride, pointer);
+        AFTER_GL_CALL;
+    }
+
     void fCompileShader(GLuint shader) {
         BEFORE_GL_CALL;
         mSymbols.fCompileShader(shader);
         AFTER_GL_CALL;
     }
 
 private:
     void raw_fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
--- a/gfx/gl/GLContextSkia.cpp
+++ b/gfx/gl/GLContextSkia.cpp
@@ -120,16 +120,22 @@ GrGLvoid glColorMask_mozilla(GrGLboolean
     return sGLContext.get()->fColorMask(red, green, blue, alpha);
 }
 
 GrGLvoid glCompileShader_mozilla(GrGLuint shader)
 {
     return sGLContext.get()->fCompileShader(shader);
 }
 
+GrGLvoid glCopyTexSubImage2D_mozilla(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset,
+                                     GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height)
+{
+    return sGLContext.get()->fCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
+}
+
 GrGLuint glCreateProgram_mozilla(void)
 {
     return sGLContext.get()->fCreateProgram();
 }
 
 GrGLuint glCreateShader_mozilla(GrGLenum type)
 {
     return sGLContext.get()->fCreateShader(type);
@@ -245,16 +251,21 @@ GrGLvoid glGenRenderbuffers_mozilla(GrGL
     return sGLContext.get()->fGenRenderbuffers(n, renderbuffers);
 }
 
 GrGLvoid glGenTextures_mozilla(GrGLsizei n, GrGLuint* textures)
 {
     return sGLContext.get()->fGenTextures(n, textures);
 }
 
+GrGLvoid glGenerateMipmap_mozilla(GrGLenum target)
+{
+    return sGLContext.get()->fGenerateMipmap(target);
+}
+
 GrGLvoid glGetBufferParameteriv_mozilla(GrGLenum target, GrGLenum pname, GrGLint* params)
 {
     return sGLContext.get()->fGetBufferParameteriv(target, pname, params);
 }
 
 GrGLvoid glGetFramebufferAttachmentParameteriv_mozilla(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params)
 {
     return sGLContext.get()->fGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
@@ -705,16 +716,67 @@ GrGLvoid glBindVertexArray_mozilla(GrGLu
 GrGLvoid glDeleteVertexArrays_mozilla(GrGLsizei n, const GrGLuint *arrays) {
     return sGLContext.get()->fDeleteVertexArrays(n, arrays);
 }
 
 GrGLvoid glGenVertexArrays_mozilla(GrGLsizei n, GrGLuint *arrays) {
     return sGLContext.get()->fGenVertexArrays(n, arrays);
 }
 
+// Additional functions required for desktop GL < version 3.2
+
+GrGLvoid glClientActiveTexture_mozilla(GrGLenum texture)
+{
+    return sGLContext.get()->fClientActiveTexture(texture);
+}
+
+GrGLvoid glDisableClientState_mozilla(GrGLenum capability)
+{
+    return sGLContext.get()->fDisableClientState(capability);
+}
+
+GrGLvoid glEnableClientState_mozilla(GrGLenum capability)
+{
+    return sGLContext.get()->fEnableClientState(capability);
+}
+
+GrGLvoid glLoadMatrixf_mozilla(const GLfloat* matrix)
+{
+    return sGLContext.get()->fLoadMatrixf(matrix);
+}
+
+GrGLvoid glLoadIdentity_mozilla()
+{
+    return sGLContext.get()->fLoadIdentity();
+}
+
+GrGLvoid glMatrixMode_mozilla(GrGLenum mode)
+{
+    return sGLContext.get()->fMatrixMode(mode);
+}
+
+GrGLvoid glTexGeni_mozilla(GrGLenum coord, GrGLenum pname, GrGLint param)
+{
+    return sGLContext.get()->fTexGeni(coord, pname, param);
+}
+
+GrGLvoid glTexGenf_mozilla(GrGLenum coord, GrGLenum pname, GrGLfloat param)
+{
+    return sGLContext.get()->fTexGenf(coord, pname, param);
+}
+
+GrGLvoid glTexGenfv_mozilla(GrGLenum coord, GrGLenum pname, const GrGLfloat* param)
+{
+    return sGLContext.get()->fTexGenfv(coord, pname, param);
+}
+
+GrGLvoid glVertexPointer_mozilla(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer)
+{
+    return sGLContext.get()->fVertexPointer(size, type, stride, pointer);
+}
 
 } // extern "C"
 
 GrGLInterface* CreateGrGLInterfaceFromGLContext(GLContext* context)
 {
     GrGLInterface* i = new GrGLInterface();
     i->fCallback = EnsureGLContext;
     i->fCallbackData = 0; // must be later initialized to be a valid DrawTargetSkia* pointer
@@ -732,16 +794,17 @@ GrGLInterface* CreateGrGLInterfaceFromGL
     i->fBufferData = glBufferData_mozilla;
     i->fBufferSubData = glBufferSubData_mozilla;
     i->fCheckFramebufferStatus = glCheckFramebufferStatus_mozilla;
     i->fClear = glClear_mozilla;
     i->fClearColor = glClearColor_mozilla;
     i->fClearStencil = glClearStencil_mozilla;
     i->fColorMask = glColorMask_mozilla;
     i->fCompileShader = glCompileShader_mozilla;
+    i->fCopyTexSubImage2D = glCopyTexSubImage2D_mozilla;
     i->fCreateProgram = glCreateProgram_mozilla;
     i->fCreateShader = glCreateShader_mozilla;
     i->fCullFace = glCullFace_mozilla;
     i->fDeleteBuffers = glDeleteBuffers_mozilla;
     i->fDeleteFramebuffers = glDeleteFramebuffers_mozilla;
     i->fDeleteProgram = glDeleteProgram_mozilla;
     i->fDeleteRenderbuffers = glDeleteRenderbuffers_mozilla;
     i->fDeleteShader = glDeleteShader_mozilla;
@@ -758,16 +821,17 @@ GrGLInterface* CreateGrGLInterfaceFromGL
     i->fFramebufferRenderbuffer = glFramebufferRenderbuffer_mozilla;
     i->fFramebufferTexture2D = glFramebufferTexture2D_mozilla;
     i->fFrontFace = glFrontFace_mozilla;
     i->fGenBuffers = glGenBuffers_mozilla;
     i->fGenFramebuffers = glGenFramebuffers_mozilla;
     i->fGenRenderbuffers = glGenRenderbuffers_mozilla;
     i->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv_mozilla;
     i->fGenTextures = glGenTextures_mozilla;
+    i->fGenerateMipmap = glGenerateMipmap_mozilla;
     i->fGetBufferParameteriv = glGetBufferParameteriv_mozilla;
     i->fGetError = glGetError_mozilla;
     i->fGetIntegerv = glGetIntegerv_mozilla;
     i->fGetProgramInfoLog = glGetProgramInfoLog_mozilla;
     i->fGetProgramiv = glGetProgramiv_mozilla;
     i->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv_mozilla;
     i->fGetShaderInfoLog = glGetShaderInfoLog_mozilla;
     i->fGetShaderiv = glGetShaderiv_mozilla;
@@ -844,16 +908,28 @@ GrGLInterface* CreateGrGLInterfaceFromGL
     i->fEndQuery = glEndQuery_mozilla;
     i->fGetQueryiv = glGetQueryiv_mozilla;
     i->fGetQueryObjectiv = glGetQueryObjectiv_mozilla;
     i->fGetQueryObjectuiv = glGetQueryObjectuiv_mozilla;
 
     // Desktop OpenGL > 2.0
     i->fDrawBuffers = glDrawBuffers_mozilla;
 
+    // Desktop OpenGL < 3.2 (which we pretend to be)
+    i->fClientActiveTexture = glClientActiveTexture_mozilla;
+    i->fDisableClientState = glDisableClientState_mozilla;
+    i->fEnableClientState = glEnableClientState_mozilla;
+    i->fLoadIdentity = glLoadIdentity_mozilla;
+    i->fLoadMatrixf = glLoadMatrixf_mozilla;
+    i->fMatrixMode = glMatrixMode_mozilla;
+    i->fTexGenf = glTexGenf_mozilla;
+    i->fTexGenfv = glTexGenfv_mozilla;
+    i->fTexGeni = glTexGeni_mozilla;
+    i->fVertexPointer = glVertexPointer_mozilla;
+
     // We support both desktop GL and GLES2
     if (context->IsGLES2()) {
         i->fBindingsExported = kES2_GrGLBinding;
     } else {
         i->fBindingsExported = kDesktop_GrGLBinding;
     }
 
     return i;
--- a/gfx/gl/GLContextSymbols.h
+++ b/gfx/gl/GLContextSymbols.h
@@ -308,16 +308,41 @@ struct GLContextSymbols
     PFNGLISFRAMEBUFFER fIsFramebuffer;
     typedef realGLboolean (GLAPIENTRY * PFNGLISRENDERBUFFER) (GLuint renderbuffer);
     PFNGLISRENDERBUFFER fIsRenderbuffer;
     typedef realGLboolean (GLAPIENTRY * PFNGLISVERTEXARRAY) (GLuint array);
     PFNGLISVERTEXARRAY fIsVertexArray;
     typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGE) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
     PFNGLRENDERBUFFERSTORAGE fRenderbufferStorage;
 
+        // These functions are only used by Skia/GL in desktop mode.
+        // Other parts of Gecko should avoid using these
+        typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTURE) (GLenum texture);
+        PFNGLCLIENTACTIVETEXTURE fClientActiveTexture;
+        typedef void (GLAPIENTRY * PFNDISABLECLIENTSTATE) (GLenum capability);
+        PFNDISABLECLIENTSTATE fDisableClientState;
+        typedef void (GLAPIENTRY * PFNENABLECLIENTSTATE) (GLenum capability);
+        PFNENABLECLIENTSTATE fEnableClientState;
+        typedef void (GLAPIENTRY * PFNLOADIDENTITY) (void);
+        PFNLOADIDENTITY fLoadIdentity;
+        typedef void (GLAPIENTRY * PFNLOADMATRIXD) (const GLdouble* matrix);
+        PFNLOADMATRIXD fLoadMatrixd;
+        typedef void (GLAPIENTRY * PFNLOADMATRIXF) (const GLfloat* matrix);
+        PFNLOADMATRIXF fLoadMatrixf;
+        typedef void (GLAPIENTRY * PFNMATRIXMODE) (GLenum mode);
+        PFNMATRIXMODE fMatrixMode;
+        typedef void (GLAPIENTRY * PFNTEXGENI) (GLenum coord, GLenum pname, GLint param);
+        PFNTEXGENI fTexGeni;
+        typedef void (GLAPIENTRY * PFNTEXGENF) (GLenum coord, GLenum pname, GLfloat param);
+        PFNTEXGENF fTexGenf;
+        typedef void (GLAPIENTRY * PFNTEXGENFV) (GLenum coord, GLenum pname, const GLfloat* param);
+        PFNTEXGENFV fTexGenfv;
+        typedef void (GLAPIENTRY * PFNVERTEXPOINTER) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+        PFNVERTEXPOINTER fVertexPointer;
+
     typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFER) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
     PFNGLBLITFRAMEBUFFER fBlitFramebuffer;
     typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLE) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height);
     PFNGLRENDERBUFFERSTORAGEMULTISAMPLE fRenderbufferStorageMultisample;
 
 
     /* These are different between GLES2 and desktop GL; we hide those differences, use the GL
      * names, but the most limited data type.