gfx/gl/SkiaGLGlue.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
-rwxr-xr-x

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 /* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "skia/GrContext.h"
michael@0 7 #include "skia/GrGLInterface.h"
michael@0 8 #include "mozilla/gfx/2D.h"
michael@0 9 #include "mozilla/ThreadLocal.h"
michael@0 10 #include "mozilla/DebugOnly.h"
michael@0 11
michael@0 12 /* SkPostConfig.h includes windows.h, which includes windef.h
michael@0 13 * which redefines min/max. We don't want that. */
michael@0 14 #ifdef _WIN32
michael@0 15 #undef min
michael@0 16 #undef max
michael@0 17 #endif
michael@0 18
michael@0 19 #include "GLContext.h"
michael@0 20 #include "SkiaGLGlue.h"
michael@0 21
michael@0 22 using mozilla::gl::GLContext;
michael@0 23 using mozilla::gl::GLFeature;
michael@0 24 using mozilla::gl::SkiaGLGlue;
michael@0 25 using mozilla::gfx::DrawTarget;
michael@0 26
michael@0 27 static mozilla::ThreadLocal<GLContext*> sGLContext;
michael@0 28
michael@0 29 extern "C" {
michael@0 30
michael@0 31 static void SetStaticGLContext(GLContext* context)
michael@0 32 {
michael@0 33 if (!sGLContext.initialized()) {
michael@0 34 mozilla::DebugOnly<bool> success = sGLContext.init();
michael@0 35 MOZ_ASSERT(success);
michael@0 36 }
michael@0 37
michael@0 38 sGLContext.set(context);
michael@0 39 }
michael@0 40
michael@0 41 void EnsureGLContext(const GrGLInterface* i)
michael@0 42 {
michael@0 43 const SkiaGLGlue* contextSkia = reinterpret_cast<const SkiaGLGlue*>(i->fCallbackData);
michael@0 44 MOZ_ASSERT(contextSkia);
michael@0 45 GLContext* gl = contextSkia->GetGLContext();
michael@0 46 gl->MakeCurrent();
michael@0 47 SetStaticGLContext(gl);
michael@0 48 }
michael@0 49
michael@0 50 // Core GL functions required by Ganesh
michael@0 51
michael@0 52 GrGLvoid glActiveTexture_mozilla(GrGLenum texture)
michael@0 53 {
michael@0 54 return sGLContext.get()->fActiveTexture(texture);
michael@0 55 }
michael@0 56
michael@0 57 GrGLvoid glAttachShader_mozilla(GrGLuint program, GrGLuint shader)
michael@0 58 {
michael@0 59 return sGLContext.get()->fAttachShader(program, shader);
michael@0 60 }
michael@0 61
michael@0 62 GrGLvoid glBindAttribLocation_mozilla(GrGLuint program, GrGLuint index, const GLchar* name)
michael@0 63 {
michael@0 64 return sGLContext.get()->fBindAttribLocation(program, index, name);
michael@0 65 }
michael@0 66
michael@0 67 GrGLvoid glBindBuffer_mozilla(GrGLenum target, GrGLuint buffer)
michael@0 68 {
michael@0 69 return sGLContext.get()->fBindBuffer(target, buffer);
michael@0 70 }
michael@0 71
michael@0 72 GrGLvoid glBindFramebuffer_mozilla(GrGLenum target, GrGLuint framebuffer)
michael@0 73 {
michael@0 74 return sGLContext.get()->fBindFramebuffer(target, framebuffer);
michael@0 75 }
michael@0 76
michael@0 77 GrGLvoid glBindRenderbuffer_mozilla(GrGLenum target, GrGLuint renderbuffer)
michael@0 78 {
michael@0 79 return sGLContext.get()->fBindRenderbuffer(target, renderbuffer);
michael@0 80 }
michael@0 81
michael@0 82 GrGLvoid glBindTexture_mozilla(GrGLenum target, GrGLuint texture)
michael@0 83 {
michael@0 84 return sGLContext.get()->fBindTexture(target, texture);
michael@0 85 }
michael@0 86
michael@0 87 GrGLvoid glBlendColor_mozilla(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha)
michael@0 88 {
michael@0 89 return sGLContext.get()->fBlendColor(red, green, blue, alpha);
michael@0 90 }
michael@0 91
michael@0 92 GrGLvoid glBlendFunc_mozilla(GrGLenum sfactor, GrGLenum dfactor)
michael@0 93 {
michael@0 94 return sGLContext.get()->fBlendFunc(sfactor, dfactor);
michael@0 95 }
michael@0 96
michael@0 97 GrGLvoid glBufferData_mozilla(GrGLenum target, GrGLsizeiptr size, const void* data, GrGLenum usage)
michael@0 98 {
michael@0 99 return sGLContext.get()->fBufferData(target, size, data, usage);
michael@0 100 }
michael@0 101
michael@0 102 GrGLvoid glBufferSubData_mozilla(GrGLenum target, GrGLintptr offset, GrGLsizeiptr size, const void* data)
michael@0 103 {
michael@0 104 return sGLContext.get()->fBufferSubData(target, offset, size, data);
michael@0 105 }
michael@0 106
michael@0 107 GrGLenum glCheckFramebufferStatus_mozilla(GrGLenum target)
michael@0 108 {
michael@0 109 return sGLContext.get()->fCheckFramebufferStatus(target);
michael@0 110 }
michael@0 111
michael@0 112 GrGLvoid glClear_mozilla(GrGLbitfield mask)
michael@0 113 {
michael@0 114 return sGLContext.get()->fClear(mask);
michael@0 115 }
michael@0 116
michael@0 117 GrGLvoid glClearColor_mozilla(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha)
michael@0 118 {
michael@0 119 return sGLContext.get()->fClearColor(red, green, blue, alpha);
michael@0 120 }
michael@0 121
michael@0 122 GrGLvoid glClearStencil_mozilla(GrGLint s)
michael@0 123 {
michael@0 124 return sGLContext.get()->fClearStencil(s);
michael@0 125 }
michael@0 126
michael@0 127 GrGLvoid glColorMask_mozilla(GrGLboolean red, GrGLboolean green, GrGLboolean blue, GrGLboolean alpha)
michael@0 128 {
michael@0 129 return sGLContext.get()->fColorMask(red, green, blue, alpha);
michael@0 130 }
michael@0 131
michael@0 132 GrGLvoid glCompileShader_mozilla(GrGLuint shader)
michael@0 133 {
michael@0 134 return sGLContext.get()->fCompileShader(shader);
michael@0 135 }
michael@0 136
michael@0 137 GrGLvoid glCopyTexSubImage2D_mozilla(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset,
michael@0 138 GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height)
michael@0 139 {
michael@0 140 return sGLContext.get()->fCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
michael@0 141 }
michael@0 142
michael@0 143 GrGLuint glCreateProgram_mozilla(void)
michael@0 144 {
michael@0 145 return sGLContext.get()->fCreateProgram();
michael@0 146 }
michael@0 147
michael@0 148 GrGLuint glCreateShader_mozilla(GrGLenum type)
michael@0 149 {
michael@0 150 return sGLContext.get()->fCreateShader(type);
michael@0 151 }
michael@0 152
michael@0 153 GrGLvoid glCullFace_mozilla(GrGLenum mode)
michael@0 154 {
michael@0 155 return sGLContext.get()->fCullFace(mode);
michael@0 156 }
michael@0 157
michael@0 158 GrGLvoid glDeleteBuffers_mozilla(GrGLsizei n, const GrGLuint* buffers)
michael@0 159 {
michael@0 160 return sGLContext.get()->fDeleteBuffers(n, buffers);
michael@0 161 }
michael@0 162
michael@0 163 GrGLvoid glDeleteFramebuffers_mozilla(GrGLsizei n, const GrGLuint* framebuffers)
michael@0 164 {
michael@0 165 return sGLContext.get()->fDeleteFramebuffers(n, framebuffers);
michael@0 166 }
michael@0 167
michael@0 168 GrGLvoid glDeleteProgram_mozilla(GrGLuint program)
michael@0 169 {
michael@0 170 return sGLContext.get()->fDeleteProgram(program);
michael@0 171 }
michael@0 172
michael@0 173 GrGLvoid glDeleteRenderbuffers_mozilla(GrGLsizei n, const GrGLuint* renderbuffers)
michael@0 174 {
michael@0 175 return sGLContext.get()->fDeleteRenderbuffers(n, renderbuffers);
michael@0 176 }
michael@0 177
michael@0 178 GrGLvoid glDeleteShader_mozilla(GrGLuint shader)
michael@0 179 {
michael@0 180 return sGLContext.get()->fDeleteShader(shader);
michael@0 181 }
michael@0 182
michael@0 183 GrGLvoid glDeleteTextures_mozilla(GrGLsizei n, const GrGLuint* textures)
michael@0 184 {
michael@0 185 return sGLContext.get()->fDeleteTextures(n, textures);
michael@0 186 }
michael@0 187
michael@0 188 GrGLvoid glDepthMask_mozilla(GrGLboolean flag)
michael@0 189 {
michael@0 190 return sGLContext.get()->fDepthMask(flag);
michael@0 191 }
michael@0 192
michael@0 193 GrGLvoid glDisable_mozilla(GrGLenum cap)
michael@0 194 {
michael@0 195 return sGLContext.get()->fDisable(cap);
michael@0 196 }
michael@0 197
michael@0 198 GrGLvoid glDisableVertexAttribArray_mozilla(GrGLuint index)
michael@0 199 {
michael@0 200 return sGLContext.get()->fDisableVertexAttribArray(index);
michael@0 201 }
michael@0 202
michael@0 203 GrGLvoid glDrawArrays_mozilla(GrGLenum mode, GrGLint first, GrGLsizei count)
michael@0 204 {
michael@0 205 return sGLContext.get()->fDrawArrays(mode, first, count);
michael@0 206 }
michael@0 207
michael@0 208 GrGLvoid glDrawElements_mozilla(GrGLenum mode, GrGLsizei count, GrGLenum type, const void* indices)
michael@0 209 {
michael@0 210 return sGLContext.get()->fDrawElements(mode, count, type, indices);
michael@0 211 }
michael@0 212
michael@0 213 GrGLvoid glEnable_mozilla(GrGLenum cap)
michael@0 214 {
michael@0 215 return sGLContext.get()->fEnable(cap);
michael@0 216 }
michael@0 217
michael@0 218 GrGLvoid glEnableVertexAttribArray_mozilla(GrGLuint index)
michael@0 219 {
michael@0 220 return sGLContext.get()->fEnableVertexAttribArray(index);
michael@0 221 }
michael@0 222
michael@0 223 GrGLvoid glFinish_mozilla()
michael@0 224 {
michael@0 225 return sGLContext.get()->fFinish();
michael@0 226 }
michael@0 227
michael@0 228 GrGLvoid glFlush_mozilla()
michael@0 229 {
michael@0 230 return sGLContext.get()->fFlush();
michael@0 231 }
michael@0 232
michael@0 233 GrGLvoid glFramebufferRenderbuffer_mozilla(GrGLenum target, GrGLenum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer)
michael@0 234 {
michael@0 235 return sGLContext.get()->fFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
michael@0 236 }
michael@0 237
michael@0 238 GrGLvoid glFramebufferTexture2D_mozilla(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level)
michael@0 239 {
michael@0 240 return sGLContext.get()->fFramebufferTexture2D(target, attachment, textarget, texture, level);
michael@0 241 }
michael@0 242
michael@0 243 GrGLvoid glFrontFace_mozilla(GrGLenum mode)
michael@0 244 {
michael@0 245 return sGLContext.get()->fFrontFace(mode);
michael@0 246 }
michael@0 247
michael@0 248 GrGLvoid glGenBuffers_mozilla(GrGLsizei n, GrGLuint* buffers)
michael@0 249 {
michael@0 250 return sGLContext.get()->fGenBuffers(n, buffers);
michael@0 251 }
michael@0 252
michael@0 253 GrGLvoid glGenFramebuffers_mozilla(GrGLsizei n, GrGLuint* framebuffers)
michael@0 254 {
michael@0 255 return sGLContext.get()->fGenFramebuffers(n, framebuffers);
michael@0 256 }
michael@0 257
michael@0 258 GrGLvoid glGenRenderbuffers_mozilla(GrGLsizei n, GrGLuint* renderbuffers)
michael@0 259 {
michael@0 260 return sGLContext.get()->fGenRenderbuffers(n, renderbuffers);
michael@0 261 }
michael@0 262
michael@0 263 GrGLvoid glGenTextures_mozilla(GrGLsizei n, GrGLuint* textures)
michael@0 264 {
michael@0 265 return sGLContext.get()->fGenTextures(n, textures);
michael@0 266 }
michael@0 267
michael@0 268 GrGLvoid glGenerateMipmap_mozilla(GrGLenum target)
michael@0 269 {
michael@0 270 return sGLContext.get()->fGenerateMipmap(target);
michael@0 271 }
michael@0 272
michael@0 273 GrGLvoid glGetBufferParameteriv_mozilla(GrGLenum target, GrGLenum pname, GrGLint* params)
michael@0 274 {
michael@0 275 return sGLContext.get()->fGetBufferParameteriv(target, pname, params);
michael@0 276 }
michael@0 277
michael@0 278 GrGLvoid glGetFramebufferAttachmentParameteriv_mozilla(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params)
michael@0 279 {
michael@0 280 return sGLContext.get()->fGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
michael@0 281 }
michael@0 282
michael@0 283 GrGLenum glGetError_mozilla()
michael@0 284 {
michael@0 285 return sGLContext.get()->fGetError();
michael@0 286 }
michael@0 287
michael@0 288 GrGLvoid glGetIntegerv_mozilla(GrGLenum pname, GrGLint* params)
michael@0 289 {
michael@0 290 return sGLContext.get()->fGetIntegerv(pname, params);
michael@0 291 }
michael@0 292
michael@0 293 GrGLvoid glGetProgramInfoLog_mozilla(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog)
michael@0 294 {
michael@0 295 return sGLContext.get()->fGetProgramInfoLog(program, bufsize, length, infolog);
michael@0 296 }
michael@0 297
michael@0 298 GrGLvoid glGetProgramiv_mozilla(GrGLuint program, GrGLenum pname, GrGLint* params)
michael@0 299 {
michael@0 300 return sGLContext.get()->fGetProgramiv(program, pname, params);
michael@0 301 }
michael@0 302
michael@0 303 GrGLvoid glGetRenderbufferParameteriv_mozilla(GrGLenum target, GrGLenum pname, GrGLint* params)
michael@0 304 {
michael@0 305 return sGLContext.get()->fGetRenderbufferParameteriv(target, pname, params);
michael@0 306 }
michael@0 307
michael@0 308 GrGLvoid glGetShaderInfoLog_mozilla(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length, char* infolog)
michael@0 309 {
michael@0 310 return sGLContext.get()->fGetShaderInfoLog(shader, bufsize, length, infolog);
michael@0 311 }
michael@0 312
michael@0 313 GrGLvoid glGetShaderiv_mozilla(GrGLuint shader, GrGLenum pname, GrGLint* params)
michael@0 314 {
michael@0 315 return sGLContext.get()->fGetShaderiv(shader, pname, params);
michael@0 316 }
michael@0 317
michael@0 318 const GLubyte* glGetString_mozilla(GrGLenum name)
michael@0 319 {
michael@0 320 // GLContext only exposes a OpenGL 2.0 style API, so we have to intercept a bunch
michael@0 321 // of checks that Ganesh makes to determine which capabilities are present
michael@0 322 // on the GL implementation and change them to match what GLContext actually exposes.
michael@0 323
michael@0 324 if (name == LOCAL_GL_VERSION) {
michael@0 325 if (sGLContext.get()->IsGLES()) {
michael@0 326 return reinterpret_cast<const GLubyte*>("OpenGL ES 2.0");
michael@0 327 } else {
michael@0 328 return reinterpret_cast<const GLubyte*>("2.0");
michael@0 329 }
michael@0 330 } else if (name == LOCAL_GL_EXTENSIONS) {
michael@0 331 // Only expose the bare minimum extensions we want to support to ensure a functional Ganesh
michael@0 332 // as GLContext only exposes certain extensions
michael@0 333 static bool extensionsStringBuilt = false;
michael@0 334 static char extensionsString[1024];
michael@0 335
michael@0 336 if (!extensionsStringBuilt) {
michael@0 337 extensionsString[0] = '\0';
michael@0 338
michael@0 339 if (sGLContext.get()->IsGLES()) {
michael@0 340 // OES is only applicable to GLES2
michael@0 341 if (sGLContext.get()->IsExtensionSupported(GLContext::OES_packed_depth_stencil)) {
michael@0 342 strcat(extensionsString, "GL_OES_packed_depth_stencil ");
michael@0 343 }
michael@0 344
michael@0 345 if (sGLContext.get()->IsExtensionSupported(GLContext::OES_rgb8_rgba8)) {
michael@0 346 strcat(extensionsString, "GL_OES_rgb8_rgba8 ");
michael@0 347 }
michael@0 348
michael@0 349 if (sGLContext.get()->IsExtensionSupported(GLContext::OES_texture_npot)) {
michael@0 350 strcat(extensionsString, "GL_OES_texture_npot ");
michael@0 351 }
michael@0 352
michael@0 353 if (sGLContext.get()->IsExtensionSupported(GLContext::OES_vertex_array_object)) {
michael@0 354 strcat(extensionsString, "GL_OES_vertex_array_object ");
michael@0 355 }
michael@0 356
michael@0 357 if (sGLContext.get()->IsSupported(GLFeature::standard_derivatives)) {
michael@0 358 strcat(extensionsString, "GL_OES_standard_derivatives ");
michael@0 359 }
michael@0 360 }
michael@0 361
michael@0 362 if (sGLContext.get()->IsExtensionSupported(GLContext::EXT_texture_format_BGRA8888)) {
michael@0 363 strcat(extensionsString, "GL_EXT_texture_format_BGRA8888 ");
michael@0 364 }
michael@0 365
michael@0 366 if (sGLContext.get()->IsExtensionSupported(GLContext::EXT_packed_depth_stencil)) {
michael@0 367 strcat(extensionsString, "GL_EXT_packed_depth_stencil ");
michael@0 368 }
michael@0 369
michael@0 370 if (sGLContext.get()->IsExtensionSupported(GLContext::EXT_bgra)) {
michael@0 371 strcat(extensionsString, "GL_EXT_bgra ");
michael@0 372 }
michael@0 373
michael@0 374 if (sGLContext.get()->IsExtensionSupported(GLContext::EXT_read_format_bgra)) {
michael@0 375 strcat(extensionsString, "GL_EXT_read_format_bgra ");
michael@0 376 }
michael@0 377
michael@0 378 extensionsStringBuilt = true;
michael@0 379 #ifdef DEBUG
michael@0 380 printf_stderr("Exported SkiaGL extensions: %s\n", extensionsString);
michael@0 381 #endif
michael@0 382 }
michael@0 383
michael@0 384 return reinterpret_cast<const GLubyte*>(extensionsString);
michael@0 385
michael@0 386 } else if (name == LOCAL_GL_SHADING_LANGUAGE_VERSION) {
michael@0 387 if (sGLContext.get()->IsGLES()) {
michael@0 388 return reinterpret_cast<const GLubyte*>("OpenGL ES GLSL ES 1.0");
michael@0 389 } else {
michael@0 390 return reinterpret_cast<const GLubyte*>("1.10");
michael@0 391 }
michael@0 392 }
michael@0 393
michael@0 394 return sGLContext.get()->fGetString(name);
michael@0 395 }
michael@0 396
michael@0 397 GrGLint glGetUniformLocation_mozilla(GrGLuint program, const char* name)
michael@0 398 {
michael@0 399 return sGLContext.get()->fGetUniformLocation(program, name);
michael@0 400 }
michael@0 401
michael@0 402 GrGLvoid glLineWidth_mozilla(GrGLfloat width)
michael@0 403 {
michael@0 404 return sGLContext.get()->fLineWidth(width);
michael@0 405 }
michael@0 406
michael@0 407 GrGLvoid glLinkProgram_mozilla(GrGLuint program)
michael@0 408 {
michael@0 409 return sGLContext.get()->fLinkProgram(program);
michael@0 410 }
michael@0 411
michael@0 412 GrGLvoid glPixelStorei_mozilla(GrGLenum pname, GrGLint param)
michael@0 413 {
michael@0 414 return sGLContext.get()->fPixelStorei(pname, param);
michael@0 415 }
michael@0 416
michael@0 417 GrGLvoid glReadPixels_mozilla(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height,
michael@0 418 GrGLenum format, GrGLenum type, void* pixels)
michael@0 419 {
michael@0 420 return sGLContext.get()->fReadPixels(x, y, width, height,
michael@0 421 format, type, pixels);
michael@0 422 }
michael@0 423
michael@0 424 GrGLvoid glRenderbufferStorage_mozilla(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height)
michael@0 425 {
michael@0 426 return sGLContext.get()->fRenderbufferStorage(target, internalformat, width, height);
michael@0 427 }
michael@0 428
michael@0 429 GrGLvoid glScissor_mozilla(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height)
michael@0 430 {
michael@0 431 return sGLContext.get()->fScissor(x, y, width, height);
michael@0 432 }
michael@0 433
michael@0 434 GrGLvoid glShaderSource_mozilla(GrGLuint shader, GrGLsizei count, const char** str, const GrGLint* length)
michael@0 435 {
michael@0 436 return sGLContext.get()->fShaderSource(shader, count, str, length);
michael@0 437 }
michael@0 438
michael@0 439 GrGLvoid glStencilFunc_mozilla(GrGLenum func, GrGLint ref, GrGLuint mask)
michael@0 440 {
michael@0 441 return sGLContext.get()->fStencilFunc(func, ref, mask);
michael@0 442 }
michael@0 443
michael@0 444 GrGLvoid glStencilMask_mozilla(GrGLuint mask)
michael@0 445 {
michael@0 446 return sGLContext.get()->fStencilMask(mask);
michael@0 447 }
michael@0 448
michael@0 449 GrGLvoid glStencilOp_mozilla(GrGLenum fail, GrGLenum zfail, GrGLenum zpass)
michael@0 450 {
michael@0 451 return sGLContext.get()->fStencilOp(fail, zfail, zpass);
michael@0 452 }
michael@0 453
michael@0 454 GrGLvoid glTexImage2D_mozilla(GrGLenum target, GrGLint level, GrGLint internalformat,
michael@0 455 GrGLsizei width, GrGLsizei height, GrGLint border,
michael@0 456 GrGLenum format, GrGLenum type, const void* pixels)
michael@0 457 {
michael@0 458 return sGLContext.get()->fTexImage2D(target, level, internalformat,
michael@0 459 width, height, border,
michael@0 460 format, type, pixels);
michael@0 461 }
michael@0 462
michael@0 463 GrGLvoid glTexParameteri_mozilla(GrGLenum target, GrGLenum pname, GrGLint param)
michael@0 464 {
michael@0 465 return sGLContext.get()->fTexParameteri(target, pname, param);
michael@0 466 }
michael@0 467
michael@0 468 GrGLvoid glTexParameteriv_mozilla(GrGLenum target, GrGLenum pname, const GrGLint* params)
michael@0 469 {
michael@0 470 return sGLContext.get()->fTexParameteriv(target, pname, params);
michael@0 471 }
michael@0 472
michael@0 473 GrGLvoid glTexSubImage2D_mozilla(GrGLenum target, GrGLint level,
michael@0 474 GrGLint xoffset, GrGLint yoffset,
michael@0 475 GrGLsizei width, GrGLsizei height,
michael@0 476 GrGLenum format, GrGLenum type, const void* pixels)
michael@0 477 {
michael@0 478 return sGLContext.get()->fTexSubImage2D(target, level,
michael@0 479 xoffset, yoffset,
michael@0 480 width, height,
michael@0 481 format, type, pixels);
michael@0 482 }
michael@0 483
michael@0 484 GrGLvoid glUniform1f_mozilla(GrGLint location, GrGLfloat v)
michael@0 485 {
michael@0 486 return sGLContext.get()->fUniform1f(location, v);
michael@0 487 }
michael@0 488
michael@0 489 GrGLvoid glUniform1i_mozilla(GrGLint location, GrGLint v)
michael@0 490 {
michael@0 491 return sGLContext.get()->fUniform1i(location, v);
michael@0 492 }
michael@0 493
michael@0 494 GrGLvoid glUniform1fv_mozilla(GrGLint location, GrGLsizei count, const GrGLfloat* v)
michael@0 495 {
michael@0 496 return sGLContext.get()->fUniform1fv(location, count, v);
michael@0 497 }
michael@0 498
michael@0 499 GrGLvoid glUniform1iv_mozilla(GrGLint location, GrGLsizei count, const GrGLint* v)
michael@0 500 {
michael@0 501 return sGLContext.get()->fUniform1iv(location, count, v);
michael@0 502 }
michael@0 503
michael@0 504 GrGLvoid glUniform2f_mozilla(GrGLint location, GrGLfloat v0, GrGLfloat v1)
michael@0 505 {
michael@0 506 return sGLContext.get()->fUniform2f(location, v0, v1);
michael@0 507 }
michael@0 508
michael@0 509 GrGLvoid glUniform2i_mozilla(GrGLint location, GrGLint v0, GrGLint v1)
michael@0 510 {
michael@0 511 return sGLContext.get()->fUniform2i(location, v0, v1);
michael@0 512 }
michael@0 513
michael@0 514 GrGLvoid glUniform2fv_mozilla(GrGLint location, GrGLsizei count, const GrGLfloat* v)
michael@0 515 {
michael@0 516 return sGLContext.get()->fUniform2fv(location, count, v);
michael@0 517 }
michael@0 518
michael@0 519 GrGLvoid glUniform2iv_mozilla(GrGLint location, GrGLsizei count, const GrGLint* v)
michael@0 520 {
michael@0 521 return sGLContext.get()->fUniform2iv(location, count, v);
michael@0 522 }
michael@0 523
michael@0 524 GrGLvoid glUniform3f_mozilla(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2)
michael@0 525 {
michael@0 526 return sGLContext.get()->fUniform3f(location, v0, v1, v2);
michael@0 527 }
michael@0 528
michael@0 529 GrGLvoid glUniform3i_mozilla(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2)
michael@0 530 {
michael@0 531 return sGLContext.get()->fUniform3i(location, v0, v1, v2);
michael@0 532 }
michael@0 533
michael@0 534 GrGLvoid glUniform3fv_mozilla(GrGLint location, GrGLsizei count, const GrGLfloat* v)
michael@0 535 {
michael@0 536 return sGLContext.get()->fUniform3fv(location, count, v);
michael@0 537 }
michael@0 538
michael@0 539 GrGLvoid glUniform3iv_mozilla(GrGLint location, GrGLsizei count, const GrGLint* v)
michael@0 540 {
michael@0 541 return sGLContext.get()->fUniform3iv(location, count, v);
michael@0 542 }
michael@0 543
michael@0 544 GrGLvoid glUniform4f_mozilla(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2, GrGLfloat v3)
michael@0 545 {
michael@0 546 return sGLContext.get()->fUniform4f(location, v0, v1, v2, v3);
michael@0 547 }
michael@0 548
michael@0 549 GrGLvoid glUniform4i_mozilla(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2, GrGLint v3)
michael@0 550 {
michael@0 551 return sGLContext.get()->fUniform4i(location, v0, v1, v2, v3);
michael@0 552 }
michael@0 553
michael@0 554 GrGLvoid glUniform4fv_mozilla(GrGLint location, GrGLsizei count, const GrGLfloat* v)
michael@0 555 {
michael@0 556 return sGLContext.get()->fUniform4fv(location, count, v);
michael@0 557 }
michael@0 558
michael@0 559 GrGLvoid glUniform4iv_mozilla(GrGLint location, GrGLsizei count, const GrGLint* v)
michael@0 560 {
michael@0 561 return sGLContext.get()->fUniform4iv(location, count, v);
michael@0 562 }
michael@0 563
michael@0 564 GrGLvoid glUniformMatrix2fv_mozilla(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value)
michael@0 565 {
michael@0 566 return sGLContext.get()->fUniformMatrix2fv(location, count, transpose, value);
michael@0 567 }
michael@0 568
michael@0 569 GrGLvoid glUniformMatrix3fv_mozilla(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value)
michael@0 570 {
michael@0 571 return sGLContext.get()->fUniformMatrix3fv(location, count, transpose, value);
michael@0 572 }
michael@0 573
michael@0 574 GrGLvoid glUniformMatrix4fv_mozilla(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value)
michael@0 575 {
michael@0 576 return sGLContext.get()->fUniformMatrix4fv(location, count, transpose, value);
michael@0 577 }
michael@0 578
michael@0 579 GrGLvoid glUseProgram_mozilla(GrGLuint program)
michael@0 580 {
michael@0 581 return sGLContext.get()->fUseProgram(program);
michael@0 582 }
michael@0 583
michael@0 584 GrGLvoid glVertexAttrib4fv_mozilla(GrGLuint index, const GrGLfloat* values)
michael@0 585 {
michael@0 586 return sGLContext.get()->fVertexAttrib4fv(index, values);
michael@0 587 }
michael@0 588
michael@0 589 GrGLvoid glVertexAttribPointer_mozilla(GrGLuint index, GrGLint size, GrGLenum type, GrGLboolean normalized, GrGLsizei stride, const void* ptr)
michael@0 590 {
michael@0 591 return sGLContext.get()->fVertexAttribPointer(index, size, type, normalized, stride, ptr);
michael@0 592 }
michael@0 593
michael@0 594 GrGLvoid glViewport_mozilla(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height)
michael@0 595 {
michael@0 596 return sGLContext.get()->fViewport(x, y, width, height);
michael@0 597 }
michael@0 598
michael@0 599 // Required if the bindings are GLES2 or desktop OpenGL 2.0
michael@0 600
michael@0 601 GrGLvoid glStencilFuncSeparate_mozilla(GrGLenum frontfunc, GrGLenum backfunc, GrGLint ref, GrGLuint mask)
michael@0 602 {
michael@0 603 return sGLContext.get()->fStencilFuncSeparate(frontfunc, backfunc, ref, mask);
michael@0 604 }
michael@0 605
michael@0 606 GrGLvoid glStencilMaskSeparate_mozilla(GrGLenum face, GrGLuint mask)
michael@0 607 {
michael@0 608 return sGLContext.get()->fStencilMaskSeparate(face, mask);
michael@0 609 }
michael@0 610
michael@0 611 GrGLvoid glStencilOpSeparate_mozilla(GrGLenum face, GrGLenum sfail, GrGLenum dpfail, GrGLenum dppass)
michael@0 612 {
michael@0 613 return sGLContext.get()->fStencilOpSeparate(face, sfail, dpfail, dppass);
michael@0 614 }
michael@0 615
michael@0 616 // Not in GLES2
michael@0 617
michael@0 618 GrGLvoid glGetTexLevelParameteriv_mozilla(GrGLenum target, GrGLint level, GrGLenum pname, GrGLint *params)
michael@0 619 {
michael@0 620 return sGLContext.get()->fGetTexLevelParameteriv(target, level, pname, params);
michael@0 621 }
michael@0 622
michael@0 623 GrGLvoid glDrawBuffer_mozilla(GrGLenum mode)
michael@0 624 {
michael@0 625 return sGLContext.get()->fDrawBuffer(mode);
michael@0 626 }
michael@0 627
michael@0 628 GrGLvoid glReadBuffer_mozilla(GrGLenum mode)
michael@0 629 {
michael@0 630 return sGLContext.get()->fReadBuffer(mode);
michael@0 631 }
michael@0 632
michael@0 633 // Desktop OpenGL version >= 1.5
michael@0 634
michael@0 635 GrGLvoid glGenQueries_mozilla(GrGLsizei n, GrGLuint* ids)
michael@0 636 {
michael@0 637 return sGLContext.get()->fGenQueries(n, ids);
michael@0 638 }
michael@0 639
michael@0 640 GrGLvoid glDeleteQueries_mozilla(GrGLsizei n, const GrGLuint* ids)
michael@0 641 {
michael@0 642 return sGLContext.get()->fDeleteQueries(n, ids);
michael@0 643 }
michael@0 644
michael@0 645 GrGLvoid glBeginQuery_mozilla(GrGLenum target, GrGLuint id)
michael@0 646 {
michael@0 647 return sGLContext.get()->fBeginQuery(target, id);
michael@0 648 }
michael@0 649
michael@0 650 GrGLvoid glEndQuery_mozilla(GrGLenum target)
michael@0 651 {
michael@0 652 return sGLContext.get()->fEndQuery(target);
michael@0 653 }
michael@0 654
michael@0 655 GrGLvoid glGetQueryiv_mozilla(GrGLenum target, GrGLenum pname, GrGLint* params)
michael@0 656 {
michael@0 657 return sGLContext.get()->fGetQueryiv(target, pname, params);
michael@0 658 }
michael@0 659
michael@0 660 GrGLvoid glGetQueryObjectiv_mozilla(GrGLuint id, GrGLenum pname, GrGLint* params)
michael@0 661 {
michael@0 662 return sGLContext.get()->fGetQueryObjectiv(id, pname, params);
michael@0 663 }
michael@0 664
michael@0 665 GrGLvoid glGetQueryObjectuiv_mozilla(GrGLuint id, GrGLenum pname, GrGLuint* params)
michael@0 666 {
michael@0 667 return sGLContext.get()->fGetQueryObjectuiv(id, pname, params);
michael@0 668 }
michael@0 669
michael@0 670 // Desktop OpenGL version >= 2.0
michael@0 671
michael@0 672 GrGLvoid glDrawBuffers_mozilla(GrGLsizei n, const GrGLenum* bufs)
michael@0 673 {
michael@0 674 return sGLContext.get()->fDrawBuffers(n, bufs);
michael@0 675 }
michael@0 676
michael@0 677 // GLContext supports glMapBuffer on everything (GL_OES_mapbuffer)
michael@0 678
michael@0 679 GrGLvoid* glMapBuffer_mozilla(GrGLenum target, GrGLenum access)
michael@0 680 {
michael@0 681 return sGLContext.get()->fMapBuffer(target, access);
michael@0 682 }
michael@0 683
michael@0 684 GrGLboolean glUnmapBuffer_mozilla(GrGLenum target)
michael@0 685 {
michael@0 686 return sGLContext.get()->fUnmapBuffer(target);
michael@0 687 }
michael@0 688
michael@0 689 // GLContext supports glCompressedTexImage2D (GL_ARB_texture_compression)
michael@0 690
michael@0 691 GrGLvoid glCompressedTexImage2D_mozilla(GrGLenum target, GrGLint level, GrGLenum internalformat,
michael@0 692 GrGLsizei width, GrGLsizei height, GrGLint border,
michael@0 693 GrGLsizei imageSize, const GrGLvoid* pixels)
michael@0 694 {
michael@0 695 return sGLContext.get()->fCompressedTexImage2D(target, level, internalformat,
michael@0 696 width, height, border,
michael@0 697 imageSize, pixels);
michael@0 698 }
michael@0 699
michael@0 700 // GLContext supports glBlitFramebuffer/glRenderbufferStorageMultisample (GL_ARB_framebuffer_object)
michael@0 701
michael@0 702 GrGLvoid glRenderbufferStorageMultisample_mozilla(GrGLenum target, GrGLsizei samples, GrGLenum internalformat,
michael@0 703 GrGLsizei width, GrGLsizei height)
michael@0 704 {
michael@0 705 return sGLContext.get()->fRenderbufferStorageMultisample(target, samples, internalformat,
michael@0 706 width, height);
michael@0 707 }
michael@0 708
michael@0 709 GrGLvoid glBlitFramebuffer_mozilla(GrGLint srcX0, GrGLint srcY0,
michael@0 710 GrGLint srcX1, GrGLint srcY1,
michael@0 711 GrGLint dstX0, GrGLint dstY0,
michael@0 712 GrGLint dstX1, GrGLint dstY1,
michael@0 713 GrGLbitfield mask, GrGLenum filter) {
michael@0 714 return sGLContext.get()->fBlitFramebuffer(srcX0, srcY0,
michael@0 715 srcX1, srcY1,
michael@0 716 dstX0, dstY0,
michael@0 717 dstX1, dstY1,
michael@0 718 mask, filter);
michael@0 719 }
michael@0 720
michael@0 721 GrGLvoid glBindVertexArray_mozilla(GrGLuint array) {
michael@0 722 return sGLContext.get()->fBindVertexArray(array);
michael@0 723 }
michael@0 724
michael@0 725 GrGLvoid glDeleteVertexArrays_mozilla(GrGLsizei n, const GrGLuint *arrays) {
michael@0 726 return sGLContext.get()->fDeleteVertexArrays(n, arrays);
michael@0 727 }
michael@0 728
michael@0 729 GrGLvoid glGenVertexArrays_mozilla(GrGLsizei n, GrGLuint *arrays) {
michael@0 730 return sGLContext.get()->fGenVertexArrays(n, arrays);
michael@0 731 }
michael@0 732
michael@0 733 // Additional functions required for desktop GL < version 3.2
michael@0 734
michael@0 735 GrGLvoid glLoadMatrixf_mozilla(const GLfloat* matrix)
michael@0 736 {
michael@0 737 return sGLContext.get()->fLoadMatrixf(matrix);
michael@0 738 }
michael@0 739
michael@0 740 GrGLvoid glLoadIdentity_mozilla()
michael@0 741 {
michael@0 742 return sGLContext.get()->fLoadIdentity();
michael@0 743 }
michael@0 744
michael@0 745 GrGLvoid glMatrixMode_mozilla(GrGLenum mode)
michael@0 746 {
michael@0 747 return sGLContext.get()->fMatrixMode(mode);
michael@0 748 }
michael@0 749
michael@0 750 GrGLvoid glTexGeni_mozilla(GrGLenum coord, GrGLenum pname, GrGLint param)
michael@0 751 {
michael@0 752 return sGLContext.get()->fTexGeni(coord, pname, param);
michael@0 753 }
michael@0 754
michael@0 755 GrGLvoid glTexGenfv_mozilla(GrGLenum coord, GrGLenum pname, const GrGLfloat* param)
michael@0 756 {
michael@0 757 return sGLContext.get()->fTexGenfv(coord, pname, param);
michael@0 758 }
michael@0 759
michael@0 760 } // extern "C"
michael@0 761
michael@0 762 static GrGLInterface* CreateGrGLInterfaceFromGLContext(GLContext* context)
michael@0 763 {
michael@0 764 SetStaticGLContext(context);
michael@0 765
michael@0 766 GrGLInterface* i = new GrGLInterface();
michael@0 767 i->fCallback = EnsureGLContext;
michael@0 768 i->fCallbackData = 0; // must be later initialized to be a valid DrawTargetSkia* pointer
michael@0 769
michael@0 770 context->MakeCurrent();
michael@0 771
michael@0 772 // We support both desktop GL and GLES2
michael@0 773 if (context->IsGLES()) {
michael@0 774 i->fStandard = kGLES_GrGLStandard;
michael@0 775 } else {
michael@0 776 i->fStandard = kGL_GrGLStandard;
michael@0 777 }
michael@0 778
michael@0 779 GrGLExtensions extensions;
michael@0 780 if (!extensions.init(i->fStandard, glGetString_mozilla, NULL, glGetIntegerv_mozilla)) {
michael@0 781 return nullptr;
michael@0 782 }
michael@0 783
michael@0 784 i->fExtensions.swap(&extensions);
michael@0 785
michael@0 786 // Core GL functions required by Ganesh
michael@0 787 i->fFunctions.fActiveTexture = glActiveTexture_mozilla;
michael@0 788 i->fFunctions.fAttachShader = glAttachShader_mozilla;
michael@0 789 i->fFunctions.fBindAttribLocation = glBindAttribLocation_mozilla;
michael@0 790 i->fFunctions.fBindBuffer = glBindBuffer_mozilla;
michael@0 791 i->fFunctions.fBindFramebuffer = glBindFramebuffer_mozilla;
michael@0 792 i->fFunctions.fBindRenderbuffer = glBindRenderbuffer_mozilla;
michael@0 793 i->fFunctions.fBindTexture = glBindTexture_mozilla;
michael@0 794 i->fFunctions.fBlendFunc = glBlendFunc_mozilla;
michael@0 795 i->fFunctions.fBlendColor = glBlendColor_mozilla;
michael@0 796 i->fFunctions.fBufferData = glBufferData_mozilla;
michael@0 797 i->fFunctions.fBufferSubData = glBufferSubData_mozilla;
michael@0 798 i->fFunctions.fCheckFramebufferStatus = glCheckFramebufferStatus_mozilla;
michael@0 799 i->fFunctions.fClear = glClear_mozilla;
michael@0 800 i->fFunctions.fClearColor = glClearColor_mozilla;
michael@0 801 i->fFunctions.fClearStencil = glClearStencil_mozilla;
michael@0 802 i->fFunctions.fColorMask = glColorMask_mozilla;
michael@0 803 i->fFunctions.fCompileShader = glCompileShader_mozilla;
michael@0 804 i->fFunctions.fCopyTexSubImage2D = glCopyTexSubImage2D_mozilla;
michael@0 805 i->fFunctions.fCreateProgram = glCreateProgram_mozilla;
michael@0 806 i->fFunctions.fCreateShader = glCreateShader_mozilla;
michael@0 807 i->fFunctions.fCullFace = glCullFace_mozilla;
michael@0 808 i->fFunctions.fDeleteBuffers = glDeleteBuffers_mozilla;
michael@0 809 i->fFunctions.fDeleteFramebuffers = glDeleteFramebuffers_mozilla;
michael@0 810 i->fFunctions.fDeleteProgram = glDeleteProgram_mozilla;
michael@0 811 i->fFunctions.fDeleteRenderbuffers = glDeleteRenderbuffers_mozilla;
michael@0 812 i->fFunctions.fDeleteShader = glDeleteShader_mozilla;
michael@0 813 i->fFunctions.fDeleteTextures = glDeleteTextures_mozilla;
michael@0 814 i->fFunctions.fDepthMask = glDepthMask_mozilla;
michael@0 815 i->fFunctions.fDisable = glDisable_mozilla;
michael@0 816 i->fFunctions.fDisableVertexAttribArray = glDisableVertexAttribArray_mozilla;
michael@0 817 i->fFunctions.fDrawArrays = glDrawArrays_mozilla;
michael@0 818 i->fFunctions.fDrawElements = glDrawElements_mozilla;
michael@0 819 i->fFunctions.fEnable = glEnable_mozilla;
michael@0 820 i->fFunctions.fEnableVertexAttribArray = glEnableVertexAttribArray_mozilla;
michael@0 821 i->fFunctions.fFinish = glFinish_mozilla;
michael@0 822 i->fFunctions.fFlush = glFlush_mozilla;
michael@0 823 i->fFunctions.fFramebufferRenderbuffer = glFramebufferRenderbuffer_mozilla;
michael@0 824 i->fFunctions.fFramebufferTexture2D = glFramebufferTexture2D_mozilla;
michael@0 825 i->fFunctions.fFrontFace = glFrontFace_mozilla;
michael@0 826 i->fFunctions.fGenBuffers = glGenBuffers_mozilla;
michael@0 827 i->fFunctions.fGenFramebuffers = glGenFramebuffers_mozilla;
michael@0 828 i->fFunctions.fGenRenderbuffers = glGenRenderbuffers_mozilla;
michael@0 829 i->fFunctions.fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv_mozilla;
michael@0 830 i->fFunctions.fGenTextures = glGenTextures_mozilla;
michael@0 831 i->fFunctions.fGenerateMipmap = glGenerateMipmap_mozilla;
michael@0 832 i->fFunctions.fGetBufferParameteriv = glGetBufferParameteriv_mozilla;
michael@0 833 i->fFunctions.fGetError = glGetError_mozilla;
michael@0 834 i->fFunctions.fGetIntegerv = glGetIntegerv_mozilla;
michael@0 835 i->fFunctions.fGetProgramInfoLog = glGetProgramInfoLog_mozilla;
michael@0 836 i->fFunctions.fGetProgramiv = glGetProgramiv_mozilla;
michael@0 837 i->fFunctions.fGetRenderbufferParameteriv = glGetRenderbufferParameteriv_mozilla;
michael@0 838 i->fFunctions.fGetShaderInfoLog = glGetShaderInfoLog_mozilla;
michael@0 839 i->fFunctions.fGetShaderiv = glGetShaderiv_mozilla;
michael@0 840 i->fFunctions.fGetString = glGetString_mozilla;
michael@0 841 i->fFunctions.fGetUniformLocation = glGetUniformLocation_mozilla;
michael@0 842 i->fFunctions.fLineWidth = glLineWidth_mozilla;
michael@0 843 i->fFunctions.fLinkProgram = glLinkProgram_mozilla;
michael@0 844 i->fFunctions.fPixelStorei = glPixelStorei_mozilla;
michael@0 845 i->fFunctions.fReadPixels = glReadPixels_mozilla;
michael@0 846 i->fFunctions.fRenderbufferStorage = glRenderbufferStorage_mozilla;
michael@0 847 i->fFunctions.fScissor = glScissor_mozilla;
michael@0 848 i->fFunctions.fShaderSource = glShaderSource_mozilla;
michael@0 849 i->fFunctions.fStencilFunc = glStencilFunc_mozilla;
michael@0 850 i->fFunctions.fStencilMask = glStencilMask_mozilla;
michael@0 851 i->fFunctions.fStencilOp = glStencilOp_mozilla;
michael@0 852 i->fFunctions.fTexImage2D = glTexImage2D_mozilla;
michael@0 853 i->fFunctions.fTexParameteri = glTexParameteri_mozilla;
michael@0 854 i->fFunctions.fTexParameteriv = glTexParameteriv_mozilla;
michael@0 855 i->fFunctions.fTexSubImage2D = glTexSubImage2D_mozilla;
michael@0 856 i->fFunctions.fUniform1f = glUniform1f_mozilla;
michael@0 857 i->fFunctions.fUniform1i = glUniform1i_mozilla;
michael@0 858 i->fFunctions.fUniform1fv = glUniform1fv_mozilla;
michael@0 859 i->fFunctions.fUniform1iv = glUniform1iv_mozilla;
michael@0 860 i->fFunctions.fUniform2f = glUniform2f_mozilla;
michael@0 861 i->fFunctions.fUniform2i = glUniform2i_mozilla;
michael@0 862 i->fFunctions.fUniform2fv = glUniform2fv_mozilla;
michael@0 863 i->fFunctions.fUniform2iv = glUniform2iv_mozilla;
michael@0 864 i->fFunctions.fUniform3f = glUniform3f_mozilla;
michael@0 865 i->fFunctions.fUniform3i = glUniform3i_mozilla;
michael@0 866 i->fFunctions.fUniform3fv = glUniform3fv_mozilla;
michael@0 867 i->fFunctions.fUniform3iv = glUniform3iv_mozilla;
michael@0 868 i->fFunctions.fUniform4f = glUniform4f_mozilla;
michael@0 869 i->fFunctions.fUniform4i = glUniform4i_mozilla;
michael@0 870 i->fFunctions.fUniform4fv = glUniform4fv_mozilla;
michael@0 871 i->fFunctions.fUniform4iv = glUniform4iv_mozilla;
michael@0 872 i->fFunctions.fUniformMatrix2fv = glUniformMatrix2fv_mozilla;
michael@0 873 i->fFunctions.fUniformMatrix3fv = glUniformMatrix3fv_mozilla;
michael@0 874 i->fFunctions.fUniformMatrix4fv = glUniformMatrix4fv_mozilla;
michael@0 875 i->fFunctions.fUseProgram = glUseProgram_mozilla;
michael@0 876 i->fFunctions.fVertexAttrib4fv = glVertexAttrib4fv_mozilla;
michael@0 877 i->fFunctions.fVertexAttribPointer = glVertexAttribPointer_mozilla;
michael@0 878 i->fFunctions.fViewport = glViewport_mozilla;
michael@0 879
michael@0 880 // Required for either desktop OpenGL 2.0 or OpenGL ES 2.0
michael@0 881 i->fFunctions.fStencilFuncSeparate = glStencilFuncSeparate_mozilla;
michael@0 882 i->fFunctions.fStencilMaskSeparate = glStencilMaskSeparate_mozilla;
michael@0 883 i->fFunctions.fStencilOpSeparate = glStencilOpSeparate_mozilla;
michael@0 884
michael@0 885 // GLContext supports glMapBuffer
michael@0 886 i->fFunctions.fMapBuffer = glMapBuffer_mozilla;
michael@0 887 i->fFunctions.fUnmapBuffer = glUnmapBuffer_mozilla;
michael@0 888
michael@0 889 // GLContext supports glRenderbufferStorageMultisample/glBlitFramebuffer
michael@0 890 i->fFunctions.fRenderbufferStorageMultisample = glRenderbufferStorageMultisample_mozilla;
michael@0 891 i->fFunctions.fBlitFramebuffer = glBlitFramebuffer_mozilla;
michael@0 892
michael@0 893 // GLContext supports glCompressedTexImage2D
michael@0 894 i->fFunctions.fCompressedTexImage2D = glCompressedTexImage2D_mozilla;
michael@0 895
michael@0 896 // GL_OES_vertex_array_object
michael@0 897 i->fFunctions.fBindVertexArray = glBindVertexArray_mozilla;
michael@0 898 i->fFunctions.fDeleteVertexArrays = glDeleteVertexArrays_mozilla;
michael@0 899 i->fFunctions.fGenVertexArrays = glGenVertexArrays_mozilla;
michael@0 900
michael@0 901 // Desktop GL
michael@0 902 i->fFunctions.fGetTexLevelParameteriv = glGetTexLevelParameteriv_mozilla;
michael@0 903 i->fFunctions.fDrawBuffer = glDrawBuffer_mozilla;
michael@0 904 i->fFunctions.fReadBuffer = glReadBuffer_mozilla;
michael@0 905
michael@0 906 // Desktop OpenGL > 1.5
michael@0 907 i->fFunctions.fGenQueries = glGenQueries_mozilla;
michael@0 908 i->fFunctions.fDeleteQueries = glDeleteQueries_mozilla;
michael@0 909 i->fFunctions.fBeginQuery = glBeginQuery_mozilla;
michael@0 910 i->fFunctions.fEndQuery = glEndQuery_mozilla;
michael@0 911 i->fFunctions.fGetQueryiv = glGetQueryiv_mozilla;
michael@0 912 i->fFunctions.fGetQueryObjectiv = glGetQueryObjectiv_mozilla;
michael@0 913 i->fFunctions.fGetQueryObjectuiv = glGetQueryObjectuiv_mozilla;
michael@0 914
michael@0 915 // Desktop OpenGL > 2.0
michael@0 916 i->fFunctions.fDrawBuffers = glDrawBuffers_mozilla;
michael@0 917
michael@0 918 // Desktop OpenGL < 3.2 (which we pretend to be)
michael@0 919 i->fFunctions.fLoadIdentity = glLoadIdentity_mozilla;
michael@0 920 i->fFunctions.fLoadMatrixf = glLoadMatrixf_mozilla;
michael@0 921 i->fFunctions.fMatrixMode = glMatrixMode_mozilla;
michael@0 922 i->fFunctions.fTexGenfv = glTexGenfv_mozilla;
michael@0 923 i->fFunctions.fTexGeni = glTexGeni_mozilla;
michael@0 924
michael@0 925 return i;
michael@0 926 }
michael@0 927
michael@0 928 SkiaGLGlue::SkiaGLGlue(GLContext* context)
michael@0 929 : mGLContext(context)
michael@0 930 {
michael@0 931 SkAutoTUnref<GrGLInterface> i(CreateGrGLInterfaceFromGLContext(mGLContext));
michael@0 932 i->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this);
michael@0 933 mGrGLInterface = i;
michael@0 934 SkAutoTUnref<GrContext> gr(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)mGrGLInterface.get()));
michael@0 935
michael@0 936 mGrContext = gr;
michael@0 937 }

mercurial