From c08c73682ae342e3e1e0fb9dc3afb99b1279cbf6 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Tue, 12 Oct 2010 17:01:59 -0400 Subject: [PATCH] Bug 597881 - OpenGL debug mode - r=vladimir --- gfx/thebes/GLContext.cpp | 296 ++--- gfx/thebes/GLContext.h | 1400 +++++++++++++++++------- gfx/thebes/GLContextProviderCGL.mm | 2 +- gfx/thebes/GLContextProviderEGL.cpp | 2 +- gfx/thebes/GLContextProviderGLX.cpp | 2 +- gfx/thebes/GLContextProviderOSMesa.cpp | 2 +- gfx/thebes/GLContextProviderWGL.cpp | 2 +- gfx/thebes/GLContextSymbols.h | 371 +++++++ gfx/thebes/Makefile.in | 1 + widget/src/gtk2/nsWindow.cpp | 1 - 10 files changed, 1523 insertions(+), 556 deletions(-) create mode 100644 gfx/thebes/GLContextSymbols.h diff --git a/gfx/thebes/GLContext.cpp b/gfx/thebes/GLContext.cpp index 91719b935431..41cafe691913 100644 --- a/gfx/thebes/GLContext.cpp +++ b/gfx/thebes/GLContext.cpp @@ -43,6 +43,7 @@ #include #include "prlink.h" +#include "prenv.h" #include "nsThreadUtils.h" @@ -53,6 +54,11 @@ namespace mozilla { namespace gl { +#ifdef DEBUG +// see comment near declaration in GLContext.h. Should be thread-local. +GLContext* GLContext::sCurrentGLContext = nsnull; +#endif + // define this here since it's global to GLContextProvider, not any // specific implementation const ContextFormat ContextFormat::BasicRGBA32Format(ContextFormat::BasicRGBA32); @@ -161,149 +167,149 @@ GLContext::InitWithPrefix(const char *prefix, PRBool trygl) } SymLoadStruct symbols[] = { - { (PRFuncPtr*) &fActiveTexture, { "ActiveTexture", "ActiveTextureARB", NULL } }, - { (PRFuncPtr*) &fAttachShader, { "AttachShader", "AttachShaderARB", NULL } }, - { (PRFuncPtr*) &fBindAttribLocation, { "BindAttribLocation", "BindAttribLocationARB", NULL } }, - { (PRFuncPtr*) &fBindBuffer, { "BindBuffer", "BindBufferARB", NULL } }, - { (PRFuncPtr*) &fBindTexture, { "BindTexture", "BindTextureARB", NULL } }, - { (PRFuncPtr*) &fBlendColor, { "BlendColor", NULL } }, - { (PRFuncPtr*) &fBlendEquation, { "BlendEquation", NULL } }, - { (PRFuncPtr*) &fBlendEquationSeparate, { "BlendEquationSeparate", "BlendEquationSeparateEXT", NULL } }, - { (PRFuncPtr*) &fBlendFunc, { "BlendFunc", NULL } }, - { (PRFuncPtr*) &fBlendFuncSeparate, { "BlendFuncSeparate", "BlendFuncSeparateEXT", NULL } }, - { (PRFuncPtr*) &fBufferData, { "BufferData", NULL } }, - { (PRFuncPtr*) &fBufferSubData, { "BufferSubData", NULL } }, - { (PRFuncPtr*) &fClear, { "Clear", NULL } }, - { (PRFuncPtr*) &fClearColor, { "ClearColor", NULL } }, - { (PRFuncPtr*) &fClearStencil, { "ClearStencil", NULL } }, - { (PRFuncPtr*) &fColorMask, { "ColorMask", NULL } }, - { (PRFuncPtr*) &fCullFace, { "CullFace", NULL } }, - { (PRFuncPtr*) &fDetachShader, { "DetachShader", "DetachShaderARB", NULL } }, - { (PRFuncPtr*) &fDepthFunc, { "DepthFunc", NULL } }, - { (PRFuncPtr*) &fDepthMask, { "DepthMask", NULL } }, - { (PRFuncPtr*) &fDisable, { "Disable", NULL } }, - { (PRFuncPtr*) &fDisableVertexAttribArray, { "DisableVertexAttribArray", "DisableVertexAttribArrayARB", NULL } }, - { (PRFuncPtr*) &fDrawArrays, { "DrawArrays", NULL } }, - { (PRFuncPtr*) &fDrawElements, { "DrawElements", NULL } }, - { (PRFuncPtr*) &fEnable, { "Enable", NULL } }, - { (PRFuncPtr*) &fEnableVertexAttribArray, { "EnableVertexAttribArray", "EnableVertexAttribArrayARB", NULL } }, - { (PRFuncPtr*) &fFinish, { "Finish", NULL } }, - { (PRFuncPtr*) &fFlush, { "Flush", NULL } }, - { (PRFuncPtr*) &fFrontFace, { "FrontFace", NULL } }, - { (PRFuncPtr*) &fGetActiveAttrib, { "GetActiveAttrib", "GetActiveAttribARB", NULL } }, - { (PRFuncPtr*) &fGetActiveUniform, { "GetActiveUniform", "GetActiveUniformARB", NULL } }, - { (PRFuncPtr*) &fGetAttachedShaders, { "GetAttachedShaders", "GetAttachedShadersARB", NULL } }, - { (PRFuncPtr*) &fGetAttribLocation, { "GetAttribLocation", "GetAttribLocationARB", NULL } }, - { (PRFuncPtr*) &fGetIntegerv, { "GetIntegerv", NULL } }, - { (PRFuncPtr*) &fGetFloatv, { "GetFloatv", NULL } }, - { (PRFuncPtr*) &fGetBooleanv, { "GetBooleanv", NULL } }, - { (PRFuncPtr*) &fGetBufferParameteriv, { "GetBufferParameteriv", "GetBufferParameterivARB", NULL } }, - { (PRFuncPtr*) &fGetError, { "GetError", NULL } }, - { (PRFuncPtr*) &fGetProgramiv, { "GetProgramiv", "GetProgramivARB", NULL } }, - { (PRFuncPtr*) &fGetProgramInfoLog, { "GetProgramInfoLog", "GetProgramInfoLogARB", NULL } }, - { (PRFuncPtr*) &fTexParameteri, { "TexParameteri", NULL } }, - { (PRFuncPtr*) &fTexParameterf, { "TexParameterf", NULL } }, - { (PRFuncPtr*) &fGetString, { "GetString", NULL } }, - { (PRFuncPtr*) &fGetTexParameterfv, { "GetTexParameterfv", NULL } }, - { (PRFuncPtr*) &fGetTexParameteriv, { "GetTexParameteriv", NULL } }, - { (PRFuncPtr*) &fGetUniformfv, { "GetUniformfv", "GetUniformfvARB", NULL } }, - { (PRFuncPtr*) &fGetUniformiv, { "GetUniformiv", "GetUniformivARB", NULL } }, - { (PRFuncPtr*) &fGetUniformLocation, { "GetUniformLocation", "GetUniformLocationARB", NULL } }, - { (PRFuncPtr*) &fGetVertexAttribfv, { "GetVertexAttribfv", "GetVertexAttribfvARB", NULL } }, - { (PRFuncPtr*) &fGetVertexAttribiv, { "GetVertexAttribiv", "GetVertexAttribivARB", NULL } }, - { (PRFuncPtr*) &fHint, { "Hint", NULL } }, - { (PRFuncPtr*) &fIsBuffer, { "IsBuffer", "IsBufferARB", NULL } }, - { (PRFuncPtr*) &fIsEnabled, { "IsEnabled", NULL } }, - { (PRFuncPtr*) &fIsProgram, { "IsProgram", "IsProgramARB", NULL } }, - { (PRFuncPtr*) &fIsShader, { "IsShader", "IsShaderARB", NULL } }, - { (PRFuncPtr*) &fIsTexture, { "IsTexture", "IsTextureARB", NULL } }, - { (PRFuncPtr*) &fLineWidth, { "LineWidth", NULL } }, - { (PRFuncPtr*) &fLinkProgram, { "LinkProgram", "LinkProgramARB", NULL } }, - { (PRFuncPtr*) &fPixelStorei, { "PixelStorei", NULL } }, - { (PRFuncPtr*) &fPolygonOffset, { "PolygonOffset", NULL } }, - { (PRFuncPtr*) &fReadPixels, { "ReadPixels", NULL } }, - { (PRFuncPtr*) &fSampleCoverage, { "SampleCoverage", NULL } }, - { (PRFuncPtr*) &priv_fScissor, { "Scissor", NULL } }, - { (PRFuncPtr*) &fStencilFunc, { "StencilFunc", NULL } }, - { (PRFuncPtr*) &fStencilFuncSeparate, { "StencilFuncSeparate", "StencilFuncSeparateEXT", NULL } }, - { (PRFuncPtr*) &fStencilMask, { "StencilMask", NULL } }, - { (PRFuncPtr*) &fStencilMaskSeparate, { "StencilMaskSeparate", "StencilMaskSeparateEXT", NULL } }, - { (PRFuncPtr*) &fStencilOp, { "StencilOp", NULL } }, - { (PRFuncPtr*) &fStencilOpSeparate, { "StencilOpSeparate", "StencilOpSeparateEXT", NULL } }, - { (PRFuncPtr*) &fTexImage2D, { "TexImage2D", NULL } }, - { (PRFuncPtr*) &fTexSubImage2D, { "TexSubImage2D", NULL } }, - { (PRFuncPtr*) &fUniform1f, { "Uniform1f", NULL } }, - { (PRFuncPtr*) &fUniform1fv, { "Uniform1fv", NULL } }, - { (PRFuncPtr*) &fUniform1i, { "Uniform1i", NULL } }, - { (PRFuncPtr*) &fUniform1iv, { "Uniform1iv", NULL } }, - { (PRFuncPtr*) &fUniform2f, { "Uniform2f", NULL } }, - { (PRFuncPtr*) &fUniform2fv, { "Uniform2fv", NULL } }, - { (PRFuncPtr*) &fUniform2i, { "Uniform2i", NULL } }, - { (PRFuncPtr*) &fUniform2iv, { "Uniform2iv", NULL } }, - { (PRFuncPtr*) &fUniform3f, { "Uniform3f", NULL } }, - { (PRFuncPtr*) &fUniform3fv, { "Uniform3fv", NULL } }, - { (PRFuncPtr*) &fUniform3i, { "Uniform3i", NULL } }, - { (PRFuncPtr*) &fUniform3iv, { "Uniform3iv", NULL } }, - { (PRFuncPtr*) &fUniform4f, { "Uniform4f", NULL } }, - { (PRFuncPtr*) &fUniform4fv, { "Uniform4fv", NULL } }, - { (PRFuncPtr*) &fUniform4i, { "Uniform4i", NULL } }, - { (PRFuncPtr*) &fUniform4iv, { "Uniform4iv", NULL } }, - { (PRFuncPtr*) &fUniformMatrix2fv, { "UniformMatrix2fv", NULL } }, - { (PRFuncPtr*) &fUniformMatrix3fv, { "UniformMatrix3fv", NULL } }, - { (PRFuncPtr*) &fUniformMatrix4fv, { "UniformMatrix4fv", NULL } }, - { (PRFuncPtr*) &fUseProgram, { "UseProgram", NULL } }, - { (PRFuncPtr*) &fValidateProgram, { "ValidateProgram", NULL } }, - { (PRFuncPtr*) &fVertexAttribPointer, { "VertexAttribPointer", NULL } }, - { (PRFuncPtr*) &fVertexAttrib1f, { "VertexAttrib1f", NULL } }, - { (PRFuncPtr*) &fVertexAttrib2f, { "VertexAttrib2f", NULL } }, - { (PRFuncPtr*) &fVertexAttrib3f, { "VertexAttrib3f", NULL } }, - { (PRFuncPtr*) &fVertexAttrib4f, { "VertexAttrib4f", NULL } }, - { (PRFuncPtr*) &fVertexAttrib1fv, { "VertexAttrib1fv", NULL } }, - { (PRFuncPtr*) &fVertexAttrib2fv, { "VertexAttrib2fv", NULL } }, - { (PRFuncPtr*) &fVertexAttrib3fv, { "VertexAttrib3fv", NULL } }, - { (PRFuncPtr*) &fVertexAttrib4fv, { "VertexAttrib4fv", NULL } }, - { (PRFuncPtr*) &priv_fViewport, { "Viewport", NULL } }, - { (PRFuncPtr*) &fCompileShader, { "CompileShader", NULL } }, - { (PRFuncPtr*) &fCopyTexImage2D, { "CopyTexImage2D", NULL } }, - { (PRFuncPtr*) &fCopyTexSubImage2D, { "CopyTexSubImage2D", NULL } }, - { (PRFuncPtr*) &fGetShaderiv, { "GetShaderiv", NULL } }, - { (PRFuncPtr*) &fGetShaderInfoLog, { "GetShaderInfoLog", NULL } }, - { (PRFuncPtr*) &fGetShaderSource, { "GetShaderSource", NULL } }, - { (PRFuncPtr*) &fShaderSource, { "ShaderSource", NULL } }, - { (PRFuncPtr*) &fVertexAttribPointer, { "VertexAttribPointer", NULL } }, - { (PRFuncPtr*) &fBindFramebuffer, { "BindFramebuffer", "BindFramebufferEXT", NULL } }, - { (PRFuncPtr*) &fBindRenderbuffer, { "BindRenderbuffer", "BindRenderbufferEXT", NULL } }, - { (PRFuncPtr*) &fCheckFramebufferStatus, { "CheckFramebufferStatus", "CheckFramebufferStatusEXT", NULL } }, - { (PRFuncPtr*) &fFramebufferRenderbuffer, { "FramebufferRenderbuffer", "FramebufferRenderbufferEXT", NULL } }, - { (PRFuncPtr*) &fFramebufferTexture2D, { "FramebufferTexture2D", "FramebufferTexture2DEXT", NULL } }, - { (PRFuncPtr*) &fGenerateMipmap, { "GenerateMipmap", "GenerateMipmapEXT", NULL } }, - { (PRFuncPtr*) &fGetFramebufferAttachmentParameteriv, { "GetFramebufferAttachmentParameteriv", "GetFramebufferAttachmentParameterivEXT", NULL } }, - { (PRFuncPtr*) &fGetRenderbufferParameteriv, { "GetRenderbufferParameteriv", "GetRenderbufferParameterivEXT", NULL } }, - { (PRFuncPtr*) &fIsFramebuffer, { "IsFramebuffer", "IsFramebufferEXT", NULL } }, - { (PRFuncPtr*) &fIsRenderbuffer, { "IsRenderbuffer", "IsRenderbufferEXT", NULL } }, - { (PRFuncPtr*) &fRenderbufferStorage, { "RenderbufferStorage", "RenderbufferStorageEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fActiveTexture, { "ActiveTexture", "ActiveTextureARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fAttachShader, { "AttachShader", "AttachShaderARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fBindAttribLocation, { "BindAttribLocation", "BindAttribLocationARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fBindBuffer, { "BindBuffer", "BindBufferARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fBindTexture, { "BindTexture", "BindTextureARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fBlendColor, { "BlendColor", NULL } }, + { (PRFuncPtr*) &mSymbols.fBlendEquation, { "BlendEquation", NULL } }, + { (PRFuncPtr*) &mSymbols.fBlendEquationSeparate, { "BlendEquationSeparate", "BlendEquationSeparateEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fBlendFunc, { "BlendFunc", NULL } }, + { (PRFuncPtr*) &mSymbols.fBlendFuncSeparate, { "BlendFuncSeparate", "BlendFuncSeparateEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fBufferData, { "BufferData", NULL } }, + { (PRFuncPtr*) &mSymbols.fBufferSubData, { "BufferSubData", NULL } }, + { (PRFuncPtr*) &mSymbols.fClear, { "Clear", NULL } }, + { (PRFuncPtr*) &mSymbols.fClearColor, { "ClearColor", NULL } }, + { (PRFuncPtr*) &mSymbols.fClearStencil, { "ClearStencil", NULL } }, + { (PRFuncPtr*) &mSymbols.fColorMask, { "ColorMask", NULL } }, + { (PRFuncPtr*) &mSymbols.fCullFace, { "CullFace", NULL } }, + { (PRFuncPtr*) &mSymbols.fDetachShader, { "DetachShader", "DetachShaderARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fDepthFunc, { "DepthFunc", NULL } }, + { (PRFuncPtr*) &mSymbols.fDepthMask, { "DepthMask", NULL } }, + { (PRFuncPtr*) &mSymbols.fDisable, { "Disable", NULL } }, + { (PRFuncPtr*) &mSymbols.fDisableVertexAttribArray, { "DisableVertexAttribArray", "DisableVertexAttribArrayARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fDrawArrays, { "DrawArrays", NULL } }, + { (PRFuncPtr*) &mSymbols.fDrawElements, { "DrawElements", NULL } }, + { (PRFuncPtr*) &mSymbols.fEnable, { "Enable", NULL } }, + { (PRFuncPtr*) &mSymbols.fEnableVertexAttribArray, { "EnableVertexAttribArray", "EnableVertexAttribArrayARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fFinish, { "Finish", NULL } }, + { (PRFuncPtr*) &mSymbols.fFlush, { "Flush", NULL } }, + { (PRFuncPtr*) &mSymbols.fFrontFace, { "FrontFace", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetActiveAttrib, { "GetActiveAttrib", "GetActiveAttribARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetActiveUniform, { "GetActiveUniform", "GetActiveUniformARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetAttachedShaders, { "GetAttachedShaders", "GetAttachedShadersARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetAttribLocation, { "GetAttribLocation", "GetAttribLocationARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetIntegerv, { "GetIntegerv", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetFloatv, { "GetFloatv", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetBooleanv, { "GetBooleanv", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetBufferParameteriv, { "GetBufferParameteriv", "GetBufferParameterivARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetError, { "GetError", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetProgramiv, { "GetProgramiv", "GetProgramivARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetProgramInfoLog, { "GetProgramInfoLog", "GetProgramInfoLogARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fTexParameteri, { "TexParameteri", NULL } }, + { (PRFuncPtr*) &mSymbols.fTexParameterf, { "TexParameterf", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetString, { "GetString", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetTexParameterfv, { "GetTexParameterfv", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetTexParameteriv, { "GetTexParameteriv", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetUniformfv, { "GetUniformfv", "GetUniformfvARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetUniformiv, { "GetUniformiv", "GetUniformivARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetUniformLocation, { "GetUniformLocation", "GetUniformLocationARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetVertexAttribfv, { "GetVertexAttribfv", "GetVertexAttribfvARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetVertexAttribiv, { "GetVertexAttribiv", "GetVertexAttribivARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fHint, { "Hint", NULL } }, + { (PRFuncPtr*) &mSymbols.fIsBuffer, { "IsBuffer", "IsBufferARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fIsEnabled, { "IsEnabled", NULL } }, + { (PRFuncPtr*) &mSymbols.fIsProgram, { "IsProgram", "IsProgramARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fIsShader, { "IsShader", "IsShaderARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fIsTexture, { "IsTexture", "IsTextureARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fLineWidth, { "LineWidth", NULL } }, + { (PRFuncPtr*) &mSymbols.fLinkProgram, { "LinkProgram", "LinkProgramARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fPixelStorei, { "PixelStorei", NULL } }, + { (PRFuncPtr*) &mSymbols.fPolygonOffset, { "PolygonOffset", NULL } }, + { (PRFuncPtr*) &mSymbols.fReadPixels, { "ReadPixels", NULL } }, + { (PRFuncPtr*) &mSymbols.fSampleCoverage, { "SampleCoverage", NULL } }, + { (PRFuncPtr*) &mSymbols.fScissor, { "Scissor", NULL } }, + { (PRFuncPtr*) &mSymbols.fStencilFunc, { "StencilFunc", NULL } }, + { (PRFuncPtr*) &mSymbols.fStencilFuncSeparate, { "StencilFuncSeparate", "StencilFuncSeparateEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fStencilMask, { "StencilMask", NULL } }, + { (PRFuncPtr*) &mSymbols.fStencilMaskSeparate, { "StencilMaskSeparate", "StencilMaskSeparateEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fStencilOp, { "StencilOp", NULL } }, + { (PRFuncPtr*) &mSymbols.fStencilOpSeparate, { "StencilOpSeparate", "StencilOpSeparateEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fTexImage2D, { "TexImage2D", NULL } }, + { (PRFuncPtr*) &mSymbols.fTexSubImage2D, { "TexSubImage2D", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform1f, { "Uniform1f", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform1fv, { "Uniform1fv", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform1i, { "Uniform1i", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform1iv, { "Uniform1iv", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform2f, { "Uniform2f", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform2fv, { "Uniform2fv", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform2i, { "Uniform2i", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform2iv, { "Uniform2iv", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform3f, { "Uniform3f", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform3fv, { "Uniform3fv", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform3i, { "Uniform3i", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform3iv, { "Uniform3iv", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform4f, { "Uniform4f", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform4fv, { "Uniform4fv", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform4i, { "Uniform4i", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniform4iv, { "Uniform4iv", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniformMatrix2fv, { "UniformMatrix2fv", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniformMatrix3fv, { "UniformMatrix3fv", NULL } }, + { (PRFuncPtr*) &mSymbols.fUniformMatrix4fv, { "UniformMatrix4fv", NULL } }, + { (PRFuncPtr*) &mSymbols.fUseProgram, { "UseProgram", NULL } }, + { (PRFuncPtr*) &mSymbols.fValidateProgram, { "ValidateProgram", NULL } }, + { (PRFuncPtr*) &mSymbols.fVertexAttribPointer, { "VertexAttribPointer", NULL } }, + { (PRFuncPtr*) &mSymbols.fVertexAttrib1f, { "VertexAttrib1f", NULL } }, + { (PRFuncPtr*) &mSymbols.fVertexAttrib2f, { "VertexAttrib2f", NULL } }, + { (PRFuncPtr*) &mSymbols.fVertexAttrib3f, { "VertexAttrib3f", NULL } }, + { (PRFuncPtr*) &mSymbols.fVertexAttrib4f, { "VertexAttrib4f", NULL } }, + { (PRFuncPtr*) &mSymbols.fVertexAttrib1fv, { "VertexAttrib1fv", NULL } }, + { (PRFuncPtr*) &mSymbols.fVertexAttrib2fv, { "VertexAttrib2fv", NULL } }, + { (PRFuncPtr*) &mSymbols.fVertexAttrib3fv, { "VertexAttrib3fv", NULL } }, + { (PRFuncPtr*) &mSymbols.fVertexAttrib4fv, { "VertexAttrib4fv", NULL } }, + { (PRFuncPtr*) &mSymbols.fViewport, { "Viewport", NULL } }, + { (PRFuncPtr*) &mSymbols.fCompileShader, { "CompileShader", NULL } }, + { (PRFuncPtr*) &mSymbols.fCopyTexImage2D, { "CopyTexImage2D", NULL } }, + { (PRFuncPtr*) &mSymbols.fCopyTexSubImage2D, { "CopyTexSubImage2D", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetShaderiv, { "GetShaderiv", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetShaderInfoLog, { "GetShaderInfoLog", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetShaderSource, { "GetShaderSource", NULL } }, + { (PRFuncPtr*) &mSymbols.fShaderSource, { "ShaderSource", NULL } }, + { (PRFuncPtr*) &mSymbols.fVertexAttribPointer, { "VertexAttribPointer", NULL } }, + { (PRFuncPtr*) &mSymbols.fBindFramebuffer, { "BindFramebuffer", "BindFramebufferEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fBindRenderbuffer, { "BindRenderbuffer", "BindRenderbufferEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fCheckFramebufferStatus, { "CheckFramebufferStatus", "CheckFramebufferStatusEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fFramebufferRenderbuffer, { "FramebufferRenderbuffer", "FramebufferRenderbufferEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fFramebufferTexture2D, { "FramebufferTexture2D", "FramebufferTexture2DEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fGenerateMipmap, { "GenerateMipmap", "GenerateMipmapEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetFramebufferAttachmentParameteriv, { "GetFramebufferAttachmentParameteriv", "GetFramebufferAttachmentParameterivEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fGetRenderbufferParameteriv, { "GetRenderbufferParameteriv", "GetRenderbufferParameterivEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fIsFramebuffer, { "IsFramebuffer", "IsFramebufferEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fIsRenderbuffer, { "IsRenderbuffer", "IsRenderbufferEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fRenderbufferStorage, { "RenderbufferStorage", "RenderbufferStorageEXT", NULL } }, - { (PRFuncPtr*) &priv_fGenBuffers, { "GenBuffers", "GenBuffersARB", NULL } }, - { (PRFuncPtr*) &priv_fGenTextures, { "GenTextures", NULL } }, - { (PRFuncPtr*) &priv_fCreateProgram, { "CreateProgram", "CreateProgramARB", NULL } }, - { (PRFuncPtr*) &priv_fCreateShader, { "CreateShader", "CreateShaderARB", NULL } }, - { (PRFuncPtr*) &priv_fGenFramebuffers, { "GenFramebuffers", "GenFramebuffersEXT", NULL } }, - { (PRFuncPtr*) &priv_fGenRenderbuffers, { "GenRenderbuffers", "GenRenderbuffersEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fGenBuffers, { "GenBuffers", "GenBuffersARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fGenTextures, { "GenTextures", NULL } }, + { (PRFuncPtr*) &mSymbols.fCreateProgram, { "CreateProgram", "CreateProgramARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fCreateShader, { "CreateShader", "CreateShaderARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fGenFramebuffers, { "GenFramebuffers", "GenFramebuffersEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fGenRenderbuffers, { "GenRenderbuffers", "GenRenderbuffersEXT", NULL } }, - { (PRFuncPtr*) &priv_fDeleteBuffers, { "DeleteBuffers", "DeleteBuffersARB", NULL } }, - { (PRFuncPtr*) &priv_fDeleteTextures, { "DeleteTextures", "DeleteTexturesARB", NULL } }, - { (PRFuncPtr*) &priv_fDeleteProgram, { "DeleteProgram", "DeleteProgramARB", NULL } }, - { (PRFuncPtr*) &priv_fDeleteShader, { "DeleteShader", "DeleteShaderARB", NULL } }, - { (PRFuncPtr*) &priv_fDeleteFramebuffers, { "DeleteFramebuffers", "DeleteFramebuffersEXT", NULL } }, - { (PRFuncPtr*) &priv_fDeleteRenderbuffers, { "DeleteRenderbuffers", "DeleteRenderbuffersEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fDeleteBuffers, { "DeleteBuffers", "DeleteBuffersARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fDeleteTextures, { "DeleteTextures", "DeleteTexturesARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fDeleteProgram, { "DeleteProgram", "DeleteProgramARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fDeleteShader, { "DeleteShader", "DeleteShaderARB", NULL } }, + { (PRFuncPtr*) &mSymbols.fDeleteFramebuffers, { "DeleteFramebuffers", "DeleteFramebuffersEXT", NULL } }, + { (PRFuncPtr*) &mSymbols.fDeleteRenderbuffers, { "DeleteRenderbuffers", "DeleteRenderbuffersEXT", NULL } }, - { mIsGLES2 ? (PRFuncPtr*) &priv_fClearDepthf : (PRFuncPtr*) &priv_fClearDepth, + { mIsGLES2 ? (PRFuncPtr*) &mSymbols.fClearDepthf : (PRFuncPtr*) &mSymbols.fClearDepth, { mIsGLES2 ? "ClearDepthf" : "ClearDepth", NULL } }, - { mIsGLES2 ? (PRFuncPtr*) &priv_fDepthRangef : (PRFuncPtr*) &priv_fDepthRange, + { mIsGLES2 ? (PRFuncPtr*) &mSymbols.fDepthRangef : (PRFuncPtr*) &mSymbols.fDepthRange, { mIsGLES2 ? "DepthRangef" : "DepthRange", NULL } }, // XXX FIXME -- we shouldn't be using glReadBuffer! - { mIsGLES2 ? (PRFuncPtr*) NULL : (PRFuncPtr*) &fReadBuffer, + { mIsGLES2 ? (PRFuncPtr*) NULL : (PRFuncPtr*) &mSymbols.fReadBuffer, { mIsGLES2 ? NULL : "ReadBuffer", NULL } }, { NULL, { NULL } }, @@ -342,6 +348,20 @@ GLContext::InitWithPrefix(const char *prefix, PRBool trygl) #endif } +#ifdef DEBUG + if (PR_GetEnv("MOZ_GL_DEBUG")) + mDebugMode |= DebugEnabled; + + // enables extra verbose output, informing of the start and finish of every GL call. + // useful e.g. to record information to investigate graphics system crashes/lockups + if (PR_GetEnv("MOZ_GL_DEBUG_VERBOSE")) + mDebugMode |= DebugTrace; + + // aborts on GL error. Can be useful to debug quicker code that is known not to generate any GL error in principle. + if (PR_GetEnv("MOZ_GL_DEBUG_ABORT_ON_ERROR")) + mDebugMode |= DebugAbortOnError; +#endif + return mInitialized; } @@ -842,9 +862,7 @@ GLContext::MarkDestroyed() fDeleteFramebuffers(1, &mBlitFramebuffer); mBlitFramebuffer = 0; - // must be last! casts are so we can get a byte size count - memset(&mFunctionListStartSentinel, 0, - (unsigned char*)&mFunctionListEndSentinel - (unsigned char*)&mFunctionListStartSentinel); + mSymbols.Zero(); } already_AddRefed diff --git a/gfx/thebes/GLContext.h b/gfx/thebes/GLContext.h index 311fbdfab385..e80faefaf827 100644 --- a/gfx/thebes/GLContext.h +++ b/gfx/thebes/GLContext.h @@ -60,15 +60,7 @@ #include "nsHashKeys.h" #include "nsRegion.h" #include "nsAutoPtr.h" - -#ifndef GLAPIENTRY -#ifdef XP_WIN -#define GLAPIENTRY __stdcall -#else -#define GLAPIENTRY -#endif -#define GLAPI -#endif +#include "nsThreadUtils.h" #if defined(MOZ_PLATFORM_MAEMO) || defined(ANDROID) #define USE_GLES2 1 @@ -76,6 +68,8 @@ typedef char realGLboolean; +#include "GLContextSymbols.h" + namespace mozilla { namespace gl { @@ -286,7 +280,8 @@ protected: nsIntRect mUpdateRect; }; -struct THEBES_API ContextFormat { +struct THEBES_API ContextFormat +{ static const ContextFormat BasicRGBA32Format; enum StandardContextFormat { @@ -300,12 +295,10 @@ struct THEBES_API ContextFormat { }; ContextFormat() { - memset(this, 0, sizeof(ContextFormat)); + memset(this, 0, sizeof(this)); } ContextFormat(const StandardContextFormat cf) { - memset(this, 0, sizeof(ContextFormat)); - switch (cf) { case BasicRGBA32: red = green = blue = alpha = 8; @@ -366,6 +359,7 @@ public: mIsGlobalSharedContext(PR_FALSE), mWindowOriginBottomLeft(PR_FALSE), mVendor(-1), + mDebugMode(0), mCreationFormat(aFormat), mSharedContext(aSharedContext), mOffscreenTexture(0), @@ -374,6 +368,9 @@ public: mOffscreenFBO(0), mOffscreenDepthRB(0), mOffscreenStencilRB(0) +#ifdef DEBUG + , mGLError(LOCAL_GL_NO_ERROR) +#endif { mUserData.Init(); } @@ -401,7 +398,16 @@ public: }; virtual GLContextType GetContextType() { return ContextTypeUnknown; } - virtual PRBool MakeCurrent(PRBool aForce = PR_FALSE) = 0; + + virtual PRBool MakeCurrentImpl(PRBool aForce = PR_FALSE) = 0; + + PRBool MakeCurrent(PRBool aForce = PR_FALSE) { +#ifdef DEBUG + sCurrentGLContext = this; +#endif + return MakeCurrentImpl(aForce); + } + virtual PRBool SetupLookupFunction() = 0; virtual void WindowDestroyed() {} @@ -422,7 +428,7 @@ public: PRBool IsDestroyed() { // MarkDestroyed will mark all these as null. - return fUseProgram == nsnull; + return mSymbols.fUseProgram == nsnull; } enum NativeDataType { @@ -714,9 +720,26 @@ protected: int mVendor; + enum { + DebugEnabled = 1 << 0, + DebugTrace = 1 << 1, + DebugAbortOnError = 1 << 2 + }; + + PRUint32 mDebugMode; + ContextFormat mCreationFormat; nsRefPtr mSharedContext; + GLContextSymbols mSymbols; + +#ifdef DEBUG + // this should be thread-local, but that is slightly annoying to implement because on Mac + // we don't have any __thread-like keyword. So for now, MOZ_GL_DEBUG assumes (and asserts) + // that only the main thread is doing OpenGL calls. + static GLContext* sCurrentGLContext; +#endif + void UpdateActualFormat(); ContextFormat mActualFormat; @@ -780,279 +803,115 @@ protected: GLContext* aContext) { return NULL; } - // - // the wrapped functions - // +protected: + nsTArray mViewportStack; + nsTArray mScissorStack; + public: - /* One would think that this would live in some nice - * perl-or-python-or-js script somewhere and would be - * autogenerated; one would be wrong. - */ - // Keep this at the start of the function pointers - void *mFunctionListStartSentinel; - typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture); - PFNGLACTIVETEXTUREPROC fActiveTexture; - typedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); - PFNGLATTACHSHADERPROC fAttachShader; - typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name); - PFNGLBINDATTRIBLOCATIONPROC fBindAttribLocation; - typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); - PFNGLBINDBUFFERPROC fBindBuffer; - typedef void (GLAPIENTRY * PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); - PFNGLBINDTEXTUREPROC fBindTexture; - typedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - PFNGLBLENDCOLORPROC fBlendColor; - typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); - PFNGLBLENDEQUATIONPROC fBlendEquation; - typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum, GLenum); - PFNGLBLENDEQUATIONSEPARATEPROC fBlendEquationSeparate; - typedef void (GLAPIENTRY * PFNGLBLENDFUNCPROC) (GLenum, GLenum); - PFNGLBLENDFUNCPROC fBlendFunc; - typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); - PFNGLBLENDFUNCSEPARATEPROC fBlendFuncSeparate; - typedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); - PFNGLBUFFERDATAPROC fBufferData; - typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); - PFNGLBUFFERSUBDATAPROC fBufferSubData; - typedef void (GLAPIENTRY * PFNGLCLEARPROC) (GLbitfield); - PFNGLCLEARPROC fClear; - typedef void (GLAPIENTRY * PFNGLCLEARCOLORPROC) (GLclampf, GLclampf, GLclampf, GLclampf); - PFNGLCLEARCOLORPROC fClearColor; - typedef void (GLAPIENTRY * PFNGLCLEARSTENCILPROC) (GLint); - PFNGLCLEARSTENCILPROC fClearStencil; - typedef void (GLAPIENTRY * PFNGLCOLORMASKPROC) (realGLboolean red, realGLboolean green, realGLboolean blue, realGLboolean alpha); - PFNGLCOLORMASKPROC fColorMask; - typedef void (GLAPIENTRY * PFNGLCULLFACEPROC) (GLenum mode); - PFNGLCULLFACEPROC fCullFace; - typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); - PFNGLDETACHSHADERPROC fDetachShader; - typedef void (GLAPIENTRY * PFNGLDEPTHFUNCPROC) (GLenum); - PFNGLDEPTHFUNCPROC fDepthFunc; - typedef void (GLAPIENTRY * PFNGLDEPTHMASKPROC) (realGLboolean); - PFNGLDEPTHMASKPROC fDepthMask; - typedef void (GLAPIENTRY * PFNGLDISABLEPROC) (GLenum); - PFNGLDISABLEPROC fDisable; - typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint); - PFNGLDISABLEVERTEXATTRIBARRAYPROC fDisableVertexAttribArray; - typedef void (GLAPIENTRY * PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); - PFNGLDRAWARRAYSPROC fDrawArrays; - typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); - PFNGLDRAWELEMENTSPROC fDrawElements; - typedef void (GLAPIENTRY * PFNGLENABLEPROC) (GLenum); - PFNGLENABLEPROC fEnable; - typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint); - PFNGLENABLEVERTEXATTRIBARRAYPROC fEnableVertexAttribArray; - typedef void (GLAPIENTRY * PFNGLFINISHPROC) (void); - PFNGLFINISHPROC fFinish; - typedef void (GLAPIENTRY * PFNGLFLUSHPROC) (void); - PFNGLFLUSHPROC fFlush; - typedef void (GLAPIENTRY * PFNGLFRONTFACEPROC) (GLenum); - PFNGLFRONTFACEPROC fFrontFace; - typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); - PFNGLGETACTIVEATTRIBPROC fGetActiveAttrib; - typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); - PFNGLGETACTIVEUNIFORMPROC fGetActiveUniform; - typedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders); - PFNGLGETATTACHEDSHADERSPROC fGetAttachedShaders; - typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name); - PFNGLGETATTRIBLOCATIONPROC fGetAttribLocation; - typedef void (GLAPIENTRY * PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params); - PFNGLGETINTEGERVPROC fGetIntegerv; - typedef void (GLAPIENTRY * PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *params); - PFNGLGETFLOATVPROC fGetFloatv; - typedef void (GLAPIENTRY * PFNGLGETBOOLEANBPROC) (GLenum pname, realGLboolean *params); - PFNGLGETBOOLEANBPROC fGetBooleanv; - typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); - PFNGLGETBUFFERPARAMETERIVPROC fGetBufferParameteriv; - typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPPROC) (GLenum target); - PFNGLGENERATEMIPMAPPROC fGenerateMipmap; - typedef GLenum (GLAPIENTRY * PFNGLGETERRORPROC) (void); - PFNGLGETERRORPROC fGetError; - typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param); - PFNGLGETPROGRAMIVPROC fGetProgramiv; - typedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); - PFNGLGETPROGRAMINFOLOGPROC fGetProgramInfoLog; - typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); - PFNGLTEXPARAMETERIPROC fTexParameteri; - typedef void (GLAPIENTRY * PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); - PFNGLTEXPARAMETERFPROC fTexParameterf; - typedef GLubyte* (GLAPIENTRY * PFNGLGETSTRINGPROC) (GLenum); - PFNGLGETSTRINGPROC fGetString; - typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); - PFNGLGETTEXPARAMETERFVPROC fGetTexParameterfv; - typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); - PFNGLGETTEXPARAMETERIVPROC fGetTexParameteriv; - typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params); - PFNGLGETUNIFORMFVPROC fGetUniformfv; - typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params); - PFNGLGETUNIFORMIVPROC fGetUniformiv; - typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLint programObj, const GLchar* name); - PFNGLGETUNIFORMLOCATIONPROC fGetUniformLocation; - typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint, GLenum, GLfloat*); - PFNGLGETVERTEXATTRIBFVPROC fGetVertexAttribfv; - typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint, GLenum, GLint*); - PFNGLGETVERTEXATTRIBIVPROC fGetVertexAttribiv; - typedef void (GLAPIENTRY * PFNGLHINTPROC) (GLenum target, GLenum mode); - PFNGLHINTPROC fHint; - typedef realGLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer); - PFNGLISBUFFERPROC fIsBuffer; - typedef realGLboolean (GLAPIENTRY * PFNGLISENABLEDPROC) (GLenum cap); - PFNGLISENABLEDPROC fIsEnabled; - typedef realGLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program); - PFNGLISPROGRAMPROC fIsProgram; - typedef realGLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader); - PFNGLISSHADERPROC fIsShader; - typedef realGLboolean (GLAPIENTRY * PFNGLISTEXTUREPROC) (GLuint texture); - PFNGLISTEXTUREPROC fIsTexture; - typedef void (GLAPIENTRY * PFNGLLINEWIDTHPROC) (GLfloat width); - PFNGLLINEWIDTHPROC fLineWidth; - typedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program); - PFNGLLINKPROGRAMPROC fLinkProgram; - typedef void (GLAPIENTRY * PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); - PFNGLPIXELSTOREIPROC fPixelStorei; - typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat bias); - PFNGLPOLYGONOFFSETPROC fPolygonOffset; - typedef void (GLAPIENTRY * PFNGLREADBUFFERPROC) (GLenum); - PFNGLREADBUFFERPROC fReadBuffer; - typedef void (GLAPIENTRY * PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); - PFNGLREADPIXELSPROC fReadPixels; - typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, realGLboolean invert); - PFNGLSAMPLECOVERAGEPROC fSampleCoverage; - typedef void (GLAPIENTRY * PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); - PFNGLSTENCILFUNCPROC fStencilFunc; - typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); - PFNGLSTENCILFUNCSEPARATEPROC fStencilFuncSeparate; - typedef void (GLAPIENTRY * PFNGLSTENCILMASKPROC) (GLuint mask); - PFNGLSTENCILMASKPROC fStencilMask; - typedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum, GLuint); - PFNGLSTENCILMASKSEPARATEPROC fStencilMaskSeparate; - typedef void (GLAPIENTRY * PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); - PFNGLSTENCILOPPROC fStencilOp; - typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); - PFNGLSTENCILOPSEPARATEPROC fStencilOpSeparate; - typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); - PFNGLTEXIMAGE2DPROC fTexImage2D; - typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); - PFNGLTEXSUBIMAGE2DPROC fTexSubImage2D; - typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); - PFNGLUNIFORM1FPROC fUniform1f; - typedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value); - PFNGLUNIFORM1FVPROC fUniform1fv; - typedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0); - PFNGLUNIFORM1IPROC fUniform1i; - typedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value); - PFNGLUNIFORM1IVPROC fUniform1iv; - typedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); - PFNGLUNIFORM2FPROC fUniform2f; - typedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value); - PFNGLUNIFORM2FVPROC fUniform2fv; - typedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); - PFNGLUNIFORM2IPROC fUniform2i; - typedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value); - PFNGLUNIFORM2IVPROC fUniform2iv; - typedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); - PFNGLUNIFORM3FPROC fUniform3f; - typedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value); - PFNGLUNIFORM3FVPROC fUniform3fv; - typedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); - PFNGLUNIFORM3IPROC fUniform3i; - typedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value); - PFNGLUNIFORM3IVPROC fUniform3iv; - typedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); - PFNGLUNIFORM4FPROC fUniform4f; - typedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value); - PFNGLUNIFORM4FVPROC fUniform4fv; - typedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); - PFNGLUNIFORM4IPROC fUniform4i; - typedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value); - PFNGLUNIFORM4IVPROC fUniform4iv; - typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value); - PFNGLUNIFORMMATRIX2FVPROC fUniformMatrix2fv; - typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value); - PFNGLUNIFORMMATRIX3FVPROC fUniformMatrix3fv; - typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value); - PFNGLUNIFORMMATRIX4FVPROC fUniformMatrix4fv; - typedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program); - PFNGLUSEPROGRAMPROC fUseProgram; - typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program); - PFNGLVALIDATEPROGRAMPROC fValidateProgram; - typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, realGLboolean normalized, GLsizei stride, const GLvoid* pointer); - PFNGLVERTEXATTRIBPOINTERPROC fVertexAttribPointer; - typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); - PFNGLVERTEXATTRIB1FPROC fVertexAttrib1f; - typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); - PFNGLVERTEXATTRIB2FPROC fVertexAttrib2f; - typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); - PFNGLVERTEXATTRIB3FPROC fVertexAttrib3f; - typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - PFNGLVERTEXATTRIB4FPROC fVertexAttrib4f; - typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v); - PFNGLVERTEXATTRIB1FVPROC fVertexAttrib1fv; - typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v); - PFNGLVERTEXATTRIB2FVPROC fVertexAttrib2fv; - typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v); - PFNGLVERTEXATTRIB3FVPROC fVertexAttrib3fv; - typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v); - PFNGLVERTEXATTRIB4FVPROC fVertexAttrib4fv; - typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader); - PFNGLCOMPILESHADERPROC fCompileShader; - typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); - PFNGLCOPYTEXIMAGE2DPROC fCopyTexImage2D; - typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); - PFNGLCOPYTEXSUBIMAGE2DPROC fCopyTexSubImage2D; - typedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param); - PFNGLGETSHADERIVPROC fGetShaderiv; - typedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); - PFNGLGETSHADERINFOLOGPROC fGetShaderInfoLog; - typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source); - PFNGLGETSHADERSOURCEPROC fGetShaderSource; - typedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths); - PFNGLSHADERSOURCEPROC fShaderSource; +#ifdef DEBUG - typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFER) (GLenum target, GLuint framebuffer); - PFNGLBINDFRAMEBUFFER fBindFramebuffer; - typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFER) (GLenum target, GLuint renderbuffer); - PFNGLBINDRENDERBUFFER fBindRenderbuffer; - typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUS) (GLenum target); - PFNGLCHECKFRAMEBUFFERSTATUS fCheckFramebufferStatus; - typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFER) (GLenum target, GLenum attachmentPoint, GLenum renderbufferTarget, GLuint renderbuffer); - PFNGLFRAMEBUFFERRENDERBUFFER fFramebufferRenderbuffer; - typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2D) (GLenum target, GLenum attachmentPoint, GLenum textureTarget, GLuint texture, GLint level); - PFNGLFRAMEBUFFERTEXTURE2D fFramebufferTexture2D; - typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIV) (GLenum target, GLenum attachment, GLenum pname, GLint* value); - PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIV fGetFramebufferAttachmentParameteriv; - typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIV) (GLenum target, GLenum pname, GLint* value); - PFNGLGETRENDERBUFFERPARAMETERIV fGetRenderbufferParameteriv; - typedef realGLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFER) (GLuint framebuffer); - PFNGLISFRAMEBUFFER fIsFramebuffer; - typedef realGLboolean (GLAPIENTRY * PFNGLISRENDERBUFFER) (GLuint renderbuffer); - PFNGLISRENDERBUFFER fIsRenderbuffer; - typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGE) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height); - PFNGLRENDERBUFFERSTORAGE fRenderbufferStorage; +#ifndef MOZ_FUNCTION_NAME +# ifdef __GNUC__ +# define MOZ_FUNCTION_NAME __PRETTY_FUNCTION__ +# elif defined(_MSC_VER) +# define MOZ_FUNCTION_NAME __FUNCTION__ +# else +# define MOZ_FUNCTION_NAME __func__ // defined in C99, supported in various C++ compilers. Just raw function name. +# endif +#endif - // keep this at the end of the function pointers - void *mFunctionListEndSentinel; +protected: + GLenum mGLError; - void fDepthRange(GLclampf a, GLclampf b) { - if (mIsGLES2) { - priv_fDepthRangef(a, b); - } else { - priv_fDepthRange(a, b); +public: + void BeforeGLCall(const char* glFunction) { + if (mDebugMode) { + // since the static member variable sCurrentGLContext is not thread-local as it should, + // we have to assert that we're in the main thread. Note that sCurrentGLContext is only used + // for the OpenGL debug mode. + if (!NS_IsMainThread()) { + NS_ERROR("OpenGL call from non-main thread. While this is fine in itself, " + "the OpenGL debug mode, which is currently enabled, doesn't support this. " + "It needs to be patched by making GLContext::sCurrentGLContext be thread-local.\n"); + NS_ABORT(); + } + if (mDebugMode & DebugTrace) + printf_stderr("[gl:%p] > %s\n", this, glFunction); + if (this != sCurrentGLContext) { + printf_stderr("Fatal: %s called on non-current context %p. " + "The current context for this thread is %p.\n", + glFunction, this, sCurrentGLContext); + NS_ABORT(); + } } } - void fClearDepth(GLclampf v) { - if (mIsGLES2) { - priv_fClearDepthf(v); - } else { - priv_fClearDepth(v); + void AfterGLCall(const char* glFunction) { + if (mDebugMode) { + // calling fFinish() immediately after every GL call makes sure that if this GL command crashes, + // the stack trace will actually point to it. Otherwise, OpenGL being an asynchronous API, stack traces + // tend to be meaningless + mSymbols.fFinish(); + mGLError = mSymbols.fGetError(); + if (mDebugMode & DebugTrace) + printf_stderr("[gl:%p] < %s [0x%04x]\n", this, glFunction, mGLError); + if (mGLError != LOCAL_GL_NO_ERROR) { + printf_stderr("GL ERROR: %s generated GL error 0x%x.", glFunction, mGLError); + if (mDebugMode & DebugAbortOnError) + NS_ABORT(); + } } } +#define BEFORE_GL_CALL do { \ + BeforeGLCall(MOZ_FUNCTION_NAME); \ +} while (0) + +#define AFTER_GL_CALL do { \ + AfterGLCall(MOZ_FUNCTION_NAME); \ +} while (0) + +#else + +#define BEFORE_GL_CALL do { } while (0) +#define AFTER_GL_CALL do { } while (0) + +#endif + + /*** In GL debug mode, we completely override glGetError ***/ + + GLenum fGetError() { +#ifdef DEBUG + // debug mode ends up eating the error in AFTER_GL_CALL + if (mDebugMode) { + GLenum err = mGLError; + mGLError = LOCAL_GL_NO_ERROR; + return err; + } +#endif + + return mSymbols.fGetError(); + } + + + /*** Scissor functions ***/ + +protected: + + // only does the glScissor call, no ScissorRect business + void raw_fScissor(GLint x, GLint y, GLsizei width, GLsizei height) { + BEFORE_GL_CALL; + mSymbols.fScissor(x, y, width, height); + AFTER_GL_CALL; + } + +public: + + // but let GL-using code use that instead, updating the ScissorRect void fScissor(GLint x, GLint y, GLsizei width, GLsizei height) { ScissorRect().SetRect(x, y, width, height); - priv_fScissor(x, y, width, height); + raw_fScissor(x, y, width, height); } nsIntRect& ScissorRect() { @@ -1065,7 +924,7 @@ public: void PushScissorRect(const nsIntRect& aRect) { mScissorStack.AppendElement(aRect); - priv_fScissor(aRect.x, aRect.y, aRect.width, aRect.height); + raw_fScissor(aRect.x, aRect.y, aRect.width, aRect.height); } void PopScissorRect() { @@ -1077,14 +936,27 @@ public: nsIntRect thisRect = ScissorRect(); mScissorStack.TruncateLength(mScissorStack.Length() - 1); if (thisRect != ScissorRect()) { - priv_fScissor(ScissorRect().x, ScissorRect().y, - ScissorRect().width, ScissorRect().height); + raw_fScissor(ScissorRect().x, ScissorRect().y, + ScissorRect().width, ScissorRect().height); } } + /*** Viewport functions ***/ + +protected: + + // only does the glViewport call, no ViewportRect business + void raw_fViewport(GLint x, GLint y, GLsizei width, GLsizei height) { + BEFORE_GL_CALL; + mSymbols.fViewport(x, y, width, height); + AFTER_GL_CALL; + } + +public: + void fViewport(GLint x, GLint y, GLsizei width, GLsizei height) { ViewportRect().SetRect(x, y, width, height); - priv_fViewport(x, y, width, height); + raw_fViewport(x, y, width, height); } nsIntRect& ViewportRect() { @@ -1097,7 +969,7 @@ public: void PushViewportRect(const nsIntRect& aRect) { mViewportStack.AppendElement(aRect); - priv_fViewport(aRect.x, aRect.y, aRect.width, aRect.height); + raw_fViewport(aRect.x, aRect.y, aRect.width, aRect.height); } void PopViewportRect() { @@ -1109,189 +981,895 @@ public: nsIntRect thisRect = ViewportRect(); mViewportStack.TruncateLength(mViewportStack.Length() - 1); if (thisRect != ViewportRect()) { - priv_fViewport(ViewportRect().x, ViewportRect().y, - ViewportRect().width, ViewportRect().height); + raw_fViewport(ViewportRect().x, ViewportRect().y, + ViewportRect().width, ViewportRect().height); } } -protected: - nsTArray mViewportStack; - nsTArray mScissorStack; + /*** other GL functions ***/ - /* These are different between GLES2 and desktop GL; we hide those differences, use the GL - * names, but the most limited data type. - */ - typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFPROC) (GLclampf, GLclampf); - PFNGLDEPTHRANGEFPROC priv_fDepthRangef; - typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFPROC) (GLclampf); - PFNGLCLEARDEPTHFPROC priv_fClearDepthf; - - typedef void (GLAPIENTRY * PFNGLDEPTHRANGEPROC) (GLclampd, GLclampd); - PFNGLDEPTHRANGEPROC priv_fDepthRange; - typedef void (GLAPIENTRY * PFNGLCLEARDEPTHPROC) (GLclampd); - PFNGLCLEARDEPTHPROC priv_fClearDepth; - - /* These are special because we end up tracking these so that we don't - * have to query the values from GL. - */ - - typedef void (GLAPIENTRY * PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); - PFNGLVIEWPORTPROC priv_fViewport; - typedef void (GLAPIENTRY * PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); - PFNGLSCISSORPROC priv_fScissor; - - - /* These are special -- they create or delete GL resources that can live - * in a shared namespace. In DEBUG, we wrap these calls so that we can - * check when we have something that failed to do cleanup at the time the - * final context is destroyed. - */ - - typedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void); - PFNGLCREATEPROGRAMPROC priv_fCreateProgram; - typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type); - PFNGLCREATESHADERPROC priv_fCreateShader; - typedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers); - PFNGLGENBUFFERSPROC priv_fGenBuffers; - typedef void (GLAPIENTRY * PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); - PFNGLGENTEXTURESPROC priv_fGenTextures; - typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERS) (GLsizei n, GLuint* ids); - PFNGLGENFRAMEBUFFERS priv_fGenFramebuffers; - typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERS) (GLsizei n, GLuint* ids); - PFNGLGENRENDERBUFFERS priv_fGenRenderbuffers; - - typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program); - PFNGLDELETEPROGRAMPROC priv_fDeleteProgram; - typedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader); - PFNGLDELETESHADERPROC priv_fDeleteShader; - typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers); - PFNGLDELETEBUFFERSPROC priv_fDeleteBuffers; - typedef void (GLAPIENTRY * PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint* textures); - PFNGLDELETETEXTURESPROC priv_fDeleteTextures; - typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERS) (GLsizei n, const GLuint* ids); - PFNGLDELETEFRAMEBUFFERS priv_fDeleteFramebuffers; - typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERS) (GLsizei n, const GLuint* ids); - PFNGLDELETERENDERBUFFERS priv_fDeleteRenderbuffers; - -public: -#ifndef DEBUG - GLuint GLAPIENTRY fCreateProgram() { - return priv_fCreateProgram(); + void fActiveTexture(GLenum texture) { + BEFORE_GL_CALL; + mSymbols.fActiveTexture(texture); + AFTER_GL_CALL; } - GLuint GLAPIENTRY fCreateShader(GLenum t) { - return priv_fCreateShader(t); + void fAttachShader(GLuint program, GLuint shader) { + BEFORE_GL_CALL; + mSymbols.fAttachShader(program, shader); + AFTER_GL_CALL; } - void GLAPIENTRY fGenBuffers(GLsizei n, GLuint* names) { - priv_fGenBuffers(n, names); + void fBindAttribLocation(GLuint program, GLuint index, const GLchar* name) { + BEFORE_GL_CALL; + mSymbols.fBindAttribLocation(program, index, name); + AFTER_GL_CALL; } - void GLAPIENTRY fGenTextures(GLsizei n, GLuint* names) { - priv_fGenTextures(n, names); + void fBindBuffer(GLenum target, GLuint buffer) { + BEFORE_GL_CALL; + mSymbols.fBindBuffer(target, buffer); + AFTER_GL_CALL; } - void GLAPIENTRY fGenFramebuffers(GLsizei n, GLuint* names) { - priv_fGenFramebuffers(n, names); + void fBindTexture(GLenum target, GLuint texture) { + BEFORE_GL_CALL; + mSymbols.fBindTexture(target, texture); + AFTER_GL_CALL; } - void GLAPIENTRY fGenRenderbuffers(GLsizei n, GLuint* names) { - priv_fGenRenderbuffers(n, names); + void fBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { + BEFORE_GL_CALL; + mSymbols.fBlendColor(red, green, blue, alpha); + AFTER_GL_CALL; } - void GLAPIENTRY fDeleteProgram(GLuint program) { - priv_fDeleteProgram(program); + void fBlendEquation(GLenum mode) { + BEFORE_GL_CALL; + mSymbols.fBlendEquation(mode); + AFTER_GL_CALL; } - void GLAPIENTRY fDeleteShader(GLuint shader) { - priv_fDeleteShader(shader); + void fBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { + BEFORE_GL_CALL; + mSymbols.fBlendEquationSeparate(modeRGB, modeAlpha); + AFTER_GL_CALL; } - void GLAPIENTRY fDeleteBuffers(GLsizei n, GLuint *names) { - priv_fDeleteBuffers(n, names); + void fBlendFunc(GLenum sfactor, GLenum dfactor) { + BEFORE_GL_CALL; + mSymbols.fBlendFunc(sfactor, dfactor); + AFTER_GL_CALL; } - void GLAPIENTRY fDeleteTextures(GLsizei n, GLuint *names) { - priv_fDeleteTextures(n, names); + void fBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) { + BEFORE_GL_CALL; + mSymbols.fBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); + AFTER_GL_CALL; } - void GLAPIENTRY fDeleteFramebuffers(GLsizei n, GLuint *names) { - priv_fDeleteFramebuffers(n, names); + void fBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) { + BEFORE_GL_CALL; + mSymbols.fBufferData(target, size, data, usage); + AFTER_GL_CALL; } - void GLAPIENTRY fDeleteRenderbuffers(GLsizei n, GLuint *names) { - priv_fDeleteRenderbuffers(n, names); - } -#else - GLContext *TrackingContext() { - GLContext *tip = this; - while (tip->mSharedContext) - tip = tip->mSharedContext; - return tip; + void fBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) { + BEFORE_GL_CALL; + mSymbols.fBufferSubData(target, offset, size, data); + AFTER_GL_CALL; } - GLuint GLAPIENTRY fCreateProgram() { - GLuint ret = priv_fCreateProgram(); - TrackingContext()->CreatedProgram(this, ret); - return ret; + void fClear(GLbitfield mask) { + BEFORE_GL_CALL; + mSymbols.fClear(mask); + AFTER_GL_CALL; } - GLuint GLAPIENTRY fCreateShader(GLenum t) { - GLuint ret = priv_fCreateShader(t); - TrackingContext()->CreatedShader(this, ret); - return ret; + void fClearColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a) { + BEFORE_GL_CALL; + mSymbols.fClearColor(r, g, b, a); + AFTER_GL_CALL; } - void GLAPIENTRY fGenBuffers(GLsizei n, GLuint* names) { - priv_fGenBuffers(n, names); - TrackingContext()->CreatedBuffers(this, n, names); + void fClearStencil(GLint s) { + BEFORE_GL_CALL; + mSymbols.fClearStencil(s); + AFTER_GL_CALL; } - void GLAPIENTRY fGenTextures(GLsizei n, GLuint* names) { - priv_fGenTextures(n, names); - TrackingContext()->CreatedTextures(this, n, names); + void fColorMask(realGLboolean red, realGLboolean green, realGLboolean blue, realGLboolean alpha) { + BEFORE_GL_CALL; + mSymbols.fColorMask(red, green, blue, alpha); + AFTER_GL_CALL; } - void GLAPIENTRY fGenFramebuffers(GLsizei n, GLuint* names) { - priv_fGenFramebuffers(n, names); - TrackingContext()->CreatedFramebuffers(this, n, names); + void fCullFace(GLenum mode) { + BEFORE_GL_CALL; + mSymbols.fCullFace(mode); + AFTER_GL_CALL; } - void GLAPIENTRY fGenRenderbuffers(GLsizei n, GLuint* names) { - priv_fGenRenderbuffers(n, names); - TrackingContext()->CreatedRenderbuffers(this, n, names); + void fDetachShader(GLuint program, GLuint shader) { + BEFORE_GL_CALL; + mSymbols.fDetachShader(program, shader); + AFTER_GL_CALL; } - void GLAPIENTRY fDeleteProgram(GLuint program) { - priv_fDeleteProgram(program); - TrackingContext()->DeletedProgram(this, program); + void fDepthFunc(GLenum func) { + BEFORE_GL_CALL; + mSymbols.fDepthFunc(func); + AFTER_GL_CALL; } - void GLAPIENTRY fDeleteShader(GLuint shader) { - priv_fDeleteShader(shader); - TrackingContext()->DeletedShader(this, shader); + void fDepthMask(realGLboolean flag) { + BEFORE_GL_CALL; + mSymbols.fDepthMask(flag); + AFTER_GL_CALL; } - void GLAPIENTRY fDeleteBuffers(GLsizei n, GLuint *names) { - priv_fDeleteBuffers(n, names); - TrackingContext()->DeletedBuffers(this, n, names); + void fDisable(GLenum capability) { + BEFORE_GL_CALL; + mSymbols.fDisable(capability); + AFTER_GL_CALL; } - void GLAPIENTRY fDeleteTextures(GLsizei n, GLuint *names) { - priv_fDeleteTextures(n, names); - TrackingContext()->DeletedTextures(this, n, names); + void fDisableVertexAttribArray(GLuint index) { + BEFORE_GL_CALL; + mSymbols.fDisableVertexAttribArray(index); + AFTER_GL_CALL; } - void GLAPIENTRY fDeleteFramebuffers(GLsizei n, GLuint *names) { - priv_fDeleteFramebuffers(n, names); - TrackingContext()->DeletedFramebuffers(this, n, names); + void fDrawArrays(GLenum mode, GLint first, GLsizei count) { + BEFORE_GL_CALL; + mSymbols.fDrawArrays(mode, first, count); + AFTER_GL_CALL; } - void GLAPIENTRY fDeleteRenderbuffers(GLsizei n, GLuint *names) { - priv_fDeleteRenderbuffers(n, names); - TrackingContext()->DeletedRenderbuffers(this, n, names); + void fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { + BEFORE_GL_CALL; + mSymbols.fDrawElements(mode, count, type, indices); + AFTER_GL_CALL; } + void fEnable(GLenum capability) { + BEFORE_GL_CALL; + mSymbols.fEnable(capability); + AFTER_GL_CALL; + } + + void fEnableVertexAttribArray(GLuint index) { + BEFORE_GL_CALL; + mSymbols.fEnableVertexAttribArray(index); + AFTER_GL_CALL; + } + + void fFinish() { + BEFORE_GL_CALL; + mSymbols.fFinish(); + AFTER_GL_CALL; + } + + void fFlush() { + BEFORE_GL_CALL; + mSymbols.fFlush(); + AFTER_GL_CALL; + } + + void fFrontFace(GLenum face) { + BEFORE_GL_CALL; + mSymbols.fFrontFace(face); + AFTER_GL_CALL; + } + + void fGetActiveAttrib(GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name) { + BEFORE_GL_CALL; + mSymbols.fGetActiveAttrib(program, index, maxLength, length, size, type, name); + AFTER_GL_CALL; + } + + void fGetActiveUniform(GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name) { + BEFORE_GL_CALL; + mSymbols.fGetActiveUniform(program, index, maxLength, length, size, type, name); + AFTER_GL_CALL; + } + + void fGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) { + BEFORE_GL_CALL; + mSymbols.fGetAttachedShaders(program, maxCount, count, shaders); + AFTER_GL_CALL; + } + + GLint fGetAttribLocation (GLuint program, const GLchar* name) { + BEFORE_GL_CALL; + GLint retval = mSymbols.fGetAttribLocation(program, name); + AFTER_GL_CALL; + return retval; + } + + void fGetIntegerv(GLenum pname, GLint *params) { + BEFORE_GL_CALL; + mSymbols.fGetIntegerv(pname, params); + AFTER_GL_CALL; + } + + void fGetFloatv(GLenum pname, GLfloat *params) { + BEFORE_GL_CALL; + mSymbols.fGetFloatv(pname, params); + AFTER_GL_CALL; + } + + void fGetBooleanv(GLenum pname, realGLboolean *params) { + BEFORE_GL_CALL; + mSymbols.fGetBooleanv(pname, params); + AFTER_GL_CALL; + } + + void fGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) { + BEFORE_GL_CALL; + mSymbols.fGetBufferParameteriv(target, pname, params); + AFTER_GL_CALL; + } + + void fGenerateMipmap(GLenum target) { + BEFORE_GL_CALL; + mSymbols.fGenerateMipmap(target); + AFTER_GL_CALL; + } + + void fGetProgramiv(GLuint program, GLenum pname, GLint* param) { + BEFORE_GL_CALL; + mSymbols.fGetProgramiv(program, pname, param); + AFTER_GL_CALL; + } + + void fGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) { + BEFORE_GL_CALL; + mSymbols.fGetProgramInfoLog(program, bufSize, length, infoLog); + AFTER_GL_CALL; + } + + void fTexParameteri(GLenum target, GLenum pname, GLint param) { + BEFORE_GL_CALL; + mSymbols.fTexParameteri(target, pname, param); + AFTER_GL_CALL; + } + + void fTexParameterf(GLenum target, GLenum pname, GLfloat param) { + BEFORE_GL_CALL; + mSymbols.fTexParameterf(target, pname, param); + AFTER_GL_CALL; + } + + const GLubyte* fGetString(GLenum name) { + BEFORE_GL_CALL; + const GLubyte *result = mSymbols.fGetString(name); + AFTER_GL_CALL; + return result; + } + + void fGetTexParameterfv(GLenum target, GLenum pname, const GLfloat *params) { + BEFORE_GL_CALL; + mSymbols.fGetTexParameterfv(target, pname, params); + AFTER_GL_CALL; + } + + void fGetTexParameteriv(GLenum target, GLenum pname, const GLint *params) { + BEFORE_GL_CALL; + mSymbols.fGetTexParameteriv(target, pname, params); + AFTER_GL_CALL; + } + + void fGetUniformfv(GLuint program, GLint location, GLfloat* params) { + BEFORE_GL_CALL; + mSymbols.fGetUniformfv(program, location, params); + AFTER_GL_CALL; + } + + void fGetUniformiv(GLuint program, GLint location, GLint* params) { + BEFORE_GL_CALL; + mSymbols.fGetUniformiv(program, location, params); + AFTER_GL_CALL; + } + + GLint fGetUniformLocation (GLint programObj, const GLchar* name) { + BEFORE_GL_CALL; + GLint retval = mSymbols.fGetUniformLocation(programObj, name); + AFTER_GL_CALL; + return retval; + } + + void fGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* retval) { + BEFORE_GL_CALL; + mSymbols.fGetVertexAttribfv(index, pname, retval); + AFTER_GL_CALL; + } + + void fGetVertexAttribiv(GLuint index, GLenum pname, GLint* retval) { + BEFORE_GL_CALL; + mSymbols.fGetVertexAttribiv(index, pname, retval); + AFTER_GL_CALL; + } + + void fHint(GLenum target, GLenum mode) { + BEFORE_GL_CALL; + mSymbols.fHint(target, mode); + AFTER_GL_CALL; + } + + realGLboolean fIsBuffer(GLuint buffer) { + BEFORE_GL_CALL; + realGLboolean retval = mSymbols.fIsBuffer(buffer); + AFTER_GL_CALL; + return retval; + } + + realGLboolean fIsEnabled (GLenum capability) { + BEFORE_GL_CALL; + realGLboolean retval = mSymbols.fIsEnabled(capability); + AFTER_GL_CALL; + return retval; + } + + realGLboolean fIsProgram (GLuint program) { + BEFORE_GL_CALL; + realGLboolean retval = mSymbols.fIsProgram(program); + AFTER_GL_CALL; + return retval; + } + + realGLboolean fIsShader (GLuint shader) { + BEFORE_GL_CALL; + realGLboolean retval = mSymbols.fIsShader(shader); + AFTER_GL_CALL; + return retval; + } + + realGLboolean fIsTexture (GLuint texture) { + BEFORE_GL_CALL; + realGLboolean retval = mSymbols.fIsTexture(texture); + AFTER_GL_CALL; + return retval; + } + + void fLineWidth(GLfloat width) { + BEFORE_GL_CALL; + mSymbols.fLineWidth(width); + AFTER_GL_CALL; + } + + void fLinkProgram(GLuint program) { + BEFORE_GL_CALL; + mSymbols.fLinkProgram(program); + AFTER_GL_CALL; + } + + void fPixelStorei(GLenum pname, GLint param) { + BEFORE_GL_CALL; + mSymbols.fPixelStorei(pname, param); + AFTER_GL_CALL; + } + + void fPolygonOffset(GLfloat factor, GLfloat bias) { + BEFORE_GL_CALL; + mSymbols.fPolygonOffset(factor, bias); + AFTER_GL_CALL; + } + + void fReadBuffer(GLenum mode) { + BEFORE_GL_CALL; + mSymbols.fReadBuffer(mode); + AFTER_GL_CALL; + } + + void fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) { + BEFORE_GL_CALL; + mSymbols.fReadPixels(x, y, width, height, format, type, pixels); + AFTER_GL_CALL; + } + + void fSampleCoverage(GLclampf value, realGLboolean invert) { + BEFORE_GL_CALL; + mSymbols.fSampleCoverage(value, invert); + AFTER_GL_CALL; + } + + void fStencilFunc(GLenum func, GLint ref, GLuint mask) { + BEFORE_GL_CALL; + mSymbols.fStencilFunc(func, ref, mask); + AFTER_GL_CALL; + } + + void fStencilFuncSeparate(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) { + BEFORE_GL_CALL; + mSymbols.fStencilFuncSeparate(frontfunc, backfunc, ref, mask); + AFTER_GL_CALL; + } + + void fStencilMask(GLuint mask) { + BEFORE_GL_CALL; + mSymbols.fStencilMask(mask); + AFTER_GL_CALL; + } + + void fStencilMaskSeparate(GLenum face, GLuint mask) { + BEFORE_GL_CALL; + mSymbols.fStencilMaskSeparate(face, mask); + AFTER_GL_CALL; + } + + void fStencilOp(GLenum fail, GLenum zfail, GLenum zpass) { + BEFORE_GL_CALL; + mSymbols.fStencilOp(fail, zfail, zpass); + AFTER_GL_CALL; + } + + void fStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) { + BEFORE_GL_CALL; + mSymbols.fStencilOpSeparate(face, sfail, dpfail, dppass); + AFTER_GL_CALL; + } + + void 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; + } + + void fTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) { + BEFORE_GL_CALL; + mSymbols.fTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + AFTER_GL_CALL; + } + + void fUniform1f(GLint location, GLfloat v0) { + BEFORE_GL_CALL; + mSymbols.fUniform1f(location, v0); + AFTER_GL_CALL; + } + + void fUniform1fv(GLint location, GLsizei count, const GLfloat* value) { + BEFORE_GL_CALL; + mSymbols.fUniform1fv(location, count, value); + AFTER_GL_CALL; + } + + void fUniform1i(GLint location, GLint v0) { + BEFORE_GL_CALL; + mSymbols.fUniform1i(location, v0); + AFTER_GL_CALL; + } + + void fUniform1iv(GLint location, GLsizei count, const GLint* value) { + BEFORE_GL_CALL; + mSymbols.fUniform1iv(location, count, value); + AFTER_GL_CALL; + } + + void fUniform2f(GLint location, GLfloat v0, GLfloat v1) { + BEFORE_GL_CALL; + mSymbols.fUniform2f(location, v0, v1); + AFTER_GL_CALL; + } + + void fUniform2fv(GLint location, GLsizei count, const GLfloat* value) { + BEFORE_GL_CALL; + mSymbols.fUniform2fv(location, count, value); + AFTER_GL_CALL; + } + + void fUniform2i(GLint location, GLint v0, GLint v1) { + BEFORE_GL_CALL; + mSymbols.fUniform2i(location, v0, v1); + AFTER_GL_CALL; + } + + void fUniform2iv(GLint location, GLsizei count, const GLint* value) { + BEFORE_GL_CALL; + mSymbols.fUniform2iv(location, count, value); + AFTER_GL_CALL; + } + + void fUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) { + BEFORE_GL_CALL; + mSymbols.fUniform3f(location, v0, v1, v2); + AFTER_GL_CALL; + } + + void fUniform3fv(GLint location, GLsizei count, const GLfloat* value) { + BEFORE_GL_CALL; + mSymbols.fUniform3fv(location, count, value); + AFTER_GL_CALL; + } + + void fUniform3i(GLint location, GLint v0, GLint v1, GLint v2) { + BEFORE_GL_CALL; + mSymbols.fUniform3i(location, v0, v1, v2); + AFTER_GL_CALL; + } + + void fUniform3iv(GLint location, GLsizei count, const GLint* value) { + BEFORE_GL_CALL; + mSymbols.fUniform3iv(location, count, value); + AFTER_GL_CALL; + } + + void fUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) { + BEFORE_GL_CALL; + mSymbols.fUniform4f(location, v0, v1, v2, v3); + AFTER_GL_CALL; + } + + void fUniform4fv(GLint location, GLsizei count, const GLfloat* value) { + BEFORE_GL_CALL; + mSymbols.fUniform4fv(location, count, value); + AFTER_GL_CALL; + } + + void fUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) { + BEFORE_GL_CALL; + mSymbols.fUniform4i(location, v0, v1, v2, v3); + AFTER_GL_CALL; + } + + void fUniform4iv(GLint location, GLsizei count, const GLint* value) { + BEFORE_GL_CALL; + mSymbols.fUniform4iv(location, count, value); + AFTER_GL_CALL; + } + + void fUniformMatrix2fv(GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value) { + BEFORE_GL_CALL; + mSymbols.fUniformMatrix2fv(location, count, transpose, value); + AFTER_GL_CALL; + } + + void fUniformMatrix3fv(GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value) { + BEFORE_GL_CALL; + mSymbols.fUniformMatrix3fv(location, count, transpose, value); + AFTER_GL_CALL; + } + + void fUniformMatrix4fv(GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value) { + BEFORE_GL_CALL; + mSymbols.fUniformMatrix4fv(location, count, transpose, value); + AFTER_GL_CALL; + } + + void fUseProgram(GLuint program) { + BEFORE_GL_CALL; + mSymbols.fUseProgram(program); + AFTER_GL_CALL; + } + + void fValidateProgram(GLuint program) { + BEFORE_GL_CALL; + mSymbols.fValidateProgram(program); + AFTER_GL_CALL; + } + + void fVertexAttribPointer(GLuint index, GLint size, GLenum type, realGLboolean normalized, GLsizei stride, const GLvoid* pointer) { + BEFORE_GL_CALL; + mSymbols.fVertexAttribPointer(index, size, type, normalized, stride, pointer); + AFTER_GL_CALL; + } + + void fVertexAttrib1f(GLuint index, GLfloat x) { + BEFORE_GL_CALL; + mSymbols.fVertexAttrib1f(index, x); + AFTER_GL_CALL; + } + + void fVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) { + BEFORE_GL_CALL; + mSymbols.fVertexAttrib2f(index, x, y); + AFTER_GL_CALL; + } + + void fVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) { + BEFORE_GL_CALL; + mSymbols.fVertexAttrib3f(index, x, y, z); + AFTER_GL_CALL; + } + + void fVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + BEFORE_GL_CALL; + mSymbols.fVertexAttrib4f(index, x, y, z, w); + AFTER_GL_CALL; + } + + void fVertexAttrib1fv(GLuint index, const GLfloat* v) { + BEFORE_GL_CALL; + mSymbols.fVertexAttrib1fv(index, v); + AFTER_GL_CALL; + } + + void fVertexAttrib2fv(GLuint index, const GLfloat* v) { + BEFORE_GL_CALL; + mSymbols.fVertexAttrib2fv(index, v); + AFTER_GL_CALL; + } + + void fVertexAttrib3fv(GLuint index, const GLfloat* v) { + BEFORE_GL_CALL; + mSymbols.fVertexAttrib3fv(index, v); + AFTER_GL_CALL; + } + + void fVertexAttrib4fv(GLuint index, const GLfloat* v) { + BEFORE_GL_CALL; + mSymbols.fVertexAttrib4fv(index, v); + AFTER_GL_CALL; + } + + void fCompileShader(GLuint shader) { + BEFORE_GL_CALL; + mSymbols.fCompileShader(shader); + AFTER_GL_CALL; + } + + void fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { + BEFORE_GL_CALL; + mSymbols.fCopyTexImage2D(target, level, internalformat, x, y, width, height, border); + AFTER_GL_CALL; + } + + void fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { + BEFORE_GL_CALL; + mSymbols.fCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); + AFTER_GL_CALL; + } + + void fGetShaderiv(GLuint shader, GLenum pname, GLint* param) { + BEFORE_GL_CALL; + mSymbols.fGetShaderiv(shader, pname, param); + AFTER_GL_CALL; + } + + void fGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) { + BEFORE_GL_CALL; + mSymbols.fGetShaderInfoLog(shader, bufSize, length, infoLog); + AFTER_GL_CALL; + } + + void fGetShaderSource(GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source) { + BEFORE_GL_CALL; + mSymbols.fGetShaderSource(obj, maxLength, length, source); + AFTER_GL_CALL; + } + + void fShaderSource(GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths) { + BEFORE_GL_CALL; + mSymbols.fShaderSource(shader, count, strings, lengths); + AFTER_GL_CALL; + } + + void fBindFramebuffer(GLenum target, GLuint framebuffer) { + BEFORE_GL_CALL; + mSymbols.fBindFramebuffer(target, framebuffer); + AFTER_GL_CALL; + } + + void fBindRenderbuffer(GLenum target, GLuint renderbuffer) { + BEFORE_GL_CALL; + mSymbols.fBindRenderbuffer(target, renderbuffer); + AFTER_GL_CALL; + } + + GLenum fCheckFramebufferStatus (GLenum target) { + BEFORE_GL_CALL; + GLenum retval = mSymbols.fCheckFramebufferStatus(target); + AFTER_GL_CALL; + return retval; + } + + void fFramebufferRenderbuffer(GLenum target, GLenum attachmentPoint, GLenum renderbufferTarget, GLuint renderbuffer) { + BEFORE_GL_CALL; + mSymbols.fFramebufferRenderbuffer(target, attachmentPoint, renderbufferTarget, renderbuffer); + AFTER_GL_CALL; + } + + void fFramebufferTexture2D(GLenum target, GLenum attachmentPoint, GLenum textureTarget, GLuint texture, GLint level) { + BEFORE_GL_CALL; + mSymbols.fFramebufferTexture2D(target, attachmentPoint, textureTarget, texture, level); + AFTER_GL_CALL; + } + + void fGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* value) { + BEFORE_GL_CALL; + mSymbols.fGetFramebufferAttachmentParameteriv(target, attachment, pname, value); + AFTER_GL_CALL; + } + + void fGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* value) { + BEFORE_GL_CALL; + mSymbols.fGetRenderbufferParameteriv(target, pname, value); + AFTER_GL_CALL; + } + + realGLboolean fIsFramebuffer (GLuint framebuffer) { + BEFORE_GL_CALL; + realGLboolean retval = mSymbols.fIsFramebuffer(framebuffer); + AFTER_GL_CALL; + return retval; + } + + realGLboolean fIsRenderbuffer (GLuint renderbuffer) { + BEFORE_GL_CALL; + realGLboolean retval = mSymbols.fIsRenderbuffer(renderbuffer); + AFTER_GL_CALL; + return retval; + } + + void fRenderbufferStorage(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height) { + BEFORE_GL_CALL; + mSymbols.fRenderbufferStorage(target, internalFormat, width, height); + AFTER_GL_CALL; + } + + void fDepthRange(GLclampf a, GLclampf b) { + BEFORE_GL_CALL; + if (mIsGLES2) { + mSymbols.fDepthRangef(a, b); + } else { + mSymbols.fDepthRange(a, b); + } + AFTER_GL_CALL; + } + + void fClearDepth(GLclampf v) { + BEFORE_GL_CALL; + if (mIsGLES2) { + mSymbols.fClearDepthf(v); + } else { + mSymbols.fClearDepth(v); + } + AFTER_GL_CALL; + } + + + #ifndef DEBUG + GLuint GLAPIENTRY fCreateProgram() { + return mSymbols.fCreateProgram(); + } + + GLuint GLAPIENTRY fCreateShader(GLenum t) { + return mSymbols.fCreateShader(t); + } + + void GLAPIENTRY fGenBuffers(GLsizei n, GLuint* names) { + mSymbols.fGenBuffers(n, names); + } + + void GLAPIENTRY fGenTextures(GLsizei n, GLuint* names) { + mSymbols.fGenTextures(n, names); + } + + void GLAPIENTRY fGenFramebuffers(GLsizei n, GLuint* names) { + mSymbols.fGenFramebuffers(n, names); + } + + void GLAPIENTRY fGenRenderbuffers(GLsizei n, GLuint* names) { + mSymbols.fGenRenderbuffers(n, names); + } + + void GLAPIENTRY fDeleteProgram(GLuint program) { + mSymbols.fDeleteProgram(program); + } + + void GLAPIENTRY fDeleteShader(GLuint shader) { + mSymbols.fDeleteShader(shader); + } + + void GLAPIENTRY fDeleteBuffers(GLsizei n, GLuint *names) { + mSymbols.fDeleteBuffers(n, names); + } + + void GLAPIENTRY fDeleteTextures(GLsizei n, GLuint *names) { + mSymbols.fDeleteTextures(n, names); + } + + void GLAPIENTRY fDeleteFramebuffers(GLsizei n, GLuint *names) { + mSymbols.fDeleteFramebuffers(n, names); + } + + void GLAPIENTRY fDeleteRenderbuffers(GLsizei n, GLuint *names) { + mSymbols.fDeleteRenderbuffers(n, names); + } + #else + GLContext *TrackingContext() { + GLContext *tip = this; + while (tip->mSharedContext) + tip = tip->mSharedContext; + return tip; + } + + GLuint GLAPIENTRY fCreateProgram() { + BEFORE_GL_CALL; + GLuint ret = mSymbols.fCreateProgram(); + AFTER_GL_CALL; + TrackingContext()->CreatedProgram(this, ret); + return ret; + } + + GLuint GLAPIENTRY fCreateShader(GLenum t) { + BEFORE_GL_CALL; + GLuint ret = mSymbols.fCreateShader(t); + AFTER_GL_CALL; + TrackingContext()->CreatedShader(this, ret); + return ret; + } + + void GLAPIENTRY fGenBuffers(GLsizei n, GLuint* names) { + BEFORE_GL_CALL; + mSymbols.fGenBuffers(n, names); + AFTER_GL_CALL; + TrackingContext()->CreatedBuffers(this, n, names); + } + + void GLAPIENTRY fGenTextures(GLsizei n, GLuint* names) { + BEFORE_GL_CALL; + mSymbols.fGenTextures(n, names); + AFTER_GL_CALL; + TrackingContext()->CreatedTextures(this, n, names); + } + + void GLAPIENTRY fGenFramebuffers(GLsizei n, GLuint* names) { + BEFORE_GL_CALL; + mSymbols.fGenFramebuffers(n, names); + AFTER_GL_CALL; + TrackingContext()->CreatedFramebuffers(this, n, names); + } + + void GLAPIENTRY fGenRenderbuffers(GLsizei n, GLuint* names) { + BEFORE_GL_CALL; + mSymbols.fGenRenderbuffers(n, names); + AFTER_GL_CALL; + TrackingContext()->CreatedRenderbuffers(this, n, names); + } + + void GLAPIENTRY fDeleteProgram(GLuint program) { + BEFORE_GL_CALL; + mSymbols.fDeleteProgram(program); + AFTER_GL_CALL; + TrackingContext()->DeletedProgram(this, program); + } + + void GLAPIENTRY fDeleteShader(GLuint shader) { + BEFORE_GL_CALL; + mSymbols.fDeleteShader(shader); + AFTER_GL_CALL; + TrackingContext()->DeletedShader(this, shader); + } + + void GLAPIENTRY fDeleteBuffers(GLsizei n, GLuint *names) { + BEFORE_GL_CALL; + mSymbols.fDeleteBuffers(n, names); + AFTER_GL_CALL; + TrackingContext()->DeletedBuffers(this, n, names); + } + + void GLAPIENTRY fDeleteTextures(GLsizei n, GLuint *names) { + BEFORE_GL_CALL; + mSymbols.fDeleteTextures(n, names); + AFTER_GL_CALL; + TrackingContext()->DeletedTextures(this, n, names); + } + + void GLAPIENTRY fDeleteFramebuffers(GLsizei n, GLuint *names) { + BEFORE_GL_CALL; + mSymbols.fDeleteFramebuffers(n, names); + AFTER_GL_CALL; + TrackingContext()->DeletedFramebuffers(this, n, names); + } + + void GLAPIENTRY fDeleteRenderbuffers(GLsizei n, GLuint *names) { + BEFORE_GL_CALL; + mSymbols.fDeleteRenderbuffers(n, names); + AFTER_GL_CALL; + TrackingContext()->DeletedRenderbuffers(this, n, names); + } + void THEBES_API CreatedProgram(GLContext *aOrigin, GLuint aName); void THEBES_API CreatedShader(GLContext *aOrigin, GLuint aName); void THEBES_API CreatedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames); diff --git a/gfx/thebes/GLContextProviderCGL.mm b/gfx/thebes/GLContextProviderCGL.mm index cdd197343b46..0f92eace85c0 100644 --- a/gfx/thebes/GLContextProviderCGL.mm +++ b/gfx/thebes/GLContextProviderCGL.mm @@ -151,7 +151,7 @@ public: } } - PRBool MakeCurrent(PRBool aForce = PR_FALSE) + PRBool MakeCurrentImpl(PRBool aForce = PR_FALSE) { if (mContext) { [mContext makeCurrentContext]; diff --git a/gfx/thebes/GLContextProviderEGL.cpp b/gfx/thebes/GLContextProviderEGL.cpp index ff53c89650f3..389587898c25 100644 --- a/gfx/thebes/GLContextProviderEGL.cpp +++ b/gfx/thebes/GLContextProviderEGL.cpp @@ -610,7 +610,7 @@ public: return PR_TRUE; } - PRBool MakeCurrent(PRBool aForce = PR_FALSE) { + PRBool MakeCurrentImpl(PRBool aForce = PR_FALSE) { PRBool succeeded = PR_TRUE; // Assume that EGL has the same problem as WGL does, diff --git a/gfx/thebes/GLContextProviderGLX.cpp b/gfx/thebes/GLContextProviderGLX.cpp index bcf12e141e58..83c78fc20728 100644 --- a/gfx/thebes/GLContextProviderGLX.cpp +++ b/gfx/thebes/GLContextProviderGLX.cpp @@ -250,7 +250,7 @@ TRY_AGAIN_NO_SHARING: return IsExtensionSupported("GL_EXT_framebuffer_object"); } - PRBool MakeCurrent(PRBool aForce = PR_FALSE) + PRBool MakeCurrentImpl(PRBool aForce = PR_FALSE) { PRBool succeeded = PR_TRUE; diff --git a/gfx/thebes/GLContextProviderOSMesa.cpp b/gfx/thebes/GLContextProviderOSMesa.cpp index ff88b1aca692..c10bf6bff09a 100644 --- a/gfx/thebes/GLContextProviderOSMesa.cpp +++ b/gfx/thebes/GLContextProviderOSMesa.cpp @@ -224,7 +224,7 @@ public: return InitWithPrefix("gl", PR_TRUE); } - PRBool MakeCurrent(PRBool aForce = PR_FALSE) + PRBool MakeCurrentImpl(PRBool aForce = PR_FALSE) { PRBool succeeded = sOSMesaLibrary.fMakeCurrent(mContext, mThebesSurface->Data(), diff --git a/gfx/thebes/GLContextProviderWGL.cpp b/gfx/thebes/GLContextProviderWGL.cpp index cc9d9a4fe1db..f2c6f3c39435 100644 --- a/gfx/thebes/GLContextProviderWGL.cpp +++ b/gfx/thebes/GLContextProviderWGL.cpp @@ -274,7 +274,7 @@ public: return InitWithPrefix("gl", PR_TRUE); } - PRBool MakeCurrent(PRBool aForce = PR_FALSE) + PRBool MakeCurrentImpl(PRBool aForce = PR_FALSE) { BOOL succeeded = PR_TRUE; diff --git a/gfx/thebes/GLContextSymbols.h b/gfx/thebes/GLContextSymbols.h new file mode 100644 index 000000000000..1aae7b0ab93f --- /dev/null +++ b/gfx/thebes/GLContextSymbols.h @@ -0,0 +1,371 @@ +/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Mozilla Corporation. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Vladimir Vukicevic + * Benoit Jacob + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef GLCONTEXTSYMBOLS_H_ +#define GLCONTEXTSYMBOLS_H_ + +/* + * This file should only be included by GLContext.h, and should be + * autogenerated in the future. + */ + +#ifndef GLAPIENTRY +#ifdef XP_WIN +#define GLAPIENTRY __stdcall +#else +#define GLAPIENTRY +#endif +#define GLAPI +#endif + +namespace mozilla { +namespace gl { + +struct GLContextSymbols +{ + GLContextSymbols() { + Zero(); + } + + void Zero() { + memset(this, 0, sizeof(this)); + } + + typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture); + PFNGLACTIVETEXTUREPROC fActiveTexture; + typedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); + PFNGLATTACHSHADERPROC fAttachShader; + typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name); + PFNGLBINDATTRIBLOCATIONPROC fBindAttribLocation; + typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); + PFNGLBINDBUFFERPROC fBindBuffer; + typedef void (GLAPIENTRY * PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); + PFNGLBINDTEXTUREPROC fBindTexture; + typedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + PFNGLBLENDCOLORPROC fBlendColor; + typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); + PFNGLBLENDEQUATIONPROC fBlendEquation; + typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum, GLenum); + PFNGLBLENDEQUATIONSEPARATEPROC fBlendEquationSeparate; + typedef void (GLAPIENTRY * PFNGLBLENDFUNCPROC) (GLenum, GLenum); + PFNGLBLENDFUNCPROC fBlendFunc; + typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); + PFNGLBLENDFUNCSEPARATEPROC fBlendFuncSeparate; + typedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); + PFNGLBUFFERDATAPROC fBufferData; + typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); + PFNGLBUFFERSUBDATAPROC fBufferSubData; + typedef void (GLAPIENTRY * PFNGLCLEARPROC) (GLbitfield); + PFNGLCLEARPROC fClear; + typedef void (GLAPIENTRY * PFNGLCLEARCOLORPROC) (GLclampf, GLclampf, GLclampf, GLclampf); + PFNGLCLEARCOLORPROC fClearColor; + typedef void (GLAPIENTRY * PFNGLCLEARSTENCILPROC) (GLint); + PFNGLCLEARSTENCILPROC fClearStencil; + typedef void (GLAPIENTRY * PFNGLCOLORMASKPROC) (realGLboolean red, realGLboolean green, realGLboolean blue, realGLboolean alpha); + PFNGLCOLORMASKPROC fColorMask; + typedef void (GLAPIENTRY * PFNGLCULLFACEPROC) (GLenum mode); + PFNGLCULLFACEPROC fCullFace; + typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); + PFNGLDETACHSHADERPROC fDetachShader; + typedef void (GLAPIENTRY * PFNGLDEPTHFUNCPROC) (GLenum); + PFNGLDEPTHFUNCPROC fDepthFunc; + typedef void (GLAPIENTRY * PFNGLDEPTHMASKPROC) (realGLboolean); + PFNGLDEPTHMASKPROC fDepthMask; + typedef void (GLAPIENTRY * PFNGLDISABLEPROC) (GLenum); + PFNGLDISABLEPROC fDisable; + typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint); + PFNGLDISABLEVERTEXATTRIBARRAYPROC fDisableVertexAttribArray; + typedef void (GLAPIENTRY * PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); + PFNGLDRAWARRAYSPROC fDrawArrays; + typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); + PFNGLDRAWELEMENTSPROC fDrawElements; + typedef void (GLAPIENTRY * PFNGLENABLEPROC) (GLenum); + PFNGLENABLEPROC fEnable; + typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint); + PFNGLENABLEVERTEXATTRIBARRAYPROC fEnableVertexAttribArray; + typedef void (GLAPIENTRY * PFNGLFINISHPROC) (void); + PFNGLFINISHPROC fFinish; + typedef void (GLAPIENTRY * PFNGLFLUSHPROC) (void); + PFNGLFLUSHPROC fFlush; + typedef void (GLAPIENTRY * PFNGLFRONTFACEPROC) (GLenum); + PFNGLFRONTFACEPROC fFrontFace; + typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); + PFNGLGETACTIVEATTRIBPROC fGetActiveAttrib; + typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); + PFNGLGETACTIVEUNIFORMPROC fGetActiveUniform; + typedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders); + PFNGLGETATTACHEDSHADERSPROC fGetAttachedShaders; + typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name); + PFNGLGETATTRIBLOCATIONPROC fGetAttribLocation; + typedef void (GLAPIENTRY * PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params); + PFNGLGETINTEGERVPROC fGetIntegerv; + typedef void (GLAPIENTRY * PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *params); + PFNGLGETFLOATVPROC fGetFloatv; + typedef void (GLAPIENTRY * PFNGLGETBOOLEANBPROC) (GLenum pname, realGLboolean *params); + PFNGLGETBOOLEANBPROC fGetBooleanv; + typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); + PFNGLGETBUFFERPARAMETERIVPROC fGetBufferParameteriv; + typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPPROC) (GLenum target); + PFNGLGENERATEMIPMAPPROC fGenerateMipmap; + typedef GLenum (GLAPIENTRY * PFNGLGETERRORPROC) (void); + PFNGLGETERRORPROC fGetError; + typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param); + PFNGLGETPROGRAMIVPROC fGetProgramiv; + typedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); + PFNGLGETPROGRAMINFOLOGPROC fGetProgramInfoLog; + typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); + PFNGLTEXPARAMETERIPROC fTexParameteri; + typedef void (GLAPIENTRY * PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); + PFNGLTEXPARAMETERFPROC fTexParameterf; + typedef GLubyte* (GLAPIENTRY * PFNGLGETSTRINGPROC) (GLenum); + PFNGLGETSTRINGPROC fGetString; + typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); + PFNGLGETTEXPARAMETERFVPROC fGetTexParameterfv; + typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); + PFNGLGETTEXPARAMETERIVPROC fGetTexParameteriv; + typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params); + PFNGLGETUNIFORMFVPROC fGetUniformfv; + typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params); + PFNGLGETUNIFORMIVPROC fGetUniformiv; + typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLint programObj, const GLchar* name); + PFNGLGETUNIFORMLOCATIONPROC fGetUniformLocation; + typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint, GLenum, GLfloat*); + PFNGLGETVERTEXATTRIBFVPROC fGetVertexAttribfv; + typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint, GLenum, GLint*); + PFNGLGETVERTEXATTRIBIVPROC fGetVertexAttribiv; + typedef void (GLAPIENTRY * PFNGLHINTPROC) (GLenum target, GLenum mode); + PFNGLHINTPROC fHint; + typedef realGLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer); + PFNGLISBUFFERPROC fIsBuffer; + typedef realGLboolean (GLAPIENTRY * PFNGLISENABLEDPROC) (GLenum cap); + PFNGLISENABLEDPROC fIsEnabled; + typedef realGLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program); + PFNGLISPROGRAMPROC fIsProgram; + typedef realGLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader); + PFNGLISSHADERPROC fIsShader; + typedef realGLboolean (GLAPIENTRY * PFNGLISTEXTUREPROC) (GLuint texture); + PFNGLISTEXTUREPROC fIsTexture; + typedef void (GLAPIENTRY * PFNGLLINEWIDTHPROC) (GLfloat width); + PFNGLLINEWIDTHPROC fLineWidth; + typedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program); + PFNGLLINKPROGRAMPROC fLinkProgram; + typedef void (GLAPIENTRY * PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); + PFNGLPIXELSTOREIPROC fPixelStorei; + typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat bias); + PFNGLPOLYGONOFFSETPROC fPolygonOffset; + typedef void (GLAPIENTRY * PFNGLREADBUFFERPROC) (GLenum); + PFNGLREADBUFFERPROC fReadBuffer; + typedef void (GLAPIENTRY * PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); + PFNGLREADPIXELSPROC fReadPixels; + typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, realGLboolean invert); + PFNGLSAMPLECOVERAGEPROC fSampleCoverage; + typedef void (GLAPIENTRY * PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); + PFNGLSTENCILFUNCPROC fStencilFunc; + typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); + PFNGLSTENCILFUNCSEPARATEPROC fStencilFuncSeparate; + typedef void (GLAPIENTRY * PFNGLSTENCILMASKPROC) (GLuint mask); + PFNGLSTENCILMASKPROC fStencilMask; + typedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum, GLuint); + PFNGLSTENCILMASKSEPARATEPROC fStencilMaskSeparate; + typedef void (GLAPIENTRY * PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); + PFNGLSTENCILOPPROC fStencilOp; + typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + PFNGLSTENCILOPSEPARATEPROC fStencilOpSeparate; + typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + PFNGLTEXIMAGE2DPROC fTexImage2D; + typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); + PFNGLTEXSUBIMAGE2DPROC fTexSubImage2D; + typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); + PFNGLUNIFORM1FPROC fUniform1f; + typedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value); + PFNGLUNIFORM1FVPROC fUniform1fv; + typedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0); + PFNGLUNIFORM1IPROC fUniform1i; + typedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value); + PFNGLUNIFORM1IVPROC fUniform1iv; + typedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); + PFNGLUNIFORM2FPROC fUniform2f; + typedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value); + PFNGLUNIFORM2FVPROC fUniform2fv; + typedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); + PFNGLUNIFORM2IPROC fUniform2i; + typedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value); + PFNGLUNIFORM2IVPROC fUniform2iv; + typedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + PFNGLUNIFORM3FPROC fUniform3f; + typedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value); + PFNGLUNIFORM3FVPROC fUniform3fv; + typedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); + PFNGLUNIFORM3IPROC fUniform3i; + typedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value); + PFNGLUNIFORM3IVPROC fUniform3iv; + typedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + PFNGLUNIFORM4FPROC fUniform4f; + typedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value); + PFNGLUNIFORM4FVPROC fUniform4fv; + typedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + PFNGLUNIFORM4IPROC fUniform4i; + typedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value); + PFNGLUNIFORM4IVPROC fUniform4iv; + typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value); + PFNGLUNIFORMMATRIX2FVPROC fUniformMatrix2fv; + typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value); + PFNGLUNIFORMMATRIX3FVPROC fUniformMatrix3fv; + typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value); + PFNGLUNIFORMMATRIX4FVPROC fUniformMatrix4fv; + typedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program); + PFNGLUSEPROGRAMPROC fUseProgram; + typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program); + PFNGLVALIDATEPROGRAMPROC fValidateProgram; + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, realGLboolean normalized, GLsizei stride, const GLvoid* pointer); + PFNGLVERTEXATTRIBPOINTERPROC fVertexAttribPointer; + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); + PFNGLVERTEXATTRIB1FPROC fVertexAttrib1f; + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); + PFNGLVERTEXATTRIB2FPROC fVertexAttrib2f; + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); + PFNGLVERTEXATTRIB3FPROC fVertexAttrib3f; + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + PFNGLVERTEXATTRIB4FPROC fVertexAttrib4f; + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v); + PFNGLVERTEXATTRIB1FVPROC fVertexAttrib1fv; + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v); + PFNGLVERTEXATTRIB2FVPROC fVertexAttrib2fv; + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v); + PFNGLVERTEXATTRIB3FVPROC fVertexAttrib3fv; + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v); + PFNGLVERTEXATTRIB4FVPROC fVertexAttrib4fv; + typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader); + PFNGLCOMPILESHADERPROC fCompileShader; + typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + PFNGLCOPYTEXIMAGE2DPROC fCopyTexImage2D; + typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + PFNGLCOPYTEXSUBIMAGE2DPROC fCopyTexSubImage2D; + typedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param); + PFNGLGETSHADERIVPROC fGetShaderiv; + typedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); + PFNGLGETSHADERINFOLOGPROC fGetShaderInfoLog; + typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source); + PFNGLGETSHADERSOURCEPROC fGetShaderSource; + typedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths); + PFNGLSHADERSOURCEPROC fShaderSource; + + typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFER) (GLenum target, GLuint framebuffer); + PFNGLBINDFRAMEBUFFER fBindFramebuffer; + typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFER) (GLenum target, GLuint renderbuffer); + PFNGLBINDRENDERBUFFER fBindRenderbuffer; + typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUS) (GLenum target); + PFNGLCHECKFRAMEBUFFERSTATUS fCheckFramebufferStatus; + typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFER) (GLenum target, GLenum attachmentPoint, GLenum renderbufferTarget, GLuint renderbuffer); + PFNGLFRAMEBUFFERRENDERBUFFER fFramebufferRenderbuffer; + typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2D) (GLenum target, GLenum attachmentPoint, GLenum textureTarget, GLuint texture, GLint level); + PFNGLFRAMEBUFFERTEXTURE2D fFramebufferTexture2D; + typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIV) (GLenum target, GLenum attachment, GLenum pname, GLint* value); + PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIV fGetFramebufferAttachmentParameteriv; + typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIV) (GLenum target, GLenum pname, GLint* value); + PFNGLGETRENDERBUFFERPARAMETERIV fGetRenderbufferParameteriv; + typedef realGLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFER) (GLuint framebuffer); + PFNGLISFRAMEBUFFER fIsFramebuffer; + typedef realGLboolean (GLAPIENTRY * PFNGLISRENDERBUFFER) (GLuint renderbuffer); + PFNGLISRENDERBUFFER fIsRenderbuffer; + typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGE) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height); + PFNGLRENDERBUFFERSTORAGE fRenderbufferStorage; + + + /* These are different between GLES2 and desktop GL; we hide those differences, use the GL + * names, but the most limited data type. + */ + typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFPROC) (GLclampf, GLclampf); + PFNGLDEPTHRANGEFPROC fDepthRangef; + typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFPROC) (GLclampf); + PFNGLCLEARDEPTHFPROC fClearDepthf; + + typedef void (GLAPIENTRY * PFNGLDEPTHRANGEPROC) (GLclampd, GLclampd); + PFNGLDEPTHRANGEPROC fDepthRange; + typedef void (GLAPIENTRY * PFNGLCLEARDEPTHPROC) (GLclampd); + PFNGLCLEARDEPTHPROC fClearDepth; + + /* These are special because we end up tracking these so that we don't + * have to query the values from GL. + */ + + typedef void (GLAPIENTRY * PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); + PFNGLVIEWPORTPROC fViewport; + typedef void (GLAPIENTRY * PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); + PFNGLSCISSORPROC fScissor; + + + /* These are special -- they create or delete GL resources that can live + * in a shared namespace. In DEBUG, we wrap these calls so that we can + * check when we have something that failed to do cleanup at the time the + * final context is destroyed. + */ + + typedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void); + PFNGLCREATEPROGRAMPROC fCreateProgram; + typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type); + PFNGLCREATESHADERPROC fCreateShader; + typedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers); + PFNGLGENBUFFERSPROC fGenBuffers; + typedef void (GLAPIENTRY * PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); + PFNGLGENTEXTURESPROC fGenTextures; + typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERS) (GLsizei n, GLuint* ids); + PFNGLGENFRAMEBUFFERS fGenFramebuffers; + typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERS) (GLsizei n, GLuint* ids); + PFNGLGENRENDERBUFFERS fGenRenderbuffers; + + typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program); + PFNGLDELETEPROGRAMPROC fDeleteProgram; + typedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader); + PFNGLDELETESHADERPROC fDeleteShader; + typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers); + PFNGLDELETEBUFFERSPROC fDeleteBuffers; + typedef void (GLAPIENTRY * PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint* textures); + PFNGLDELETETEXTURESPROC fDeleteTextures; + typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERS) (GLsizei n, const GLuint* ids); + PFNGLDELETEFRAMEBUFFERS fDeleteFramebuffers; + typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERS) (GLsizei n, const GLuint* ids); + PFNGLDELETERENDERBUFFERS fDeleteRenderbuffers; + +}; + +} +} + +#endif /* GLCONTEXTSYMBOLS_H_ */ diff --git a/gfx/thebes/Makefile.in b/gfx/thebes/Makefile.in index 4405267246ca..6ba2913917a7 100644 --- a/gfx/thebes/Makefile.in +++ b/gfx/thebes/Makefile.in @@ -40,6 +40,7 @@ EXPORTS = \ gfxUserFontSet.h \ GLDefs.h \ GLContext.h \ + GLContextSymbols.h \ GLContextProvider.h \ GLContextProviderImpl.h \ nsCoreAnimationSupport.h \ diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp index a94f17be0417..eefb9143c4aa 100644 --- a/widget/src/gtk2/nsWindow.cpp +++ b/widget/src/gtk2/nsWindow.cpp @@ -44,7 +44,6 @@ #endif #include "prlink.h" - #include "nsWindow.h" #include "nsGTKToolkit.h" #include "nsIDeviceContext.h"