aboutsummaryrefslogtreecommitdiffhomepage
path: root/gpu/src/ios
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-19 13:28:54 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-19 13:28:54 +0000
commit0b77d6892b067ad402c9678b0226bff70599fbe2 (patch)
treec3659ba65d516bedf2d3a021f2b9f4be94d3f04b /gpu/src/ios
parent098660020cf06ef9a95934b9635ab6996145b3e2 (diff)
Make GrGLInterface a per-GrContext refcounted object rather than a global
Review URL: http://codereview.appspot.com/4901046/ git-svn-id: http://skia.googlecode.com/svn/trunk@2140 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/src/ios')
-rw-r--r--gpu/src/ios/GrGLDefaultInterface_iOS.cpp251
1 files changed, 124 insertions, 127 deletions
diff --git a/gpu/src/ios/GrGLDefaultInterface_iOS.cpp b/gpu/src/ios/GrGLDefaultInterface_iOS.cpp
index 7bdbcc7079..6f5b28b463 100644
--- a/gpu/src/ios/GrGLDefaultInterface_iOS.cpp
+++ b/gpu/src/ios/GrGLDefaultInterface_iOS.cpp
@@ -15,138 +15,135 @@
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
-void GrGLSetDefaultGLInterface() {
- static GrGLInterface gDefaultInterface;
- static bool gDefaultInterfaceInit;
- if (!gDefaultInterfaceInit) {
- gDefaultInterface.fNPOTRenderTargetSupport = kProbe_GrGLCapability;
- gDefaultInterface.fMinRenderTargetHeight = kProbe_GrGLCapability;
- gDefaultInterface.fMinRenderTargetWidth = kProbe_GrGLCapability;
-
- gDefaultInterface.fActiveTexture = glActiveTexture;
- gDefaultInterface.fAttachShader = glAttachShader;
- gDefaultInterface.fBindAttribLocation = glBindAttribLocation;
- gDefaultInterface.fBindBuffer = glBindBuffer;
- gDefaultInterface.fBindTexture = glBindTexture;
- gDefaultInterface.fBlendColor = glBlendColor;
- gDefaultInterface.fBlendFunc = glBlendFunc;
- gDefaultInterface.fBufferData = (GrGLBufferDataProc)glBufferData;
- gDefaultInterface.fBufferSubData = (GrGLBufferSubDataProc)glBufferSubData;
- gDefaultInterface.fClear = glClear;
- gDefaultInterface.fClearColor = glClearColor;
- gDefaultInterface.fClearStencil = glClearStencil;
- gDefaultInterface.fClientActiveTexture = glClientActiveTexture;
- gDefaultInterface.fColorMask = glColorMask;
- gDefaultInterface.fColorPointer = glColorPointer;
- gDefaultInterface.fColor4ub = glColor4ub;
- gDefaultInterface.fCompileShader = glCompileShader;
- gDefaultInterface.fCompressedTexImage2D = glCompressedTexImage2D;
- gDefaultInterface.fCreateProgram = glCreateProgram;
- gDefaultInterface.fCreateShader = glCreateShader;
- gDefaultInterface.fCullFace = glCullFace;
- gDefaultInterface.fDeleteBuffers = glDeleteBuffers;
- gDefaultInterface.fDeleteProgram = glDeleteProgram;
- gDefaultInterface.fDeleteShader = glDeleteShader;
- gDefaultInterface.fDeleteTextures = glDeleteTextures;
- gDefaultInterface.fDepthMask = glDepthMask;
- gDefaultInterface.fDisable = glDisable;
- gDefaultInterface.fDisableClientState = glDisableClientState;
- gDefaultInterface.fDisableVertexAttribArray =
- glDisableVertexAttribArray;
- gDefaultInterface.fDrawArrays = glDrawArrays;
- gDefaultInterface.fDrawElements = glDrawElements;
- gDefaultInterface.fEnable = glEnable;
- gDefaultInterface.fEnableClientState = glEnableClientState;
- gDefaultInterface.fEnableVertexAttribArray = glEnableVertexAttribArray;
- gDefaultInterface.fFrontFace = glFrontFace;
- gDefaultInterface.fGenBuffers = glGenBuffers;
- gDefaultInterface.fGetBufferParameteriv = glGetBufferParameteriv;
- gDefaultInterface.fGetError = glGetError;
- gDefaultInterface.fGetIntegerv = glGetIntegerv;
- gDefaultInterface.fGetProgramInfoLog = glGetProgramInfoLog;
- gDefaultInterface.fGetProgramiv = glGetProgramiv;
- gDefaultInterface.fGetShaderInfoLog = glGetShaderInfoLog;
- gDefaultInterface.fGetShaderiv = glGetShaderiv;
- gDefaultInterface.fGetString = glGetString;
- gDefaultInterface.fGenTextures = glGenTextures;
- gDefaultInterface.fGetUniformLocation = glGetUniformLocation;
- gDefaultInterface.fLineWidth = glLineWidth;
- gDefaultInterface.fLinkProgram = glLinkProgram;
- gDefaultInterface.fLoadMatrixf = glLoadMatrixf;
- gDefaultInterface.fMatrixMode = glMatrixMode;
- gDefaultInterface.fPointSize = glPointSize;
- gDefaultInterface.fPixelStorei = glPixelStorei;
- gDefaultInterface.fReadBuffer = NULL;
- gDefaultInterface.fReadPixels = glReadPixels;
- gDefaultInterface.fScissor = glScissor;
- gDefaultInterface.fShadeModel = glShadeModel;
- gDefaultInterface.fShaderSource = glShaderSource;
- gDefaultInterface.fStencilFunc = glStencilFunc;
- gDefaultInterface.fStencilFuncSeparate = glStencilFuncSeparate;
- gDefaultInterface.fStencilMask = glStencilMask;
- gDefaultInterface.fStencilMaskSeparate = glStencilMaskSeparate;
- gDefaultInterface.fStencilOp = glStencilOp;
- gDefaultInterface.fStencilOpSeparate = glStencilOpSeparate;
- gDefaultInterface.fTexCoordPointer = glTexCoordPointer;
- gDefaultInterface.fTexEnvi = glTexEnvi;
- // mac uses GLenum for internalFormat param (non-standard)
- // amounts to int vs. uint.
- gDefaultInterface.fTexImage2D = (GrGLTexImage2DProc)glTexImage2D;
- gDefaultInterface.fTexParameteri = glTexParameteri;
- gDefaultInterface.fTexSubImage2D = glTexSubImage2D;
- gDefaultInterface.fUniform1f = glUniform1f;
- gDefaultInterface.fUniform1i = glUniform1i;
- gDefaultInterface.fUniform1fv = glUniform1fv;
- gDefaultInterface.fUniform1iv = glUniform1iv;
- gDefaultInterface.fUniform2f = glUniform2f;
- gDefaultInterface.fUniform2i = glUniform2i;
- gDefaultInterface.fUniform2fv = glUniform2fv;
- gDefaultInterface.fUniform2iv = glUniform2iv;
- gDefaultInterface.fUniform3f = glUniform3f;
- gDefaultInterface.fUniform3i = glUniform3i;
- gDefaultInterface.fUniform3fv = glUniform3fv;
- gDefaultInterface.fUniform3iv = glUniform3iv;
- gDefaultInterface.fUniform4f = glUniform4f;
- gDefaultInterface.fUniform4i = glUniform4i;
- gDefaultInterface.fUniform4fv = glUniform4fv;
- gDefaultInterface.fUniform4iv = glUniform4iv;
- gDefaultInterface.fUniform4fv = glUniform4fv;
- gDefaultInterface.fUniformMatrix2fv = glUniformMatrix2fv;
- gDefaultInterface.fUniformMatrix3fv = glUniformMatrix3fv;
- gDefaultInterface.fUniformMatrix4fv = glUniformMatrix4fv;
- gDefaultInterface.fUseProgram = glUseProgram;
- gDefaultInterface.fVertexAttrib4fv = glVertexAttrib4fv;
- gDefaultInterface.fVertexAttribPointer = glVertexAttribPointer;
- gDefaultInterface.fVertexPointer = glVertexPointer;
- gDefaultInterface.fViewport = glViewport;
-
- gDefaultInterface.fGenFramebuffers = glGenFramebuffers;
- gDefaultInterface.fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
- gDefaultInterface.fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
- gDefaultInterface.fBindFramebuffer = glBindFramebuffer;
- gDefaultInterface.fFramebufferTexture2D = glFramebufferTexture2D;
- gDefaultInterface.fCheckFramebufferStatus = glCheckFramebufferStatus;
- gDefaultInterface.fDeleteFramebuffers = glDeleteFramebuffers;
- gDefaultInterface.fRenderbufferStorage = glRenderbufferStorage;
- gDefaultInterface.fGenRenderbuffers = glGenRenderbuffers;
- gDefaultInterface.fDeleteRenderbuffers = glDeleteRenderbuffers;
- gDefaultInterface.fFramebufferRenderbuffer = glFramebufferRenderbuffer;
- gDefaultInterface.fBindRenderbuffer = glBindRenderbuffer;
+void GrGLInitializeDefaultGLInterface() {
+ GrGLInterface* defaultInterface = new GrGLInterface();
+
+ defaultInterface->fNPOTRenderTargetSupport = kProbe_GrGLCapability;
+ defaultInterface->fMinRenderTargetHeight = kProbe_GrGLCapability;
+ defaultInterface->fMinRenderTargetWidth = kProbe_GrGLCapability;
+ defaultInterface->fActiveTexture = glActiveTexture;
+ defaultInterface->fAttachShader = glAttachShader;
+ defaultInterface->fBindAttribLocation = glBindAttribLocation;
+ defaultInterface->fBindBuffer = glBindBuffer;
+ defaultInterface->fBindTexture = glBindTexture;
+ defaultInterface->fBlendColor = glBlendColor;
+ defaultInterface->fBlendFunc = glBlendFunc;
+ defaultInterface->fBufferData = (GrGLBufferDataProc)glBufferData;
+ defaultInterface->fBufferSubData = (GrGLBufferSubDataProc)glBufferSubData;
+ defaultInterface->fClear = glClear;
+ defaultInterface->fClearColor = glClearColor;
+ defaultInterface->fClearStencil = glClearStencil;
+ defaultInterface->fClientActiveTexture = glClientActiveTexture;
+ defaultInterface->fColorMask = glColorMask;
+ defaultInterface->fColorPointer = glColorPointer;
+ defaultInterface->fColor4ub = glColor4ub;
+ defaultInterface->fCompileShader = glCompileShader;
+ defaultInterface->fCompressedTexImage2D = glCompressedTexImage2D;
+ defaultInterface->fCreateProgram = glCreateProgram;
+ defaultInterface->fCreateShader = glCreateShader;
+ defaultInterface->fCullFace = glCullFace;
+ defaultInterface->fDeleteBuffers = glDeleteBuffers;
+ defaultInterface->fDeleteProgram = glDeleteProgram;
+ defaultInterface->fDeleteShader = glDeleteShader;
+ defaultInterface->fDeleteTextures = glDeleteTextures;
+ defaultInterface->fDepthMask = glDepthMask;
+ defaultInterface->fDisable = glDisable;
+ defaultInterface->fDisableClientState = glDisableClientState;
+ defaultInterface->fDisableVertexAttribArray =
+ glDisableVertexAttribArray;
+ defaultInterface->fDrawArrays = glDrawArrays;
+ defaultInterface->fDrawBuffer = NULL;
+ defaultInterface->fDrawBuffers = NULL;
+ defaultInterface->fDrawElements = glDrawElements;
+ defaultInterface->fEnable = glEnable;
+ defaultInterface->fEnableClientState = glEnableClientState;
+ defaultInterface->fEnableVertexAttribArray = glEnableVertexAttribArray;
+ defaultInterface->fFrontFace = glFrontFace;
+ defaultInterface->fGenBuffers = glGenBuffers;
+ defaultInterface->fGetBufferParameteriv = glGetBufferParameteriv;
+ defaultInterface->fGetError = glGetError;
+ defaultInterface->fGetIntegerv = glGetIntegerv;
+ defaultInterface->fGetProgramInfoLog = glGetProgramInfoLog;
+ defaultInterface->fGetProgramiv = glGetProgramiv;
+ defaultInterface->fGetShaderInfoLog = glGetShaderInfoLog;
+ defaultInterface->fGetShaderiv = glGetShaderiv;
+ defaultInterface->fGetString = glGetString;
+ defaultInterface->fGenTextures = glGenTextures;
+ defaultInterface->fGetUniformLocation = glGetUniformLocation;
+ defaultInterface->fLineWidth = glLineWidth;
+ defaultInterface->fLinkProgram = glLinkProgram;
+ defaultInterface->fLoadMatrixf = glLoadMatrixf;
+ defaultInterface->fMatrixMode = glMatrixMode;
+ defaultInterface->fPointSize = glPointSize;
+ defaultInterface->fPixelStorei = glPixelStorei;
+ defaultInterface->fReadBuffer = NULL;
+ defaultInterface->fReadPixels = glReadPixels;
+ defaultInterface->fScissor = glScissor;
+ defaultInterface->fShadeModel = glShadeModel;
+ defaultInterface->fShaderSource = glShaderSource;
+ defaultInterface->fStencilFunc = glStencilFunc;
+ defaultInterface->fStencilFuncSeparate = glStencilFuncSeparate;
+ defaultInterface->fStencilMask = glStencilMask;
+ defaultInterface->fStencilMaskSeparate = glStencilMaskSeparate;
+ defaultInterface->fStencilOp = glStencilOp;
+ defaultInterface->fStencilOpSeparate = glStencilOpSeparate;
+ defaultInterface->fTexCoordPointer = glTexCoordPointer;
+ defaultInterface->fTexEnvi = glTexEnvi;
+ // mac uses GLenum for internalFormat param (non-standard)
+ // amounts to int vs. uint.
+ defaultInterface->fTexImage2D = (GrGLTexImage2DProc)glTexImage2D;
+ defaultInterface->fTexParameteri = glTexParameteri;
+ defaultInterface->fTexSubImage2D = glTexSubImage2D;
+ defaultInterface->fUniform1f = glUniform1f;
+ defaultInterface->fUniform1i = glUniform1i;
+ defaultInterface->fUniform1fv = glUniform1fv;
+ defaultInterface->fUniform1iv = glUniform1iv;
+ defaultInterface->fUniform2f = glUniform2f;
+ defaultInterface->fUniform2i = glUniform2i;
+ defaultInterface->fUniform2fv = glUniform2fv;
+ defaultInterface->fUniform2iv = glUniform2iv;
+ defaultInterface->fUniform3f = glUniform3f;
+ defaultInterface->fUniform3i = glUniform3i;
+ defaultInterface->fUniform3fv = glUniform3fv;
+ defaultInterface->fUniform3iv = glUniform3iv;
+ defaultInterface->fUniform4f = glUniform4f;
+ defaultInterface->fUniform4i = glUniform4i;
+ defaultInterface->fUniform4fv = glUniform4fv;
+ defaultInterface->fUniform4iv = glUniform4iv;
+ defaultInterface->fUniform4fv = glUniform4fv;
+ defaultInterface->fUniformMatrix2fv = glUniformMatrix2fv;
+ defaultInterface->fUniformMatrix3fv = glUniformMatrix3fv;
+ defaultInterface->fUniformMatrix4fv = glUniformMatrix4fv;
+ defaultInterface->fUseProgram = glUseProgram;
+ defaultInterface->fVertexAttrib4fv = glVertexAttrib4fv;
+ defaultInterface->fVertexAttribPointer = glVertexAttribPointer;
+ defaultInterface->fVertexPointer = glVertexPointer;
+ defaultInterface->fViewport = glViewport;
+ defaultInterface->fGenFramebuffers = glGenFramebuffers;
+ defaultInterface->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
+ defaultInterface->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
+ defaultInterface->fBindFramebuffer = glBindFramebuffer;
+ defaultInterface->fFramebufferTexture2D = glFramebufferTexture2D;
+ defaultInterface->fCheckFramebufferStatus = glCheckFramebufferStatus;
+ defaultInterface->fDeleteFramebuffers = glDeleteFramebuffers;
+ defaultInterface->fRenderbufferStorage = glRenderbufferStorage;
+ defaultInterface->fGenRenderbuffers = glGenRenderbuffers;
+ defaultInterface->fDeleteRenderbuffers = glDeleteRenderbuffers;
+ defaultInterface->fFramebufferRenderbuffer = glFramebufferRenderbuffer;
+ defaultInterface->fBindRenderbuffer = glBindRenderbuffer;
#if GL_OES_mapbuffer
- gDefaultInterface.fMapBuffer = glMapBufferOES;
- gDefaultInterface.fUnmapBuffer = glUnmapBufferOES;
+ defaultInterface->fMapBuffer = glMapBufferOES;
+ defaultInterface->fUnmapBuffer = glUnmapBufferOES;
#endif
#if GL_APPLE_framebuffer_multisample
- gDefaultInterface.fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleAPPLE;
- gDefaultInterface.fResolveMultisampleFramebuffer = glResolveMultisampleFramebufferAPPLE;
+ defaultInterface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleAPPLE;
+ defaultInterface->fResolveMultisampleFramebuffer = glResolveMultisampleFramebufferAPPLE;
#endif
- gDefaultInterface.fBindFragDataLocationIndexed = NULL;
+ defaultInterface->fBindFragDataLocationIndexed = NULL;
- gDefaultInterface.fBindingsExported = kES2_GrGLBinding;
-
- gDefaultInterfaceInit = true;
- }
- GrGLSetGLInterface(&gDefaultInterface);
+ defaultInterface->fBindingsExported = kES2_GrGLBinding | kES1_GrGLBinding;
+
+ GrGLSetDefaultGLInterface(&defaultInterface)->unref();
} \ No newline at end of file