gfx/skia/trunk/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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 #include "../GrGLUtil.h"
michael@0 12
michael@0 13 #include <GL/glx.h>
michael@0 14 #include <GL/gl.h>
michael@0 15 #include <GL/glext.h>
michael@0 16 #include <GL/glu.h>
michael@0 17
michael@0 18 #define GR_GL_GET_PROC(F) interface->fFunctions.f ## F = (GrGL ## F ## Proc) \
michael@0 19 glXGetProcAddress(reinterpret_cast<const GLubyte*>("gl" #F));
michael@0 20 #define GR_GL_GET_PROC_SUFFIX(F, S) interface->fFunctions.f ## F = (GrGL ## F ## Proc) \
michael@0 21 glXGetProcAddress(reinterpret_cast<const GLubyte*>("gl" #F #S));
michael@0 22
michael@0 23 const GrGLInterface* GrGLCreateNativeInterface() {
michael@0 24 if (NULL != glXGetCurrentContext()) {
michael@0 25
michael@0 26 const char* versionString = (const char*) glGetString(GL_VERSION);
michael@0 27 GrGLVersion glVer = GrGLGetVersionFromString(versionString);
michael@0 28
michael@0 29 // This may or may not succeed depending on the gl version.
michael@0 30 GrGLGetStringiProc glGetStringi =
michael@0 31 (GrGLGetStringiProc) glXGetProcAddress(reinterpret_cast<const GLubyte*>("glGetStringi"));
michael@0 32
michael@0 33 GrGLExtensions extensions;
michael@0 34 if (!extensions.init(kGL_GrGLStandard, glGetString, glGetStringi, glGetIntegerv)) {
michael@0 35 return NULL;
michael@0 36 }
michael@0 37
michael@0 38 if (glVer < GR_GL_VER(1,5)) {
michael@0 39 // We must have array and element_array buffer objects.
michael@0 40 return NULL;
michael@0 41 }
michael@0 42
michael@0 43 GrGLInterface* interface = SkNEW(GrGLInterface());
michael@0 44 GrGLInterface::Functions* functions = &interface->fFunctions;
michael@0 45
michael@0 46 functions->fActiveTexture = glActiveTexture;
michael@0 47 GR_GL_GET_PROC(AttachShader);
michael@0 48 GR_GL_GET_PROC(BindAttribLocation);
michael@0 49 GR_GL_GET_PROC(BindBuffer);
michael@0 50 GR_GL_GET_PROC(BindFragDataLocation);
michael@0 51 GR_GL_GET_PROC(BeginQuery);
michael@0 52 functions->fBindTexture = glBindTexture;
michael@0 53 functions->fBlendFunc = glBlendFunc;
michael@0 54
michael@0 55 if (glVer >= GR_GL_VER(1,4) ||
michael@0 56 extensions.has("GL_ARB_imaging") ||
michael@0 57 extensions.has("GL_EXT_blend_color")) {
michael@0 58 GR_GL_GET_PROC(BlendColor);
michael@0 59 }
michael@0 60
michael@0 61 GR_GL_GET_PROC(BufferData);
michael@0 62 GR_GL_GET_PROC(BufferSubData);
michael@0 63 functions->fClear = glClear;
michael@0 64 functions->fClearColor = glClearColor;
michael@0 65 functions->fClearStencil = glClearStencil;
michael@0 66 functions->fColorMask = glColorMask;
michael@0 67 GR_GL_GET_PROC(CompileShader);
michael@0 68 functions->fCompressedTexImage2D = glCompressedTexImage2D;
michael@0 69 functions->fCopyTexSubImage2D = glCopyTexSubImage2D;
michael@0 70 GR_GL_GET_PROC(CreateProgram);
michael@0 71 GR_GL_GET_PROC(CreateShader);
michael@0 72 functions->fCullFace = glCullFace;
michael@0 73 GR_GL_GET_PROC(DeleteBuffers);
michael@0 74 GR_GL_GET_PROC(DeleteProgram);
michael@0 75 GR_GL_GET_PROC(DeleteQueries);
michael@0 76 GR_GL_GET_PROC(DeleteShader);
michael@0 77 functions->fDeleteTextures = glDeleteTextures;
michael@0 78 functions->fDepthMask = glDepthMask;
michael@0 79 functions->fDisable = glDisable;
michael@0 80 GR_GL_GET_PROC(DisableVertexAttribArray);
michael@0 81 functions->fDrawArrays = glDrawArrays;
michael@0 82 functions->fDrawBuffer = glDrawBuffer;
michael@0 83 GR_GL_GET_PROC(DrawBuffers);
michael@0 84 functions->fDrawElements = glDrawElements;
michael@0 85 functions->fEnable = glEnable;
michael@0 86 GR_GL_GET_PROC(EnableVertexAttribArray);
michael@0 87 GR_GL_GET_PROC(EndQuery);
michael@0 88 functions->fFinish = glFinish;
michael@0 89 functions->fFlush = glFlush;
michael@0 90 functions->fFrontFace = glFrontFace;
michael@0 91 GR_GL_GET_PROC(GenBuffers);
michael@0 92 GR_GL_GET_PROC(GenerateMipmap);
michael@0 93 GR_GL_GET_PROC(GetBufferParameteriv);
michael@0 94 functions->fGetError = glGetError;
michael@0 95 functions->fGetIntegerv = glGetIntegerv;
michael@0 96 GR_GL_GET_PROC(GetQueryObjectiv);
michael@0 97 GR_GL_GET_PROC(GetQueryObjectuiv);
michael@0 98 if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) {
michael@0 99 GR_GL_GET_PROC(GetQueryObjecti64v);
michael@0 100 GR_GL_GET_PROC(GetQueryObjectui64v);
michael@0 101 GR_GL_GET_PROC(QueryCounter);
michael@0 102 } else if (extensions.has("GL_EXT_timer_query")) {
michael@0 103 GR_GL_GET_PROC_SUFFIX(GetQueryObjecti64v, EXT);
michael@0 104 GR_GL_GET_PROC_SUFFIX(GetQueryObjectui64v, EXT);
michael@0 105 }
michael@0 106 GR_GL_GET_PROC(GetQueryiv);
michael@0 107 GR_GL_GET_PROC(GetProgramInfoLog);
michael@0 108 GR_GL_GET_PROC(GetProgramiv);
michael@0 109 GR_GL_GET_PROC(GetShaderInfoLog);
michael@0 110 GR_GL_GET_PROC(GetShaderiv);
michael@0 111 functions->fGetString = glGetString;
michael@0 112 GR_GL_GET_PROC(GetStringi);
michael@0 113 functions->fGetTexLevelParameteriv = glGetTexLevelParameteriv;
michael@0 114 GR_GL_GET_PROC(GenQueries);
michael@0 115 functions->fGenTextures = glGenTextures;
michael@0 116 GR_GL_GET_PROC(GetUniformLocation);
michael@0 117 functions->fLineWidth = glLineWidth;
michael@0 118 GR_GL_GET_PROC(LinkProgram);
michael@0 119 GR_GL_GET_PROC(MapBuffer);
michael@0 120 functions->fPixelStorei = glPixelStorei;
michael@0 121 functions->fReadBuffer = glReadBuffer;
michael@0 122 functions->fReadPixels = glReadPixels;
michael@0 123 functions->fScissor = glScissor;
michael@0 124 GR_GL_GET_PROC(ShaderSource);
michael@0 125 functions->fStencilFunc = glStencilFunc;
michael@0 126 GR_GL_GET_PROC(StencilFuncSeparate);
michael@0 127 functions->fStencilMask = glStencilMask;
michael@0 128 GR_GL_GET_PROC(StencilMaskSeparate);
michael@0 129 functions->fStencilOp = glStencilOp;
michael@0 130 GR_GL_GET_PROC(StencilOpSeparate);
michael@0 131 functions->fTexImage2D = glTexImage2D;
michael@0 132 functions->fTexGenfv = glTexGenfv;
michael@0 133 functions->fTexGeni = glTexGeni;
michael@0 134 functions->fTexParameteri = glTexParameteri;
michael@0 135 functions->fTexParameteriv = glTexParameteriv;
michael@0 136 if (glVer >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) {
michael@0 137 GR_GL_GET_PROC(TexStorage2D);
michael@0 138 } else if (extensions.has("GL_EXT_texture_storage")) {
michael@0 139 GR_GL_GET_PROC_SUFFIX(TexStorage2D, EXT);
michael@0 140 }
michael@0 141 functions->fTexSubImage2D = glTexSubImage2D;
michael@0 142 GR_GL_GET_PROC(Uniform1f);
michael@0 143 GR_GL_GET_PROC(Uniform1i);
michael@0 144 GR_GL_GET_PROC(Uniform1fv);
michael@0 145 GR_GL_GET_PROC(Uniform1iv);
michael@0 146 GR_GL_GET_PROC(Uniform2f);
michael@0 147 GR_GL_GET_PROC(Uniform2i);
michael@0 148 GR_GL_GET_PROC(Uniform2fv);
michael@0 149 GR_GL_GET_PROC(Uniform2iv);
michael@0 150 GR_GL_GET_PROC(Uniform3f);
michael@0 151 GR_GL_GET_PROC(Uniform3i);
michael@0 152 GR_GL_GET_PROC(Uniform3fv);
michael@0 153 GR_GL_GET_PROC(Uniform3iv);
michael@0 154 GR_GL_GET_PROC(Uniform4f);
michael@0 155 GR_GL_GET_PROC(Uniform4i);
michael@0 156 GR_GL_GET_PROC(Uniform4fv);
michael@0 157 GR_GL_GET_PROC(Uniform4iv);
michael@0 158 GR_GL_GET_PROC(UniformMatrix2fv);
michael@0 159 GR_GL_GET_PROC(UniformMatrix3fv);
michael@0 160 GR_GL_GET_PROC(UniformMatrix4fv);
michael@0 161 GR_GL_GET_PROC(UnmapBuffer);
michael@0 162 GR_GL_GET_PROC(UseProgram);
michael@0 163 GR_GL_GET_PROC(VertexAttrib4fv);
michael@0 164 GR_GL_GET_PROC(VertexAttribPointer);
michael@0 165 functions->fViewport = glViewport;
michael@0 166 GR_GL_GET_PROC(BindFragDataLocationIndexed);
michael@0 167
michael@0 168 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) {
michael@0 169 // no ARB suffix for GL_ARB_vertex_array_object
michael@0 170 GR_GL_GET_PROC(BindVertexArray);
michael@0 171 GR_GL_GET_PROC(GenVertexArrays);
michael@0 172 GR_GL_GET_PROC(DeleteVertexArrays);
michael@0 173 }
michael@0 174
michael@0 175 // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since
michael@0 176 // GL_ARB_framebuffer_object doesn't use ARB suffix.)
michael@0 177 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) {
michael@0 178 GR_GL_GET_PROC(GenFramebuffers);
michael@0 179 GR_GL_GET_PROC(GetFramebufferAttachmentParameteriv);
michael@0 180 GR_GL_GET_PROC(GetRenderbufferParameteriv);
michael@0 181 GR_GL_GET_PROC(BindFramebuffer);
michael@0 182 GR_GL_GET_PROC(FramebufferTexture2D);
michael@0 183 GR_GL_GET_PROC(CheckFramebufferStatus);
michael@0 184 GR_GL_GET_PROC(DeleteFramebuffers);
michael@0 185 GR_GL_GET_PROC(RenderbufferStorage);
michael@0 186 GR_GL_GET_PROC(GenRenderbuffers);
michael@0 187 GR_GL_GET_PROC(DeleteRenderbuffers);
michael@0 188 GR_GL_GET_PROC(FramebufferRenderbuffer);
michael@0 189 GR_GL_GET_PROC(BindRenderbuffer);
michael@0 190 GR_GL_GET_PROC(RenderbufferStorageMultisample);
michael@0 191 GR_GL_GET_PROC(BlitFramebuffer);
michael@0 192 } else if (extensions.has("GL_EXT_framebuffer_object")) {
michael@0 193 GR_GL_GET_PROC_SUFFIX(GenFramebuffers, EXT);
michael@0 194 GR_GL_GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT);
michael@0 195 GR_GL_GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT);
michael@0 196 GR_GL_GET_PROC_SUFFIX(BindFramebuffer, EXT);
michael@0 197 GR_GL_GET_PROC_SUFFIX(FramebufferTexture2D, EXT);
michael@0 198 GR_GL_GET_PROC_SUFFIX(CheckFramebufferStatus, EXT);
michael@0 199 GR_GL_GET_PROC_SUFFIX(DeleteFramebuffers, EXT);
michael@0 200 GR_GL_GET_PROC_SUFFIX(RenderbufferStorage, EXT);
michael@0 201 GR_GL_GET_PROC_SUFFIX(GenRenderbuffers, EXT);
michael@0 202 GR_GL_GET_PROC_SUFFIX(DeleteRenderbuffers, EXT);
michael@0 203 GR_GL_GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT);
michael@0 204 GR_GL_GET_PROC_SUFFIX(BindRenderbuffer, EXT);
michael@0 205 if (extensions.has("GL_EXT_framebuffer_multisample")) {
michael@0 206 GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT);
michael@0 207 }
michael@0 208 if (extensions.has("GL_EXT_framebuffer_blit")) {
michael@0 209 GR_GL_GET_PROC_SUFFIX(BlitFramebuffer, EXT);
michael@0 210 }
michael@0 211 } else {
michael@0 212 // we must have FBOs
michael@0 213 delete interface;
michael@0 214 return NULL;
michael@0 215 }
michael@0 216
michael@0 217 GR_GL_GET_PROC(LoadIdentity);
michael@0 218 GR_GL_GET_PROC(LoadMatrixf);
michael@0 219 GR_GL_GET_PROC(MatrixMode);
michael@0 220
michael@0 221 if (extensions.has("GL_NV_path_rendering")) {
michael@0 222 GR_GL_GET_PROC_SUFFIX(PathCommands, NV);
michael@0 223 GR_GL_GET_PROC_SUFFIX(PathCoords, NV);
michael@0 224 GR_GL_GET_PROC_SUFFIX(PathSubCommands, NV);
michael@0 225 GR_GL_GET_PROC_SUFFIX(PathSubCoords, NV);
michael@0 226 GR_GL_GET_PROC_SUFFIX(PathString, NV);
michael@0 227 GR_GL_GET_PROC_SUFFIX(PathGlyphs, NV);
michael@0 228 GR_GL_GET_PROC_SUFFIX(PathGlyphRange, NV);
michael@0 229 GR_GL_GET_PROC_SUFFIX(WeightPaths, NV);
michael@0 230 GR_GL_GET_PROC_SUFFIX(CopyPath, NV);
michael@0 231 GR_GL_GET_PROC_SUFFIX(InterpolatePaths, NV);
michael@0 232 GR_GL_GET_PROC_SUFFIX(TransformPath, NV);
michael@0 233 GR_GL_GET_PROC_SUFFIX(PathParameteriv, NV);
michael@0 234 GR_GL_GET_PROC_SUFFIX(PathParameteri, NV);
michael@0 235 GR_GL_GET_PROC_SUFFIX(PathParameterfv, NV);
michael@0 236 GR_GL_GET_PROC_SUFFIX(PathParameterf, NV);
michael@0 237 GR_GL_GET_PROC_SUFFIX(PathDashArray, NV);
michael@0 238 GR_GL_GET_PROC_SUFFIX(GenPaths, NV);
michael@0 239 GR_GL_GET_PROC_SUFFIX(DeletePaths, NV);
michael@0 240 GR_GL_GET_PROC_SUFFIX(IsPath, NV);
michael@0 241 GR_GL_GET_PROC_SUFFIX(PathStencilFunc, NV);
michael@0 242 GR_GL_GET_PROC_SUFFIX(PathStencilDepthOffset, NV);
michael@0 243 GR_GL_GET_PROC_SUFFIX(StencilFillPath, NV);
michael@0 244 GR_GL_GET_PROC_SUFFIX(StencilStrokePath, NV);
michael@0 245 GR_GL_GET_PROC_SUFFIX(StencilFillPathInstanced, NV);
michael@0 246 GR_GL_GET_PROC_SUFFIX(StencilStrokePathInstanced, NV);
michael@0 247 GR_GL_GET_PROC_SUFFIX(PathCoverDepthFunc, NV);
michael@0 248 GR_GL_GET_PROC_SUFFIX(PathColorGen, NV);
michael@0 249 GR_GL_GET_PROC_SUFFIX(PathTexGen, NV);
michael@0 250 GR_GL_GET_PROC_SUFFIX(PathFogGen, NV);
michael@0 251 GR_GL_GET_PROC_SUFFIX(CoverFillPath, NV);
michael@0 252 GR_GL_GET_PROC_SUFFIX(CoverStrokePath, NV);
michael@0 253 GR_GL_GET_PROC_SUFFIX(CoverFillPathInstanced, NV);
michael@0 254 GR_GL_GET_PROC_SUFFIX(CoverStrokePathInstanced, NV);
michael@0 255 GR_GL_GET_PROC_SUFFIX(GetPathParameteriv, NV);
michael@0 256 GR_GL_GET_PROC_SUFFIX(GetPathParameterfv, NV);
michael@0 257 GR_GL_GET_PROC_SUFFIX(GetPathCommands, NV);
michael@0 258 GR_GL_GET_PROC_SUFFIX(GetPathCoords, NV);
michael@0 259 GR_GL_GET_PROC_SUFFIX(GetPathDashArray, NV);
michael@0 260 GR_GL_GET_PROC_SUFFIX(GetPathMetrics, NV);
michael@0 261 GR_GL_GET_PROC_SUFFIX(GetPathMetricRange, NV);
michael@0 262 GR_GL_GET_PROC_SUFFIX(GetPathSpacing, NV);
michael@0 263 GR_GL_GET_PROC_SUFFIX(GetPathColorGeniv, NV);
michael@0 264 GR_GL_GET_PROC_SUFFIX(GetPathColorGenfv, NV);
michael@0 265 GR_GL_GET_PROC_SUFFIX(GetPathTexGeniv, NV);
michael@0 266 GR_GL_GET_PROC_SUFFIX(GetPathTexGenfv, NV);
michael@0 267 GR_GL_GET_PROC_SUFFIX(IsPointInFillPath, NV);
michael@0 268 GR_GL_GET_PROC_SUFFIX(IsPointInStrokePath, NV);
michael@0 269 GR_GL_GET_PROC_SUFFIX(GetPathLength, NV);
michael@0 270 GR_GL_GET_PROC_SUFFIX(PointAlongPath, NV);
michael@0 271 }
michael@0 272
michael@0 273 if (extensions.has("GL_EXT_debug_marker")) {
michael@0 274 GR_GL_GET_PROC_SUFFIX(InsertEventMarker, EXT);
michael@0 275 GR_GL_GET_PROC_SUFFIX(PushGroupMarker, EXT);
michael@0 276 GR_GL_GET_PROC_SUFFIX(PopGroupMarker, EXT);
michael@0 277 }
michael@0 278
michael@0 279 interface->fStandard = kGL_GrGLStandard;
michael@0 280 interface->fExtensions.swap(&extensions);
michael@0 281
michael@0 282 return interface;
michael@0 283 } else {
michael@0 284 return NULL;
michael@0 285 }
michael@0 286 }

mercurial