Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | |
michael@0 | 2 | /* |
michael@0 | 3 | * Copyright 2011 Google Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #include "gl/GrGLInterface.h" |
michael@0 | 11 | |
michael@0 | 12 | #import <OpenGLES/ES2/gl.h> |
michael@0 | 13 | #import <OpenGLES/ES2/glext.h> |
michael@0 | 14 | |
michael@0 | 15 | const GrGLInterface* GrGLCreateNativeInterface() { |
michael@0 | 16 | GrGLInterface* interface = SkNEW(GrGLInterface); |
michael@0 | 17 | |
michael@0 | 18 | GrGLInterface::Functions* functions = &interface->fFunctions; |
michael@0 | 19 | |
michael@0 | 20 | functions->fActiveTexture = glActiveTexture; |
michael@0 | 21 | functions->fAttachShader = glAttachShader; |
michael@0 | 22 | functions->fBindAttribLocation = glBindAttribLocation; |
michael@0 | 23 | functions->fBindBuffer = glBindBuffer; |
michael@0 | 24 | functions->fBindTexture = glBindTexture; |
michael@0 | 25 | functions->fBlendColor = glBlendColor; |
michael@0 | 26 | functions->fBlendFunc = glBlendFunc; |
michael@0 | 27 | functions->fBufferData = (GrGLBufferDataProc)glBufferData; |
michael@0 | 28 | functions->fBufferSubData = (GrGLBufferSubDataProc)glBufferSubData; |
michael@0 | 29 | functions->fClear = glClear; |
michael@0 | 30 | functions->fClearColor = glClearColor; |
michael@0 | 31 | functions->fClearStencil = glClearStencil; |
michael@0 | 32 | functions->fColorMask = glColorMask; |
michael@0 | 33 | functions->fCompileShader = glCompileShader; |
michael@0 | 34 | functions->fCompressedTexImage2D = glCompressedTexImage2D; |
michael@0 | 35 | functions->fCopyTexSubImage2D = glCopyTexSubImage2D; |
michael@0 | 36 | functions->fCreateProgram = glCreateProgram; |
michael@0 | 37 | functions->fCreateShader = glCreateShader; |
michael@0 | 38 | functions->fCullFace = glCullFace; |
michael@0 | 39 | functions->fDeleteBuffers = glDeleteBuffers; |
michael@0 | 40 | functions->fDeleteProgram = glDeleteProgram; |
michael@0 | 41 | functions->fDeleteShader = glDeleteShader; |
michael@0 | 42 | functions->fDeleteTextures = glDeleteTextures; |
michael@0 | 43 | functions->fDepthMask = glDepthMask; |
michael@0 | 44 | functions->fDisable = glDisable; |
michael@0 | 45 | functions->fDisableVertexAttribArray = glDisableVertexAttribArray; |
michael@0 | 46 | functions->fDrawArrays = glDrawArrays; |
michael@0 | 47 | functions->fDrawBuffer = NULL; |
michael@0 | 48 | functions->fDrawBuffers = NULL; |
michael@0 | 49 | functions->fDrawElements = glDrawElements; |
michael@0 | 50 | functions->fEnable = glEnable; |
michael@0 | 51 | functions->fEnableVertexAttribArray = glEnableVertexAttribArray; |
michael@0 | 52 | functions->fFinish = glFinish; |
michael@0 | 53 | functions->fFlush = glFlush; |
michael@0 | 54 | functions->fFrontFace = glFrontFace; |
michael@0 | 55 | functions->fGenBuffers = glGenBuffers; |
michael@0 | 56 | functions->fGenerateMipmap = glGenerateMipmap; |
michael@0 | 57 | functions->fGetBufferParameteriv = glGetBufferParameteriv; |
michael@0 | 58 | functions->fGetError = glGetError; |
michael@0 | 59 | functions->fGetIntegerv = glGetIntegerv; |
michael@0 | 60 | functions->fGetProgramInfoLog = glGetProgramInfoLog; |
michael@0 | 61 | functions->fGetProgramiv = glGetProgramiv; |
michael@0 | 62 | functions->fGetShaderInfoLog = glGetShaderInfoLog; |
michael@0 | 63 | functions->fGetShaderiv = glGetShaderiv; |
michael@0 | 64 | functions->fGetString = glGetString; |
michael@0 | 65 | functions->fGenTextures = glGenTextures; |
michael@0 | 66 | functions->fGetUniformLocation = glGetUniformLocation; |
michael@0 | 67 | functions->fLineWidth = glLineWidth; |
michael@0 | 68 | functions->fLinkProgram = glLinkProgram; |
michael@0 | 69 | functions->fPixelStorei = glPixelStorei; |
michael@0 | 70 | functions->fReadBuffer = NULL; |
michael@0 | 71 | functions->fReadPixels = glReadPixels; |
michael@0 | 72 | functions->fScissor = glScissor; |
michael@0 | 73 | functions->fShaderSource = glShaderSource; |
michael@0 | 74 | functions->fStencilFunc = glStencilFunc; |
michael@0 | 75 | functions->fStencilFuncSeparate = glStencilFuncSeparate; |
michael@0 | 76 | functions->fStencilMask = glStencilMask; |
michael@0 | 77 | functions->fStencilMaskSeparate = glStencilMaskSeparate; |
michael@0 | 78 | functions->fStencilOp = glStencilOp; |
michael@0 | 79 | functions->fStencilOpSeparate = glStencilOpSeparate; |
michael@0 | 80 | // mac uses GLenum for internalFormat param (non-standard) |
michael@0 | 81 | // amounts to int vs. uint. |
michael@0 | 82 | functions->fTexImage2D = (GrGLTexImage2DProc)glTexImage2D; |
michael@0 | 83 | #if GL_ARB_texture_storage |
michael@0 | 84 | functions->fTexStorage2D = glTexStorage2D; |
michael@0 | 85 | #elif GL_EXT_texture_storage |
michael@0 | 86 | functions->fTexStorage2D = glTexStorage2DEXT; |
michael@0 | 87 | #endif |
michael@0 | 88 | #if GL_EXT_discard_framebuffer |
michael@0 | 89 | functions->fDiscardFramebuffer = glDiscardFramebufferEXT; |
michael@0 | 90 | #endif |
michael@0 | 91 | functions->fTexParameteri = glTexParameteri; |
michael@0 | 92 | functions->fTexParameteriv = glTexParameteriv; |
michael@0 | 93 | functions->fTexSubImage2D = glTexSubImage2D; |
michael@0 | 94 | functions->fUniform1f = glUniform1f; |
michael@0 | 95 | functions->fUniform1i = glUniform1i; |
michael@0 | 96 | functions->fUniform1fv = glUniform1fv; |
michael@0 | 97 | functions->fUniform1iv = glUniform1iv; |
michael@0 | 98 | functions->fUniform2f = glUniform2f; |
michael@0 | 99 | functions->fUniform2i = glUniform2i; |
michael@0 | 100 | functions->fUniform2fv = glUniform2fv; |
michael@0 | 101 | functions->fUniform2iv = glUniform2iv; |
michael@0 | 102 | functions->fUniform3f = glUniform3f; |
michael@0 | 103 | functions->fUniform3i = glUniform3i; |
michael@0 | 104 | functions->fUniform3fv = glUniform3fv; |
michael@0 | 105 | functions->fUniform3iv = glUniform3iv; |
michael@0 | 106 | functions->fUniform4f = glUniform4f; |
michael@0 | 107 | functions->fUniform4i = glUniform4i; |
michael@0 | 108 | functions->fUniform4fv = glUniform4fv; |
michael@0 | 109 | functions->fUniform4iv = glUniform4iv; |
michael@0 | 110 | functions->fUniform4fv = glUniform4fv; |
michael@0 | 111 | functions->fUniformMatrix2fv = glUniformMatrix2fv; |
michael@0 | 112 | functions->fUniformMatrix3fv = glUniformMatrix3fv; |
michael@0 | 113 | functions->fUniformMatrix4fv = glUniformMatrix4fv; |
michael@0 | 114 | functions->fUseProgram = glUseProgram; |
michael@0 | 115 | functions->fVertexAttrib4fv = glVertexAttrib4fv; |
michael@0 | 116 | functions->fVertexAttribPointer = glVertexAttribPointer; |
michael@0 | 117 | functions->fViewport = glViewport; |
michael@0 | 118 | functions->fGenFramebuffers = glGenFramebuffers; |
michael@0 | 119 | functions->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv; |
michael@0 | 120 | functions->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv; |
michael@0 | 121 | functions->fBindFramebuffer = glBindFramebuffer; |
michael@0 | 122 | functions->fFramebufferTexture2D = glFramebufferTexture2D; |
michael@0 | 123 | functions->fCheckFramebufferStatus = glCheckFramebufferStatus; |
michael@0 | 124 | functions->fDeleteFramebuffers = glDeleteFramebuffers; |
michael@0 | 125 | functions->fRenderbufferStorage = glRenderbufferStorage; |
michael@0 | 126 | functions->fGenRenderbuffers = glGenRenderbuffers; |
michael@0 | 127 | functions->fDeleteRenderbuffers = glDeleteRenderbuffers; |
michael@0 | 128 | functions->fFramebufferRenderbuffer = glFramebufferRenderbuffer; |
michael@0 | 129 | functions->fBindRenderbuffer = glBindRenderbuffer; |
michael@0 | 130 | |
michael@0 | 131 | #if GL_OES_mapbuffer |
michael@0 | 132 | functions->fMapBuffer = glMapBufferOES; |
michael@0 | 133 | functions->fUnmapBuffer = glUnmapBufferOES; |
michael@0 | 134 | #endif |
michael@0 | 135 | |
michael@0 | 136 | #if GL_APPLE_framebuffer_multisample |
michael@0 | 137 | functions->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleAPPLE; |
michael@0 | 138 | functions->fResolveMultisampleFramebuffer = glResolveMultisampleFramebufferAPPLE; |
michael@0 | 139 | #endif |
michael@0 | 140 | |
michael@0 | 141 | #if GL_OES_vertex_array_object |
michael@0 | 142 | functions->fBindVertexArray = glBindVertexArrayOES; |
michael@0 | 143 | functions->fDeleteVertexArrays = glDeleteVertexArraysOES; |
michael@0 | 144 | functions->fGenVertexArrays = glGenVertexArraysOES; |
michael@0 | 145 | #endif |
michael@0 | 146 | |
michael@0 | 147 | #if GL_EXT_debug_marker |
michael@0 | 148 | functions->fInsertEventMarker = glInsertEventMarkerEXT; |
michael@0 | 149 | functions->fPushGroupMarker = glPushGroupMarkerEXT; |
michael@0 | 150 | functions->fPopGroupMarker = glPopGroupMarkerEXT; |
michael@0 | 151 | #endif |
michael@0 | 152 | |
michael@0 | 153 | interface->fStandard = kGLES_GrGLStandard; |
michael@0 | 154 | interface->fExtensions.init(kGLES_GrGLStandard, glGetString, NULL, glGetIntegerv); |
michael@0 | 155 | |
michael@0 | 156 | return interface; |
michael@0 | 157 | } |