2012-10-28 00:47:58 +04:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-03-06 01:49:37 +04:00
|
|
|
#include "skia/GrContext.h"
|
2012-10-28 00:47:58 +04:00
|
|
|
#include "skia/GrGLInterface.h"
|
2013-06-17 06:07:18 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-06-17 23:45:56 +04:00
|
|
|
#include "mozilla/ThreadLocal.h"
|
|
|
|
#include "mozilla/DebugOnly.h"
|
2012-10-28 00:47:58 +04:00
|
|
|
|
|
|
|
/* SkPostConfig.h includes windows.h, which includes windef.h
|
|
|
|
* which redefines min/max. We don't want that. */
|
|
|
|
#ifdef _WIN32
|
|
|
|
#undef min
|
|
|
|
#undef max
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "GLContext.h"
|
2014-03-06 01:49:37 +04:00
|
|
|
#include "SkiaGLGlue.h"
|
2012-10-28 00:47:58 +04:00
|
|
|
|
|
|
|
using mozilla::gl::GLContext;
|
2014-01-10 23:50:25 +04:00
|
|
|
using mozilla::gl::GLFeature;
|
2014-03-06 01:49:37 +04:00
|
|
|
using mozilla::gl::SkiaGLGlue;
|
2013-06-17 06:07:18 +04:00
|
|
|
using mozilla::gfx::DrawTarget;
|
2012-10-28 00:47:58 +04:00
|
|
|
|
2013-06-17 23:45:56 +04:00
|
|
|
static mozilla::ThreadLocal<GLContext*> sGLContext;
|
2012-10-28 00:47:58 +04:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
2014-03-19 03:37:56 +04:00
|
|
|
static void SetStaticGLContext(GLContext* context)
|
2012-10-28 00:47:58 +04:00
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
if (!sGLContext.initialized()) {
|
|
|
|
mozilla::DebugOnly<bool> success = sGLContext.init();
|
|
|
|
MOZ_ASSERT(success);
|
|
|
|
}
|
2014-03-19 03:37:56 +04:00
|
|
|
|
|
|
|
sGLContext.set(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EnsureGLContext(const GrGLInterface* i)
|
|
|
|
{
|
|
|
|
const SkiaGLGlue* contextSkia = reinterpret_cast<const SkiaGLGlue*>(i->fCallbackData);
|
|
|
|
MOZ_ASSERT(contextSkia);
|
|
|
|
GLContext* gl = contextSkia->GetGLContext();
|
|
|
|
gl->MakeCurrent();
|
|
|
|
SetStaticGLContext(gl);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Core GL functions required by Ganesh
|
|
|
|
|
|
|
|
GrGLvoid glActiveTexture_mozilla(GrGLenum texture)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fActiveTexture(texture);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glAttachShader_mozilla(GrGLuint program, GrGLuint shader)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fAttachShader(program, shader);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glBindAttribLocation_mozilla(GrGLuint program, GrGLuint index, const GLchar* name)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fBindAttribLocation(program, index, name);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glBindBuffer_mozilla(GrGLenum target, GrGLuint buffer)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fBindBuffer(target, buffer);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glBindFramebuffer_mozilla(GrGLenum target, GrGLuint framebuffer)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fBindFramebuffer(target, framebuffer);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glBindRenderbuffer_mozilla(GrGLenum target, GrGLuint renderbuffer)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fBindRenderbuffer(target, renderbuffer);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glBindTexture_mozilla(GrGLenum target, GrGLuint texture)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fBindTexture(target, texture);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glBlendColor_mozilla(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fBlendColor(red, green, blue, alpha);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glBlendFunc_mozilla(GrGLenum sfactor, GrGLenum dfactor)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fBlendFunc(sfactor, dfactor);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glBufferData_mozilla(GrGLenum target, GrGLsizeiptr size, const void* data, GrGLenum usage)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fBufferData(target, size, data, usage);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glBufferSubData_mozilla(GrGLenum target, GrGLintptr offset, GrGLsizeiptr size, const void* data)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fBufferSubData(target, offset, size, data);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLenum glCheckFramebufferStatus_mozilla(GrGLenum target)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fCheckFramebufferStatus(target);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glClear_mozilla(GrGLbitfield mask)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fClear(mask);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glClearColor_mozilla(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fClearColor(red, green, blue, alpha);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glClearStencil_mozilla(GrGLint s)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fClearStencil(s);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glColorMask_mozilla(GrGLboolean red, GrGLboolean green, GrGLboolean blue, GrGLboolean alpha)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fColorMask(red, green, blue, alpha);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glCompileShader_mozilla(GrGLuint shader)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fCompileShader(shader);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
2013-06-08 07:11:58 +04:00
|
|
|
GrGLvoid glCopyTexSubImage2D_mozilla(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset,
|
|
|
|
GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height)
|
|
|
|
{
|
|
|
|
return sGLContext.get()->fCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
|
|
|
|
}
|
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
GrGLuint glCreateProgram_mozilla(void)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fCreateProgram();
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLuint glCreateShader_mozilla(GrGLenum type)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fCreateShader(type);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glCullFace_mozilla(GrGLenum mode)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fCullFace(mode);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDeleteBuffers_mozilla(GrGLsizei n, const GrGLuint* buffers)
|
|
|
|
{
|
2014-02-14 03:02:03 +04:00
|
|
|
return sGLContext.get()->fDeleteBuffers(n, buffers);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDeleteFramebuffers_mozilla(GrGLsizei n, const GrGLuint* framebuffers)
|
|
|
|
{
|
2014-02-14 03:02:03 +04:00
|
|
|
return sGLContext.get()->fDeleteFramebuffers(n, framebuffers);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDeleteProgram_mozilla(GrGLuint program)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fDeleteProgram(program);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDeleteRenderbuffers_mozilla(GrGLsizei n, const GrGLuint* renderbuffers)
|
|
|
|
{
|
2014-02-14 03:02:03 +04:00
|
|
|
return sGLContext.get()->fDeleteRenderbuffers(n, renderbuffers);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDeleteShader_mozilla(GrGLuint shader)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fDeleteShader(shader);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDeleteTextures_mozilla(GrGLsizei n, const GrGLuint* textures)
|
|
|
|
{
|
2014-02-14 03:02:03 +04:00
|
|
|
return sGLContext.get()->fDeleteTextures(n, textures);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDepthMask_mozilla(GrGLboolean flag)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fDepthMask(flag);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDisable_mozilla(GrGLenum cap)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fDisable(cap);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDisableVertexAttribArray_mozilla(GrGLuint index)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fDisableVertexAttribArray(index);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDrawArrays_mozilla(GrGLenum mode, GrGLint first, GrGLsizei count)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fDrawArrays(mode, first, count);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDrawElements_mozilla(GrGLenum mode, GrGLsizei count, GrGLenum type, const void* indices)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fDrawElements(mode, count, type, indices);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glEnable_mozilla(GrGLenum cap)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fEnable(cap);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glEnableVertexAttribArray_mozilla(GrGLuint index)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fEnableVertexAttribArray(index);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glFinish_mozilla()
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fFinish();
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glFlush_mozilla()
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fFlush();
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glFramebufferRenderbuffer_mozilla(GrGLenum target, GrGLenum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glFramebufferTexture2D_mozilla(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fFramebufferTexture2D(target, attachment, textarget, texture, level);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glFrontFace_mozilla(GrGLenum mode)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fFrontFace(mode);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGenBuffers_mozilla(GrGLsizei n, GrGLuint* buffers)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGenBuffers(n, buffers);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGenFramebuffers_mozilla(GrGLsizei n, GrGLuint* framebuffers)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGenFramebuffers(n, framebuffers);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGenRenderbuffers_mozilla(GrGLsizei n, GrGLuint* renderbuffers)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGenRenderbuffers(n, renderbuffers);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGenTextures_mozilla(GrGLsizei n, GrGLuint* textures)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGenTextures(n, textures);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
2013-06-08 07:11:58 +04:00
|
|
|
GrGLvoid glGenerateMipmap_mozilla(GrGLenum target)
|
|
|
|
{
|
|
|
|
return sGLContext.get()->fGenerateMipmap(target);
|
|
|
|
}
|
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
GrGLvoid glGetBufferParameteriv_mozilla(GrGLenum target, GrGLenum pname, GrGLint* params)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetBufferParameteriv(target, pname, params);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGetFramebufferAttachmentParameteriv_mozilla(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLenum glGetError_mozilla()
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetError();
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGetIntegerv_mozilla(GrGLenum pname, GrGLint* params)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetIntegerv(pname, params);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGetProgramInfoLog_mozilla(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetProgramInfoLog(program, bufsize, length, infolog);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGetProgramiv_mozilla(GrGLuint program, GrGLenum pname, GrGLint* params)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetProgramiv(program, pname, params);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGetRenderbufferParameteriv_mozilla(GrGLenum target, GrGLenum pname, GrGLint* params)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetRenderbufferParameteriv(target, pname, params);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGetShaderInfoLog_mozilla(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length, char* infolog)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetShaderInfoLog(shader, bufsize, length, infolog);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGetShaderiv_mozilla(GrGLuint shader, GrGLenum pname, GrGLint* params)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetShaderiv(shader, pname, params);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
const GLubyte* glGetString_mozilla(GrGLenum name)
|
|
|
|
{
|
|
|
|
// GLContext only exposes a OpenGL 2.0 style API, so we have to intercept a bunch
|
|
|
|
// of checks that Ganesh makes to determine which capabilities are present
|
|
|
|
// on the GL implementation and change them to match what GLContext actually exposes.
|
|
|
|
|
|
|
|
if (name == LOCAL_GL_VERSION) {
|
2014-03-31 13:10:49 +04:00
|
|
|
if (sGLContext.get()->IsGLES()) {
|
2012-10-28 00:47:58 +04:00
|
|
|
return reinterpret_cast<const GLubyte*>("OpenGL ES 2.0");
|
|
|
|
} else {
|
|
|
|
return reinterpret_cast<const GLubyte*>("2.0");
|
|
|
|
}
|
|
|
|
} else if (name == LOCAL_GL_EXTENSIONS) {
|
|
|
|
// Only expose the bare minimum extensions we want to support to ensure a functional Ganesh
|
|
|
|
// as GLContext only exposes certain extensions
|
|
|
|
static bool extensionsStringBuilt = false;
|
2013-08-01 04:10:55 +04:00
|
|
|
static char extensionsString[1024];
|
2012-10-28 00:47:58 +04:00
|
|
|
|
|
|
|
if (!extensionsStringBuilt) {
|
2013-08-01 04:10:55 +04:00
|
|
|
extensionsString[0] = '\0';
|
|
|
|
|
2014-03-31 13:10:49 +04:00
|
|
|
if (sGLContext.get()->IsGLES()) {
|
2013-08-01 04:10:55 +04:00
|
|
|
// OES is only applicable to GLES2
|
|
|
|
if (sGLContext.get()->IsExtensionSupported(GLContext::OES_packed_depth_stencil)) {
|
|
|
|
strcat(extensionsString, "GL_OES_packed_depth_stencil ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sGLContext.get()->IsExtensionSupported(GLContext::OES_rgb8_rgba8)) {
|
|
|
|
strcat(extensionsString, "GL_OES_rgb8_rgba8 ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sGLContext.get()->IsExtensionSupported(GLContext::OES_texture_npot)) {
|
|
|
|
strcat(extensionsString, "GL_OES_texture_npot ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sGLContext.get()->IsExtensionSupported(GLContext::OES_vertex_array_object)) {
|
|
|
|
strcat(extensionsString, "GL_OES_vertex_array_object ");
|
|
|
|
}
|
|
|
|
|
2014-01-10 23:50:25 +04:00
|
|
|
if (sGLContext.get()->IsSupported(GLFeature::standard_derivatives)) {
|
2013-08-01 04:10:55 +04:00
|
|
|
strcat(extensionsString, "GL_OES_standard_derivatives ");
|
|
|
|
}
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
2013-08-01 04:10:55 +04:00
|
|
|
if (sGLContext.get()->IsExtensionSupported(GLContext::EXT_texture_format_BGRA8888)) {
|
|
|
|
strcat(extensionsString, "GL_EXT_texture_format_BGRA8888 ");
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
2013-06-17 23:45:56 +04:00
|
|
|
if (sGLContext.get()->IsExtensionSupported(GLContext::EXT_packed_depth_stencil)) {
|
2013-03-12 14:33:36 +04:00
|
|
|
strcat(extensionsString, "GL_EXT_packed_depth_stencil ");
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
2013-06-27 18:20:21 +04:00
|
|
|
if (sGLContext.get()->IsExtensionSupported(GLContext::EXT_bgra)) {
|
|
|
|
strcat(extensionsString, "GL_EXT_bgra ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sGLContext.get()->IsExtensionSupported(GLContext::EXT_read_format_bgra)) {
|
|
|
|
strcat(extensionsString, "GL_EXT_read_format_bgra ");
|
|
|
|
}
|
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
extensionsStringBuilt = true;
|
2013-08-01 04:10:55 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf_stderr("Exported SkiaGL extensions: %s\n", extensionsString);
|
|
|
|
#endif
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
2013-03-12 14:33:36 +04:00
|
|
|
return reinterpret_cast<const GLubyte*>(extensionsString);
|
2012-10-28 00:47:58 +04:00
|
|
|
|
|
|
|
} else if (name == LOCAL_GL_SHADING_LANGUAGE_VERSION) {
|
2014-03-31 13:10:49 +04:00
|
|
|
if (sGLContext.get()->IsGLES()) {
|
2012-10-28 00:47:58 +04:00
|
|
|
return reinterpret_cast<const GLubyte*>("OpenGL ES GLSL ES 1.0");
|
|
|
|
} else {
|
|
|
|
return reinterpret_cast<const GLubyte*>("1.10");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetString(name);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLint glGetUniformLocation_mozilla(GrGLuint program, const char* name)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetUniformLocation(program, name);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glLineWidth_mozilla(GrGLfloat width)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fLineWidth(width);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glLinkProgram_mozilla(GrGLuint program)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fLinkProgram(program);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glPixelStorei_mozilla(GrGLenum pname, GrGLint param)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fPixelStorei(pname, param);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glReadPixels_mozilla(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height,
|
|
|
|
GrGLenum format, GrGLenum type, void* pixels)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fReadPixels(x, y, width, height,
|
2012-10-28 00:47:58 +04:00
|
|
|
format, type, pixels);
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glRenderbufferStorage_mozilla(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fRenderbufferStorage(target, internalformat, width, height);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glScissor_mozilla(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fScissor(x, y, width, height);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glShaderSource_mozilla(GrGLuint shader, GrGLsizei count, const char** str, const GrGLint* length)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fShaderSource(shader, count, str, length);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glStencilFunc_mozilla(GrGLenum func, GrGLint ref, GrGLuint mask)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fStencilFunc(func, ref, mask);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glStencilMask_mozilla(GrGLuint mask)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fStencilMask(mask);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glStencilOp_mozilla(GrGLenum fail, GrGLenum zfail, GrGLenum zpass)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fStencilOp(fail, zfail, zpass);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glTexImage2D_mozilla(GrGLenum target, GrGLint level, GrGLint internalformat,
|
|
|
|
GrGLsizei width, GrGLsizei height, GrGLint border,
|
|
|
|
GrGLenum format, GrGLenum type, const void* pixels)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fTexImage2D(target, level, internalformat,
|
2012-10-28 00:47:58 +04:00
|
|
|
width, height, border,
|
|
|
|
format, type, pixels);
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glTexParameteri_mozilla(GrGLenum target, GrGLenum pname, GrGLint param)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fTexParameteri(target, pname, param);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glTexParameteriv_mozilla(GrGLenum target, GrGLenum pname, const GrGLint* params)
|
|
|
|
{
|
2014-02-14 03:02:03 +04:00
|
|
|
return sGLContext.get()->fTexParameteriv(target, pname, params);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glTexSubImage2D_mozilla(GrGLenum target, GrGLint level,
|
|
|
|
GrGLint xoffset, GrGLint yoffset,
|
|
|
|
GrGLsizei width, GrGLsizei height,
|
|
|
|
GrGLenum format, GrGLenum type, const void* pixels)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fTexSubImage2D(target, level,
|
2012-10-28 00:47:58 +04:00
|
|
|
xoffset, yoffset,
|
|
|
|
width, height,
|
|
|
|
format, type, pixels);
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform1f_mozilla(GrGLint location, GrGLfloat v)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform1f(location, v);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform1i_mozilla(GrGLint location, GrGLint v)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform1i(location, v);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform1fv_mozilla(GrGLint location, GrGLsizei count, const GrGLfloat* v)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform1fv(location, count, v);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform1iv_mozilla(GrGLint location, GrGLsizei count, const GrGLint* v)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform1iv(location, count, v);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform2f_mozilla(GrGLint location, GrGLfloat v0, GrGLfloat v1)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform2f(location, v0, v1);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform2i_mozilla(GrGLint location, GrGLint v0, GrGLint v1)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform2i(location, v0, v1);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform2fv_mozilla(GrGLint location, GrGLsizei count, const GrGLfloat* v)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform2fv(location, count, v);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform2iv_mozilla(GrGLint location, GrGLsizei count, const GrGLint* v)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform2iv(location, count, v);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform3f_mozilla(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform3f(location, v0, v1, v2);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform3i_mozilla(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform3i(location, v0, v1, v2);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform3fv_mozilla(GrGLint location, GrGLsizei count, const GrGLfloat* v)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform3fv(location, count, v);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform3iv_mozilla(GrGLint location, GrGLsizei count, const GrGLint* v)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform3iv(location, count, v);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform4f_mozilla(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2, GrGLfloat v3)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform4f(location, v0, v1, v2, v3);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform4i_mozilla(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2, GrGLint v3)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform4i(location, v0, v1, v2, v3);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform4fv_mozilla(GrGLint location, GrGLsizei count, const GrGLfloat* v)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform4fv(location, count, v);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniform4iv_mozilla(GrGLint location, GrGLsizei count, const GrGLint* v)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniform4iv(location, count, v);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniformMatrix2fv_mozilla(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniformMatrix2fv(location, count, transpose, value);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniformMatrix3fv_mozilla(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniformMatrix3fv(location, count, transpose, value);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUniformMatrix4fv_mozilla(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUniformMatrix4fv(location, count, transpose, value);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glUseProgram_mozilla(GrGLuint program)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUseProgram(program);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glVertexAttrib4fv_mozilla(GrGLuint index, const GrGLfloat* values)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fVertexAttrib4fv(index, values);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glVertexAttribPointer_mozilla(GrGLuint index, GrGLint size, GrGLenum type, GrGLboolean normalized, GrGLsizei stride, const void* ptr)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fVertexAttribPointer(index, size, type, normalized, stride, ptr);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glViewport_mozilla(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fViewport(x, y, width, height);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Required if the bindings are GLES2 or desktop OpenGL 2.0
|
|
|
|
|
|
|
|
GrGLvoid glStencilFuncSeparate_mozilla(GrGLenum frontfunc, GrGLenum backfunc, GrGLint ref, GrGLuint mask)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fStencilFuncSeparate(frontfunc, backfunc, ref, mask);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glStencilMaskSeparate_mozilla(GrGLenum face, GrGLuint mask)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fStencilMaskSeparate(face, mask);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glStencilOpSeparate_mozilla(GrGLenum face, GrGLenum sfail, GrGLenum dpfail, GrGLenum dppass)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fStencilOpSeparate(face, sfail, dpfail, dppass);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Not in GLES2
|
|
|
|
|
|
|
|
GrGLvoid glGetTexLevelParameteriv_mozilla(GrGLenum target, GrGLint level, GrGLenum pname, GrGLint *params)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetTexLevelParameteriv(target, level, pname, params);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDrawBuffer_mozilla(GrGLenum mode)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fDrawBuffer(mode);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glReadBuffer_mozilla(GrGLenum mode)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fReadBuffer(mode);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Desktop OpenGL version >= 1.5
|
|
|
|
|
|
|
|
GrGLvoid glGenQueries_mozilla(GrGLsizei n, GrGLuint* ids)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGenQueries(n, ids);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDeleteQueries_mozilla(GrGLsizei n, const GrGLuint* ids)
|
|
|
|
{
|
2014-02-14 03:02:03 +04:00
|
|
|
return sGLContext.get()->fDeleteQueries(n, ids);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glBeginQuery_mozilla(GrGLenum target, GrGLuint id)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fBeginQuery(target, id);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glEndQuery_mozilla(GrGLenum target)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fEndQuery(target);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGetQueryiv_mozilla(GrGLenum target, GrGLenum pname, GrGLint* params)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetQueryiv(target, pname, params);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGetQueryObjectiv_mozilla(GrGLuint id, GrGLenum pname, GrGLint* params)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetQueryObjectiv(id, pname, params);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGetQueryObjectuiv_mozilla(GrGLuint id, GrGLenum pname, GrGLuint* params)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fGetQueryObjectuiv(id, pname, params);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Desktop OpenGL version >= 2.0
|
|
|
|
|
|
|
|
GrGLvoid glDrawBuffers_mozilla(GrGLsizei n, const GrGLenum* bufs)
|
|
|
|
{
|
2014-02-14 03:02:03 +04:00
|
|
|
return sGLContext.get()->fDrawBuffers(n, bufs);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// GLContext supports glMapBuffer on everything (GL_OES_mapbuffer)
|
|
|
|
|
|
|
|
GrGLvoid* glMapBuffer_mozilla(GrGLenum target, GrGLenum access)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fMapBuffer(target, access);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GrGLboolean glUnmapBuffer_mozilla(GrGLenum target)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fUnmapBuffer(target);
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// GLContext supports glCompressedTexImage2D (GL_ARB_texture_compression)
|
|
|
|
|
|
|
|
GrGLvoid glCompressedTexImage2D_mozilla(GrGLenum target, GrGLint level, GrGLenum internalformat,
|
|
|
|
GrGLsizei width, GrGLsizei height, GrGLint border,
|
|
|
|
GrGLsizei imageSize, const GrGLvoid* pixels)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fCompressedTexImage2D(target, level, internalformat,
|
2012-10-28 00:47:58 +04:00
|
|
|
width, height, border,
|
|
|
|
imageSize, pixels);
|
|
|
|
}
|
|
|
|
|
|
|
|
// GLContext supports glBlitFramebuffer/glRenderbufferStorageMultisample (GL_ARB_framebuffer_object)
|
|
|
|
|
|
|
|
GrGLvoid glRenderbufferStorageMultisample_mozilla(GrGLenum target, GrGLsizei samples, GrGLenum internalformat,
|
|
|
|
GrGLsizei width, GrGLsizei height)
|
|
|
|
{
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fRenderbufferStorageMultisample(target, samples, internalformat,
|
2012-10-28 00:47:58 +04:00
|
|
|
width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glBlitFramebuffer_mozilla(GrGLint srcX0, GrGLint srcY0,
|
|
|
|
GrGLint srcX1, GrGLint srcY1,
|
|
|
|
GrGLint dstX0, GrGLint dstY0,
|
|
|
|
GrGLint dstX1, GrGLint dstY1,
|
|
|
|
GrGLbitfield mask, GrGLenum filter) {
|
2013-06-17 23:45:56 +04:00
|
|
|
return sGLContext.get()->fBlitFramebuffer(srcX0, srcY0,
|
2012-10-28 00:47:58 +04:00
|
|
|
srcX1, srcY1,
|
|
|
|
dstX0, dstY0,
|
|
|
|
dstX1, dstY1,
|
|
|
|
mask, filter);
|
|
|
|
}
|
|
|
|
|
2013-08-01 04:10:55 +04:00
|
|
|
GrGLvoid glBindVertexArray_mozilla(GrGLuint array) {
|
|
|
|
return sGLContext.get()->fBindVertexArray(array);
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glDeleteVertexArrays_mozilla(GrGLsizei n, const GrGLuint *arrays) {
|
|
|
|
return sGLContext.get()->fDeleteVertexArrays(n, arrays);
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid glGenVertexArrays_mozilla(GrGLsizei n, GrGLuint *arrays) {
|
|
|
|
return sGLContext.get()->fGenVertexArrays(n, arrays);
|
|
|
|
}
|
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
} // extern "C"
|
|
|
|
|
2014-03-06 01:49:37 +04:00
|
|
|
static GrGLInterface* CreateGrGLInterfaceFromGLContext(GLContext* context)
|
2012-10-28 00:47:58 +04:00
|
|
|
{
|
2014-03-19 03:37:56 +04:00
|
|
|
SetStaticGLContext(context);
|
|
|
|
|
2013-06-17 06:07:18 +04:00
|
|
|
GrGLInterface* i = new GrGLInterface();
|
|
|
|
i->fCallback = EnsureGLContext;
|
|
|
|
i->fCallbackData = 0; // must be later initialized to be a valid DrawTargetSkia* pointer
|
2012-10-28 00:47:58 +04:00
|
|
|
|
2014-03-19 03:37:56 +04:00
|
|
|
context->MakeCurrent();
|
|
|
|
|
|
|
|
// We support both desktop GL and GLES2
|
2014-03-31 13:10:49 +04:00
|
|
|
if (context->IsGLES()) {
|
2014-03-19 03:37:56 +04:00
|
|
|
i->fStandard = kGLES_GrGLStandard;
|
|
|
|
} else {
|
|
|
|
i->fStandard = kGL_GrGLStandard;
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLExtensions extensions;
|
|
|
|
if (!extensions.init(i->fStandard, glGetString_mozilla, NULL, glGetIntegerv_mozilla)) {
|
2014-07-10 00:40:40 +04:00
|
|
|
delete i;
|
2014-03-19 03:37:56 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
i->fExtensions.swap(&extensions);
|
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
// Core GL functions required by Ganesh
|
2014-03-20 22:08:19 +04:00
|
|
|
i->fFunctions.fActiveTexture = glActiveTexture_mozilla;
|
|
|
|
i->fFunctions.fAttachShader = glAttachShader_mozilla;
|
|
|
|
i->fFunctions.fBindAttribLocation = glBindAttribLocation_mozilla;
|
|
|
|
i->fFunctions.fBindBuffer = glBindBuffer_mozilla;
|
|
|
|
i->fFunctions.fBindFramebuffer = glBindFramebuffer_mozilla;
|
|
|
|
i->fFunctions.fBindRenderbuffer = glBindRenderbuffer_mozilla;
|
|
|
|
i->fFunctions.fBindTexture = glBindTexture_mozilla;
|
|
|
|
i->fFunctions.fBlendFunc = glBlendFunc_mozilla;
|
|
|
|
i->fFunctions.fBlendColor = glBlendColor_mozilla;
|
|
|
|
i->fFunctions.fBufferData = glBufferData_mozilla;
|
|
|
|
i->fFunctions.fBufferSubData = glBufferSubData_mozilla;
|
|
|
|
i->fFunctions.fCheckFramebufferStatus = glCheckFramebufferStatus_mozilla;
|
|
|
|
i->fFunctions.fClear = glClear_mozilla;
|
|
|
|
i->fFunctions.fClearColor = glClearColor_mozilla;
|
|
|
|
i->fFunctions.fClearStencil = glClearStencil_mozilla;
|
|
|
|
i->fFunctions.fColorMask = glColorMask_mozilla;
|
|
|
|
i->fFunctions.fCompileShader = glCompileShader_mozilla;
|
|
|
|
i->fFunctions.fCopyTexSubImage2D = glCopyTexSubImage2D_mozilla;
|
|
|
|
i->fFunctions.fCreateProgram = glCreateProgram_mozilla;
|
|
|
|
i->fFunctions.fCreateShader = glCreateShader_mozilla;
|
|
|
|
i->fFunctions.fCullFace = glCullFace_mozilla;
|
|
|
|
i->fFunctions.fDeleteBuffers = glDeleteBuffers_mozilla;
|
|
|
|
i->fFunctions.fDeleteFramebuffers = glDeleteFramebuffers_mozilla;
|
|
|
|
i->fFunctions.fDeleteProgram = glDeleteProgram_mozilla;
|
|
|
|
i->fFunctions.fDeleteRenderbuffers = glDeleteRenderbuffers_mozilla;
|
|
|
|
i->fFunctions.fDeleteShader = glDeleteShader_mozilla;
|
|
|
|
i->fFunctions.fDeleteTextures = glDeleteTextures_mozilla;
|
|
|
|
i->fFunctions.fDepthMask = glDepthMask_mozilla;
|
|
|
|
i->fFunctions.fDisable = glDisable_mozilla;
|
|
|
|
i->fFunctions.fDisableVertexAttribArray = glDisableVertexAttribArray_mozilla;
|
|
|
|
i->fFunctions.fDrawArrays = glDrawArrays_mozilla;
|
|
|
|
i->fFunctions.fDrawElements = glDrawElements_mozilla;
|
|
|
|
i->fFunctions.fEnable = glEnable_mozilla;
|
|
|
|
i->fFunctions.fEnableVertexAttribArray = glEnableVertexAttribArray_mozilla;
|
|
|
|
i->fFunctions.fFinish = glFinish_mozilla;
|
|
|
|
i->fFunctions.fFlush = glFlush_mozilla;
|
|
|
|
i->fFunctions.fFramebufferRenderbuffer = glFramebufferRenderbuffer_mozilla;
|
|
|
|
i->fFunctions.fFramebufferTexture2D = glFramebufferTexture2D_mozilla;
|
|
|
|
i->fFunctions.fFrontFace = glFrontFace_mozilla;
|
|
|
|
i->fFunctions.fGenBuffers = glGenBuffers_mozilla;
|
|
|
|
i->fFunctions.fGenFramebuffers = glGenFramebuffers_mozilla;
|
|
|
|
i->fFunctions.fGenRenderbuffers = glGenRenderbuffers_mozilla;
|
|
|
|
i->fFunctions.fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv_mozilla;
|
|
|
|
i->fFunctions.fGenTextures = glGenTextures_mozilla;
|
|
|
|
i->fFunctions.fGenerateMipmap = glGenerateMipmap_mozilla;
|
|
|
|
i->fFunctions.fGetBufferParameteriv = glGetBufferParameteriv_mozilla;
|
|
|
|
i->fFunctions.fGetError = glGetError_mozilla;
|
|
|
|
i->fFunctions.fGetIntegerv = glGetIntegerv_mozilla;
|
|
|
|
i->fFunctions.fGetProgramInfoLog = glGetProgramInfoLog_mozilla;
|
|
|
|
i->fFunctions.fGetProgramiv = glGetProgramiv_mozilla;
|
|
|
|
i->fFunctions.fGetRenderbufferParameteriv = glGetRenderbufferParameteriv_mozilla;
|
|
|
|
i->fFunctions.fGetShaderInfoLog = glGetShaderInfoLog_mozilla;
|
|
|
|
i->fFunctions.fGetShaderiv = glGetShaderiv_mozilla;
|
|
|
|
i->fFunctions.fGetString = glGetString_mozilla;
|
|
|
|
i->fFunctions.fGetUniformLocation = glGetUniformLocation_mozilla;
|
|
|
|
i->fFunctions.fLineWidth = glLineWidth_mozilla;
|
|
|
|
i->fFunctions.fLinkProgram = glLinkProgram_mozilla;
|
|
|
|
i->fFunctions.fPixelStorei = glPixelStorei_mozilla;
|
|
|
|
i->fFunctions.fReadPixels = glReadPixels_mozilla;
|
|
|
|
i->fFunctions.fRenderbufferStorage = glRenderbufferStorage_mozilla;
|
|
|
|
i->fFunctions.fScissor = glScissor_mozilla;
|
|
|
|
i->fFunctions.fShaderSource = glShaderSource_mozilla;
|
|
|
|
i->fFunctions.fStencilFunc = glStencilFunc_mozilla;
|
|
|
|
i->fFunctions.fStencilMask = glStencilMask_mozilla;
|
|
|
|
i->fFunctions.fStencilOp = glStencilOp_mozilla;
|
|
|
|
i->fFunctions.fTexImage2D = glTexImage2D_mozilla;
|
|
|
|
i->fFunctions.fTexParameteri = glTexParameteri_mozilla;
|
|
|
|
i->fFunctions.fTexParameteriv = glTexParameteriv_mozilla;
|
|
|
|
i->fFunctions.fTexSubImage2D = glTexSubImage2D_mozilla;
|
|
|
|
i->fFunctions.fUniform1f = glUniform1f_mozilla;
|
|
|
|
i->fFunctions.fUniform1i = glUniform1i_mozilla;
|
|
|
|
i->fFunctions.fUniform1fv = glUniform1fv_mozilla;
|
|
|
|
i->fFunctions.fUniform1iv = glUniform1iv_mozilla;
|
|
|
|
i->fFunctions.fUniform2f = glUniform2f_mozilla;
|
|
|
|
i->fFunctions.fUniform2i = glUniform2i_mozilla;
|
|
|
|
i->fFunctions.fUniform2fv = glUniform2fv_mozilla;
|
|
|
|
i->fFunctions.fUniform2iv = glUniform2iv_mozilla;
|
|
|
|
i->fFunctions.fUniform3f = glUniform3f_mozilla;
|
|
|
|
i->fFunctions.fUniform3i = glUniform3i_mozilla;
|
|
|
|
i->fFunctions.fUniform3fv = glUniform3fv_mozilla;
|
|
|
|
i->fFunctions.fUniform3iv = glUniform3iv_mozilla;
|
|
|
|
i->fFunctions.fUniform4f = glUniform4f_mozilla;
|
|
|
|
i->fFunctions.fUniform4i = glUniform4i_mozilla;
|
|
|
|
i->fFunctions.fUniform4fv = glUniform4fv_mozilla;
|
|
|
|
i->fFunctions.fUniform4iv = glUniform4iv_mozilla;
|
|
|
|
i->fFunctions.fUniformMatrix2fv = glUniformMatrix2fv_mozilla;
|
|
|
|
i->fFunctions.fUniformMatrix3fv = glUniformMatrix3fv_mozilla;
|
|
|
|
i->fFunctions.fUniformMatrix4fv = glUniformMatrix4fv_mozilla;
|
|
|
|
i->fFunctions.fUseProgram = glUseProgram_mozilla;
|
|
|
|
i->fFunctions.fVertexAttrib4fv = glVertexAttrib4fv_mozilla;
|
|
|
|
i->fFunctions.fVertexAttribPointer = glVertexAttribPointer_mozilla;
|
|
|
|
i->fFunctions.fViewport = glViewport_mozilla;
|
2012-10-28 00:47:58 +04:00
|
|
|
|
|
|
|
// Required for either desktop OpenGL 2.0 or OpenGL ES 2.0
|
2014-03-20 22:08:19 +04:00
|
|
|
i->fFunctions.fStencilFuncSeparate = glStencilFuncSeparate_mozilla;
|
|
|
|
i->fFunctions.fStencilMaskSeparate = glStencilMaskSeparate_mozilla;
|
|
|
|
i->fFunctions.fStencilOpSeparate = glStencilOpSeparate_mozilla;
|
2012-10-28 00:47:58 +04:00
|
|
|
|
|
|
|
// GLContext supports glMapBuffer
|
2014-03-20 22:08:19 +04:00
|
|
|
i->fFunctions.fMapBuffer = glMapBuffer_mozilla;
|
|
|
|
i->fFunctions.fUnmapBuffer = glUnmapBuffer_mozilla;
|
2012-10-28 00:47:58 +04:00
|
|
|
|
|
|
|
// GLContext supports glRenderbufferStorageMultisample/glBlitFramebuffer
|
2014-03-20 22:08:19 +04:00
|
|
|
i->fFunctions.fRenderbufferStorageMultisample = glRenderbufferStorageMultisample_mozilla;
|
|
|
|
i->fFunctions.fBlitFramebuffer = glBlitFramebuffer_mozilla;
|
2012-10-28 00:47:58 +04:00
|
|
|
|
|
|
|
// GLContext supports glCompressedTexImage2D
|
2014-03-20 22:08:19 +04:00
|
|
|
i->fFunctions.fCompressedTexImage2D = glCompressedTexImage2D_mozilla;
|
2012-10-28 00:47:58 +04:00
|
|
|
|
2013-08-01 04:10:55 +04:00
|
|
|
// GL_OES_vertex_array_object
|
2014-03-20 22:08:19 +04:00
|
|
|
i->fFunctions.fBindVertexArray = glBindVertexArray_mozilla;
|
|
|
|
i->fFunctions.fDeleteVertexArrays = glDeleteVertexArrays_mozilla;
|
|
|
|
i->fFunctions.fGenVertexArrays = glGenVertexArrays_mozilla;
|
2013-08-01 04:10:55 +04:00
|
|
|
|
2012-10-28 00:47:58 +04:00
|
|
|
// Desktop GL
|
2014-03-20 22:08:19 +04:00
|
|
|
i->fFunctions.fGetTexLevelParameteriv = glGetTexLevelParameteriv_mozilla;
|
|
|
|
i->fFunctions.fDrawBuffer = glDrawBuffer_mozilla;
|
|
|
|
i->fFunctions.fReadBuffer = glReadBuffer_mozilla;
|
2012-10-28 00:47:58 +04:00
|
|
|
|
|
|
|
// Desktop OpenGL > 1.5
|
2014-03-20 22:08:19 +04:00
|
|
|
i->fFunctions.fGenQueries = glGenQueries_mozilla;
|
|
|
|
i->fFunctions.fDeleteQueries = glDeleteQueries_mozilla;
|
|
|
|
i->fFunctions.fBeginQuery = glBeginQuery_mozilla;
|
|
|
|
i->fFunctions.fEndQuery = glEndQuery_mozilla;
|
|
|
|
i->fFunctions.fGetQueryiv = glGetQueryiv_mozilla;
|
|
|
|
i->fFunctions.fGetQueryObjectiv = glGetQueryObjectiv_mozilla;
|
|
|
|
i->fFunctions.fGetQueryObjectuiv = glGetQueryObjectuiv_mozilla;
|
2012-10-28 00:47:58 +04:00
|
|
|
|
|
|
|
// Desktop OpenGL > 2.0
|
2014-03-20 22:08:19 +04:00
|
|
|
i->fFunctions.fDrawBuffers = glDrawBuffers_mozilla;
|
2012-10-28 00:47:58 +04:00
|
|
|
|
2013-06-17 06:07:18 +04:00
|
|
|
return i;
|
2012-10-28 00:47:58 +04:00
|
|
|
}
|
2014-03-06 01:49:37 +04:00
|
|
|
|
|
|
|
SkiaGLGlue::SkiaGLGlue(GLContext* context)
|
|
|
|
: mGLContext(context)
|
|
|
|
{
|
2014-08-06 20:01:44 +04:00
|
|
|
mGrGLInterface.adopt(CreateGrGLInterfaceFromGLContext(mGLContext));
|
|
|
|
mGrGLInterface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this);
|
|
|
|
mGrContext.adopt(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)mGrGLInterface.get()));
|
2014-03-06 01:49:37 +04:00
|
|
|
}
|