зеркало из https://github.com/mozilla/moz-skia.git
Make GrGLInterface a per-GrContext refcounted object rather than a global
Review URL: http://codereview.appspot.com/4901046/ git-svn-id: http://skia.googlecode.com/svn/trunk@2140 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
098660020c
Коммит
0b77d6892b
|
@ -149,39 +149,49 @@
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern void GrGLCheckErr(const char* location, const char* call);
|
||||
struct GrGLInterface;
|
||||
|
||||
extern void GrGLClearErr();
|
||||
extern void GrGLCheckErr(const GrGLInterface* gl,
|
||||
const char* location,
|
||||
const char* call);
|
||||
|
||||
extern void GrGLClearErr(const GrGLInterface* gl);
|
||||
|
||||
#if GR_GL_CHECK_ERROR
|
||||
extern bool gCheckErrorGL;
|
||||
#define GR_GL_CHECK_ERROR_IMPL(X) if (gCheckErrorGL) GrGLCheckErr(GR_FILE_AND_LINE_STR, #X)
|
||||
#define GR_GL_CHECK_ERROR_IMPL(IFACE, X) \
|
||||
if (gCheckErrorGL) \
|
||||
GrGLCheckErr(IFACE, GR_FILE_AND_LINE_STR, #X)
|
||||
#else
|
||||
#define GR_GL_CHECK_ERROR_IMPL(X)
|
||||
#define GR_GL_CHECK_ERROR_IMPL(IFACE, X)
|
||||
#endif
|
||||
|
||||
#if GR_GL_LOG_CALLS
|
||||
extern bool gLogCallsGL;
|
||||
#define GR_GL_LOG_CALLS_IMPL(X) if (gLogCallsGL) GrPrintf(GR_FILE_AND_LINE_STR "GL: " #X "\n")
|
||||
#define GR_GL_LOG_CALLS_IMPL(X)
|
||||
if (gLogCallsGL) \
|
||||
GrPrintf(GR_FILE_AND_LINE_STR "GL: " #X "\n")
|
||||
#else
|
||||
#define GR_GL_LOG_CALLS_IMPL(X)
|
||||
#endif
|
||||
|
||||
#define GR_GL(X) GrGLGetGLInterface()->f##X;; GR_GL_LOG_CALLS_IMPL(X); GR_GL_CHECK_ERROR_IMPL(X);
|
||||
#define GR_GL_NO_ERR(X) GrGLGetGLInterface()->f##X;; GR_GL_LOG_CALLS_IMPL(X);
|
||||
#define GR_GL_CALL(IFACE, X) \
|
||||
GR_GL_CALL_NOERRCHECK(IFACE, X) \
|
||||
GR_GL_CHECK_ERROR_IMPL(IFACE, X)
|
||||
|
||||
#define GR_GL_SUPPORT_DESKTOP (kDesktop_GrGLBinding == GrGLGetGLInterface()->fBindingsExported)
|
||||
#define GR_GL_SUPPORT_ES1 (kES1_GrGLBinding == GrGLGetGLInterface()->fBindingsExported)
|
||||
#define GR_GL_SUPPORT_ES2 (kES2_GrGLBinding == GrGLGetGLInterface()->fBindingsExported)
|
||||
#define GR_GL_SUPPORT_ES (GR_GL_SUPPORT_ES1 || GR_GL_SUPPORT_ES2)
|
||||
#define GR_GL_CALL_NOERRCHECK(IFACE, X) \
|
||||
IFACE->f##X; \
|
||||
GR_GL_LOG_CALLS_IMPL(X);
|
||||
|
||||
#define GR_GL_GET_ERROR(IFACE) (IFACE)->fGetError()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* GrGLRestoreResetRowLength() will reset GL_UNPACK_ROW_LENGTH to 0. We write
|
||||
* GrGLResetRowLength() will reset GL_UNPACK_ROW_LENGTH to 0. We write
|
||||
* this wrapper, since GL_UNPACK_ROW_LENGTH is not available on all GL versions
|
||||
*/
|
||||
extern void GrGLRestoreResetRowLength();
|
||||
extern void GrGLResetRowLength(const GrGLInterface*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -189,28 +199,28 @@ extern void GrGLRestoreResetRowLength();
|
|||
* Some drivers want the var-int arg to be zero-initialized on input.
|
||||
*/
|
||||
#define GR_GL_INIT_ZERO 0
|
||||
#define GR_GL_GetIntegerv(e, p) \
|
||||
#define GR_GL_GetIntegerv(gl, e, p) \
|
||||
do { \
|
||||
*(p) = GR_GL_INIT_ZERO; \
|
||||
GR_GL(GetIntegerv(e, p)); \
|
||||
GR_GL_CALL(gl, GetIntegerv(e, p)); \
|
||||
} while (0)
|
||||
|
||||
#define GR_GL_GetFramebufferAttachmentParameteriv(t, a, pname, p) \
|
||||
do { \
|
||||
*(p) = GR_GL_INIT_ZERO; \
|
||||
GR_GL(GetFramebufferAttachmentParameteriv(t, a, pname, p)); \
|
||||
#define GR_GL_GetFramebufferAttachmentParameteriv(gl, t, a, pname, p) \
|
||||
do { \
|
||||
*(p) = GR_GL_INIT_ZERO; \
|
||||
GR_GL_CALL(gl, GetFramebufferAttachmentParameteriv(t, a, pname, p)); \
|
||||
} while (0)
|
||||
|
||||
#define GR_GL_GetRenderbufferParameteriv(t, pname, p) \
|
||||
do { \
|
||||
*(p) = GR_GL_INIT_ZERO; \
|
||||
GR_GL(GetRenderbufferParameteriv(t, pname, p)); \
|
||||
#define GR_GL_GetRenderbufferParameteriv(gl, t, pname, p) \
|
||||
do { \
|
||||
*(p) = GR_GL_INIT_ZERO; \
|
||||
GR_GL_CALL(gl, GetRenderbufferParameteriv(t, pname, p)); \
|
||||
} while (0)
|
||||
|
||||
#define GR_GL_GetTexLevelParameteriv(t, l, pname, p) \
|
||||
do { \
|
||||
*(p) = GR_GL_INIT_ZERO; \
|
||||
GR_GL(GetTexLevelParameteriv(t, l, pname, p)); \
|
||||
#define GR_GL_GetTexLevelParameteriv(gl, t, l, pname, p) \
|
||||
do { \
|
||||
*(p) = GR_GL_INIT_ZERO; \
|
||||
GR_GL_CALL(gl, GetTexLevelParameteriv(t, l, pname, p)); \
|
||||
} while (0)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#define GrGLInterface_DEFINED
|
||||
|
||||
#include "GrGLConfig.h"
|
||||
#include "GrTypes.h"
|
||||
#include "GrRefCnt.h"
|
||||
|
||||
#if !defined(GR_GL_FUNCTION_TYPE)
|
||||
#define GR_GL_FUNCTION_TYPE
|
||||
|
@ -32,28 +32,38 @@ bool has_gl_extension_from_string(const char* ext,
|
|||
const char* extensionString);
|
||||
|
||||
// these variants call glGetString()
|
||||
bool has_gl_extension(const char* ext);
|
||||
void gl_version(int* major, int* minor);
|
||||
float gl_version_as_float();
|
||||
bool has_gl_extension(const GrGLInterface*, const char* ext);
|
||||
void gl_version(const GrGLInterface*, int* major, int* minor);
|
||||
float gl_version_as_float(const GrGLInterface*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* Routines managing the global interface used to invoke OpenGL calls.
|
||||
/**
|
||||
* Rather than depend on platform-specific GL headers and libraries, we require
|
||||
* the client to provide a struct of GL function pointers. This struct can be
|
||||
* specified per-GrContext as a parameter to GrContext::Create. If NULL is
|
||||
* passed to Create then the "default" GL interface is used. If the default is
|
||||
* also NULL GrContext creation will fail.
|
||||
*
|
||||
* The default interface is specified by calling GrGLSetDefaultInterface. If
|
||||
* this function hasn't been called or was last called with NULL then
|
||||
* GrGLInitializeDefaultGLInterface will be called to attempt to initialize it.
|
||||
* There are several implementations of this function provided. Each builds a
|
||||
* GrGLInterface for a specific platform and sets it as the default. There is
|
||||
* also an implementation that does nothing. You can link in any of the provided
|
||||
* implementations or your own implementation that sets up the GL function
|
||||
* pointers for your specific platform.
|
||||
*/
|
||||
struct GrGLInterface;
|
||||
GR_API GrGLInterface* GrGLGetGLInterface();
|
||||
GR_API void GrGLSetGLInterface(GrGLInterface* gl_interface);
|
||||
|
||||
/*
|
||||
* This is called when GrGLSetGLInterface() hasn't been called before creating
|
||||
* a GrGpuGL object. It provides a default implementation. The actual
|
||||
* implementation depends on which GrGLDefaultInterface_*.cpp has been linked.
|
||||
* There are some platform-specific implementations provided as well as
|
||||
* GrGLDefaultInterface_none.cpp which does nothing (effectively requiring an
|
||||
* explicit GrGLSetGLInterface call by the host).
|
||||
*/
|
||||
void GrGLSetDefaultGLInterface();
|
||||
struct GrGLInterface;
|
||||
|
||||
GR_API const GrGLInterface* GrGLGetDefaultGLInterface();
|
||||
// returns param so that you can unref it
|
||||
GR_API const GrGLInterface* GrGLSetDefaultGLInterface(const GrGLInterface* gl_interface);
|
||||
|
||||
// If this is implemented it must allocate a GrGLInterface on the heap because
|
||||
// GrGLInterface subclasses SkRefCnt.
|
||||
void GrGLInitializeDefaultGLInterface();
|
||||
|
||||
typedef unsigned int GrGLenum;
|
||||
typedef unsigned char GrGLboolean;
|
||||
|
@ -220,8 +230,24 @@ enum GrGLCapability {
|
|||
* functions, and extensions. The system assumes that the address of the
|
||||
* extension pointer will be valid across contexts.
|
||||
*/
|
||||
struct GrGLInterface {
|
||||
struct GR_API GrGLInterface : public GrRefCnt {
|
||||
|
||||
GrGLInterface();
|
||||
|
||||
bool validate(GrEngine engine) const;
|
||||
bool supportsDesktop() const {
|
||||
return 0 != (kDesktop_GrGLBinding & fBindingsExported);
|
||||
}
|
||||
bool supportsES1() const {
|
||||
return 0 != (kES1_GrGLBinding & fBindingsExported);
|
||||
}
|
||||
bool supportsES2() const {
|
||||
return 0 != (kES2_GrGLBinding & fBindingsExported);
|
||||
}
|
||||
bool supportsES() const {
|
||||
return 0 != ((kES1_GrGLBinding | kES2_GrGLBinding) &
|
||||
fBindingsExported);
|
||||
}
|
||||
|
||||
// Indicator variable specifying the type of GL implementation
|
||||
// exported: GLES{1|2} or Desktop.
|
||||
|
@ -362,11 +388,6 @@ struct GrGLInterface {
|
|||
// Dual Source Blending
|
||||
GrGLBindFragDataLocationIndexedProc fBindFragDataLocationIndexed;
|
||||
|
||||
// Code that initializes this struct using a static initializer should
|
||||
// make this the last entry in the static initializer. It can help to guard
|
||||
// against failing to initialize newly-added members of this struct.
|
||||
enum { kStaticInitEndGuard } fStaticInitEndGuard;
|
||||
|
||||
private:
|
||||
bool validateShaderFunctions() const;
|
||||
bool validateFixedFunctions() const;
|
||||
|
|
|
@ -173,13 +173,11 @@ static inline int16_t GrToS16(intptr_t x) {
|
|||
enum GrEngine {
|
||||
kOpenGL_Shaders_GrEngine,
|
||||
kOpenGL_Fixed_GrEngine,
|
||||
kDirect3D9_GrEngine
|
||||
};
|
||||
|
||||
/**
|
||||
* Engine-specific 3D context handle
|
||||
* Unused for GL.
|
||||
* IDirect3DDevice9* for D3D9
|
||||
* GrGLInterface* for OpenGL. If NULL will use the default GL interface.
|
||||
*/
|
||||
typedef intptr_t GrPlatform3DContext;
|
||||
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
*/
|
||||
|
||||
|
||||
void GrGLSetDefaultGLInterface() {
|
||||
void GrGLInitializeDefaultGLInterface() {
|
||||
}
|
||||
|
|
|
@ -23,17 +23,17 @@ struct GrGLIRect {
|
|||
GrGLsizei fWidth;
|
||||
GrGLsizei fHeight;
|
||||
|
||||
void pushToGLViewport() const {
|
||||
GR_GL(Viewport(fLeft, fBottom, fWidth, fHeight));
|
||||
void pushToGLViewport(const GrGLInterface* gl) const {
|
||||
GR_GL_CALL(gl, Viewport(fLeft, fBottom, fWidth, fHeight));
|
||||
}
|
||||
|
||||
void pushToGLScissor() const {
|
||||
GR_GL(Scissor(fLeft, fBottom, fWidth, fHeight));
|
||||
void pushToGLScissor(const GrGLInterface* gl) const {
|
||||
GR_GL_CALL(gl, Scissor(fLeft, fBottom, fWidth, fHeight));
|
||||
}
|
||||
|
||||
void setFromGLViewport() {
|
||||
void setFromGLViewport(const GrGLInterface* gl) {
|
||||
GR_STATIC_ASSERT(sizeof(GrGLIRect) == 4*sizeof(GrGLint));
|
||||
GR_GL_GetIntegerv(GR_GL_VIEWPORT, (GrGLint*) this);
|
||||
GR_GL_GetIntegerv(gl, GR_GL_VIEWPORT, (GrGLint*) this);
|
||||
}
|
||||
|
||||
// sometimes we have a GrIRect from the client that we
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#define GPUGL static_cast<GrGpuGL*>(getGpu())
|
||||
|
||||
#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
|
||||
|
||||
GrGLIndexBuffer::GrGLIndexBuffer(GrGpuGL* gpu,
|
||||
GrGLuint id,
|
||||
size_t sizeInBytes,
|
||||
|
@ -27,7 +29,7 @@ void GrGLIndexBuffer::onRelease() {
|
|||
// make sure we've not been abandoned
|
||||
if (fBufferID) {
|
||||
GPUGL->notifyIndexBufferDelete(this);
|
||||
GR_GL(DeleteBuffers(1, &fBufferID));
|
||||
GL_CALL(DeleteBuffers(1, &fBufferID));
|
||||
fBufferID = 0;
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +40,7 @@ void GrGLIndexBuffer::onAbandon() {
|
|||
}
|
||||
|
||||
void GrGLIndexBuffer::bind() const {
|
||||
GR_GL(BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, fBufferID));
|
||||
GL_CALL(BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, fBufferID));
|
||||
GPUGL->notifyIndexBufferBind(this);
|
||||
}
|
||||
|
||||
|
@ -52,9 +54,13 @@ void* GrGLIndexBuffer::lock() {
|
|||
if (GPUGL->supportsBufferLocking()) {
|
||||
this->bind();
|
||||
// Let driver know it can discard the old data
|
||||
GR_GL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, this->sizeInBytes(), NULL,
|
||||
this->dynamic() ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW));
|
||||
fLockPtr = GR_GL(MapBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, GR_GL_WRITE_ONLY));
|
||||
GL_CALL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER,
|
||||
this->sizeInBytes(),
|
||||
NULL,
|
||||
this->dynamic() ? GR_GL_DYNAMIC_DRAW :
|
||||
GR_GL_STATIC_DRAW));
|
||||
fLockPtr = GL_CALL(MapBuffer(GR_GL_ELEMENT_ARRAY_BUFFER,
|
||||
GR_GL_WRITE_ONLY));
|
||||
|
||||
return fLockPtr;
|
||||
}
|
||||
|
@ -71,7 +77,7 @@ void GrGLIndexBuffer::unlock() {
|
|||
GrAssert(GPUGL->supportsBufferLocking());
|
||||
|
||||
this->bind();
|
||||
GR_GL(UnmapBuffer(GR_GL_ELEMENT_ARRAY_BUFFER));
|
||||
GL_CALL(UnmapBuffer(GR_GL_ELEMENT_ARRAY_BUFFER));
|
||||
fLockPtr = NULL;
|
||||
}
|
||||
|
||||
|
@ -80,8 +86,8 @@ bool GrGLIndexBuffer::isLocked() const {
|
|||
if (this->isValid() && GPUGL->supportsBufferLocking()) {
|
||||
this->bind();
|
||||
GrGLint mapped;
|
||||
GR_GL(GetBufferParameteriv(GR_GL_ELEMENT_ARRAY_BUFFER,
|
||||
GR_GL_BUFFER_MAPPED, &mapped));
|
||||
GL_CALL(GetBufferParameteriv(GR_GL_ELEMENT_ARRAY_BUFFER,
|
||||
GR_GL_BUFFER_MAPPED, &mapped));
|
||||
GrAssert(!!mapped == !!fLockPtr);
|
||||
}
|
||||
#endif
|
||||
|
@ -97,12 +103,15 @@ bool GrGLIndexBuffer::updateData(const void* src, size_t srcSizeInBytes) {
|
|||
this->bind();
|
||||
GrGLenum usage = dynamic() ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW;
|
||||
if (this->sizeInBytes() == srcSizeInBytes) {
|
||||
GR_GL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, srcSizeInBytes, src, usage));
|
||||
GL_CALL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER,
|
||||
srcSizeInBytes, src, usage));
|
||||
} else {
|
||||
#if GR_GL_USE_BUFFER_DATA_NULL_HINT
|
||||
GR_GL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, this->sizeInBytes(), NULL, usage));
|
||||
GL_CALL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER,
|
||||
this->sizeInBytes(), NULL, usage));
|
||||
#endif
|
||||
GR_GL(BufferSubData(GR_GL_ELEMENT_ARRAY_BUFFER, 0, srcSizeInBytes, src));
|
||||
GL_CALL(BufferSubData(GR_GL_ELEMENT_ARRAY_BUFFER,
|
||||
0, srcSizeInBytes, src));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -116,7 +125,8 @@ bool GrGLIndexBuffer::updateSubData(const void* src,
|
|||
return false;
|
||||
}
|
||||
this->bind();
|
||||
GR_GL(BufferSubData(GR_GL_ELEMENT_ARRAY_BUFFER, offset, srcSizeInBytes, src));
|
||||
GL_CALL(BufferSubData(GR_GL_ELEMENT_ARRAY_BUFFER,
|
||||
offset, srcSizeInBytes, src));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,14 +7,13 @@
|
|||
*/
|
||||
|
||||
|
||||
|
||||
#include "GrTypes.h"
|
||||
#include "GrGLInterface.h"
|
||||
#include "GrGLDefines.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
GrGLInterface* gGLInterface = NULL;
|
||||
static SkAutoTUnref<const GrGLInterface> gDefaultGLInterface;
|
||||
|
||||
void gl_version_from_string(int* major, int* minor,
|
||||
const char* versionString) {
|
||||
|
@ -84,33 +83,160 @@ bool has_gl_extension_from_string(const char* ext,
|
|||
return false;
|
||||
}
|
||||
|
||||
GR_API void GrGLSetGLInterface(GrGLInterface* gl_interface) {
|
||||
gGLInterface = gl_interface;
|
||||
GR_API const GrGLInterface* GrGLSetDefaultGLInterface(const GrGLInterface* gl_interface) {
|
||||
gl_interface->ref();
|
||||
gDefaultGLInterface.reset(gl_interface);
|
||||
return gl_interface;
|
||||
}
|
||||
|
||||
GR_API GrGLInterface* GrGLGetGLInterface() {
|
||||
return gGLInterface;
|
||||
GR_API const GrGLInterface* GrGLGetDefaultGLInterface() {
|
||||
if (NULL == gDefaultGLInterface.get()) {
|
||||
GrGLInitializeDefaultGLInterface();
|
||||
}
|
||||
return gDefaultGLInterface.get();
|
||||
}
|
||||
|
||||
bool has_gl_extension(const char* ext) {
|
||||
bool has_gl_extension(const GrGLInterface* gl, const char* ext) {
|
||||
const char* glstr = reinterpret_cast<const char*>(
|
||||
GrGLGetGLInterface()->fGetString(GR_GL_EXTENSIONS));
|
||||
gl->fGetString(GR_GL_EXTENSIONS));
|
||||
|
||||
return has_gl_extension_from_string(ext, glstr);
|
||||
}
|
||||
|
||||
void gl_version(int* major, int* minor) {
|
||||
void gl_version(const GrGLInterface* gl, int* major, int* minor) {
|
||||
const char* v = reinterpret_cast<const char*>(
|
||||
GrGLGetGLInterface()->fGetString(GR_GL_VERSION));
|
||||
gl->fGetString(GR_GL_VERSION));
|
||||
gl_version_from_string(major, minor, v);
|
||||
}
|
||||
|
||||
float gl_version_as_float() {
|
||||
float gl_version_as_float(const GrGLInterface* gl) {
|
||||
const char* v = reinterpret_cast<const char*>(
|
||||
GrGLGetGLInterface()->fGetString(GR_GL_VERSION));
|
||||
gl->fGetString(GR_GL_VERSION));
|
||||
return gl_version_as_float_from_string(v);
|
||||
}
|
||||
|
||||
GrGLInterface::GrGLInterface() {
|
||||
fBindingsExported = (GrGLBinding)0;
|
||||
fNPOTRenderTargetSupport = kProbe_GrGLCapability;
|
||||
fMinRenderTargetHeight = kProbe_GrGLCapability;
|
||||
fMinRenderTargetWidth = kProbe_GrGLCapability;
|
||||
|
||||
fActiveTexture = NULL;
|
||||
fAttachShader = NULL;
|
||||
fBindAttribLocation = NULL;
|
||||
fBindBuffer = NULL;
|
||||
fBindTexture = NULL;
|
||||
fBlendColor = NULL;
|
||||
fBlendFunc = NULL;
|
||||
fBufferData = NULL;
|
||||
fBufferSubData = NULL;
|
||||
fClear = NULL;
|
||||
fClearColor = NULL;
|
||||
fClearStencil = NULL;
|
||||
fClientActiveTexture = NULL;
|
||||
fColor4ub = NULL;
|
||||
fColorMask = NULL;
|
||||
fColorPointer = NULL;
|
||||
fCompileShader = NULL;
|
||||
fCompressedTexImage2D = NULL;
|
||||
fCreateProgram = NULL;
|
||||
fCreateShader = NULL;
|
||||
fCullFace = NULL;
|
||||
fDeleteBuffers = NULL;
|
||||
fDeleteProgram = NULL;
|
||||
fDeleteShader = NULL;
|
||||
fDeleteTextures = NULL;
|
||||
fDepthMask = NULL;
|
||||
fDisable = NULL;
|
||||
fDisableClientState = NULL;
|
||||
fDisableVertexAttribArray = NULL;
|
||||
fDrawArrays = NULL;
|
||||
fDrawBuffer = NULL;
|
||||
fDrawBuffers = NULL;
|
||||
fDrawElements = NULL;
|
||||
fEnable = NULL;
|
||||
fEnableClientState = NULL;
|
||||
fEnableVertexAttribArray = NULL;
|
||||
fFrontFace = NULL;
|
||||
fGenBuffers = NULL;
|
||||
fGenTextures = NULL;
|
||||
fGetBufferParameteriv = NULL;
|
||||
fGetError = NULL;
|
||||
fGetIntegerv = NULL;
|
||||
fGetProgramInfoLog = NULL;
|
||||
fGetProgramiv = NULL;
|
||||
fGetShaderInfoLog = NULL;
|
||||
fGetShaderiv = NULL;
|
||||
fGetString = NULL;
|
||||
fGetTexLevelParameteriv = NULL;
|
||||
fGetUniformLocation = NULL;
|
||||
fLineWidth = NULL;
|
||||
fLinkProgram = NULL;
|
||||
fLoadMatrixf = NULL;
|
||||
fMatrixMode = NULL;
|
||||
fPixelStorei = NULL;
|
||||
fPointSize = NULL;
|
||||
fReadBuffer = NULL;
|
||||
fReadPixels = NULL;
|
||||
fScissor = NULL;
|
||||
fShadeModel = NULL;
|
||||
fShaderSource = NULL;
|
||||
fStencilFunc = NULL;
|
||||
fStencilFuncSeparate = NULL;
|
||||
fStencilMask = NULL;
|
||||
fStencilMaskSeparate = NULL;
|
||||
fStencilOp = NULL;
|
||||
fStencilOpSeparate = NULL;
|
||||
fTexCoordPointer = NULL;
|
||||
fTexEnvi = NULL;
|
||||
fTexImage2D = NULL;
|
||||
fTexParameteri = NULL;
|
||||
fTexSubImage2D = NULL;
|
||||
fUniform1f = NULL;
|
||||
fUniform1i = NULL;
|
||||
fUniform1fv = NULL;
|
||||
fUniform1iv = NULL;
|
||||
fUniform2f = NULL;
|
||||
fUniform2i = NULL;
|
||||
fUniform2fv = NULL;
|
||||
fUniform2iv = NULL;
|
||||
fUniform3f = NULL;
|
||||
fUniform3i = NULL;
|
||||
fUniform3fv = NULL;
|
||||
fUniform3iv = NULL;
|
||||
fUniform4f = NULL;
|
||||
fUniform4i = NULL;
|
||||
fUniform4fv = NULL;
|
||||
fUniform4iv = NULL;
|
||||
fUniformMatrix2fv = NULL;
|
||||
fUniformMatrix3fv = NULL;
|
||||
fUniformMatrix4fv = NULL;
|
||||
fUseProgram = NULL;
|
||||
fVertexAttrib4fv = NULL;
|
||||
fVertexAttribPointer = NULL;
|
||||
fVertexPointer = NULL;
|
||||
fViewport = NULL;
|
||||
fBindFramebuffer = NULL;
|
||||
fBindRenderbuffer = NULL;
|
||||
fCheckFramebufferStatus = NULL;
|
||||
fDeleteFramebuffers = NULL;
|
||||
fDeleteRenderbuffers = NULL;
|
||||
fFramebufferRenderbuffer = NULL;
|
||||
fFramebufferTexture2D = NULL;
|
||||
fGenFramebuffers = NULL;
|
||||
fGenRenderbuffers = NULL;
|
||||
fGetFramebufferAttachmentParameteriv = NULL;
|
||||
fGetRenderbufferParameteriv = NULL;
|
||||
fRenderbufferStorage = NULL;
|
||||
fRenderbufferStorageMultisample = NULL;
|
||||
fBlitFramebuffer = NULL;
|
||||
fResolveMultisampleFramebuffer = NULL;
|
||||
fMapBuffer = NULL;
|
||||
fUnmapBuffer = NULL;
|
||||
fBindFragDataLocationIndexed = NULL;
|
||||
}
|
||||
|
||||
|
||||
bool GrGLInterface::validateShaderFunctions() const {
|
||||
// required for GrGpuGLShaders
|
||||
if (NULL == fAttachShader ||
|
||||
|
@ -176,13 +302,12 @@ bool GrGLInterface::validateFixedFunctions() const {
|
|||
|
||||
bool GrGLInterface::validate(GrEngine engine) const {
|
||||
|
||||
bool isDesktop = kDesktop_GrGLBinding == fBindingsExported;
|
||||
bool isDesktop = this->supportsDesktop();
|
||||
|
||||
// ES1 and 2 can be supported in the same interface
|
||||
bool isES = ((kES1_GrGLBinding | kES2_GrGLBinding) & fBindingsExported &&
|
||||
!(~(kES1_GrGLBinding | kES2_GrGLBinding) & fBindingsExported));
|
||||
bool isES = this->supportsES();
|
||||
|
||||
if (!isDesktop && !isES) {
|
||||
if (isDesktop == isES) {
|
||||
// must have one, don't support both in same interface
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -261,7 +386,7 @@ bool GrGLInterface::validate(GrEngine engine) const {
|
|||
int major, minor;
|
||||
const char* ext;
|
||||
|
||||
gl_version(&major, &minor);
|
||||
gl_version(this, &major, &minor);
|
||||
ext = (const char*)fGetString(GR_GL_EXTENSIONS);
|
||||
|
||||
// Now check that baseline ES/Desktop fns not covered above are present
|
||||
|
|
|
@ -16,16 +16,16 @@
|
|||
|
||||
namespace {
|
||||
|
||||
const char* GrPrecision() {
|
||||
if (GR_GL_SUPPORT_ES2) {
|
||||
const char* GrPrecision(const GrGLInterface* gl) {
|
||||
if (gl->supportsES()) {
|
||||
return "mediump";
|
||||
} else {
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
|
||||
const char* GrShaderPrecision() {
|
||||
if (GR_GL_SUPPORT_ES2) {
|
||||
const char* GrShaderPrecision(const GrGLInterface* gl) {
|
||||
if (gl->supportsES()) {
|
||||
return "precision mediump float;\n";
|
||||
} else {
|
||||
return "";
|
||||
|
@ -320,7 +320,8 @@ static void addColorFilter(GrStringBuilder* fsCode, const char * outputVar,
|
|||
add_helper(outputVar, colorStr.c_str(), constStr.c_str(), fsCode);
|
||||
}
|
||||
|
||||
bool GrGLProgram::genProgram(GrGLProgram::CachedData* programData) const {
|
||||
bool GrGLProgram::genProgram(const GrGLInterface* gl,
|
||||
GrGLProgram::CachedData* programData) const {
|
||||
|
||||
ShaderCodeSegments segments;
|
||||
const uint32_t& layout = fProgramDesc.fVertexLayout;
|
||||
|
@ -438,7 +439,7 @@ bool GrGLProgram::genProgram(GrGLProgram::CachedData* programData) const {
|
|||
inCoords = texCoordAttrs[tcIdx].c_str();
|
||||
}
|
||||
|
||||
genStageCode(s,
|
||||
genStageCode(gl, s,
|
||||
fProgramDesc.fStages[s],
|
||||
inColor.size() ? inColor.c_str() : NULL,
|
||||
outColor.c_str(),
|
||||
|
@ -561,7 +562,7 @@ bool GrGLProgram::genProgram(GrGLProgram::CachedData* programData) const {
|
|||
inCoords = texCoordAttrs[tcIdx].c_str();
|
||||
}
|
||||
|
||||
genStageCode(s,
|
||||
genStageCode(gl, s,
|
||||
fProgramDesc.fStages[s],
|
||||
inCoverage.size() ? inCoverage.c_str() : NULL,
|
||||
outCoverage.c_str(),
|
||||
|
@ -619,23 +620,24 @@ bool GrGLProgram::genProgram(GrGLProgram::CachedData* programData) const {
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// compile and setup attribs and unis
|
||||
|
||||
if (!CompileFSAndVS(segments, programData)) {
|
||||
if (!CompileFSAndVS(gl, segments, programData)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this->bindOutputsAttribsAndLinkProgram(texCoordAttrs,
|
||||
if (!this->bindOutputsAttribsAndLinkProgram(gl, texCoordAttrs,
|
||||
usingDeclaredOutputs,
|
||||
dualSourceOutputWritten,
|
||||
programData)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->getUniformLocationsAndInitCache(programData);
|
||||
this->getUniformLocationsAndInitCache(gl, programData);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GrGLProgram::CompileFSAndVS(const ShaderCodeSegments& segments,
|
||||
bool GrGLProgram::CompileFSAndVS(const GrGLInterface* gl,
|
||||
const ShaderCodeSegments& segments,
|
||||
CachedData* programData) {
|
||||
|
||||
static const int MAX_STRINGS = 6;
|
||||
|
@ -678,10 +680,8 @@ bool GrGLProgram::CompileFSAndVS(const ShaderCodeSegments& segments,
|
|||
GrPrintf("\n");
|
||||
#endif
|
||||
GrAssert(stringCnt <= MAX_STRINGS);
|
||||
programData->fVShaderID = CompileShader(GR_GL_VERTEX_SHADER,
|
||||
stringCnt,
|
||||
strings,
|
||||
lengths);
|
||||
programData->fVShaderID = CompileShader(gl, GR_GL_VERTEX_SHADER,
|
||||
stringCnt, strings, lengths);
|
||||
|
||||
if (!programData->fVShaderID) {
|
||||
return false;
|
||||
|
@ -694,9 +694,9 @@ bool GrGLProgram::CompileFSAndVS(const ShaderCodeSegments& segments,
|
|||
lengths[stringCnt] = segments.fHeader.size();
|
||||
++stringCnt;
|
||||
}
|
||||
if (strlen(GrShaderPrecision()) > 1) {
|
||||
strings[stringCnt] = GrShaderPrecision();
|
||||
lengths[stringCnt] = strlen(GrShaderPrecision());
|
||||
if (strlen(GrShaderPrecision(gl)) > 1) {
|
||||
strings[stringCnt] = GrShaderPrecision(gl);
|
||||
lengths[stringCnt] = strlen(GrShaderPrecision(gl));
|
||||
++stringCnt;
|
||||
}
|
||||
if (segments.fFSUnis.size()) {
|
||||
|
@ -727,7 +727,7 @@ bool GrGLProgram::CompileFSAndVS(const ShaderCodeSegments& segments,
|
|||
|
||||
#if PRINT_SHADERS
|
||||
GrPrintf(segments.fHeader.c_str());
|
||||
GrPrintf(GrShaderPrecision());
|
||||
GrPrintf(GrShaderPrecision(gl));
|
||||
GrPrintf(segments.fFSUnis.c_str());
|
||||
GrPrintf(segments.fVaryings.c_str());
|
||||
GrPrintf(segments.fFSOutputs.c_str());
|
||||
|
@ -736,10 +736,8 @@ bool GrGLProgram::CompileFSAndVS(const ShaderCodeSegments& segments,
|
|||
GrPrintf("\n");
|
||||
#endif
|
||||
GrAssert(stringCnt <= MAX_STRINGS);
|
||||
programData->fFShaderID = CompileShader(GR_GL_FRAGMENT_SHADER,
|
||||
stringCnt,
|
||||
strings,
|
||||
lengths);
|
||||
programData->fFShaderID = CompileShader(gl, GR_GL_FRAGMENT_SHADER,
|
||||
stringCnt, strings, lengths);
|
||||
|
||||
if (!programData->fFShaderID) {
|
||||
return false;
|
||||
|
@ -748,29 +746,31 @@ bool GrGLProgram::CompileFSAndVS(const ShaderCodeSegments& segments,
|
|||
return true;
|
||||
}
|
||||
|
||||
GrGLuint GrGLProgram::CompileShader(GrGLenum type,
|
||||
int stringCnt,
|
||||
const char** strings,
|
||||
int* stringLengths) {
|
||||
GrGLuint GrGLProgram::CompileShader(const GrGLInterface* gl,
|
||||
GrGLenum type,
|
||||
int stringCnt,
|
||||
const char** strings,
|
||||
int* stringLengths) {
|
||||
SK_TRACE_EVENT1("GrGLProgram::CompileShader",
|
||||
"stringCount", SkStringPrintf("%i", stringCnt).c_str());
|
||||
|
||||
GrGLuint shader = GR_GL(CreateShader(type));
|
||||
GrGLuint shader = GR_GL_CALL(gl, CreateShader(type));
|
||||
if (0 == shader) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
GrGLint compiled = GR_GL_INIT_ZERO;
|
||||
GR_GL(ShaderSource(shader, stringCnt, strings, stringLengths));
|
||||
GR_GL(CompileShader(shader));
|
||||
GR_GL(GetShaderiv(shader, GR_GL_COMPILE_STATUS, &compiled));
|
||||
GR_GL_CALL(gl, ShaderSource(shader, stringCnt, strings, stringLengths));
|
||||
GR_GL_CALL(gl, CompileShader(shader));
|
||||
GR_GL_CALL(gl, GetShaderiv(shader, GR_GL_COMPILE_STATUS, &compiled));
|
||||
|
||||
if (!compiled) {
|
||||
GrGLint infoLen = GR_GL_INIT_ZERO;
|
||||
GR_GL(GetShaderiv(shader, GR_GL_INFO_LOG_LENGTH, &infoLen));
|
||||
GR_GL_CALL(gl, GetShaderiv(shader, GR_GL_INFO_LOG_LENGTH, &infoLen));
|
||||
SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugger
|
||||
if (infoLen > 0) {
|
||||
GR_GL(GetShaderInfoLog(shader, infoLen+1, NULL, (char*)log.get()));
|
||||
GR_GL_CALL(gl, GetShaderInfoLog(shader, infoLen+1,
|
||||
NULL, (char*)log.get()));
|
||||
for (int i = 0; i < stringCnt; ++i) {
|
||||
if (NULL == stringLengths || stringLengths[i] < 0) {
|
||||
GrPrintf(strings[i]);
|
||||
|
@ -781,49 +781,51 @@ GrGLuint GrGLProgram::CompileShader(GrGLenum type,
|
|||
GrPrintf("\n%s", log.get());
|
||||
}
|
||||
GrAssert(!"Shader compilation failed!");
|
||||
GR_GL(DeleteShader(shader));
|
||||
GR_GL_CALL(gl, DeleteShader(shader));
|
||||
return 0;
|
||||
}
|
||||
return shader;
|
||||
}
|
||||
|
||||
bool GrGLProgram::bindOutputsAttribsAndLinkProgram(
|
||||
const GrGLInterface* gl,
|
||||
GrStringBuilder texCoordAttrNames[],
|
||||
bool bindColorOut,
|
||||
bool bindDualSrcOut,
|
||||
CachedData* programData) const {
|
||||
programData->fProgramID = GR_GL(CreateProgram());
|
||||
programData->fProgramID = GR_GL_CALL(gl, CreateProgram());
|
||||
if (!programData->fProgramID) {
|
||||
return false;
|
||||
}
|
||||
const GrGLint& progID = programData->fProgramID;
|
||||
|
||||
GR_GL(AttachShader(progID, programData->fVShaderID));
|
||||
GR_GL(AttachShader(progID, programData->fFShaderID));
|
||||
GR_GL_CALL(gl, AttachShader(progID, programData->fVShaderID));
|
||||
GR_GL_CALL(gl, AttachShader(progID, programData->fFShaderID));
|
||||
|
||||
if (bindColorOut) {
|
||||
GR_GL(BindFragDataLocationIndexed(programData->fProgramID,
|
||||
GR_GL_CALL(gl, BindFragDataLocationIndexed(programData->fProgramID,
|
||||
0, 0, declared_color_output_name()));
|
||||
}
|
||||
if (bindDualSrcOut) {
|
||||
GR_GL(BindFragDataLocationIndexed(programData->fProgramID,
|
||||
GR_GL_CALL(gl, BindFragDataLocationIndexed(programData->fProgramID,
|
||||
0, 1, dual_source_output_name()));
|
||||
}
|
||||
|
||||
// Bind the attrib locations to same values for all shaders
|
||||
GR_GL(BindAttribLocation(progID, PositionAttributeIdx(), POS_ATTR_NAME));
|
||||
GR_GL_CALL(gl, BindAttribLocation(progID, PositionAttributeIdx(),
|
||||
POS_ATTR_NAME));
|
||||
for (int t = 0; t < GrDrawTarget::kMaxTexCoords; ++t) {
|
||||
if (texCoordAttrNames[t].size()) {
|
||||
GR_GL(BindAttribLocation(progID,
|
||||
TexCoordAttributeIdx(t),
|
||||
texCoordAttrNames[t].c_str()));
|
||||
GR_GL_CALL(gl, BindAttribLocation(progID,
|
||||
TexCoordAttributeIdx(t),
|
||||
texCoordAttrNames[t].c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
if (kSetAsAttribute == programData->fUniLocations.fViewMatrixUni) {
|
||||
GR_GL(BindAttribLocation(progID,
|
||||
ViewMatrixAttributeIdx(),
|
||||
VIEW_MATRIX_NAME));
|
||||
GR_GL_CALL(gl, BindAttribLocation(progID,
|
||||
ViewMatrixAttributeIdx(),
|
||||
VIEW_MATRIX_NAME));
|
||||
}
|
||||
|
||||
for (int s = 0; s < GrDrawTarget::kNumStages; ++s) {
|
||||
|
@ -831,59 +833,59 @@ bool GrGLProgram::bindOutputsAttribsAndLinkProgram(
|
|||
if (kSetAsAttribute == unis.fTextureMatrixUni) {
|
||||
GrStringBuilder matName;
|
||||
tex_matrix_name(s, &matName);
|
||||
GR_GL(BindAttribLocation(progID,
|
||||
TextureMatrixAttributeIdx(s),
|
||||
matName.c_str()));
|
||||
GR_GL_CALL(gl, BindAttribLocation(progID,
|
||||
TextureMatrixAttributeIdx(s),
|
||||
matName.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
GR_GL(BindAttribLocation(progID, ColorAttributeIdx(), COL_ATTR_NAME));
|
||||
GR_GL_CALL(gl, BindAttribLocation(progID, ColorAttributeIdx(),
|
||||
COL_ATTR_NAME));
|
||||
|
||||
GR_GL(LinkProgram(progID));
|
||||
GR_GL_CALL(gl, LinkProgram(progID));
|
||||
|
||||
GrGLint linked = GR_GL_INIT_ZERO;
|
||||
GR_GL(GetProgramiv(progID, GR_GL_LINK_STATUS, &linked));
|
||||
GR_GL_CALL(gl, GetProgramiv(progID, GR_GL_LINK_STATUS, &linked));
|
||||
if (!linked) {
|
||||
GrGLint infoLen = GR_GL_INIT_ZERO;
|
||||
GR_GL(GetProgramiv(progID, GR_GL_INFO_LOG_LENGTH, &infoLen));
|
||||
GR_GL_CALL(gl, GetProgramiv(progID, GR_GL_INFO_LOG_LENGTH, &infoLen));
|
||||
SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugger
|
||||
if (infoLen > 0) {
|
||||
GR_GL(GetProgramInfoLog(progID,
|
||||
infoLen+1,
|
||||
NULL,
|
||||
(char*)log.get()));
|
||||
GR_GL_CALL(gl, GetProgramInfoLog(progID, infoLen+1,
|
||||
NULL, (char*)log.get()));
|
||||
GrPrintf((char*)log.get());
|
||||
}
|
||||
GrAssert(!"Error linking program");
|
||||
GR_GL(DeleteProgram(progID));
|
||||
GR_GL_CALL(gl, DeleteProgram(progID));
|
||||
programData->fProgramID = 0;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void GrGLProgram::getUniformLocationsAndInitCache(CachedData* programData) const {
|
||||
void GrGLProgram::getUniformLocationsAndInitCache(const GrGLInterface* gl,
|
||||
CachedData* programData) const {
|
||||
const GrGLint& progID = programData->fProgramID;
|
||||
|
||||
if (kUseUniform == programData->fUniLocations.fViewMatrixUni) {
|
||||
programData->fUniLocations.fViewMatrixUni =
|
||||
GR_GL(GetUniformLocation(progID, VIEW_MATRIX_NAME));
|
||||
GR_GL_CALL(gl, GetUniformLocation(progID, VIEW_MATRIX_NAME));
|
||||
GrAssert(kUnusedUniform != programData->fUniLocations.fViewMatrixUni);
|
||||
}
|
||||
if (kUseUniform == programData->fUniLocations.fColorUni) {
|
||||
programData->fUniLocations.fColorUni =
|
||||
GR_GL(GetUniformLocation(progID, COL_UNI_NAME));
|
||||
GR_GL_CALL(gl, GetUniformLocation(progID, COL_UNI_NAME));
|
||||
GrAssert(kUnusedUniform != programData->fUniLocations.fColorUni);
|
||||
}
|
||||
if (kUseUniform == programData->fUniLocations.fColorFilterUni) {
|
||||
programData->fUniLocations.fColorFilterUni =
|
||||
GR_GL(GetUniformLocation(progID, COL_FILTER_UNI_NAME));
|
||||
GR_GL_CALL(gl, GetUniformLocation(progID, COL_FILTER_UNI_NAME));
|
||||
GrAssert(kUnusedUniform != programData->fUniLocations.fColorFilterUni);
|
||||
}
|
||||
|
||||
if (kUseUniform == programData->fUniLocations.fEdgesUni) {
|
||||
programData->fUniLocations.fEdgesUni =
|
||||
GR_GL(GetUniformLocation(progID, EDGES_UNI_NAME));
|
||||
GR_GL_CALL(gl, GetUniformLocation(progID, EDGES_UNI_NAME));
|
||||
GrAssert(kUnusedUniform != programData->fUniLocations.fEdgesUni);
|
||||
} else {
|
||||
programData->fUniLocations.fEdgesUni = kUnusedUniform;
|
||||
|
@ -895,18 +897,17 @@ void GrGLProgram::getUniformLocationsAndInitCache(CachedData* programData) const
|
|||
if (kUseUniform == locations.fTextureMatrixUni) {
|
||||
GrStringBuilder texMName;
|
||||
tex_matrix_name(s, &texMName);
|
||||
locations.fTextureMatrixUni = GR_GL(GetUniformLocation(
|
||||
progID,
|
||||
texMName.c_str()));
|
||||
locations.fTextureMatrixUni =
|
||||
GR_GL_CALL(gl, GetUniformLocation(progID, texMName.c_str()));
|
||||
GrAssert(kUnusedUniform != locations.fTextureMatrixUni);
|
||||
}
|
||||
|
||||
if (kUseUniform == locations.fSamplerUni) {
|
||||
GrStringBuilder samplerName;
|
||||
sampler_name(s, &samplerName);
|
||||
locations.fSamplerUni = GR_GL(GetUniformLocation(
|
||||
progID,
|
||||
samplerName.c_str()));
|
||||
locations.fSamplerUni =
|
||||
GR_GL_CALL(gl, GetUniformLocation(progID,
|
||||
samplerName.c_str()));
|
||||
GrAssert(kUnusedUniform != locations.fSamplerUni);
|
||||
}
|
||||
|
||||
|
@ -914,51 +915,50 @@ void GrGLProgram::getUniformLocationsAndInitCache(CachedData* programData) const
|
|||
GrStringBuilder texelSizeName;
|
||||
normalized_texel_size_name(s, &texelSizeName);
|
||||
locations.fNormalizedTexelSizeUni =
|
||||
GR_GL(GetUniformLocation(progID, texelSizeName.c_str()));
|
||||
GR_GL_CALL(gl, GetUniformLocation(progID,
|
||||
texelSizeName.c_str()));
|
||||
GrAssert(kUnusedUniform != locations.fNormalizedTexelSizeUni);
|
||||
}
|
||||
|
||||
if (kUseUniform == locations.fRadial2Uni) {
|
||||
GrStringBuilder radial2ParamName;
|
||||
radial2_param_name(s, &radial2ParamName);
|
||||
locations.fRadial2Uni = GR_GL(GetUniformLocation(
|
||||
progID,
|
||||
radial2ParamName.c_str()));
|
||||
locations.fRadial2Uni =
|
||||
GR_GL_CALL(gl, GetUniformLocation(progID,
|
||||
radial2ParamName.c_str()));
|
||||
GrAssert(kUnusedUniform != locations.fRadial2Uni);
|
||||
}
|
||||
|
||||
if (kUseUniform == locations.fTexDomUni) {
|
||||
GrStringBuilder texDomName;
|
||||
tex_domain_name(s, &texDomName);
|
||||
locations.fTexDomUni = GR_GL(GetUniformLocation(
|
||||
progID,
|
||||
texDomName.c_str()));
|
||||
locations.fTexDomUni =
|
||||
GR_GL_CALL(gl, GetUniformLocation(progID,
|
||||
texDomName.c_str()));
|
||||
GrAssert(kUnusedUniform != locations.fTexDomUni);
|
||||
}
|
||||
|
||||
GrStringBuilder kernelName, imageIncrementName;
|
||||
convolve_param_names(s, &kernelName, &imageIncrementName);
|
||||
if (kUseUniform == locations.fKernelUni) {
|
||||
locations.fKernelUni = GR_GL(GetUniformLocation(
|
||||
progID,
|
||||
kernelName.c_str()));
|
||||
locations.fKernelUni = GR_GL_CALL(gl, GetUniformLocation(
|
||||
progID, kernelName.c_str()));
|
||||
GrAssert(kUnusedUniform != locations.fKernelUni);
|
||||
}
|
||||
|
||||
if (kUseUniform == locations.fImageIncrementUni) {
|
||||
locations.fImageIncrementUni = GR_GL(GetUniformLocation(
|
||||
progID,
|
||||
imageIncrementName.c_str()));
|
||||
locations.fImageIncrementUni = GR_GL_CALL(gl, GetUniformLocation(progID,
|
||||
imageIncrementName.c_str()));
|
||||
GrAssert(kUnusedUniform != locations.fImageIncrementUni);
|
||||
}
|
||||
}
|
||||
}
|
||||
GR_GL(UseProgram(progID));
|
||||
GR_GL_CALL(gl, UseProgram(progID));
|
||||
|
||||
// init sampler unis and set bogus values for state tracking
|
||||
for (int s = 0; s < GrDrawTarget::kNumStages; ++s) {
|
||||
if (kUnusedUniform != programData->fUniLocations.fStages[s].fSamplerUni) {
|
||||
GR_GL(Uniform1i(programData->fUniLocations.fStages[s].fSamplerUni, s));
|
||||
GR_GL_CALL(gl, Uniform1i(programData->fUniLocations.fStages[s].fSamplerUni, s));
|
||||
}
|
||||
programData->fTextureMatrices[s] = GrMatrix::InvalidMatrix();
|
||||
programData->fRadial2CenterX1[s] = GR_ScalarMax;
|
||||
|
@ -975,7 +975,8 @@ void GrGLProgram::getUniformLocationsAndInitCache(CachedData* programData) const
|
|||
// Stage code generation
|
||||
//============================================================================
|
||||
|
||||
void GrGLProgram::genStageCode(int stageNum,
|
||||
void GrGLProgram::genStageCode(const GrGLInterface* gl,
|
||||
int stageNum,
|
||||
const GrGLProgram::StageDesc& desc,
|
||||
const char* fsInColor, // NULL means no incoming color
|
||||
const char* fsOutColor,
|
||||
|
@ -1051,7 +1052,7 @@ void GrGLProgram::genStageCode(int stageNum,
|
|||
StageDesc::kRadial2GradientDegenerate_CoordMapping == desc.fCoordMapping) {
|
||||
|
||||
segments->fVSUnis.appendf("uniform %s float %s[6];\n",
|
||||
GrPrecision(), radial2ParamsName.c_str());
|
||||
GrPrecision(gl), radial2ParamsName.c_str());
|
||||
segments->fFSUnis.appendf("uniform float %s[6];\n",
|
||||
radial2ParamsName.c_str());
|
||||
locations->fRadial2Uni = kUseUniform;
|
||||
|
@ -1077,7 +1078,7 @@ void GrGLProgram::genStageCode(int stageNum,
|
|||
segments->fFSUnis.appendf("uniform vec2 %s;\n",
|
||||
imageIncrementName.c_str());
|
||||
segments->fVSUnis.appendf("uniform %s vec2 %s;\n",
|
||||
GrPrecision(),
|
||||
GrPrecision(gl),
|
||||
imageIncrementName.c_str());
|
||||
locations->fKernelUni = kUseUniform;
|
||||
locations->fImageIncrementUni = kUseUniform;
|
||||
|
|
|
@ -51,7 +51,8 @@ public:
|
|||
* The result of heavy init is not stored in datamembers of GrGLProgam,
|
||||
* but in a separate cacheable container.
|
||||
*/
|
||||
bool genProgram(CachedData* programData) const;
|
||||
bool genProgram(const GrGLInterface* gl,
|
||||
CachedData* programData) const;
|
||||
|
||||
/**
|
||||
* The shader may modify the blend coeffecients. Params are in/out
|
||||
|
@ -273,7 +274,8 @@ private:
|
|||
|
||||
// should set all fields in locations var to kUseUniform if the
|
||||
// corresponding uniform is required for the program.
|
||||
void genStageCode(int stageNum,
|
||||
void genStageCode(const GrGLInterface* gl,
|
||||
int stageNum,
|
||||
const ProgramDesc::StageDesc& desc,
|
||||
const char* fsInColor, // NULL means no incoming color
|
||||
const char* fsOutColor,
|
||||
|
@ -281,18 +283,21 @@ private:
|
|||
ShaderCodeSegments* segments,
|
||||
StageUniLocations* locations) const;
|
||||
|
||||
static bool CompileFSAndVS(const ShaderCodeSegments& segments,
|
||||
static bool CompileFSAndVS(const GrGLInterface* gl,
|
||||
const ShaderCodeSegments& segments,
|
||||
CachedData* programData);
|
||||
|
||||
// Compiles a GL shader, returns shader ID or 0 if failed
|
||||
// params have same meaning as glShaderSource
|
||||
static GrGLuint CompileShader(GrGLenum type, int stringCnt,
|
||||
static GrGLuint CompileShader(const GrGLInterface* gl,
|
||||
GrGLenum type, int stringCnt,
|
||||
const char** strings,
|
||||
int* stringLengths);
|
||||
|
||||
// Creates a GL program ID, binds shader attributes to GL vertex attrs, and
|
||||
// links the program
|
||||
bool bindOutputsAttribsAndLinkProgram(
|
||||
const GrGLInterface* gl,
|
||||
GrStringBuilder texCoordAttrNames[GrDrawTarget::kMaxTexCoords],
|
||||
bool bindColorOut,
|
||||
bool bindDualSrcOut,
|
||||
|
@ -300,7 +305,8 @@ private:
|
|||
|
||||
// Gets locations for all uniforms set to kUseUniform and initializes cache
|
||||
// to invalid values.
|
||||
void getUniformLocationsAndInitCache(CachedData* programData) const;
|
||||
void getUniformLocationsAndInitCache(const GrGLInterface* gl,
|
||||
CachedData* programData) const;
|
||||
|
||||
friend class GrGpuGLShaders;
|
||||
};
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#define GPUGL static_cast<GrGpuGL*>(getGpu())
|
||||
|
||||
#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
|
||||
|
||||
void GrGLRenderTarget::init(const Desc& desc,
|
||||
const GrGLIRect& viewport,
|
||||
GrGLTexID* texID) {
|
||||
|
@ -64,13 +66,13 @@ void GrGLRenderTarget::onRelease() {
|
|||
GPUGL->notifyRenderTargetDelete(this);
|
||||
if (fOwnIDs) {
|
||||
if (fTexFBOID) {
|
||||
GR_GL(DeleteFramebuffers(1, &fTexFBOID));
|
||||
GL_CALL(DeleteFramebuffers(1, &fTexFBOID));
|
||||
}
|
||||
if (fRTFBOID && fRTFBOID != fTexFBOID) {
|
||||
GR_GL(DeleteFramebuffers(1, &fRTFBOID));
|
||||
GL_CALL(DeleteFramebuffers(1, &fRTFBOID));
|
||||
}
|
||||
if (fMSColorRenderbufferID) {
|
||||
GR_GL(DeleteRenderbuffers(1, &fMSColorRenderbufferID));
|
||||
GL_CALL(DeleteRenderbuffers(1, &fMSColorRenderbufferID));
|
||||
}
|
||||
}
|
||||
fRTFBOID = 0;
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#include "GrGLStencilBuffer.h"
|
||||
#include "GrGpuGL.h"
|
||||
|
||||
GrGLStencilBuffer::~GrGLStencilBuffer() {
|
||||
this->release();
|
||||
}
|
||||
|
||||
size_t GrGLStencilBuffer::sizeInBytes() const {
|
||||
uint64_t size = this->width();
|
||||
size *= this->height();
|
||||
size *= fFormat.fTotalBits;
|
||||
size *= GrMax(1,this->numSamples());
|
||||
return static_cast<size_t>(size / 8);
|
||||
}
|
||||
|
||||
void GrGLStencilBuffer::onRelease() {
|
||||
if (0 != fRenderbufferID) {
|
||||
GrGpuGL* gpuGL = (GrGpuGL*) this->getGpu();
|
||||
const GrGLInterface* gl = gpuGL->glInterface();
|
||||
GR_GL_CALL(gl, DeleteRenderbuffers(1, &fRenderbufferID));
|
||||
fRenderbufferID = 0;
|
||||
}
|
||||
INHERITED::onRelease();
|
||||
}
|
||||
|
||||
void GrGLStencilBuffer::onAbandon() {
|
||||
fRenderbufferID = 0;
|
||||
INHERITED::onAbandon();
|
||||
}
|
||||
|
||||
|
|
@ -32,39 +32,20 @@ public:
|
|||
, fRenderbufferID(rbid) {
|
||||
}
|
||||
|
||||
virtual ~GrGLStencilBuffer() {
|
||||
this->release();
|
||||
}
|
||||
virtual ~GrGLStencilBuffer();
|
||||
|
||||
virtual size_t sizeInBytes() const {
|
||||
uint64_t size = this->width();
|
||||
size *= this->height();
|
||||
size *= fFormat.fTotalBits;
|
||||
size *= GrMax(1,this->numSamples());
|
||||
return (size_t)(size / 8);
|
||||
}
|
||||
virtual size_t sizeInBytes() const;
|
||||
|
||||
GrGLuint renderbufferID() const {
|
||||
return fRenderbufferID;
|
||||
}
|
||||
|
||||
const Format& format() const {
|
||||
return fFormat;
|
||||
}
|
||||
const Format& format() const { return fFormat; }
|
||||
|
||||
protected:
|
||||
virtual void onRelease() {
|
||||
if (0 != fRenderbufferID) {
|
||||
GR_GL(DeleteRenderbuffers(1, &fRenderbufferID));
|
||||
fRenderbufferID = 0;
|
||||
}
|
||||
INHERITED::onRelease();
|
||||
}
|
||||
virtual void onRelease();
|
||||
|
||||
virtual void onAbandon() {
|
||||
fRenderbufferID = 0;
|
||||
INHERITED::onAbandon();
|
||||
}
|
||||
virtual void onAbandon();
|
||||
|
||||
private:
|
||||
Format fFormat;
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
|
||||
#define GPUGL static_cast<GrGpuGL*>(getGpu())
|
||||
|
||||
const GrGLenum* GrGLTexture::WrapMode2GLWrap() {
|
||||
#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
|
||||
|
||||
const GrGLenum* GrGLTexture::WrapMode2GLWrap(GrGLBinding binding) {
|
||||
static const GrGLenum mirrorRepeatModes[] = {
|
||||
GR_GL_CLAMP_TO_EDGE,
|
||||
GR_GL_REPEAT,
|
||||
|
@ -26,7 +28,7 @@ const GrGLenum* GrGLTexture::WrapMode2GLWrap() {
|
|||
GR_GL_REPEAT
|
||||
};
|
||||
|
||||
if (GR_GL_SUPPORT_ES1 && !GR_GL_SUPPORT_ES2) {
|
||||
if (kES1_GrGLBinding == binding) {
|
||||
return repeatModes; // GL_MIRRORED_REPEAT not supported.
|
||||
} else {
|
||||
return mirrorRepeatModes;
|
||||
|
@ -41,7 +43,8 @@ void GrGLTexture::init(GrGpuGL* gpu,
|
|||
GrAssert(0 != textureDesc.fTextureID);
|
||||
|
||||
fTexParams = initialTexParams;
|
||||
fTexIDObj = new GrGLTexID(textureDesc.fTextureID,
|
||||
fTexIDObj = new GrGLTexID(GPUGL->glInterface(),
|
||||
textureDesc.fTextureID,
|
||||
textureDesc.fOwnsID);
|
||||
fUploadFormat = textureDesc.fUploadFormat;
|
||||
fUploadByteCount = textureDesc.fUploadByteCount;
|
||||
|
@ -132,10 +135,10 @@ void GrGLTexture::uploadTextureData(int x,
|
|||
*/
|
||||
bool restoreGLRowLength = false;
|
||||
bool flipY = kBottomUp_Orientation == fOrientation;
|
||||
if (GR_GL_SUPPORT_DESKTOP && !flipY) {
|
||||
if (kDesktop_GrGLBinding == GPUGL->glBinding() && !flipY) {
|
||||
// can't use this for flipping, only non-neg values allowed. :(
|
||||
if (srcData && rowBytes) {
|
||||
GR_GL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH,
|
||||
GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH,
|
||||
rowBytes / fUploadByteCount));
|
||||
restoreGLRowLength = true;
|
||||
}
|
||||
|
@ -166,14 +169,14 @@ void GrGLTexture::uploadTextureData(int x,
|
|||
if (flipY) {
|
||||
y = this->height() - (y + height);
|
||||
}
|
||||
GR_GL(BindTexture(GR_GL_TEXTURE_2D, fTexIDObj->id()));
|
||||
GR_GL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, fUploadByteCount));
|
||||
GR_GL(TexSubImage2D(GR_GL_TEXTURE_2D, 0, x, y, width, height,
|
||||
fUploadFormat, fUploadType, srcData));
|
||||
GL_CALL(BindTexture(GR_GL_TEXTURE_2D, fTexIDObj->id()));
|
||||
GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, fUploadByteCount));
|
||||
GL_CALL(TexSubImage2D(GR_GL_TEXTURE_2D, 0, x, y, width, height,
|
||||
fUploadFormat, fUploadType, srcData));
|
||||
|
||||
if (GR_GL_SUPPORT_DESKTOP) {
|
||||
if (kDesktop_GrGLBinding == GPUGL->glBinding()) {
|
||||
if (restoreGLRowLength) {
|
||||
GR_GL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
|
||||
GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,15 @@
|
|||
class GrGLTexID : public GrRefCnt {
|
||||
|
||||
public:
|
||||
GrGLTexID(GrGLuint texID, bool ownsID) : fTexID(texID), fOwnsID(ownsID) {}
|
||||
GrGLTexID(const GrGLInterface* gl, GrGLuint texID, bool ownsID)
|
||||
: fGL(gl)
|
||||
, fTexID(texID)
|
||||
, fOwnsID(ownsID) {
|
||||
}
|
||||
|
||||
virtual ~GrGLTexID() {
|
||||
if (0 != fTexID && fOwnsID) {
|
||||
GR_GL(DeleteTextures(1, &fTexID));
|
||||
GR_GL_CALL(fGL, DeleteTextures(1, &fTexID));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,8 +36,9 @@ public:
|
|||
GrGLuint id() const { return fTexID; }
|
||||
|
||||
private:
|
||||
GrGLuint fTexID;
|
||||
bool fOwnsID;
|
||||
const GrGLInterface* fGL;
|
||||
GrGLuint fTexID;
|
||||
bool fOwnsID;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -119,7 +124,7 @@ public:
|
|||
// and it is up to the GrGpuGL derivative to handle y-mirroing.
|
||||
Orientation orientation() const { return fOrientation; }
|
||||
|
||||
static const GrGLenum* WrapMode2GLWrap();
|
||||
static const GrGLenum* WrapMode2GLWrap(GrGLBinding binding);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -10,14 +10,16 @@
|
|||
#include "GrGLConfig.h"
|
||||
#include "GrGLInterface.h"
|
||||
|
||||
void GrGLClearErr() {
|
||||
while (GR_GL_NO_ERROR != GrGLGetGLInterface()->fGetError()) {}
|
||||
void GrGLClearErr(const GrGLInterface* gl) {
|
||||
while (GR_GL_NO_ERROR != gl->fGetError()) {}
|
||||
}
|
||||
|
||||
void GrGLCheckErr(const char* location, const char* call) {
|
||||
uint32_t err = GrGLGetGLInterface()->fGetError();
|
||||
void GrGLCheckErr(const GrGLInterface* gl,
|
||||
const char* location,
|
||||
const char* call) {
|
||||
uint32_t err = GR_GL_GET_ERROR(gl);
|
||||
if (GR_GL_NO_ERROR != err) {
|
||||
GrPrintf("---- glGetError %x", err);
|
||||
GrPrintf("---- glGetError %x", GR_GL_GET_ERROR(gl));
|
||||
if (NULL != location) {
|
||||
GrPrintf(" at\n\t%s", location);
|
||||
}
|
||||
|
@ -28,9 +30,9 @@ void GrGLCheckErr(const char* location, const char* call) {
|
|||
}
|
||||
}
|
||||
|
||||
void GrGLRestoreResetRowLength() {
|
||||
if (GR_GL_SUPPORT_DESKTOP) {
|
||||
GR_GL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
|
||||
void GrGLResetRowLength(const GrGLInterface* gl) {
|
||||
if (gl->supportsDesktop()) {
|
||||
GR_GL_CALL(gl, PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#define GPUGL static_cast<GrGpuGL*>(getGpu())
|
||||
|
||||
#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
|
||||
|
||||
GrGLVertexBuffer::GrGLVertexBuffer(GrGpuGL* gpu,
|
||||
GrGLuint id,
|
||||
size_t sizeInBytes,
|
||||
|
@ -26,7 +28,7 @@ void GrGLVertexBuffer::onRelease() {
|
|||
// make sure we've not been abandoned
|
||||
if (fBufferID) {
|
||||
GPUGL->notifyVertexBufferDelete(this);
|
||||
GR_GL(DeleteBuffers(1, &fBufferID));
|
||||
GL_CALL(DeleteBuffers(1, &fBufferID));
|
||||
fBufferID = 0;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +39,7 @@ void GrGLVertexBuffer::onAbandon() {
|
|||
}
|
||||
|
||||
void GrGLVertexBuffer::bind() const {
|
||||
GR_GL(BindBuffer(GR_GL_ARRAY_BUFFER, fBufferID));
|
||||
GL_CALL(BindBuffer(GR_GL_ARRAY_BUFFER, fBufferID));
|
||||
GPUGL->notifyVertexBufferBind(this);
|
||||
}
|
||||
|
||||
|
@ -51,9 +53,10 @@ void* GrGLVertexBuffer::lock() {
|
|||
if (GPUGL->supportsBufferLocking()) {
|
||||
this->bind();
|
||||
// Let driver know it can discard the old data
|
||||
GR_GL(BufferData(GR_GL_ARRAY_BUFFER, this->sizeInBytes(), NULL,
|
||||
this->dynamic() ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW));
|
||||
fLockPtr = GR_GL(MapBuffer(GR_GL_ARRAY_BUFFER, GR_GL_WRITE_ONLY));
|
||||
GL_CALL(BufferData(GR_GL_ARRAY_BUFFER, this->sizeInBytes(), NULL,
|
||||
this->dynamic() ? GR_GL_DYNAMIC_DRAW :
|
||||
GR_GL_STATIC_DRAW));
|
||||
fLockPtr = GL_CALL(MapBuffer(GR_GL_ARRAY_BUFFER, GR_GL_WRITE_ONLY));
|
||||
return fLockPtr;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -70,7 +73,7 @@ void GrGLVertexBuffer::unlock() {
|
|||
GrAssert(GPUGL->supportsBufferLocking());
|
||||
|
||||
this->bind();
|
||||
GR_GL(UnmapBuffer(GR_GL_ARRAY_BUFFER));
|
||||
GL_CALL(UnmapBuffer(GR_GL_ARRAY_BUFFER));
|
||||
fLockPtr = NULL;
|
||||
}
|
||||
|
||||
|
@ -80,7 +83,8 @@ bool GrGLVertexBuffer::isLocked() const {
|
|||
if (this->isValid() && GPUGL->supportsBufferLocking()) {
|
||||
GrGLint mapped;
|
||||
this->bind();
|
||||
GR_GL(GetBufferParameteriv(GR_GL_ARRAY_BUFFER, GR_GL_BUFFER_MAPPED, &mapped));
|
||||
GL_CALL(GetBufferParameteriv(GR_GL_ARRAY_BUFFER,
|
||||
GR_GL_BUFFER_MAPPED, &mapped));
|
||||
GrAssert(!!mapped == !!fLockPtr);
|
||||
}
|
||||
#endif
|
||||
|
@ -96,12 +100,13 @@ bool GrGLVertexBuffer::updateData(const void* src, size_t srcSizeInBytes) {
|
|||
this->bind();
|
||||
GrGLenum usage = dynamic() ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW;
|
||||
if (this->sizeInBytes() == srcSizeInBytes) {
|
||||
GR_GL(BufferData(GR_GL_ARRAY_BUFFER, srcSizeInBytes, src, usage));
|
||||
GL_CALL(BufferData(GR_GL_ARRAY_BUFFER, srcSizeInBytes, src, usage));
|
||||
} else {
|
||||
#if GR_GL_USE_BUFFER_DATA_NULL_HINT
|
||||
GR_GL(BufferData(GR_GL_ARRAY_BUFFER, this->sizeInBytes(), NULL, usage));
|
||||
GL_CALL(BufferData(GR_GL_ARRAY_BUFFER,
|
||||
this->sizeInBytes(), NULL, usage));
|
||||
#endif
|
||||
GR_GL(BufferSubData(GR_GL_ARRAY_BUFFER, 0, srcSizeInBytes, src));
|
||||
GL_CALL(BufferSubData(GR_GL_ARRAY_BUFFER, 0, srcSizeInBytes, src));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -115,7 +120,7 @@ bool GrGLVertexBuffer::updateSubData(const void* src,
|
|||
return false;
|
||||
}
|
||||
this->bind();
|
||||
GR_GL(BufferSubData(GR_GL_ARRAY_BUFFER, offset, srcSizeInBytes, src));
|
||||
GL_CALL(BufferSubData(GR_GL_ARRAY_BUFFER, offset, srcSizeInBytes, src));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,18 +22,21 @@
|
|||
|
||||
GrGpu* GrGpu::Create(GrEngine engine, GrPlatform3DContext context3D) {
|
||||
|
||||
const GrGLInterface* glInterface;
|
||||
|
||||
if (kOpenGL_Shaders_GrEngine == engine ||
|
||||
kOpenGL_Fixed_GrEngine == engine) {
|
||||
// If no GL bindings have been installed, fall-back to calling the
|
||||
// GL functions that have been linked with the executable.
|
||||
if (!GrGLGetGLInterface()) {
|
||||
GrGLSetDefaultGLInterface();
|
||||
// If there is no platform-default then just fail.
|
||||
if (!GrGLGetGLInterface()) {
|
||||
return NULL;
|
||||
}
|
||||
glInterface = reinterpret_cast<const GrGLInterface*>(context3D);
|
||||
if (NULL == glInterface) {
|
||||
glInterface = GrGLGetDefaultGLInterface();
|
||||
}
|
||||
if (!GrGLGetGLInterface()->validate(engine)) {
|
||||
if (NULL == glInterface) {
|
||||
#if GR_DEBUG
|
||||
GrPrintf("No GL interface provided!");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
if (!glInterface->validate(engine)) {
|
||||
#if GR_DEBUG
|
||||
GrPrintf("Failed GL interface validation!");
|
||||
#endif
|
||||
|
@ -45,24 +48,12 @@ GrGpu* GrGpu::Create(GrEngine engine, GrPlatform3DContext context3D) {
|
|||
|
||||
switch (engine) {
|
||||
case kOpenGL_Shaders_GrEngine:
|
||||
GrAssert(NULL == (void*)context3D);
|
||||
{
|
||||
#if 0 // old code path, will be removed soon
|
||||
gpu = new GrGpuGLShaders2;
|
||||
#else
|
||||
gpu = new GrGpuGLShaders;
|
||||
#endif
|
||||
}
|
||||
GrAssert(NULL != glInterface);
|
||||
gpu = new GrGpuGLShaders(glInterface);
|
||||
break;
|
||||
case kOpenGL_Fixed_GrEngine:
|
||||
GrAssert(NULL == (void*)context3D);
|
||||
gpu = new GrGpuGLFixed;
|
||||
break;
|
||||
case kDirect3D9_GrEngine:
|
||||
GrAssert(NULL != (void*)context3D);
|
||||
#if GR_WIN32_BUILD
|
||||
// gpu = new GrGpuD3D9((IDirect3DDevice9*)context3D);
|
||||
#endif
|
||||
GrAssert(NULL != glInterface);
|
||||
gpu = new GrGpuGLFixed(glInterface);
|
||||
break;
|
||||
default:
|
||||
GrAssert(!"unknown engine");
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -24,8 +24,11 @@ class GrGpuGL : public GrGpu {
|
|||
public:
|
||||
virtual ~GrGpuGL();
|
||||
|
||||
const GrGLInterface* glInterface() const { return fGL; }
|
||||
GrGLBinding glBinding() const { return fGLBinding; }
|
||||
|
||||
protected:
|
||||
GrGpuGL();
|
||||
GrGpuGL(const GrGLInterface* glInterface, GrGLBinding glBinding);
|
||||
|
||||
struct {
|
||||
size_t fVertexOffset;
|
||||
|
@ -225,6 +228,9 @@ private:
|
|||
// from our loop that tries stencil formats and calls check fb status.
|
||||
int fLastSuccessfulStencilFmtIdx;
|
||||
|
||||
const GrGLInterface* fGL;
|
||||
GrGLBinding fGLBinding;
|
||||
|
||||
typedef GrGpu INHERITED;
|
||||
};
|
||||
|
||||
|
|
|
@ -46,9 +46,22 @@ static const GrGLenum gMatrixMode2Enum[] = {
|
|||
GR_GL_MODELVIEW, GR_GL_TEXTURE
|
||||
};
|
||||
|
||||
#define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGpuGLFixed::GrGpuGLFixed() {
|
||||
namespace {
|
||||
GrGLBinding get_binding_in_use(const GrGLInterface* gl) {
|
||||
if (gl->supportsDesktop()) {
|
||||
return kDesktop_GrGLBinding;
|
||||
} else {
|
||||
GrAssert(gl->supportsES1());
|
||||
return kES1_GrGLBinding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GrGpuGLFixed::GrGpuGLFixed(const GrGLInterface* gl)
|
||||
: GrGpuGL(gl, get_binding_in_use(gl)) {
|
||||
f4X4DownsampleFilterSupport = false;
|
||||
fDualSourceBlendingSupport = false;
|
||||
}
|
||||
|
@ -59,22 +72,42 @@ GrGpuGLFixed::~GrGpuGLFixed() {
|
|||
void GrGpuGLFixed::resetContext() {
|
||||
INHERITED::resetContext();
|
||||
|
||||
GR_GL(Disable(GR_GL_TEXTURE_2D));
|
||||
GL_CALL(Disable(GR_GL_TEXTURE_2D));
|
||||
|
||||
for (int s = 0; s < kNumStages; ++s) {
|
||||
setTextureUnit(s);
|
||||
GR_GL(EnableClientState(GR_GL_VERTEX_ARRAY));
|
||||
GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_TEXTURE_ENV_MODE, GR_GL_COMBINE));
|
||||
GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_COMBINE_RGB, GR_GL_MODULATE));
|
||||
GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC0_RGB, GR_GL_TEXTURE0+s));
|
||||
GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC1_RGB, GR_GL_PREVIOUS));
|
||||
GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_OPERAND1_RGB, GR_GL_SRC_COLOR));
|
||||
GL_CALL(EnableClientState(GR_GL_VERTEX_ARRAY));
|
||||
GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV,
|
||||
GR_GL_TEXTURE_ENV_MODE,
|
||||
GR_GL_COMBINE));
|
||||
GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV,
|
||||
GR_GL_COMBINE_RGB,
|
||||
GR_GL_MODULATE));
|
||||
GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV,
|
||||
GR_GL_SRC0_RGB,
|
||||
GR_GL_TEXTURE0+s));
|
||||
GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV,
|
||||
GR_GL_SRC1_RGB,
|
||||
GR_GL_PREVIOUS));
|
||||
GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV,
|
||||
GR_GL_OPERAND1_RGB,
|
||||
GR_GL_SRC_COLOR));
|
||||
|
||||
GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_COMBINE_ALPHA, GR_GL_MODULATE));
|
||||
GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC0_ALPHA, GR_GL_TEXTURE0+s));
|
||||
GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_OPERAND0_ALPHA, GR_GL_SRC_ALPHA));
|
||||
GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC1_ALPHA, GR_GL_PREVIOUS));
|
||||
GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_OPERAND1_ALPHA, GR_GL_SRC_ALPHA));
|
||||
GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV,
|
||||
GR_GL_COMBINE_ALPHA,
|
||||
GR_GL_MODULATE));
|
||||
GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV,
|
||||
GR_GL_SRC0_ALPHA,
|
||||
GR_GL_TEXTURE0+s));
|
||||
GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV,
|
||||
GR_GL_OPERAND0_ALPHA,
|
||||
GR_GL_SRC_ALPHA));
|
||||
GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV,
|
||||
GR_GL_SRC1_ALPHA,
|
||||
GR_GL_PREVIOUS));
|
||||
GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV,
|
||||
GR_GL_OPERAND1_ALPHA,
|
||||
GR_GL_SRC_ALPHA));
|
||||
|
||||
// color oprand0 changes between GL_SRC_COLR and GL_SRC_ALPHA depending
|
||||
// upon whether we have a (premultiplied) RGBA texture or just an ALPHA
|
||||
|
@ -85,14 +118,14 @@ void GrGpuGLFixed::resetContext() {
|
|||
|
||||
fHWGeometryState.fVertexLayout = 0;
|
||||
fHWGeometryState.fVertexOffset = ~0;
|
||||
GR_GL(EnableClientState(GR_GL_VERTEX_ARRAY));
|
||||
GR_GL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY));
|
||||
GR_GL(ShadeModel(GR_GL_FLAT));
|
||||
GR_GL(DisableClientState(GR_GL_COLOR_ARRAY));
|
||||
GL_CALL(EnableClientState(GR_GL_VERTEX_ARRAY));
|
||||
GL_CALL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY));
|
||||
GL_CALL(ShadeModel(GR_GL_FLAT));
|
||||
GL_CALL(DisableClientState(GR_GL_COLOR_ARRAY));
|
||||
|
||||
GR_GL(PointSize(1.f));
|
||||
GL_CALL(PointSize(1.f));
|
||||
|
||||
GrGLClearErr();
|
||||
GrGLClearErr(this->glInterface());
|
||||
fTextVerts = false;
|
||||
|
||||
fBaseVertex = 0xffffffff;
|
||||
|
@ -113,8 +146,8 @@ void GrGpuGLFixed::flushProjectionMatrix() {
|
|||
mat[12] = -1.f;
|
||||
mat[13] = 1.f;
|
||||
|
||||
GR_GL(MatrixMode(GR_GL_PROJECTION));
|
||||
GR_GL(LoadMatrixf(mat));
|
||||
GL_CALL(MatrixMode(GR_GL_PROJECTION));
|
||||
GL_CALL(LoadMatrixf(mat));
|
||||
}
|
||||
|
||||
bool GrGpuGLFixed::flushGraphicsState(GrPrimitiveType type) {
|
||||
|
@ -129,7 +162,7 @@ bool GrGpuGLFixed::flushGraphicsState(GrPrimitiveType type) {
|
|||
}
|
||||
}
|
||||
|
||||
if (GR_GL_SUPPORT_ES1) {
|
||||
if (kES1_GrGLBinding == this->glBinding()) {
|
||||
if (BlendCoeffReferencesConstant(fCurrDrawState.fSrcBlend) ||
|
||||
BlendCoeffReferencesConstant(fCurrDrawState.fDstBlend)) {
|
||||
unimpl("ES1 doesn't support blend constant");
|
||||
|
@ -152,9 +185,9 @@ bool GrGpuGLFixed::flushGraphicsState(GrPrimitiveType type) {
|
|||
if (usingTextures[s] != wasUsingTexture) {
|
||||
setTextureUnit(s);
|
||||
if (usingTextures[s]) {
|
||||
GR_GL(Enable(GR_GL_TEXTURE_2D));
|
||||
GL_CALL(Enable(GR_GL_TEXTURE_2D));
|
||||
} else {
|
||||
GR_GL(Disable(GR_GL_TEXTURE_2D));
|
||||
GL_CALL(Disable(GR_GL_TEXTURE_2D));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,17 +198,17 @@ bool GrGpuGLFixed::flushGraphicsState(GrPrimitiveType type) {
|
|||
|
||||
if (vertColor != prevVertColor) {
|
||||
if (vertColor) {
|
||||
GR_GL(ShadeModel(GR_GL_SMOOTH));
|
||||
GL_CALL(ShadeModel(GR_GL_SMOOTH));
|
||||
// invalidate the immediate mode color
|
||||
fHWDrawState.fColor = GrColor_ILLEGAL;
|
||||
} else {
|
||||
GR_GL(ShadeModel(GR_GL_FLAT));
|
||||
GL_CALL(ShadeModel(GR_GL_FLAT));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!vertColor && fHWDrawState.fColor != fCurrDrawState.fColor) {
|
||||
GR_GL(Color4ub(GrColorUnpackR(fCurrDrawState.fColor),
|
||||
GL_CALL(Color4ub(GrColorUnpackR(fCurrDrawState.fColor),
|
||||
GrColorUnpackG(fCurrDrawState.fColor),
|
||||
GrColorUnpackB(fCurrDrawState.fColor),
|
||||
GrColorUnpackA(fCurrDrawState.fColor)));
|
||||
|
@ -193,7 +226,7 @@ bool GrGpuGLFixed::flushGraphicsState(GrPrimitiveType type) {
|
|||
kColor_TextureEnvRGBOperand;
|
||||
if (fHWRGBOperand0[s] != nextRGBOperand0) {
|
||||
setTextureUnit(s);
|
||||
GR_GL(TexEnvi(GR_GL_TEXTURE_ENV,
|
||||
GL_CALL(TexEnvi(GR_GL_TEXTURE_ENV,
|
||||
GR_GL_OPERAND0_RGB,
|
||||
(nextRGBOperand0==kAlpha_TextureEnvRGBOperand) ?
|
||||
GR_GL_SRC_ALPHA :
|
||||
|
@ -212,8 +245,8 @@ bool GrGpuGLFixed::flushGraphicsState(GrPrimitiveType type) {
|
|||
GrGpuMatrix glm;
|
||||
glm.set(texMat);
|
||||
setTextureUnit(s);
|
||||
GR_GL(MatrixMode(GR_GL_TEXTURE));
|
||||
GR_GL(LoadMatrixf(glm.fMat));
|
||||
GL_CALL(MatrixMode(GR_GL_TEXTURE));
|
||||
GL_CALL(LoadMatrixf(glm.fMat));
|
||||
recordHWSamplerMatrix(s, getSamplerMatrix(s));
|
||||
}
|
||||
} else {
|
||||
|
@ -226,8 +259,8 @@ bool GrGpuGLFixed::flushGraphicsState(GrPrimitiveType type) {
|
|||
if (fHWDrawState.fViewMatrix != fCurrDrawState.fViewMatrix) {
|
||||
GrGpuMatrix glm;
|
||||
glm.set(fCurrDrawState.fViewMatrix);
|
||||
GR_GL(MatrixMode(GR_GL_MODELVIEW));
|
||||
GR_GL(LoadMatrixf(glm.fMat));
|
||||
GL_CALL(MatrixMode(GR_GL_MODELVIEW));
|
||||
GL_CALL(LoadMatrixf(glm.fMat));
|
||||
fHWDrawState.fViewMatrix =
|
||||
fCurrDrawState.fViewMatrix;
|
||||
}
|
||||
|
@ -285,7 +318,8 @@ void GrGpuGLFixed::setupGeometry(int* startVertex,
|
|||
this->getGeomSrc().fVertexLayout)));
|
||||
|
||||
if (posAndTexChange) {
|
||||
GR_GL(VertexPointer(2, scalarType, newStride, (GrGLvoid*)vertexOffset));
|
||||
GL_CALL(VertexPointer(2, scalarType,
|
||||
newStride, (GrGLvoid*)vertexOffset));
|
||||
fHWGeometryState.fVertexOffset = vertexOffset;
|
||||
}
|
||||
|
||||
|
@ -293,32 +327,37 @@ void GrGpuGLFixed::setupGeometry(int* startVertex,
|
|||
// need to enable array if tex coord offset is 0
|
||||
// (using positions as coords)
|
||||
if (newTexCoordOffsets[s] >= 0) {
|
||||
GrGLvoid* texCoordOffset = (GrGLvoid*)(vertexOffset + newTexCoordOffsets[s]);
|
||||
GrGLvoid* texCoordOffset = (GrGLvoid*)(vertexOffset +
|
||||
newTexCoordOffsets[s]);
|
||||
if (oldTexCoordOffsets[s] < 0) {
|
||||
GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
|
||||
GR_GL(EnableClientState(GR_GL_TEXTURE_COORD_ARRAY));
|
||||
GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordOffset));
|
||||
GL_CALL(ClientActiveTexture(GR_GL_TEXTURE0+s));
|
||||
GL_CALL(EnableClientState(GR_GL_TEXTURE_COORD_ARRAY));
|
||||
GL_CALL(TexCoordPointer(2, scalarType,
|
||||
newStride, texCoordOffset));
|
||||
} else if (posAndTexChange ||
|
||||
newTexCoordOffsets[s] != oldTexCoordOffsets[s]) {
|
||||
GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
|
||||
GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordOffset));
|
||||
GL_CALL(ClientActiveTexture(GR_GL_TEXTURE0+s));
|
||||
GL_CALL(TexCoordPointer(2, scalarType,
|
||||
newStride, texCoordOffset));
|
||||
}
|
||||
} else if (oldTexCoordOffsets[s] >= 0) {
|
||||
GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
|
||||
GR_GL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY));
|
||||
GL_CALL(ClientActiveTexture(GR_GL_TEXTURE0+s));
|
||||
GL_CALL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY));
|
||||
}
|
||||
}
|
||||
|
||||
if (newColorOffset > 0) {
|
||||
GrGLvoid* colorOffset = (GrGLvoid*)(vertexOffset + newColorOffset);
|
||||
if (oldColorOffset <= 0) {
|
||||
GR_GL(EnableClientState(GR_GL_COLOR_ARRAY));
|
||||
GR_GL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, newStride, colorOffset));
|
||||
GL_CALL(EnableClientState(GR_GL_COLOR_ARRAY));
|
||||
GL_CALL(ColorPointer(4, GR_GL_UNSIGNED_BYTE,
|
||||
newStride, colorOffset));
|
||||
} else if (allOffsetsChange || newColorOffset != oldColorOffset) {
|
||||
GR_GL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, newStride, colorOffset));
|
||||
GL_CALL(ColorPointer(4, GR_GL_UNSIGNED_BYTE,
|
||||
newStride, colorOffset));
|
||||
}
|
||||
} else if (oldColorOffset > 0) {
|
||||
GR_GL(DisableClientState(GR_GL_COLOR_ARRAY));
|
||||
GL_CALL(DisableClientState(GR_GL_COLOR_ARRAY));
|
||||
}
|
||||
|
||||
fHWGeometryState.fVertexLayout = this->getGeomSrc().fVertexLayout;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// Fixed Pipeline OpenGL or OpenGL ES 1.x
|
||||
class GrGpuGLFixed : public GrGpuGL {
|
||||
public:
|
||||
GrGpuGLFixed();
|
||||
GrGpuGLFixed(const GrGLInterface* glInterface);
|
||||
virtual ~GrGpuGLFixed();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -51,19 +51,20 @@ private:
|
|||
enum {
|
||||
kMaxEntries = 32
|
||||
};
|
||||
Entry fEntries[kMaxEntries];
|
||||
int fCount;
|
||||
unsigned int fCurrLRUStamp;
|
||||
|
||||
Entry fEntries[kMaxEntries];
|
||||
int fCount;
|
||||
unsigned int fCurrLRUStamp;
|
||||
const GrGLInterface* fGL;
|
||||
public:
|
||||
ProgramCache()
|
||||
ProgramCache(const GrGLInterface* gl)
|
||||
: fCount(0)
|
||||
, fCurrLRUStamp(0) {
|
||||
, fCurrLRUStamp(0)
|
||||
, fGL(gl) {
|
||||
}
|
||||
|
||||
~ProgramCache() {
|
||||
for (int i = 0; i < fCount; ++i) {
|
||||
GrGpuGLShaders::DeleteProgram(&fEntries[i].fProgramData);
|
||||
GrGpuGLShaders::DeleteProgram(fGL, &fEntries[i].fProgramData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +85,7 @@ public:
|
|||
|
||||
Entry* entry = fHashCache.find(newEntry.fKey);
|
||||
if (NULL == entry) {
|
||||
if (!desc.genProgram(&newEntry.fProgramData)) {
|
||||
if (!desc.genProgram(fGL, &newEntry.fProgramData)) {
|
||||
return NULL;
|
||||
}
|
||||
if (fCount < kMaxEntries) {
|
||||
|
@ -99,7 +100,7 @@ public:
|
|||
}
|
||||
}
|
||||
fHashCache.remove(entry->fKey, entry);
|
||||
GrGpuGLShaders::DeleteProgram(&entry->fProgramData);
|
||||
GrGpuGLShaders::DeleteProgram(fGL, &entry->fProgramData);
|
||||
}
|
||||
entry->copyAndTakeOwnership(newEntry);
|
||||
fHashCache.insert(entry->fKey, entry);
|
||||
|
@ -122,15 +123,18 @@ void GrGpuGLShaders::abandonResources(){
|
|||
fProgramCache->abandon();
|
||||
}
|
||||
|
||||
void GrGpuGLShaders::DeleteProgram(CachedData* programData) {
|
||||
GR_GL(DeleteShader(programData->fVShaderID));
|
||||
GR_GL(DeleteShader(programData->fFShaderID));
|
||||
GR_GL(DeleteProgram(programData->fProgramID));
|
||||
void GrGpuGLShaders::DeleteProgram(const GrGLInterface* gl,
|
||||
CachedData* programData) {
|
||||
GR_GL_CALL(gl, DeleteShader(programData->fVShaderID));
|
||||
GR_GL_CALL(gl, DeleteShader(programData->fFShaderID));
|
||||
GR_GL_CALL(gl, DeleteProgram(programData->fProgramID));
|
||||
GR_DEBUGCODE(memset(programData, 0, sizeof(*programData));)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
|
||||
|
||||
namespace {
|
||||
template <typename T>
|
||||
T random_val(GrRandom* r, T count) {
|
||||
|
@ -225,25 +229,37 @@ bool GrGpuGLShaders::programUnitTest() {
|
|||
stage.fKernelWidth = 4 * random.nextF() + 2;
|
||||
}
|
||||
CachedData cachedData;
|
||||
if (!program.genProgram(&cachedData)) {
|
||||
if (!program.genProgram(this->glInterface(), &cachedData)) {
|
||||
return false;
|
||||
}
|
||||
DeleteProgram(&cachedData);
|
||||
DeleteProgram(this->glInterface(), &cachedData);
|
||||
bool again = false;
|
||||
if (again) {
|
||||
program.genProgram(&cachedData);
|
||||
DeleteProgram(&cachedData);
|
||||
program.genProgram(this->glInterface(), &cachedData);
|
||||
DeleteProgram(this->glInterface(), &cachedData);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
GrGpuGLShaders::GrGpuGLShaders() {
|
||||
namespace {
|
||||
GrGLBinding get_binding_in_use(const GrGLInterface* gl) {
|
||||
if (gl->supportsDesktop()) {
|
||||
return kDesktop_GrGLBinding;
|
||||
} else {
|
||||
GrAssert(gl->supportsES2());
|
||||
return kES2_GrGLBinding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GrGpuGLShaders::GrGpuGLShaders(const GrGLInterface* gl)
|
||||
: GrGpuGL(gl, get_binding_in_use(gl)) {
|
||||
|
||||
resetContext();
|
||||
|
||||
f4X4DownsampleFilterSupport = true;
|
||||
if (GR_GL_SUPPORT_DESKTOP) {
|
||||
if (kDesktop_GrGLBinding == this->glBinding()) {
|
||||
fDualSourceBlendingSupport =
|
||||
fGLVersion >= 3.3f ||
|
||||
this->hasExtension("GL_ARB_blend_func_extended");
|
||||
|
@ -252,7 +268,7 @@ GrGpuGLShaders::GrGpuGLShaders() {
|
|||
}
|
||||
|
||||
fProgramData = NULL;
|
||||
fProgramCache = new ProgramCache();
|
||||
fProgramCache = new ProgramCache(gl);
|
||||
|
||||
#if 0
|
||||
this->programUnitTest();
|
||||
|
@ -289,11 +305,11 @@ void GrGpuGLShaders::resetContext() {
|
|||
|
||||
fHWGeometryState.fVertexLayout = 0;
|
||||
fHWGeometryState.fVertexOffset = ~0;
|
||||
GR_GL(DisableVertexAttribArray(GrGLProgram::ColorAttributeIdx()));
|
||||
GL_CALL(DisableVertexAttribArray(GrGLProgram::ColorAttributeIdx()));
|
||||
for (int t = 0; t < kMaxTexCoords; ++t) {
|
||||
GR_GL(DisableVertexAttribArray(GrGLProgram::TexCoordAttributeIdx(t)));
|
||||
GL_CALL(DisableVertexAttribArray(GrGLProgram::TexCoordAttributeIdx(t)));
|
||||
}
|
||||
GR_GL(EnableVertexAttribArray(GrGLProgram::PositionAttributeIdx()));
|
||||
GL_CALL(EnableVertexAttribArray(GrGLProgram::PositionAttributeIdx()));
|
||||
|
||||
fHWProgramID = 0;
|
||||
}
|
||||
|
@ -324,14 +340,14 @@ void GrGpuGLShaders::flushViewMatrix() {
|
|||
if (GrGLProgram::kSetAsAttribute ==
|
||||
fProgramData->fUniLocations.fViewMatrixUni) {
|
||||
int baseIdx = GrGLProgram::ViewMatrixAttributeIdx();
|
||||
GR_GL(VertexAttrib4fv(baseIdx + 0, mt+0));
|
||||
GR_GL(VertexAttrib4fv(baseIdx + 1, mt+3));
|
||||
GR_GL(VertexAttrib4fv(baseIdx + 2, mt+6));
|
||||
GL_CALL(VertexAttrib4fv(baseIdx + 0, mt+0));
|
||||
GL_CALL(VertexAttrib4fv(baseIdx + 1, mt+3));
|
||||
GL_CALL(VertexAttrib4fv(baseIdx + 2, mt+6));
|
||||
} else {
|
||||
GrAssert(GrGLProgram::kUnusedUniform !=
|
||||
fProgramData->fUniLocations.fViewMatrixUni);
|
||||
GR_GL(UniformMatrix3fv(fProgramData->fUniLocations.fViewMatrixUni,
|
||||
1, false, mt));
|
||||
GL_CALL(UniformMatrix3fv(fProgramData->fUniLocations.fViewMatrixUni,
|
||||
1, false, mt));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,7 +386,7 @@ void GrGpuGLShaders::flushTextureDomain(int s) {
|
|||
values[1] *= SkScalarToFloat(texture->contentScaleY());
|
||||
values[3] *= SkScalarToFloat(texture->contentScaleY());
|
||||
|
||||
GR_GL(Uniform4fv(uni, 1, values));
|
||||
GL_CALL(Uniform4fv(uni, 1, values));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -409,11 +425,11 @@ void GrGpuGLShaders::flushTextureMatrix(int s) {
|
|||
if (GrGLProgram::kSetAsAttribute ==
|
||||
fProgramData->fUniLocations.fStages[s].fTextureMatrixUni) {
|
||||
int baseIdx = GrGLProgram::TextureMatrixAttributeIdx(s);
|
||||
GR_GL(VertexAttrib4fv(baseIdx + 0, mt+0));
|
||||
GR_GL(VertexAttrib4fv(baseIdx + 1, mt+3));
|
||||
GR_GL(VertexAttrib4fv(baseIdx + 2, mt+6));
|
||||
GL_CALL(VertexAttrib4fv(baseIdx + 0, mt+0));
|
||||
GL_CALL(VertexAttrib4fv(baseIdx + 1, mt+3));
|
||||
GL_CALL(VertexAttrib4fv(baseIdx + 2, mt+6));
|
||||
} else {
|
||||
GR_GL(UniformMatrix3fv(uni, 1, false, mt));
|
||||
GL_CALL(UniformMatrix3fv(uni, 1, false, mt));
|
||||
}
|
||||
recordHWSamplerMatrix(s, getSamplerMatrix(s));
|
||||
}
|
||||
|
@ -447,7 +463,7 @@ void GrGpuGLShaders::flushRadial2(int s) {
|
|||
GrScalarToFloat(GrMul(radius0, radius0)),
|
||||
sampler.isRadial2PosRoot() ? 1.f : -1.f
|
||||
};
|
||||
GR_GL(Uniform1fv(uni, 6, values));
|
||||
GL_CALL(Uniform1fv(uni, 6, values));
|
||||
fProgramData->fRadial2CenterX1[s] = sampler.getRadial2CenterX1();
|
||||
fProgramData->fRadial2Radius0[s] = sampler.getRadial2Radius0();
|
||||
fProgramData->fRadial2PosRoot[s] = sampler.isRadial2PosRoot();
|
||||
|
@ -458,11 +474,12 @@ void GrGpuGLShaders::flushConvolution(int s) {
|
|||
const GrSamplerState& sampler = fCurrDrawState.fSamplerStates[s];
|
||||
int kernelUni = fProgramData->fUniLocations.fStages[s].fKernelUni;
|
||||
if (GrGLProgram::kUnusedUniform != kernelUni) {
|
||||
GR_GL(Uniform1fv(kernelUni, sampler.getKernelWidth(), sampler.getKernel()));
|
||||
GL_CALL(Uniform1fv(kernelUni, sampler.getKernelWidth(),
|
||||
sampler.getKernel()));
|
||||
}
|
||||
int imageIncrementUni = fProgramData->fUniLocations.fStages[s].fImageIncrementUni;
|
||||
if (GrGLProgram::kUnusedUniform != imageIncrementUni) {
|
||||
GR_GL(Uniform2fv(imageIncrementUni, 1, sampler.getImageIncrement()));
|
||||
GL_CALL(Uniform2fv(imageIncrementUni, 1, sampler.getImageIncrement()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -475,7 +492,7 @@ void GrGpuGLShaders::flushTexelSize(int s) {
|
|||
|
||||
float texelSize[] = {1.f / texture->allocatedWidth(),
|
||||
1.f / texture->allocatedHeight()};
|
||||
GR_GL(Uniform2fv(uni, 1, texelSize));
|
||||
GL_CALL(Uniform2fv(uni, 1, texelSize));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -493,7 +510,7 @@ void GrGpuGLShaders::flushEdgeAAData() {
|
|||
edges[i].fY = -b;
|
||||
edges[i].fZ += b * height;
|
||||
}
|
||||
GR_GL(Uniform3fv(uni, count, &edges[0].fX));
|
||||
GL_CALL(Uniform3fv(uni, count, &edges[0].fX));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,7 +535,8 @@ void GrGpuGLShaders::flushColor() {
|
|||
if (fHWDrawState.fColor != fCurrDrawState.fColor) {
|
||||
// OpenGL ES only supports the float varities of glVertexAttrib
|
||||
float c[] = GR_COLOR_TO_VEC4(fCurrDrawState.fColor);
|
||||
GR_GL(VertexAttrib4fv(GrGLProgram::ColorAttributeIdx(), c));
|
||||
GL_CALL(VertexAttrib4fv(GrGLProgram::ColorAttributeIdx(),
|
||||
c));
|
||||
fHWDrawState.fColor = fCurrDrawState.fColor;
|
||||
}
|
||||
break;
|
||||
|
@ -528,7 +546,8 @@ void GrGpuGLShaders::flushColor() {
|
|||
float c[] = GR_COLOR_TO_VEC4(fCurrDrawState.fColor);
|
||||
GrAssert(GrGLProgram::kUnusedUniform !=
|
||||
fProgramData->fUniLocations.fColorUni);
|
||||
GR_GL(Uniform4fv(fProgramData->fUniLocations.fColorUni, 1, c));
|
||||
GL_CALL(Uniform4fv(fProgramData->fUniLocations.fColorUni,
|
||||
1, c));
|
||||
fProgramData->fColor = fCurrDrawState.fColor;
|
||||
}
|
||||
break;
|
||||
|
@ -544,7 +563,7 @@ void GrGpuGLShaders::flushColor() {
|
|||
&& fProgramData->fColorFilterColor
|
||||
!= fCurrDrawState.fColorFilterColor) {
|
||||
float c[] = GR_COLOR_TO_VEC4(fCurrDrawState.fColorFilterColor);
|
||||
GR_GL(Uniform4fv(fProgramData->fUniLocations.fColorFilterUni, 1, c));
|
||||
GL_CALL(Uniform4fv(fProgramData->fUniLocations.fColorFilterUni, 1, c));
|
||||
fProgramData->fColorFilterColor = fCurrDrawState.fColorFilterColor;
|
||||
}
|
||||
}
|
||||
|
@ -571,7 +590,7 @@ bool GrGpuGLShaders::flushGraphicsState(GrPrimitiveType type) {
|
|||
}
|
||||
|
||||
if (fHWProgramID != fProgramData->fProgramID) {
|
||||
GR_GL(UseProgram(fProgramData->fProgramID));
|
||||
GL_CALL(UseProgram(fProgramData->fProgramID));
|
||||
fHWProgramID = fProgramData->fProgramID;
|
||||
}
|
||||
GrBlendCoeff srcCoeff = fCurrDrawState.fSrcBlend;
|
||||
|
@ -669,7 +688,7 @@ void GrGpuGLShaders::setupGeometry(int* startVertex,
|
|||
|
||||
if (posAndTexChange) {
|
||||
int idx = GrGLProgram::PositionAttributeIdx();
|
||||
GR_GL(VertexAttribPointer(idx, 2, scalarType, false, newStride,
|
||||
GL_CALL(VertexAttribPointer(idx, 2, scalarType, false, newStride,
|
||||
(GrGLvoid*)vertexOffset));
|
||||
fHWGeometryState.fVertexOffset = vertexOffset;
|
||||
}
|
||||
|
@ -679,16 +698,16 @@ void GrGpuGLShaders::setupGeometry(int* startVertex,
|
|||
GrGLvoid* texCoordOffset = (GrGLvoid*)(vertexOffset + newTexCoordOffsets[t]);
|
||||
int idx = GrGLProgram::TexCoordAttributeIdx(t);
|
||||
if (oldTexCoordOffsets[t] <= 0) {
|
||||
GR_GL(EnableVertexAttribArray(idx));
|
||||
GR_GL(VertexAttribPointer(idx, 2, scalarType, texCoordNorm,
|
||||
GL_CALL(EnableVertexAttribArray(idx));
|
||||
GL_CALL(VertexAttribPointer(idx, 2, scalarType, texCoordNorm,
|
||||
newStride, texCoordOffset));
|
||||
} else if (posAndTexChange ||
|
||||
newTexCoordOffsets[t] != oldTexCoordOffsets[t]) {
|
||||
GR_GL(VertexAttribPointer(idx, 2, scalarType, texCoordNorm,
|
||||
GL_CALL(VertexAttribPointer(idx, 2, scalarType, texCoordNorm,
|
||||
newStride, texCoordOffset));
|
||||
}
|
||||
} else if (oldTexCoordOffsets[t] > 0) {
|
||||
GR_GL(DisableVertexAttribArray(GrGLProgram::TexCoordAttributeIdx(t)));
|
||||
GL_CALL(DisableVertexAttribArray(GrGLProgram::TexCoordAttributeIdx(t)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -696,15 +715,15 @@ void GrGpuGLShaders::setupGeometry(int* startVertex,
|
|||
GrGLvoid* colorOffset = (int8_t*)(vertexOffset + newColorOffset);
|
||||
int idx = GrGLProgram::ColorAttributeIdx();
|
||||
if (oldColorOffset <= 0) {
|
||||
GR_GL(EnableVertexAttribArray(idx));
|
||||
GR_GL(VertexAttribPointer(idx, 4, GR_GL_UNSIGNED_BYTE,
|
||||
GL_CALL(EnableVertexAttribArray(idx));
|
||||
GL_CALL(VertexAttribPointer(idx, 4, GR_GL_UNSIGNED_BYTE,
|
||||
true, newStride, colorOffset));
|
||||
} else if (allOffsetsChange || newColorOffset != oldColorOffset) {
|
||||
GR_GL(VertexAttribPointer(idx, 4, GR_GL_UNSIGNED_BYTE,
|
||||
GL_CALL(VertexAttribPointer(idx, 4, GR_GL_UNSIGNED_BYTE,
|
||||
true, newStride, colorOffset));
|
||||
}
|
||||
} else if (oldColorOffset > 0) {
|
||||
GR_GL(DisableVertexAttribArray(GrGLProgram::ColorAttributeIdx()));
|
||||
GL_CALL(DisableVertexAttribArray(GrGLProgram::ColorAttributeIdx()));
|
||||
}
|
||||
|
||||
fHWGeometryState.fVertexLayout = this->getGeomSrc().fVertexLayout;
|
||||
|
|
|
@ -19,7 +19,7 @@ class GrGpuGLProgram;
|
|||
// Programmable OpenGL or OpenGL ES 2.0
|
||||
class GrGpuGLShaders : public GrGpuGL {
|
||||
public:
|
||||
GrGpuGLShaders();
|
||||
GrGpuGLShaders(const GrGLInterface* glInterface);
|
||||
virtual ~GrGpuGLShaders();
|
||||
|
||||
virtual void resetContext();
|
||||
|
@ -74,7 +74,8 @@ private:
|
|||
// flushes the edges for edge AA
|
||||
void flushEdgeAAData();
|
||||
|
||||
static void DeleteProgram(CachedData* programData);
|
||||
static void DeleteProgram(const GrGLInterface* gl,
|
||||
CachedData* programData);
|
||||
|
||||
void buildProgram(GrPrimitiveType type);
|
||||
|
||||
|
|
|
@ -12,134 +12,104 @@
|
|||
|
||||
#include "gl2.h"
|
||||
#include "gl2ext.h"
|
||||
/*
|
||||
#include "gpu/GLES2/gl2.h"
|
||||
#include "gpu/GLES2/gl2ext.h"
|
||||
*/
|
||||
void GrGLSetDefaultGLInterface() {
|
||||
static GrGLInterface cmd_buffer_interface = {
|
||||
kES2_GrGLBinding,
|
||||
kProbe_GrGLCapability, // fNPOTRenderTargetSupport
|
||||
kProbe_GrGLCapability, // fMinRenderTargetHeight
|
||||
kProbe_GrGLCapability, // fMinRenderTargetWidth
|
||||
glActiveTexture,
|
||||
glAttachShader,
|
||||
glBindAttribLocation,
|
||||
glBindBuffer,
|
||||
glBindTexture,
|
||||
glBlendColor,
|
||||
glBlendFunc,
|
||||
glBufferData,
|
||||
glBufferSubData,
|
||||
glClear,
|
||||
glClearColor,
|
||||
glClearStencil,
|
||||
NULL, // glClientActiveTexture
|
||||
NULL, // glColor4ub
|
||||
glColorMask,
|
||||
NULL, // glColorPointer
|
||||
glCompileShader,
|
||||
glCompressedTexImage2D,
|
||||
glCreateProgram,
|
||||
glCreateShader,
|
||||
glCullFace,
|
||||
glDeleteBuffers,
|
||||
glDeleteProgram,
|
||||
glDeleteShader,
|
||||
glDeleteTextures,
|
||||
glDepthMask,
|
||||
glDisable,
|
||||
NULL, // glDisableClientState
|
||||
glDisableVertexAttribArray,
|
||||
glDrawArrays,
|
||||
NULL, // glDrawBuffer
|
||||
NULL, // glDrawBuffers
|
||||
glDrawElements,
|
||||
glEnable,
|
||||
NULL, // glEnableClientState
|
||||
glEnableVertexAttribArray,
|
||||
glFrontFace,
|
||||
glGenBuffers,
|
||||
glGenTextures,
|
||||
glGetBufferParameteriv,
|
||||
glGetError,
|
||||
glGetIntegerv,
|
||||
glGetProgramInfoLog,
|
||||
glGetProgramiv,
|
||||
glGetShaderInfoLog,
|
||||
glGetShaderiv,
|
||||
glGetString,
|
||||
NULL, // glGetTexLevelParameteriv
|
||||
glGetUniformLocation,
|
||||
glLineWidth,
|
||||
glLinkProgram,
|
||||
NULL, // glLoadMatrixf
|
||||
NULL, // glMatrixMode
|
||||
glPixelStorei,
|
||||
NULL, // glPointSize
|
||||
NULL, // glReadBuffer
|
||||
glReadPixels,
|
||||
glScissor,
|
||||
NULL, // glShadeModel
|
||||
glShaderSource,
|
||||
glStencilFunc,
|
||||
glStencilFuncSeparate,
|
||||
glStencilMask,
|
||||
glStencilMaskSeparate,
|
||||
glStencilOp,
|
||||
glStencilOpSeparate,
|
||||
NULL, // glTexCoordPointer
|
||||
NULL, // glTexEnvi
|
||||
glTexImage2D,
|
||||
glTexParameteri,
|
||||
glTexSubImage2D,
|
||||
glUniform1f,
|
||||
glUniform1i,
|
||||
glUniform1fv,
|
||||
glUniform1iv,
|
||||
glUniform2f,
|
||||
glUniform2i,
|
||||
glUniform2fv,
|
||||
glUniform2iv,
|
||||
glUniform3f,
|
||||
glUniform3i,
|
||||
glUniform3fv,
|
||||
glUniform3iv,
|
||||
glUniform4f,
|
||||
glUniform4i,
|
||||
glUniform4fv,
|
||||
glUniform4iv,
|
||||
glUniformMatrix2fv,
|
||||
glUniformMatrix3fv,
|
||||
glUniformMatrix4fv,
|
||||
glUseProgram,
|
||||
glVertexAttrib4fv,
|
||||
glVertexAttribPointer,
|
||||
NULL, // glVertexPointer
|
||||
glViewport,
|
||||
glBindFramebuffer,
|
||||
glBindRenderbuffer,
|
||||
glCheckFramebufferStatus,
|
||||
glDeleteFramebuffers,
|
||||
glDeleteRenderbuffers,
|
||||
glFramebufferRenderbuffer,
|
||||
glFramebufferTexture2D,
|
||||
glGenFramebuffers,
|
||||
glGenRenderbuffers,
|
||||
glGetFramebufferAttachmentParameteriv,
|
||||
glGetRenderbufferParameteriv,
|
||||
glRenderbufferStorage,
|
||||
NULL, // glRenderbufferStorageMultisampleEXT,
|
||||
NULL, // glBlitFramebufferEXT,
|
||||
NULL, // glResolveMultisampleFramebuffer
|
||||
glMapBufferOES,
|
||||
glUnmapBufferOES,
|
||||
NULL, // glBindFragDataLocationIndexed
|
||||
GrGLInterface::kStaticInitEndGuard
|
||||
};
|
||||
static bool host_StubGL_initialized = false;
|
||||
if (!host_StubGL_initialized) {
|
||||
GrGLSetGLInterface(&cmd_buffer_interface);
|
||||
host_StubGL_initialized = true;
|
||||
}
|
||||
|
||||
void GrGLInitializeDefaultGLInterface() {
|
||||
GrGLSetGLInterface* glInterface = new GrGLInterface;
|
||||
|
||||
glInterface->fBindingsExported = kES2_GrGLBinding;
|
||||
glInterface->fActiveTexture = glActiveTexture;
|
||||
glInterface->fAttachShader = glAttachShader;
|
||||
glInterface->fBindAttribLocation = glBindAttribLocation;
|
||||
glInterface->fBindBuffer = glBindBuffer;
|
||||
glInterface->fBindTexture = glBindTexture;
|
||||
glInterface->fBlendColor = glBlendColor;
|
||||
glInterface->fBlendFunc = glBlendFunc;
|
||||
glInterface->fBufferData = glBufferData;
|
||||
glInterface->fBufferSubData = glBufferSubData;
|
||||
glInterface->fClear = glClear;
|
||||
glInterface->fClearColor = glClearColor;
|
||||
glInterface->fClearStencil = glClearStencil;
|
||||
glInterface->fColorMask = glColorMask;
|
||||
glInterface->fCompileShader = glCompileShader;
|
||||
glInterface->fCompressedTexImage2D = glCompressedTexImage2D;
|
||||
glInterface->fCreateProgram = glCreateProgram;
|
||||
glInterface->fCreateShader = glCreateShader;
|
||||
glInterface->fCullFace = glCullFace;
|
||||
glInterface->fDeleteBuffers = glDeleteBuffers;
|
||||
glInterface->fDeleteProgram = glDeleteProgram;
|
||||
glInterface->fDeleteShader = glDeleteShader;
|
||||
glInterface->fDeleteTextures = glDeleteTextures;
|
||||
glInterface->fDepthMask = glDepthMask;
|
||||
glInterface->fDisable = glDisable;
|
||||
glInterface->fDisableVertexAttribArray = glDisableVertexAttribArray;
|
||||
glInterface->fDrawArrays = glDrawArrays;
|
||||
glInterface->fDrawElements = glDrawElements;
|
||||
glInterface->fEnable = glEnable;
|
||||
glInterface->fEnableVertexAttribArray = glEnableVertexAttribArray;
|
||||
glInterface->fFrontFace = glFrontFace;
|
||||
glInterface->fGenBuffers = glGenBuffers;
|
||||
glInterface->fGenTextures = glGenTextures;
|
||||
glInterface->fGetBufferParameteriv = glGetBufferParameteriv;
|
||||
glInterface->fGetError = glGetError;
|
||||
glInterface->fGetIntegerv = glGetIntegerv;
|
||||
glInterface->fGetProgramInfoLog = glGetProgramInfoLog;
|
||||
glInterface->fGetProgramiv = glGetProgramiv;
|
||||
glInterface->fGetShaderInfoLog = glGetShaderInfoLog;
|
||||
glInterface->fGetShaderiv = glGetShaderiv;
|
||||
glInterface->fGetString = glGetString;
|
||||
glInterface->fGetUniformLocation = glGetUniformLocation;
|
||||
glInterface->fLineWidth = glLineWidth;
|
||||
glInterface->fLinkProgram = glLinkProgram;
|
||||
glInterface->fPixelStorei = glPixelStorei;
|
||||
glInterface->fReadPixels = glReadPixels;
|
||||
glInterface->fScissor = glScissor;
|
||||
glInterface->fShaderSource = glShaderSource;
|
||||
glInterface->fStencilFunc = glStencilFunc;
|
||||
glInterface->fStencilFuncSeparate = glStencilFuncSeparate;
|
||||
glInterface->fStencilMask = glStencilMask;
|
||||
glInterface->fStencilMaskSeparate = glStencilMaskSeparate;
|
||||
glInterface->fStencilOp = glStencilOp;
|
||||
glInterface->fStencilOpSeparate = glStencilOpSeparate;
|
||||
glInterface->fTexImage2D = glTexImage2D;
|
||||
glInterface->fTexParameteri = glTexParameteri;
|
||||
glInterface->fTexSubImage2D = glTexSubImage2D;
|
||||
glInterface->fUniform1f = glUniform1f;
|
||||
glInterface->fUniform1i = glUniform1i;
|
||||
glInterface->fUniform1fv = glUniform1fv;
|
||||
glInterface->fUniform1iv = glUniform1iv;
|
||||
glInterface->fUniform2f = glUniform2f;
|
||||
glInterface->fUniform2i = glUniform2i;
|
||||
glInterface->fUniform2fv = glUniform2fv;
|
||||
glInterface->fUniform2iv = glUniform2iv;
|
||||
glInterface->fUniform3f = glUniform3f;
|
||||
glInterface->fUniform3i = glUniform3i;
|
||||
glInterface->fUniform3fv = glUniform3fv;
|
||||
glInterface->fUniform3iv = glUniform3iv;
|
||||
glInterface->fUniform4f = glUniform4f;
|
||||
glInterface->fUniform4i = glUniform4i;
|
||||
glInterface->fUniform4fv = glUniform4fv;
|
||||
glInterface->fUniform4iv = glUniform4iv;
|
||||
glInterface->fUniformMatrix2fv = glUniformMatrix2fv;
|
||||
glInterface->fUniformMatrix3fv = glUniformMatrix3fv;
|
||||
glInterface->fUniformMatrix4fv = glUniformMatrix4fv;
|
||||
glInterface->fUseProgram = glUseProgram;
|
||||
glInterface->fVertexAttrib4fv = glVertexAttrib4fv;
|
||||
glInterface->fVertexAttribPointer = glVertexAttribPointer;
|
||||
glInterface->fViewport = glViewport;
|
||||
glInterface->fBindFramebuffer = glBindFramebuffer;
|
||||
glInterface->fBindRenderbuffer = glBindRenderbuffer;
|
||||
glInterface->fCheckFramebufferStatus = glCheckFramebufferStatus;
|
||||
glInterface->fDeleteFramebuffers = glDeleteFramebuffers;
|
||||
glInterface->fDeleteRenderbuffers = glDeleteRenderbuffers;
|
||||
glInterface->fFramebufferRenderbuffer = glFramebufferRenderbuffer;
|
||||
glInterface->fFramebufferTexture2D = glFramebufferTexture2D;
|
||||
glInterface->fGenFramebuffers = glGenFramebuffers;
|
||||
glInterface->fGenRenderbuffers = glGenRenderbuffers;
|
||||
glInterface->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
|
||||
glInterface->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
|
||||
glInterface->fRenderbufferStorage = glRenderbufferStorage;
|
||||
glInterface->fMapBufferOES = glMapBufferOES;
|
||||
glInterface->fUnmapBufferOES = glUnmapBufferOES;
|
||||
|
||||
GrGLSetDefaultInterface(glInterface)->unref();
|
||||
}
|
||||
|
|
|
@ -15,138 +15,135 @@
|
|||
#import <OpenGLES/ES2/gl.h>
|
||||
#import <OpenGLES/ES2/glext.h>
|
||||
|
||||
void GrGLSetDefaultGLInterface() {
|
||||
static GrGLInterface gDefaultInterface;
|
||||
static bool gDefaultInterfaceInit;
|
||||
if (!gDefaultInterfaceInit) {
|
||||
gDefaultInterface.fNPOTRenderTargetSupport = kProbe_GrGLCapability;
|
||||
gDefaultInterface.fMinRenderTargetHeight = kProbe_GrGLCapability;
|
||||
gDefaultInterface.fMinRenderTargetWidth = kProbe_GrGLCapability;
|
||||
|
||||
gDefaultInterface.fActiveTexture = glActiveTexture;
|
||||
gDefaultInterface.fAttachShader = glAttachShader;
|
||||
gDefaultInterface.fBindAttribLocation = glBindAttribLocation;
|
||||
gDefaultInterface.fBindBuffer = glBindBuffer;
|
||||
gDefaultInterface.fBindTexture = glBindTexture;
|
||||
gDefaultInterface.fBlendColor = glBlendColor;
|
||||
gDefaultInterface.fBlendFunc = glBlendFunc;
|
||||
gDefaultInterface.fBufferData = (GrGLBufferDataProc)glBufferData;
|
||||
gDefaultInterface.fBufferSubData = (GrGLBufferSubDataProc)glBufferSubData;
|
||||
gDefaultInterface.fClear = glClear;
|
||||
gDefaultInterface.fClearColor = glClearColor;
|
||||
gDefaultInterface.fClearStencil = glClearStencil;
|
||||
gDefaultInterface.fClientActiveTexture = glClientActiveTexture;
|
||||
gDefaultInterface.fColorMask = glColorMask;
|
||||
gDefaultInterface.fColorPointer = glColorPointer;
|
||||
gDefaultInterface.fColor4ub = glColor4ub;
|
||||
gDefaultInterface.fCompileShader = glCompileShader;
|
||||
gDefaultInterface.fCompressedTexImage2D = glCompressedTexImage2D;
|
||||
gDefaultInterface.fCreateProgram = glCreateProgram;
|
||||
gDefaultInterface.fCreateShader = glCreateShader;
|
||||
gDefaultInterface.fCullFace = glCullFace;
|
||||
gDefaultInterface.fDeleteBuffers = glDeleteBuffers;
|
||||
gDefaultInterface.fDeleteProgram = glDeleteProgram;
|
||||
gDefaultInterface.fDeleteShader = glDeleteShader;
|
||||
gDefaultInterface.fDeleteTextures = glDeleteTextures;
|
||||
gDefaultInterface.fDepthMask = glDepthMask;
|
||||
gDefaultInterface.fDisable = glDisable;
|
||||
gDefaultInterface.fDisableClientState = glDisableClientState;
|
||||
gDefaultInterface.fDisableVertexAttribArray =
|
||||
glDisableVertexAttribArray;
|
||||
gDefaultInterface.fDrawArrays = glDrawArrays;
|
||||
gDefaultInterface.fDrawElements = glDrawElements;
|
||||
gDefaultInterface.fEnable = glEnable;
|
||||
gDefaultInterface.fEnableClientState = glEnableClientState;
|
||||
gDefaultInterface.fEnableVertexAttribArray = glEnableVertexAttribArray;
|
||||
gDefaultInterface.fFrontFace = glFrontFace;
|
||||
gDefaultInterface.fGenBuffers = glGenBuffers;
|
||||
gDefaultInterface.fGetBufferParameteriv = glGetBufferParameteriv;
|
||||
gDefaultInterface.fGetError = glGetError;
|
||||
gDefaultInterface.fGetIntegerv = glGetIntegerv;
|
||||
gDefaultInterface.fGetProgramInfoLog = glGetProgramInfoLog;
|
||||
gDefaultInterface.fGetProgramiv = glGetProgramiv;
|
||||
gDefaultInterface.fGetShaderInfoLog = glGetShaderInfoLog;
|
||||
gDefaultInterface.fGetShaderiv = glGetShaderiv;
|
||||
gDefaultInterface.fGetString = glGetString;
|
||||
gDefaultInterface.fGenTextures = glGenTextures;
|
||||
gDefaultInterface.fGetUniformLocation = glGetUniformLocation;
|
||||
gDefaultInterface.fLineWidth = glLineWidth;
|
||||
gDefaultInterface.fLinkProgram = glLinkProgram;
|
||||
gDefaultInterface.fLoadMatrixf = glLoadMatrixf;
|
||||
gDefaultInterface.fMatrixMode = glMatrixMode;
|
||||
gDefaultInterface.fPointSize = glPointSize;
|
||||
gDefaultInterface.fPixelStorei = glPixelStorei;
|
||||
gDefaultInterface.fReadBuffer = NULL;
|
||||
gDefaultInterface.fReadPixels = glReadPixels;
|
||||
gDefaultInterface.fScissor = glScissor;
|
||||
gDefaultInterface.fShadeModel = glShadeModel;
|
||||
gDefaultInterface.fShaderSource = glShaderSource;
|
||||
gDefaultInterface.fStencilFunc = glStencilFunc;
|
||||
gDefaultInterface.fStencilFuncSeparate = glStencilFuncSeparate;
|
||||
gDefaultInterface.fStencilMask = glStencilMask;
|
||||
gDefaultInterface.fStencilMaskSeparate = glStencilMaskSeparate;
|
||||
gDefaultInterface.fStencilOp = glStencilOp;
|
||||
gDefaultInterface.fStencilOpSeparate = glStencilOpSeparate;
|
||||
gDefaultInterface.fTexCoordPointer = glTexCoordPointer;
|
||||
gDefaultInterface.fTexEnvi = glTexEnvi;
|
||||
// mac uses GLenum for internalFormat param (non-standard)
|
||||
// amounts to int vs. uint.
|
||||
gDefaultInterface.fTexImage2D = (GrGLTexImage2DProc)glTexImage2D;
|
||||
gDefaultInterface.fTexParameteri = glTexParameteri;
|
||||
gDefaultInterface.fTexSubImage2D = glTexSubImage2D;
|
||||
gDefaultInterface.fUniform1f = glUniform1f;
|
||||
gDefaultInterface.fUniform1i = glUniform1i;
|
||||
gDefaultInterface.fUniform1fv = glUniform1fv;
|
||||
gDefaultInterface.fUniform1iv = glUniform1iv;
|
||||
gDefaultInterface.fUniform2f = glUniform2f;
|
||||
gDefaultInterface.fUniform2i = glUniform2i;
|
||||
gDefaultInterface.fUniform2fv = glUniform2fv;
|
||||
gDefaultInterface.fUniform2iv = glUniform2iv;
|
||||
gDefaultInterface.fUniform3f = glUniform3f;
|
||||
gDefaultInterface.fUniform3i = glUniform3i;
|
||||
gDefaultInterface.fUniform3fv = glUniform3fv;
|
||||
gDefaultInterface.fUniform3iv = glUniform3iv;
|
||||
gDefaultInterface.fUniform4f = glUniform4f;
|
||||
gDefaultInterface.fUniform4i = glUniform4i;
|
||||
gDefaultInterface.fUniform4fv = glUniform4fv;
|
||||
gDefaultInterface.fUniform4iv = glUniform4iv;
|
||||
gDefaultInterface.fUniform4fv = glUniform4fv;
|
||||
gDefaultInterface.fUniformMatrix2fv = glUniformMatrix2fv;
|
||||
gDefaultInterface.fUniformMatrix3fv = glUniformMatrix3fv;
|
||||
gDefaultInterface.fUniformMatrix4fv = glUniformMatrix4fv;
|
||||
gDefaultInterface.fUseProgram = glUseProgram;
|
||||
gDefaultInterface.fVertexAttrib4fv = glVertexAttrib4fv;
|
||||
gDefaultInterface.fVertexAttribPointer = glVertexAttribPointer;
|
||||
gDefaultInterface.fVertexPointer = glVertexPointer;
|
||||
gDefaultInterface.fViewport = glViewport;
|
||||
|
||||
gDefaultInterface.fGenFramebuffers = glGenFramebuffers;
|
||||
gDefaultInterface.fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
|
||||
gDefaultInterface.fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
|
||||
gDefaultInterface.fBindFramebuffer = glBindFramebuffer;
|
||||
gDefaultInterface.fFramebufferTexture2D = glFramebufferTexture2D;
|
||||
gDefaultInterface.fCheckFramebufferStatus = glCheckFramebufferStatus;
|
||||
gDefaultInterface.fDeleteFramebuffers = glDeleteFramebuffers;
|
||||
gDefaultInterface.fRenderbufferStorage = glRenderbufferStorage;
|
||||
gDefaultInterface.fGenRenderbuffers = glGenRenderbuffers;
|
||||
gDefaultInterface.fDeleteRenderbuffers = glDeleteRenderbuffers;
|
||||
gDefaultInterface.fFramebufferRenderbuffer = glFramebufferRenderbuffer;
|
||||
gDefaultInterface.fBindRenderbuffer = glBindRenderbuffer;
|
||||
void GrGLInitializeDefaultGLInterface() {
|
||||
GrGLInterface* defaultInterface = new GrGLInterface();
|
||||
|
||||
defaultInterface->fNPOTRenderTargetSupport = kProbe_GrGLCapability;
|
||||
defaultInterface->fMinRenderTargetHeight = kProbe_GrGLCapability;
|
||||
defaultInterface->fMinRenderTargetWidth = kProbe_GrGLCapability;
|
||||
defaultInterface->fActiveTexture = glActiveTexture;
|
||||
defaultInterface->fAttachShader = glAttachShader;
|
||||
defaultInterface->fBindAttribLocation = glBindAttribLocation;
|
||||
defaultInterface->fBindBuffer = glBindBuffer;
|
||||
defaultInterface->fBindTexture = glBindTexture;
|
||||
defaultInterface->fBlendColor = glBlendColor;
|
||||
defaultInterface->fBlendFunc = glBlendFunc;
|
||||
defaultInterface->fBufferData = (GrGLBufferDataProc)glBufferData;
|
||||
defaultInterface->fBufferSubData = (GrGLBufferSubDataProc)glBufferSubData;
|
||||
defaultInterface->fClear = glClear;
|
||||
defaultInterface->fClearColor = glClearColor;
|
||||
defaultInterface->fClearStencil = glClearStencil;
|
||||
defaultInterface->fClientActiveTexture = glClientActiveTexture;
|
||||
defaultInterface->fColorMask = glColorMask;
|
||||
defaultInterface->fColorPointer = glColorPointer;
|
||||
defaultInterface->fColor4ub = glColor4ub;
|
||||
defaultInterface->fCompileShader = glCompileShader;
|
||||
defaultInterface->fCompressedTexImage2D = glCompressedTexImage2D;
|
||||
defaultInterface->fCreateProgram = glCreateProgram;
|
||||
defaultInterface->fCreateShader = glCreateShader;
|
||||
defaultInterface->fCullFace = glCullFace;
|
||||
defaultInterface->fDeleteBuffers = glDeleteBuffers;
|
||||
defaultInterface->fDeleteProgram = glDeleteProgram;
|
||||
defaultInterface->fDeleteShader = glDeleteShader;
|
||||
defaultInterface->fDeleteTextures = glDeleteTextures;
|
||||
defaultInterface->fDepthMask = glDepthMask;
|
||||
defaultInterface->fDisable = glDisable;
|
||||
defaultInterface->fDisableClientState = glDisableClientState;
|
||||
defaultInterface->fDisableVertexAttribArray =
|
||||
glDisableVertexAttribArray;
|
||||
defaultInterface->fDrawArrays = glDrawArrays;
|
||||
defaultInterface->fDrawBuffer = NULL;
|
||||
defaultInterface->fDrawBuffers = NULL;
|
||||
defaultInterface->fDrawElements = glDrawElements;
|
||||
defaultInterface->fEnable = glEnable;
|
||||
defaultInterface->fEnableClientState = glEnableClientState;
|
||||
defaultInterface->fEnableVertexAttribArray = glEnableVertexAttribArray;
|
||||
defaultInterface->fFrontFace = glFrontFace;
|
||||
defaultInterface->fGenBuffers = glGenBuffers;
|
||||
defaultInterface->fGetBufferParameteriv = glGetBufferParameteriv;
|
||||
defaultInterface->fGetError = glGetError;
|
||||
defaultInterface->fGetIntegerv = glGetIntegerv;
|
||||
defaultInterface->fGetProgramInfoLog = glGetProgramInfoLog;
|
||||
defaultInterface->fGetProgramiv = glGetProgramiv;
|
||||
defaultInterface->fGetShaderInfoLog = glGetShaderInfoLog;
|
||||
defaultInterface->fGetShaderiv = glGetShaderiv;
|
||||
defaultInterface->fGetString = glGetString;
|
||||
defaultInterface->fGenTextures = glGenTextures;
|
||||
defaultInterface->fGetUniformLocation = glGetUniformLocation;
|
||||
defaultInterface->fLineWidth = glLineWidth;
|
||||
defaultInterface->fLinkProgram = glLinkProgram;
|
||||
defaultInterface->fLoadMatrixf = glLoadMatrixf;
|
||||
defaultInterface->fMatrixMode = glMatrixMode;
|
||||
defaultInterface->fPointSize = glPointSize;
|
||||
defaultInterface->fPixelStorei = glPixelStorei;
|
||||
defaultInterface->fReadBuffer = NULL;
|
||||
defaultInterface->fReadPixels = glReadPixels;
|
||||
defaultInterface->fScissor = glScissor;
|
||||
defaultInterface->fShadeModel = glShadeModel;
|
||||
defaultInterface->fShaderSource = glShaderSource;
|
||||
defaultInterface->fStencilFunc = glStencilFunc;
|
||||
defaultInterface->fStencilFuncSeparate = glStencilFuncSeparate;
|
||||
defaultInterface->fStencilMask = glStencilMask;
|
||||
defaultInterface->fStencilMaskSeparate = glStencilMaskSeparate;
|
||||
defaultInterface->fStencilOp = glStencilOp;
|
||||
defaultInterface->fStencilOpSeparate = glStencilOpSeparate;
|
||||
defaultInterface->fTexCoordPointer = glTexCoordPointer;
|
||||
defaultInterface->fTexEnvi = glTexEnvi;
|
||||
// mac uses GLenum for internalFormat param (non-standard)
|
||||
// amounts to int vs. uint.
|
||||
defaultInterface->fTexImage2D = (GrGLTexImage2DProc)glTexImage2D;
|
||||
defaultInterface->fTexParameteri = glTexParameteri;
|
||||
defaultInterface->fTexSubImage2D = glTexSubImage2D;
|
||||
defaultInterface->fUniform1f = glUniform1f;
|
||||
defaultInterface->fUniform1i = glUniform1i;
|
||||
defaultInterface->fUniform1fv = glUniform1fv;
|
||||
defaultInterface->fUniform1iv = glUniform1iv;
|
||||
defaultInterface->fUniform2f = glUniform2f;
|
||||
defaultInterface->fUniform2i = glUniform2i;
|
||||
defaultInterface->fUniform2fv = glUniform2fv;
|
||||
defaultInterface->fUniform2iv = glUniform2iv;
|
||||
defaultInterface->fUniform3f = glUniform3f;
|
||||
defaultInterface->fUniform3i = glUniform3i;
|
||||
defaultInterface->fUniform3fv = glUniform3fv;
|
||||
defaultInterface->fUniform3iv = glUniform3iv;
|
||||
defaultInterface->fUniform4f = glUniform4f;
|
||||
defaultInterface->fUniform4i = glUniform4i;
|
||||
defaultInterface->fUniform4fv = glUniform4fv;
|
||||
defaultInterface->fUniform4iv = glUniform4iv;
|
||||
defaultInterface->fUniform4fv = glUniform4fv;
|
||||
defaultInterface->fUniformMatrix2fv = glUniformMatrix2fv;
|
||||
defaultInterface->fUniformMatrix3fv = glUniformMatrix3fv;
|
||||
defaultInterface->fUniformMatrix4fv = glUniformMatrix4fv;
|
||||
defaultInterface->fUseProgram = glUseProgram;
|
||||
defaultInterface->fVertexAttrib4fv = glVertexAttrib4fv;
|
||||
defaultInterface->fVertexAttribPointer = glVertexAttribPointer;
|
||||
defaultInterface->fVertexPointer = glVertexPointer;
|
||||
defaultInterface->fViewport = glViewport;
|
||||
defaultInterface->fGenFramebuffers = glGenFramebuffers;
|
||||
defaultInterface->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
|
||||
defaultInterface->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
|
||||
defaultInterface->fBindFramebuffer = glBindFramebuffer;
|
||||
defaultInterface->fFramebufferTexture2D = glFramebufferTexture2D;
|
||||
defaultInterface->fCheckFramebufferStatus = glCheckFramebufferStatus;
|
||||
defaultInterface->fDeleteFramebuffers = glDeleteFramebuffers;
|
||||
defaultInterface->fRenderbufferStorage = glRenderbufferStorage;
|
||||
defaultInterface->fGenRenderbuffers = glGenRenderbuffers;
|
||||
defaultInterface->fDeleteRenderbuffers = glDeleteRenderbuffers;
|
||||
defaultInterface->fFramebufferRenderbuffer = glFramebufferRenderbuffer;
|
||||
defaultInterface->fBindRenderbuffer = glBindRenderbuffer;
|
||||
|
||||
#if GL_OES_mapbuffer
|
||||
gDefaultInterface.fMapBuffer = glMapBufferOES;
|
||||
gDefaultInterface.fUnmapBuffer = glUnmapBufferOES;
|
||||
defaultInterface->fMapBuffer = glMapBufferOES;
|
||||
defaultInterface->fUnmapBuffer = glUnmapBufferOES;
|
||||
#endif
|
||||
|
||||
#if GL_APPLE_framebuffer_multisample
|
||||
gDefaultInterface.fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleAPPLE;
|
||||
gDefaultInterface.fResolveMultisampleFramebuffer = glResolveMultisampleFramebufferAPPLE;
|
||||
defaultInterface->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleAPPLE;
|
||||
defaultInterface->fResolveMultisampleFramebuffer = glResolveMultisampleFramebufferAPPLE;
|
||||
#endif
|
||||
gDefaultInterface.fBindFragDataLocationIndexed = NULL;
|
||||
defaultInterface->fBindFragDataLocationIndexed = NULL;
|
||||
|
||||
gDefaultInterface.fBindingsExported = kES2_GrGLBinding;
|
||||
|
||||
gDefaultInterfaceInit = true;
|
||||
}
|
||||
GrGLSetGLInterface(&gDefaultInterface);
|
||||
defaultInterface->fBindingsExported = kES2_GrGLBinding | kES1_GrGLBinding;
|
||||
|
||||
GrGLSetDefaultGLInterface(&defaultInterface)->unref();
|
||||
}
|
|
@ -12,159 +12,152 @@
|
|||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glext.h>
|
||||
|
||||
void GrGLSetDefaultGLInterface() {
|
||||
static GrGLInterface gDefaultInterface;
|
||||
static bool gDefaultInterfaceInit;
|
||||
if (!gDefaultInterfaceInit) {
|
||||
gDefaultInterface.fNPOTRenderTargetSupport = kProbe_GrGLCapability;
|
||||
gDefaultInterface.fMinRenderTargetHeight = kProbe_GrGLCapability;
|
||||
gDefaultInterface.fMinRenderTargetWidth = kProbe_GrGLCapability;
|
||||
|
||||
gDefaultInterface.fActiveTexture = glActiveTexture;
|
||||
gDefaultInterface.fAttachShader = glAttachShader;
|
||||
gDefaultInterface.fBindAttribLocation = glBindAttribLocation;
|
||||
gDefaultInterface.fBindBuffer = glBindBuffer;
|
||||
gDefaultInterface.fBindTexture = glBindTexture;
|
||||
gDefaultInterface.fBlendColor = glBlendColor;
|
||||
gDefaultInterface.fBlendFunc = glBlendFunc;
|
||||
gDefaultInterface.fBufferData = glBufferData;
|
||||
gDefaultInterface.fBufferSubData = glBufferSubData;
|
||||
gDefaultInterface.fClear = glClear;
|
||||
gDefaultInterface.fClearColor = glClearColor;
|
||||
gDefaultInterface.fClearStencil = glClearStencil;
|
||||
gDefaultInterface.fClientActiveTexture = glClientActiveTexture;
|
||||
gDefaultInterface.fColorMask = glColorMask;
|
||||
gDefaultInterface.fColorPointer = glColorPointer;
|
||||
gDefaultInterface.fColor4ub = glColor4ub;
|
||||
gDefaultInterface.fCompileShader = glCompileShader;
|
||||
gDefaultInterface.fCompressedTexImage2D = glCompressedTexImage2D;
|
||||
gDefaultInterface.fCreateProgram = glCreateProgram;
|
||||
gDefaultInterface.fCreateShader = glCreateShader;
|
||||
gDefaultInterface.fCullFace = glCullFace;
|
||||
gDefaultInterface.fDeleteBuffers = glDeleteBuffers;
|
||||
gDefaultInterface.fDeleteProgram = glDeleteProgram;
|
||||
gDefaultInterface.fDeleteShader = glDeleteShader;
|
||||
gDefaultInterface.fDeleteTextures = glDeleteTextures;
|
||||
gDefaultInterface.fDepthMask = glDepthMask;
|
||||
gDefaultInterface.fDisable = glDisable;
|
||||
gDefaultInterface.fDisableClientState = glDisableClientState;
|
||||
gDefaultInterface.fDisableVertexAttribArray =
|
||||
glDisableVertexAttribArray;
|
||||
gDefaultInterface.fDrawArrays = glDrawArrays;
|
||||
gDefaultInterface.fDrawBuffer = glDrawBuffer;
|
||||
gDefaultInterface.fDrawBuffers = glDrawBuffers;
|
||||
gDefaultInterface.fDrawElements = glDrawElements;
|
||||
gDefaultInterface.fEnable = glEnable;
|
||||
gDefaultInterface.fEnableClientState = glEnableClientState;
|
||||
gDefaultInterface.fEnableVertexAttribArray = glEnableVertexAttribArray;
|
||||
gDefaultInterface.fFrontFace = glFrontFace;
|
||||
gDefaultInterface.fGenBuffers = glGenBuffers;
|
||||
gDefaultInterface.fGetBufferParameteriv = glGetBufferParameteriv;
|
||||
gDefaultInterface.fGetError = glGetError;
|
||||
gDefaultInterface.fGetIntegerv = glGetIntegerv;
|
||||
gDefaultInterface.fGetProgramInfoLog = glGetProgramInfoLog;
|
||||
gDefaultInterface.fGetProgramiv = glGetProgramiv;
|
||||
gDefaultInterface.fGetShaderInfoLog = glGetShaderInfoLog;
|
||||
gDefaultInterface.fGetShaderiv = glGetShaderiv;
|
||||
gDefaultInterface.fGetString = glGetString;
|
||||
gDefaultInterface.fGetTexLevelParameteriv = glGetTexLevelParameteriv;
|
||||
gDefaultInterface.fGenTextures = glGenTextures;
|
||||
gDefaultInterface.fGetUniformLocation = glGetUniformLocation;
|
||||
gDefaultInterface.fLineWidth = glLineWidth;
|
||||
gDefaultInterface.fLinkProgram = glLinkProgram;
|
||||
gDefaultInterface.fLoadMatrixf = glLoadMatrixf;
|
||||
gDefaultInterface.fMapBuffer = glMapBuffer;
|
||||
gDefaultInterface.fMatrixMode = glMatrixMode;
|
||||
gDefaultInterface.fPointSize = glPointSize;
|
||||
gDefaultInterface.fPixelStorei = glPixelStorei;
|
||||
gDefaultInterface.fReadBuffer = glReadBuffer;
|
||||
gDefaultInterface.fReadPixels = glReadPixels;
|
||||
gDefaultInterface.fScissor = glScissor;
|
||||
gDefaultInterface.fShadeModel = glShadeModel;
|
||||
gDefaultInterface.fShaderSource = glShaderSource;
|
||||
gDefaultInterface.fStencilFunc = glStencilFunc;
|
||||
gDefaultInterface.fStencilFuncSeparate = glStencilFuncSeparate;
|
||||
gDefaultInterface.fStencilMask = glStencilMask;
|
||||
gDefaultInterface.fStencilMaskSeparate = glStencilMaskSeparate;
|
||||
gDefaultInterface.fStencilOp = glStencilOp;
|
||||
gDefaultInterface.fStencilOpSeparate = glStencilOpSeparate;
|
||||
gDefaultInterface.fTexCoordPointer = glTexCoordPointer;
|
||||
gDefaultInterface.fTexEnvi = glTexEnvi;
|
||||
// mac uses GLenum for internalFormat param (non-standard)
|
||||
// amounts to int vs. uint.
|
||||
gDefaultInterface.fTexImage2D = (GrGLTexImage2DProc)glTexImage2D;
|
||||
gDefaultInterface.fTexParameteri = glTexParameteri;
|
||||
gDefaultInterface.fTexSubImage2D = glTexSubImage2D;
|
||||
gDefaultInterface.fUniform1f = glUniform1f;
|
||||
gDefaultInterface.fUniform1i = glUniform1i;
|
||||
gDefaultInterface.fUniform1fv = glUniform1fv;
|
||||
gDefaultInterface.fUniform1iv = glUniform1iv;
|
||||
gDefaultInterface.fUniform2f = glUniform2f;
|
||||
gDefaultInterface.fUniform2i = glUniform2i;
|
||||
gDefaultInterface.fUniform2fv = glUniform2fv;
|
||||
gDefaultInterface.fUniform2iv = glUniform2iv;
|
||||
gDefaultInterface.fUniform3f = glUniform3f;
|
||||
gDefaultInterface.fUniform3i = glUniform3i;
|
||||
gDefaultInterface.fUniform3fv = glUniform3fv;
|
||||
gDefaultInterface.fUniform3iv = glUniform3iv;
|
||||
gDefaultInterface.fUniform4f = glUniform4f;
|
||||
gDefaultInterface.fUniform4i = glUniform4i;
|
||||
gDefaultInterface.fUniform4fv = glUniform4fv;
|
||||
gDefaultInterface.fUniform4iv = glUniform4iv;
|
||||
gDefaultInterface.fUniform4fv = glUniform4fv;
|
||||
gDefaultInterface.fUniformMatrix2fv = glUniformMatrix2fv;
|
||||
gDefaultInterface.fUniformMatrix3fv = glUniformMatrix3fv;
|
||||
gDefaultInterface.fUniformMatrix4fv = glUniformMatrix4fv;
|
||||
gDefaultInterface.fUnmapBuffer = glUnmapBuffer;
|
||||
gDefaultInterface.fUseProgram = glUseProgram;
|
||||
gDefaultInterface.fVertexAttrib4fv = glVertexAttrib4fv;
|
||||
gDefaultInterface.fVertexAttribPointer = glVertexAttribPointer;
|
||||
gDefaultInterface.fVertexPointer = glVertexPointer;
|
||||
gDefaultInterface.fViewport = glViewport;
|
||||
void GrGLInitializeDefaultGLInterface() {
|
||||
GrGLInterface* defaultInterface = new GrGLInterface;
|
||||
defaultInterface->fBindingsExported = kDesktop_GrGLBinding;
|
||||
defaultInterface->fActiveTexture = glActiveTexture;
|
||||
defaultInterface->fAttachShader = glAttachShader;
|
||||
defaultInterface->fBindAttribLocation = glBindAttribLocation;
|
||||
defaultInterface->fBindBuffer = glBindBuffer;
|
||||
defaultInterface->fBindTexture = glBindTexture;
|
||||
defaultInterface->fBlendColor = glBlendColor;
|
||||
defaultInterface->fBlendFunc = glBlendFunc;
|
||||
defaultInterface->fBufferData = glBufferData;
|
||||
defaultInterface->fBufferSubData = glBufferSubData;
|
||||
defaultInterface->fClear = glClear;
|
||||
defaultInterface->fClearColor = glClearColor;
|
||||
defaultInterface->fClearStencil = glClearStencil;
|
||||
defaultInterface->fClientActiveTexture = glClientActiveTexture;
|
||||
defaultInterface->fColorMask = glColorMask;
|
||||
defaultInterface->fColorPointer = glColorPointer;
|
||||
defaultInterface->fColor4ub = glColor4ub;
|
||||
defaultInterface->fCompileShader = glCompileShader;
|
||||
defaultInterface->fCompressedTexImage2D = glCompressedTexImage2D;
|
||||
defaultInterface->fCreateProgram = glCreateProgram;
|
||||
defaultInterface->fCreateShader = glCreateShader;
|
||||
defaultInterface->fCullFace = glCullFace;
|
||||
defaultInterface->fDeleteBuffers = glDeleteBuffers;
|
||||
defaultInterface->fDeleteProgram = glDeleteProgram;
|
||||
defaultInterface->fDeleteShader = glDeleteShader;
|
||||
defaultInterface->fDeleteTextures = glDeleteTextures;
|
||||
defaultInterface->fDepthMask = glDepthMask;
|
||||
defaultInterface->fDisable = glDisable;
|
||||
defaultInterface->fDisableClientState = glDisableClientState;
|
||||
defaultInterface->fDisableVertexAttribArray =
|
||||
glDisableVertexAttribArray;
|
||||
defaultInterface->fDrawArrays = glDrawArrays;
|
||||
defaultInterface->fDrawBuffer = glDrawBuffer;
|
||||
defaultInterface->fDrawBuffers = glDrawBuffers;
|
||||
defaultInterface->fDrawElements = glDrawElements;
|
||||
defaultInterface->fEnable = glEnable;
|
||||
defaultInterface->fEnableClientState = glEnableClientState;
|
||||
defaultInterface->fEnableVertexAttribArray = glEnableVertexAttribArray;
|
||||
defaultInterface->fFrontFace = glFrontFace;
|
||||
defaultInterface->fGenBuffers = glGenBuffers;
|
||||
defaultInterface->fGetBufferParameteriv = glGetBufferParameteriv;
|
||||
defaultInterface->fGetError = glGetError;
|
||||
defaultInterface->fGetIntegerv = glGetIntegerv;
|
||||
defaultInterface->fGetProgramInfoLog = glGetProgramInfoLog;
|
||||
defaultInterface->fGetProgramiv = glGetProgramiv;
|
||||
defaultInterface->fGetShaderInfoLog = glGetShaderInfoLog;
|
||||
defaultInterface->fGetShaderiv = glGetShaderiv;
|
||||
defaultInterface->fGetString = glGetString;
|
||||
defaultInterface->fGetTexLevelParameteriv = glGetTexLevelParameteriv;
|
||||
defaultInterface->fGenTextures = glGenTextures;
|
||||
defaultInterface->fGetUniformLocation = glGetUniformLocation;
|
||||
defaultInterface->fLineWidth = glLineWidth;
|
||||
defaultInterface->fLinkProgram = glLinkProgram;
|
||||
defaultInterface->fLoadMatrixf = glLoadMatrixf;
|
||||
defaultInterface->fMapBuffer = glMapBuffer;
|
||||
defaultInterface->fMatrixMode = glMatrixMode;
|
||||
defaultInterface->fPointSize = glPointSize;
|
||||
defaultInterface->fPixelStorei = glPixelStorei;
|
||||
defaultInterface->fReadBuffer = glReadBuffer;
|
||||
defaultInterface->fReadPixels = glReadPixels;
|
||||
defaultInterface->fScissor = glScissor;
|
||||
defaultInterface->fShadeModel = glShadeModel;
|
||||
defaultInterface->fShaderSource = glShaderSource;
|
||||
defaultInterface->fStencilFunc = glStencilFunc;
|
||||
defaultInterface->fStencilFuncSeparate = glStencilFuncSeparate;
|
||||
defaultInterface->fStencilMask = glStencilMask;
|
||||
defaultInterface->fStencilMaskSeparate = glStencilMaskSeparate;
|
||||
defaultInterface->fStencilOp = glStencilOp;
|
||||
defaultInterface->fStencilOpSeparate = glStencilOpSeparate;
|
||||
defaultInterface->fTexCoordPointer = glTexCoordPointer;
|
||||
defaultInterface->fTexEnvi = glTexEnvi;
|
||||
// mac uses GLenum for internalFormat param (non-standard)
|
||||
// amounts to int vs. uint.
|
||||
defaultInterface->fTexImage2D = (GrGLTexImage2DProc)glTexImage2D;
|
||||
defaultInterface->fTexParameteri = glTexParameteri;
|
||||
defaultInterface->fTexSubImage2D = glTexSubImage2D;
|
||||
defaultInterface->fUniform1f = glUniform1f;
|
||||
defaultInterface->fUniform1i = glUniform1i;
|
||||
defaultInterface->fUniform1fv = glUniform1fv;
|
||||
defaultInterface->fUniform1iv = glUniform1iv;
|
||||
defaultInterface->fUniform2f = glUniform2f;
|
||||
defaultInterface->fUniform2i = glUniform2i;
|
||||
defaultInterface->fUniform2fv = glUniform2fv;
|
||||
defaultInterface->fUniform2iv = glUniform2iv;
|
||||
defaultInterface->fUniform3f = glUniform3f;
|
||||
defaultInterface->fUniform3i = glUniform3i;
|
||||
defaultInterface->fUniform3fv = glUniform3fv;
|
||||
defaultInterface->fUniform3iv = glUniform3iv;
|
||||
defaultInterface->fUniform4f = glUniform4f;
|
||||
defaultInterface->fUniform4i = glUniform4i;
|
||||
defaultInterface->fUniform4fv = glUniform4fv;
|
||||
defaultInterface->fUniform4iv = glUniform4iv;
|
||||
defaultInterface->fUniform4fv = glUniform4fv;
|
||||
defaultInterface->fUniformMatrix2fv = glUniformMatrix2fv;
|
||||
defaultInterface->fUniformMatrix3fv = glUniformMatrix3fv;
|
||||
defaultInterface->fUniformMatrix4fv = glUniformMatrix4fv;
|
||||
defaultInterface->fUnmapBuffer = glUnmapBuffer;
|
||||
defaultInterface->fUseProgram = glUseProgram;
|
||||
defaultInterface->fVertexAttrib4fv = glVertexAttrib4fv;
|
||||
defaultInterface->fVertexAttribPointer = glVertexAttribPointer;
|
||||
defaultInterface->fVertexPointer = glVertexPointer;
|
||||
defaultInterface->fViewport = glViewport;
|
||||
|
||||
#if GL_ARB_framebuffer_object
|
||||
gDefaultInterface.fGenFramebuffers = glGenFramebuffers;
|
||||
gDefaultInterface.fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
|
||||
gDefaultInterface.fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
|
||||
gDefaultInterface.fBindFramebuffer = glBindFramebuffer;
|
||||
gDefaultInterface.fFramebufferTexture2D = glFramebufferTexture2D;
|
||||
gDefaultInterface.fCheckFramebufferStatus = glCheckFramebufferStatus;
|
||||
gDefaultInterface.fDeleteFramebuffers = glDeleteFramebuffers;
|
||||
gDefaultInterface.fRenderbufferStorage = glRenderbufferStorage;
|
||||
gDefaultInterface.fGenRenderbuffers = glGenRenderbuffers;
|
||||
gDefaultInterface.fDeleteRenderbuffers = glDeleteRenderbuffers;
|
||||
gDefaultInterface.fFramebufferRenderbuffer = glFramebufferRenderbuffer;
|
||||
gDefaultInterface.fBindRenderbuffer = glBindRenderbuffer;
|
||||
gDefaultInterface.fRenderbufferStorageMultisample =
|
||||
glRenderbufferStorageMultisample;
|
||||
gDefaultInterface.fBlitFramebuffer = glBlitFramebuffer;
|
||||
defaultInterface->fGenFramebuffers = glGenFramebuffers;
|
||||
defaultInterface->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
|
||||
defaultInterface->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
|
||||
defaultInterface->fBindFramebuffer = glBindFramebuffer;
|
||||
defaultInterface->fFramebufferTexture2D = glFramebufferTexture2D;
|
||||
defaultInterface->fCheckFramebufferStatus = glCheckFramebufferStatus;
|
||||
defaultInterface->fDeleteFramebuffers = glDeleteFramebuffers;
|
||||
defaultInterface->fRenderbufferStorage = glRenderbufferStorage;
|
||||
defaultInterface->fGenRenderbuffers = glGenRenderbuffers;
|
||||
defaultInterface->fDeleteRenderbuffers = glDeleteRenderbuffers;
|
||||
defaultInterface->fFramebufferRenderbuffer = glFramebufferRenderbuffer;
|
||||
defaultInterface->fBindRenderbuffer = glBindRenderbuffer;
|
||||
defaultInterface->fRenderbufferStorageMultisample =
|
||||
glRenderbufferStorageMultisample;
|
||||
defaultInterface->fBlitFramebuffer = glBlitFramebuffer;
|
||||
#elif GL_EXT_framebuffer_object
|
||||
gDefaultInterface.fGenFramebuffers = glGenFramebuffersEXT;
|
||||
gDefaultInterface.fGetFramebufferAttachmentivParameter = glGetFramebufferAttachmentParameterivEXT;
|
||||
gDefaultInterface.fGLGetRenderbufferParameteriv = glGetRenderbufferParameterivEXT;
|
||||
gDefaultInterface.fBindFramebuffer = glBindFramebufferEXT;
|
||||
gDefaultInterface.fFramebufferTexture2D = glFramebufferTexture2DEXT;
|
||||
gDefaultInterface.fCheckFramebufferStatus = glCheckFramebufferStatusEXT;
|
||||
gDefaultInterface.fDeleteFramebuffers = glDeleteFramebuffersEXT;
|
||||
gDefaultInterface.fRenderbufferStorage = glRenderbufferStorageEXT;
|
||||
gDefaultInterface.fGenRenderbuffers = glGenRenderbuffersEXT;
|
||||
gDefaultInterface.fDeleteRenderbuffers = glDeleteRenderbuffers;
|
||||
gDefaultInterface.fFramebufferRenderbuffer =
|
||||
glFramebufferRenderbufferEXT;
|
||||
gDefaultInterface.fBindRenderbuffer = glBindRenderbufferEXT;
|
||||
#if GL_EXT_framebuffer_multisample
|
||||
gDefaultInterface.fRenderbufferStorageMultisample =
|
||||
glRenderbufferStorageMultisampleEXT;
|
||||
#endif
|
||||
#if GL_EXT_framebuffer_blit
|
||||
gDefaultInterface.fBlitFramebuffer = glBlitFramebufferEXT;
|
||||
#endif
|
||||
defaultInterface->fGenFramebuffers = glGenFramebuffersEXT;
|
||||
defaultInterface->fGetFramebufferAttachmentivParameter = glGetFramebufferAttachmentParameterivEXT;
|
||||
defaultInterface->fGLGetRenderbufferParameteriv = glGetRenderbufferParameterivEXT;
|
||||
defaultInterface->fBindFramebuffer = glBindFramebufferEXT;
|
||||
defaultInterface->fFramebufferTexture2D = glFramebufferTexture2DEXT;
|
||||
defaultInterface->fCheckFramebufferStatus = glCheckFramebufferStatusEXT;
|
||||
defaultInterface->fDeleteFramebuffers = glDeleteFramebuffersEXT;
|
||||
defaultInterface->fRenderbufferStorage = glRenderbufferStorageEXT;
|
||||
defaultInterface->fGenRenderbuffers = glGenRenderbuffersEXT;
|
||||
defaultInterface->fDeleteRenderbuffers = glDeleteRenderbuffers;
|
||||
defaultInterface->fFramebufferRenderbuffer =
|
||||
glFramebufferRenderbufferEXT;
|
||||
defaultInterface->fBindRenderbuffer = glBindRenderbufferEXT;
|
||||
#if GL_EXT_framebuffer_multisample
|
||||
defaultInterface->fRenderbufferStorageMultisample =
|
||||
glRenderbufferStorageMultisampleEXT;
|
||||
#endif
|
||||
gDefaultInterface.fBindFragDataLocationIndexed = NULL;
|
||||
#if GL_EXT_framebuffer_blit
|
||||
defaultInterface->fBlitFramebuffer = glBlitFramebufferEXT;
|
||||
#endif
|
||||
#endif
|
||||
defaultInterface->fBindFragDataLocationIndexed = NULL;
|
||||
|
||||
gDefaultInterface.fBindingsExported = kDesktop_GrGLBinding;
|
||||
defaultInterface->fBindingsExported = kDesktop_GrGLBinding;
|
||||
|
||||
gDefaultInterfaceInit = true;
|
||||
}
|
||||
GrGLSetGLInterface(&gDefaultInterface);
|
||||
GrGLSetDefaultGLInterface(defaultInterface)->unref();
|
||||
}
|
||||
|
|
|
@ -13,15 +13,14 @@
|
|||
#include <GL/glext.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
#define GR_GL_GET_PROC(F) gDefaultInterface.f ## F = (GrGL ## F ## Proc) \
|
||||
#define GR_GL_GET_PROC(F) defaultInterface->f ## F = (GrGL ## F ## Proc) \
|
||||
OSMesaGetProcAddress("gl" #F);
|
||||
#define GR_GL_GET_PROC_SUFFIX(F, S) gDefaultInterface.f ## F = (GrGL ## F ## Proc) \
|
||||
#define GR_GL_GET_PROC_SUFFIX(F, S) defaultInterface->f ## F = (GrGL ## F ## Proc) \
|
||||
OSMesaGetProcAddress("gl" #F #S);
|
||||
|
||||
void GrGLSetDefaultGLInterface() {
|
||||
static GrGLInterface gDefaultInterface;
|
||||
static bool gDefaultInterfaceInit;
|
||||
if (!gDefaultInterfaceInit && NULL != OSMesaGetCurrentContext()) {
|
||||
void GrGLInitializeDefaultGLInterface() {
|
||||
if (NULL != OSMesaGetCurrentContext()) {
|
||||
GrGLInterface defaultInterface = new GrGLInterface();
|
||||
int major, minor;
|
||||
const char* versionString = (const char*) glGetString(GL_VERSION);
|
||||
const char* extString = (const char*) glGetString(GL_EXTENSIONS);
|
||||
|
@ -31,83 +30,83 @@ void GrGLSetDefaultGLInterface() {
|
|||
// We must have array and element_array buffer objects.
|
||||
return;
|
||||
}
|
||||
gDefaultInterface.fNPOTRenderTargetSupport = kProbe_GrGLCapability;
|
||||
gDefaultInterface.fMinRenderTargetHeight = kProbe_GrGLCapability;
|
||||
gDefaultInterface.fMinRenderTargetWidth = kProbe_GrGLCapability;
|
||||
defaultInterface->fNPOTRenderTargetSupport = kProbe_GrGLCapability;
|
||||
defaultInterface->fMinRenderTargetHeight = kProbe_GrGLCapability;
|
||||
defaultInterface->fMinRenderTargetWidth = kProbe_GrGLCapability;
|
||||
|
||||
gDefaultInterface.fActiveTexture = glActiveTexture;
|
||||
defaultInterface->fActiveTexture = glActiveTexture;
|
||||
GR_GL_GET_PROC(AttachShader);
|
||||
GR_GL_GET_PROC(BindAttribLocation);
|
||||
GR_GL_GET_PROC(BindBuffer);
|
||||
gDefaultInterface.fBindTexture = glBindTexture;
|
||||
gDefaultInterface.fBlendColor = glBlendColor;
|
||||
gDefaultInterface.fBlendFunc = glBlendFunc;
|
||||
defaultInterface->fBindTexture = glBindTexture;
|
||||
defaultInterface->fBlendColor = glBlendColor;
|
||||
defaultInterface->fBlendFunc = glBlendFunc;
|
||||
GR_GL_GET_PROC(BufferData);
|
||||
GR_GL_GET_PROC(BufferSubData);
|
||||
gDefaultInterface.fClear = glClear;
|
||||
gDefaultInterface.fClearColor = glClearColor;
|
||||
gDefaultInterface.fClearStencil = glClearStencil;
|
||||
gDefaultInterface.fClientActiveTexture = glClientActiveTexture;
|
||||
gDefaultInterface.fColorMask = glColorMask;
|
||||
gDefaultInterface.fColorPointer = glColorPointer;
|
||||
gDefaultInterface.fColor4ub = glColor4ub;
|
||||
defaultInterface->fClear = glClear;
|
||||
defaultInterface->fClearColor = glClearColor;
|
||||
defaultInterface->fClearStencil = glClearStencil;
|
||||
defaultInterface->fClientActiveTexture = glClientActiveTexture;
|
||||
defaultInterface->fColorMask = glColorMask;
|
||||
defaultInterface->fColorPointer = glColorPointer;
|
||||
defaultInterface->fColor4ub = glColor4ub;
|
||||
GR_GL_GET_PROC(CompileShader);
|
||||
gDefaultInterface.fCompressedTexImage2D = glCompressedTexImage2D;
|
||||
defaultInterface->fCompressedTexImage2D = glCompressedTexImage2D;
|
||||
GR_GL_GET_PROC(CreateProgram);
|
||||
GR_GL_GET_PROC(CreateShader);
|
||||
gDefaultInterface.fCullFace = glCullFace;
|
||||
defaultInterface->fCullFace = glCullFace;
|
||||
GR_GL_GET_PROC(DeleteBuffers);
|
||||
GR_GL_GET_PROC(DeleteProgram);
|
||||
GR_GL_GET_PROC(DeleteShader);
|
||||
gDefaultInterface.fDeleteTextures = glDeleteTextures;
|
||||
gDefaultInterface.fDepthMask = glDepthMask;
|
||||
gDefaultInterface.fDisable = glDisable;
|
||||
gDefaultInterface.fDisableClientState = glDisableClientState;
|
||||
defaultInterface->fDeleteTextures = glDeleteTextures;
|
||||
defaultInterface->fDepthMask = glDepthMask;
|
||||
defaultInterface->fDisable = glDisable;
|
||||
defaultInterface->fDisableClientState = glDisableClientState;
|
||||
GR_GL_GET_PROC(DisableVertexAttribArray);
|
||||
gDefaultInterface.fDrawArrays = glDrawArrays;
|
||||
gDefaultInterface.fDrawBuffer = glDrawBuffer;
|
||||
defaultInterface->fDrawArrays = glDrawArrays;
|
||||
defaultInterface->fDrawBuffer = glDrawBuffer;
|
||||
GR_GL_GET_PROC(DrawBuffers);
|
||||
gDefaultInterface.fDrawElements = glDrawElements;
|
||||
gDefaultInterface.fEnable = glEnable;
|
||||
gDefaultInterface.fEnableClientState = glEnableClientState;
|
||||
defaultInterface->fDrawElements = glDrawElements;
|
||||
defaultInterface->fEnable = glEnable;
|
||||
defaultInterface->fEnableClientState = glEnableClientState;
|
||||
GR_GL_GET_PROC(EnableVertexAttribArray);
|
||||
gDefaultInterface.fFrontFace = glFrontFace;
|
||||
defaultInterface->fFrontFace = glFrontFace;
|
||||
GR_GL_GET_PROC(GenBuffers);
|
||||
GR_GL_GET_PROC(GetBufferParameteriv);
|
||||
gDefaultInterface.fGetError = glGetError;
|
||||
gDefaultInterface.fGetIntegerv = glGetIntegerv;
|
||||
defaultInterface->fGetError = glGetError;
|
||||
defaultInterface->fGetIntegerv = glGetIntegerv;
|
||||
GR_GL_GET_PROC(GetProgramInfoLog);
|
||||
GR_GL_GET_PROC(GetProgramiv);
|
||||
GR_GL_GET_PROC(GetShaderInfoLog);
|
||||
GR_GL_GET_PROC(GetShaderiv);
|
||||
gDefaultInterface.fGetString = glGetString;
|
||||
gDefaultInterface.fGetTexLevelParameteriv = glGetTexLevelParameteriv;
|
||||
gDefaultInterface.fGenTextures = glGenTextures;
|
||||
defaultInterface->fGetString = glGetString;
|
||||
defaultInterface->fGetTexLevelParameteriv = glGetTexLevelParameteriv;
|
||||
defaultInterface->fGenTextures = glGenTextures;
|
||||
GR_GL_GET_PROC(GetUniformLocation);
|
||||
gDefaultInterface.fLineWidth = glLineWidth;
|
||||
defaultInterface->fLineWidth = glLineWidth;
|
||||
GR_GL_GET_PROC(LinkProgram);
|
||||
gDefaultInterface.fLoadMatrixf = glLoadMatrixf;
|
||||
defaultInterface->fLoadMatrixf = glLoadMatrixf;
|
||||
GR_GL_GET_PROC(MapBuffer);
|
||||
gDefaultInterface.fMatrixMode = glMatrixMode;
|
||||
gDefaultInterface.fPointSize = glPointSize;
|
||||
gDefaultInterface.fPixelStorei = glPixelStorei;
|
||||
gDefaultInterface.fReadBuffer = glReadBuffer;
|
||||
gDefaultInterface.fReadPixels = glReadPixels;
|
||||
gDefaultInterface.fScissor = glScissor;
|
||||
gDefaultInterface.fShadeModel = glShadeModel;
|
||||
defaultInterface->fMatrixMode = glMatrixMode;
|
||||
defaultInterface->fPointSize = glPointSize;
|
||||
defaultInterface->fPixelStorei = glPixelStorei;
|
||||
defaultInterface->fReadBuffer = glReadBuffer;
|
||||
defaultInterface->fReadPixels = glReadPixels;
|
||||
defaultInterface->fScissor = glScissor;
|
||||
defaultInterface->fShadeModel = glShadeModel;
|
||||
GR_GL_GET_PROC(ShaderSource);
|
||||
gDefaultInterface.fStencilFunc = glStencilFunc;
|
||||
defaultInterface->fStencilFunc = glStencilFunc;
|
||||
GR_GL_GET_PROC(StencilFuncSeparate);
|
||||
gDefaultInterface.fStencilMask = glStencilMask;
|
||||
defaultInterface->fStencilMask = glStencilMask;
|
||||
GR_GL_GET_PROC(StencilMaskSeparate);
|
||||
gDefaultInterface.fStencilOp = glStencilOp;
|
||||
defaultInterface->fStencilOp = glStencilOp;
|
||||
GR_GL_GET_PROC(StencilOpSeparate);
|
||||
gDefaultInterface.fTexCoordPointer = glTexCoordPointer;
|
||||
gDefaultInterface.fTexEnvi = glTexEnvi;
|
||||
defaultInterface->fTexCoordPointer = glTexCoordPointer;
|
||||
defaultInterface->fTexEnvi = glTexEnvi;
|
||||
//OSMesa on Mac's glTexImage2D takes a GLenum for internalFormat rather than a GLint.
|
||||
gDefaultInterface.fTexImage2D = reinterpret_cast<GrGLTexImage2DProc>(glTexImage2D);
|
||||
gDefaultInterface.fTexParameteri = glTexParameteri;
|
||||
gDefaultInterface.fTexSubImage2D = glTexSubImage2D;
|
||||
defaultInterface->fTexImage2D = reinterpret_cast<GrGLTexImage2DProc>(glTexImage2D);
|
||||
defaultInterface->fTexParameteri = glTexParameteri;
|
||||
defaultInterface->fTexSubImage2D = glTexSubImage2D;
|
||||
GR_GL_GET_PROC(Uniform1f);
|
||||
GR_GL_GET_PROC(Uniform1i);
|
||||
GR_GL_GET_PROC(Uniform1fv);
|
||||
|
@ -131,8 +130,8 @@ void GrGLSetDefaultGLInterface() {
|
|||
GR_GL_GET_PROC(UseProgram);
|
||||
GR_GL_GET_PROC(VertexAttrib4fv);
|
||||
GR_GL_GET_PROC(VertexAttribPointer);
|
||||
gDefaultInterface.fVertexPointer = glVertexPointer;
|
||||
gDefaultInterface.fViewport = glViewport;
|
||||
defaultInterface->fVertexPointer = glVertexPointer;
|
||||
defaultInterface->fViewport = glViewport;
|
||||
|
||||
// First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since
|
||||
// GL_ARB_framebuffer_object doesn't use ARB suffix.)
|
||||
|
@ -179,10 +178,7 @@ void GrGLSetDefaultGLInterface() {
|
|||
return;
|
||||
}
|
||||
GR_GL_GET_PROC(BindFragDataLocationIndexed);
|
||||
gDefaultInterface.fBindingsExported = kDesktop_GrGLBinding;
|
||||
|
||||
gDefaultInterfaceInit = true;
|
||||
defaultInterface->fBindingsExported = kDesktop_GrGLBinding;
|
||||
GrGLSetDefaultGLInterface(defaultInterface)->unref();
|
||||
}
|
||||
if (gDefaultInterfaceInit)
|
||||
GrGLSetGLInterface(&gDefaultInterface);
|
||||
}
|
||||
|
|
|
@ -14,15 +14,13 @@
|
|||
#include <GL/glext.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
#define GR_GL_GET_PROC(F) gDefaultInterface.f ## F = (GrGL ## F ## Proc) \
|
||||
#define GR_GL_GET_PROC(F) defaultInterface->f ## F = (GrGL ## F ## Proc) \
|
||||
glXGetProcAddress(reinterpret_cast<const GLubyte*>("gl" #F));
|
||||
#define GR_GL_GET_PROC_SUFFIX(F, S) gDefaultInterface.f ## F = (GrGL ## F ## Proc) \
|
||||
#define GR_GL_GET_PROC_SUFFIX(F, S) defaultInterface->f ## F = (GrGL ## F ## Proc) \
|
||||
glXGetProcAddress(reinterpret_cast<const GLubyte*>("gl" #F #S));
|
||||
|
||||
void GrGLSetDefaultGLInterface() {
|
||||
static GrGLInterface gDefaultInterface;
|
||||
static bool gDefaultInterfaceInit;
|
||||
if (!gDefaultInterfaceInit && NULL != glXGetCurrentContext()) {
|
||||
void GrGLInitializeDefaultGLInterface() {
|
||||
if (NULL != glXGetCurrentContext()) {
|
||||
int major, minor;
|
||||
const char* versionString = (const char*) glGetString(GL_VERSION);
|
||||
const char* extString = (const char*) glGetString(GL_EXTENSIONS);
|
||||
|
@ -33,82 +31,84 @@ void GrGLSetDefaultGLInterface() {
|
|||
return;
|
||||
}
|
||||
|
||||
gDefaultInterface.fNPOTRenderTargetSupport = kProbe_GrGLCapability;
|
||||
gDefaultInterface.fMinRenderTargetHeight = kProbe_GrGLCapability;
|
||||
gDefaultInterface.fMinRenderTargetWidth = kProbe_GrGLCapability;
|
||||
GrGLInterface* defaultInterface = new GrGLInterface();
|
||||
|
||||
gDefaultInterface.fActiveTexture = glActiveTexture;
|
||||
defaultInterface->fNPOTRenderTargetSupport = kProbe_GrGLCapability;
|
||||
defaultInterface->fMinRenderTargetHeight = kProbe_GrGLCapability;
|
||||
defaultInterface->fMinRenderTargetWidth = kProbe_GrGLCapability;
|
||||
|
||||
defaultInterface->fActiveTexture = glActiveTexture;
|
||||
GR_GL_GET_PROC(AttachShader);
|
||||
GR_GL_GET_PROC(BindAttribLocation);
|
||||
GR_GL_GET_PROC(BindBuffer);
|
||||
gDefaultInterface.fBindTexture = glBindTexture;
|
||||
gDefaultInterface.fBlendColor = glBlendColor;
|
||||
gDefaultInterface.fBlendFunc = glBlendFunc;
|
||||
defaultInterface->fBindTexture = glBindTexture;
|
||||
defaultInterface->fBlendColor = glBlendColor;
|
||||
defaultInterface->fBlendFunc = glBlendFunc;
|
||||
GR_GL_GET_PROC(BufferData);
|
||||
GR_GL_GET_PROC(BufferSubData);
|
||||
gDefaultInterface.fClear = glClear;
|
||||
gDefaultInterface.fClearColor = glClearColor;
|
||||
gDefaultInterface.fClearStencil = glClearStencil;
|
||||
gDefaultInterface.fClientActiveTexture = glClientActiveTexture;
|
||||
gDefaultInterface.fColorMask = glColorMask;
|
||||
gDefaultInterface.fColorPointer = glColorPointer;
|
||||
gDefaultInterface.fColor4ub = glColor4ub;
|
||||
defaultInterface->fClear = glClear;
|
||||
defaultInterface->fClearColor = glClearColor;
|
||||
defaultInterface->fClearStencil = glClearStencil;
|
||||
defaultInterface->fClientActiveTexture = glClientActiveTexture;
|
||||
defaultInterface->fColorMask = glColorMask;
|
||||
defaultInterface->fColorPointer = glColorPointer;
|
||||
defaultInterface->fColor4ub = glColor4ub;
|
||||
GR_GL_GET_PROC(CompileShader);
|
||||
gDefaultInterface.fCompressedTexImage2D = glCompressedTexImage2D;
|
||||
defaultInterface->fCompressedTexImage2D = glCompressedTexImage2D;
|
||||
GR_GL_GET_PROC(CreateProgram);
|
||||
GR_GL_GET_PROC(CreateShader);
|
||||
gDefaultInterface.fCullFace = glCullFace;
|
||||
defaultInterface->fCullFace = glCullFace;
|
||||
GR_GL_GET_PROC(DeleteBuffers);
|
||||
GR_GL_GET_PROC(DeleteProgram);
|
||||
GR_GL_GET_PROC(DeleteShader);
|
||||
gDefaultInterface.fDeleteTextures = glDeleteTextures;
|
||||
gDefaultInterface.fDepthMask = glDepthMask;
|
||||
gDefaultInterface.fDisable = glDisable;
|
||||
gDefaultInterface.fDisableClientState = glDisableClientState;
|
||||
defaultInterface->fDeleteTextures = glDeleteTextures;
|
||||
defaultInterface->fDepthMask = glDepthMask;
|
||||
defaultInterface->fDisable = glDisable;
|
||||
defaultInterface->fDisableClientState = glDisableClientState;
|
||||
GR_GL_GET_PROC(DisableVertexAttribArray);
|
||||
gDefaultInterface.fDrawArrays = glDrawArrays;
|
||||
gDefaultInterface.fDrawBuffer = glDrawBuffer;
|
||||
defaultInterface->fDrawArrays = glDrawArrays;
|
||||
defaultInterface->fDrawBuffer = glDrawBuffer;
|
||||
GR_GL_GET_PROC(DrawBuffers);
|
||||
gDefaultInterface.fDrawElements = glDrawElements;
|
||||
gDefaultInterface.fEnable = glEnable;
|
||||
gDefaultInterface.fEnableClientState = glEnableClientState;
|
||||
defaultInterface->fDrawElements = glDrawElements;
|
||||
defaultInterface->fEnable = glEnable;
|
||||
defaultInterface->fEnableClientState = glEnableClientState;
|
||||
GR_GL_GET_PROC(EnableVertexAttribArray);
|
||||
gDefaultInterface.fFrontFace = glFrontFace;
|
||||
defaultInterface->fFrontFace = glFrontFace;
|
||||
GR_GL_GET_PROC(GenBuffers);
|
||||
GR_GL_GET_PROC(GetBufferParameteriv);
|
||||
gDefaultInterface.fGetError = glGetError;
|
||||
gDefaultInterface.fGetIntegerv = glGetIntegerv;
|
||||
defaultInterface->fGetError = glGetError;
|
||||
defaultInterface->fGetIntegerv = glGetIntegerv;
|
||||
GR_GL_GET_PROC(GetProgramInfoLog);
|
||||
GR_GL_GET_PROC(GetProgramiv);
|
||||
GR_GL_GET_PROC(GetShaderInfoLog);
|
||||
GR_GL_GET_PROC(GetShaderiv);
|
||||
gDefaultInterface.fGetString = glGetString;
|
||||
gDefaultInterface.fGetTexLevelParameteriv = glGetTexLevelParameteriv;
|
||||
gDefaultInterface.fGenTextures = glGenTextures;
|
||||
defaultInterface->fGetString = glGetString;
|
||||
defaultInterface->fGetTexLevelParameteriv = glGetTexLevelParameteriv;
|
||||
defaultInterface->fGenTextures = glGenTextures;
|
||||
GR_GL_GET_PROC(GetUniformLocation);
|
||||
gDefaultInterface.fLineWidth = glLineWidth;
|
||||
defaultInterface->fLineWidth = glLineWidth;
|
||||
GR_GL_GET_PROC(LinkProgram);
|
||||
gDefaultInterface.fLoadMatrixf = glLoadMatrixf;
|
||||
defaultInterface->fLoadMatrixf = glLoadMatrixf;
|
||||
GR_GL_GET_PROC(MapBuffer);
|
||||
gDefaultInterface.fMatrixMode = glMatrixMode;
|
||||
gDefaultInterface.fPointSize = glPointSize;
|
||||
gDefaultInterface.fPixelStorei = glPixelStorei;
|
||||
gDefaultInterface.fReadBuffer = glReadBuffer;
|
||||
gDefaultInterface.fReadPixels = glReadPixels;
|
||||
gDefaultInterface.fScissor = glScissor;
|
||||
gDefaultInterface.fShadeModel = glShadeModel;
|
||||
defaultInterface->fMatrixMode = glMatrixMode;
|
||||
defaultInterface->fPointSize = glPointSize;
|
||||
defaultInterface->fPixelStorei = glPixelStorei;
|
||||
defaultInterface->fReadBuffer = glReadBuffer;
|
||||
defaultInterface->fReadPixels = glReadPixels;
|
||||
defaultInterface->fScissor = glScissor;
|
||||
defaultInterface->fShadeModel = glShadeModel;
|
||||
GR_GL_GET_PROC(ShaderSource);
|
||||
gDefaultInterface.fStencilFunc = glStencilFunc;
|
||||
defaultInterface->fStencilFunc = glStencilFunc;
|
||||
GR_GL_GET_PROC(StencilFuncSeparate);
|
||||
gDefaultInterface.fStencilMask = glStencilMask;
|
||||
defaultInterface->fStencilMask = glStencilMask;
|
||||
GR_GL_GET_PROC(StencilMaskSeparate);
|
||||
gDefaultInterface.fStencilOp = glStencilOp;
|
||||
defaultInterface->fStencilOp = glStencilOp;
|
||||
GR_GL_GET_PROC(StencilOpSeparate);
|
||||
gDefaultInterface.fTexCoordPointer = glTexCoordPointer;
|
||||
gDefaultInterface.fTexEnvi = glTexEnvi;
|
||||
gDefaultInterface.fTexImage2D = glTexImage2D;
|
||||
gDefaultInterface.fTexParameteri = glTexParameteri;
|
||||
gDefaultInterface.fTexSubImage2D = glTexSubImage2D;
|
||||
defaultInterface->fTexCoordPointer = glTexCoordPointer;
|
||||
defaultInterface->fTexEnvi = glTexEnvi;
|
||||
defaultInterface->fTexImage2D = glTexImage2D;
|
||||
defaultInterface->fTexParameteri = glTexParameteri;
|
||||
defaultInterface->fTexSubImage2D = glTexSubImage2D;
|
||||
GR_GL_GET_PROC(Uniform1f);
|
||||
GR_GL_GET_PROC(Uniform1i);
|
||||
GR_GL_GET_PROC(Uniform1fv);
|
||||
|
@ -132,8 +132,8 @@ void GrGLSetDefaultGLInterface() {
|
|||
GR_GL_GET_PROC(UseProgram);
|
||||
GR_GL_GET_PROC(VertexAttrib4fv);
|
||||
GR_GL_GET_PROC(VertexAttribPointer);
|
||||
gDefaultInterface.fVertexPointer = glVertexPointer;
|
||||
gDefaultInterface.fViewport = glViewport;
|
||||
defaultInterface->fVertexPointer = glVertexPointer;
|
||||
defaultInterface->fViewport = glViewport;
|
||||
GR_GL_GET_PROC(BindFragDataLocationIndexed);
|
||||
|
||||
// First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since
|
||||
|
@ -180,10 +180,8 @@ void GrGLSetDefaultGLInterface() {
|
|||
// we must have FBOs
|
||||
return;
|
||||
}
|
||||
gDefaultInterface.fBindingsExported = kDesktop_GrGLBinding;
|
||||
defaultInterface->fBindingsExported = kDesktop_GrGLBinding;
|
||||
|
||||
gDefaultInterfaceInit = true;
|
||||
GrGLSetDefaultGLInterface(defaultInterface)->unref();
|
||||
}
|
||||
if (gDefaultInterfaceInit)
|
||||
GrGLSetGLInterface(&gDefaultInterface);
|
||||
}
|
||||
|
|
|
@ -18,179 +18,173 @@
|
|||
* Otherwise, a springboard would be needed that hides the calling convention.
|
||||
*/
|
||||
|
||||
#define GR_GL_GET_PROC(F) gDefaultInterface.f ## F = (GrGL ## F ## Proc) wglGetProcAddress("gl" #F);
|
||||
#define GR_GL_GET_PROC_SUFFIX(F, S) gDefaultInterface.f ## F = (GrGL ## F ## Proc) wglGetProcAddress("gl" #F #S);
|
||||
#define GR_GL_GET_PROC(F) defaultInterface->f ## F = (GrGL ## F ## Proc) wglGetProcAddress("gl" #F);
|
||||
#define GR_GL_GET_PROC_SUFFIX(F, S) defaultInterface->f ## F = (GrGL ## F ## Proc) wglGetProcAddress("gl" #F #S);
|
||||
|
||||
void GrGLSetDefaultGLInterface() {
|
||||
static GrGLInterface gDefaultInterface;
|
||||
static bool gDefaultInterfaceInit;
|
||||
if (!gDefaultInterfaceInit) {
|
||||
void GrGLInitializeDefaultGLInterface() {
|
||||
|
||||
// wglGetProcAddress requires a context.
|
||||
if (NULL != wglGetCurrentContext()) {
|
||||
int major, minor;
|
||||
const char* versionString = (const char*) glGetString(GL_VERSION);
|
||||
const char* extString = (const char*) glGetString(GL_EXTENSIONS);
|
||||
gl_version_from_string(&major, &minor, versionString);
|
||||
// wglGetProcAddress requires a context.
|
||||
if (NULL != wglGetCurrentContext()) {
|
||||
int major, minor;
|
||||
const char* versionString = (const char*) glGetString(GL_VERSION);
|
||||
const char* extString = (const char*) glGetString(GL_EXTENSIONS);
|
||||
gl_version_from_string(&major, &minor, versionString);
|
||||
|
||||
if (major == 1 && minor < 5) {
|
||||
// We must have array and element_array buffer objects.
|
||||
return;
|
||||
}
|
||||
|
||||
gDefaultInterface.fNPOTRenderTargetSupport = kProbe_GrGLCapability;
|
||||
gDefaultInterface.fMinRenderTargetHeight = kProbe_GrGLCapability;
|
||||
gDefaultInterface.fMinRenderTargetWidth = kProbe_GrGLCapability;
|
||||
|
||||
// Functions that are part of GL 1.1 will return NULL in
|
||||
// wglGetProcAddress
|
||||
gDefaultInterface.fBlendFunc = glBlendFunc;
|
||||
gDefaultInterface.fClear = glClear;
|
||||
gDefaultInterface.fClearColor = glClearColor;
|
||||
gDefaultInterface.fClearStencil = glClearStencil;
|
||||
gDefaultInterface.fColor4ub = glColor4ub;
|
||||
gDefaultInterface.fColorMask = glColorMask;
|
||||
gDefaultInterface.fColorPointer = glColorPointer;
|
||||
gDefaultInterface.fCullFace = glCullFace;
|
||||
gDefaultInterface.fDeleteTextures = glDeleteTextures;
|
||||
gDefaultInterface.fDepthMask = glDepthMask;
|
||||
gDefaultInterface.fDisable = glDisable;
|
||||
gDefaultInterface.fDisableClientState = glDisableClientState;
|
||||
gDefaultInterface.fDrawArrays = glDrawArrays;
|
||||
gDefaultInterface.fDrawBuffer = glDrawBuffer;
|
||||
gDefaultInterface.fDrawElements = glDrawElements;
|
||||
gDefaultInterface.fEnable = glEnable;
|
||||
gDefaultInterface.fEnableClientState = glEnableClientState;
|
||||
gDefaultInterface.fFrontFace = glFrontFace;
|
||||
gDefaultInterface.fGenTextures = glGenTextures;
|
||||
gDefaultInterface.fGetError = glGetError;
|
||||
gDefaultInterface.fGetIntegerv = glGetIntegerv;
|
||||
gDefaultInterface.fGetString = glGetString;
|
||||
gDefaultInterface.fGetTexLevelParameteriv = glGetTexLevelParameteriv;
|
||||
gDefaultInterface.fLineWidth = glLineWidth;
|
||||
gDefaultInterface.fLoadMatrixf = glLoadMatrixf;
|
||||
gDefaultInterface.fMatrixMode = glMatrixMode;
|
||||
gDefaultInterface.fPixelStorei = glPixelStorei;
|
||||
gDefaultInterface.fPointSize = glPointSize;
|
||||
gDefaultInterface.fReadBuffer = glReadBuffer;
|
||||
gDefaultInterface.fReadPixels = glReadPixels;
|
||||
gDefaultInterface.fScissor = glScissor;
|
||||
gDefaultInterface.fShadeModel = glShadeModel;
|
||||
gDefaultInterface.fStencilFunc = glStencilFunc;
|
||||
gDefaultInterface.fStencilMask = glStencilMask;
|
||||
gDefaultInterface.fStencilOp = glStencilOp;
|
||||
gDefaultInterface.fTexImage2D = glTexImage2D;
|
||||
gDefaultInterface.fTexParameteri = glTexParameteri;
|
||||
gDefaultInterface.fTexCoordPointer = glTexCoordPointer;
|
||||
gDefaultInterface.fTexEnvi = glTexEnvi;
|
||||
gDefaultInterface.fTexSubImage2D = glTexSubImage2D;
|
||||
gDefaultInterface.fViewport = glViewport;
|
||||
gDefaultInterface.fVertexPointer = glVertexPointer;
|
||||
|
||||
GR_GL_GET_PROC(ActiveTexture);
|
||||
GR_GL_GET_PROC(AttachShader);
|
||||
GR_GL_GET_PROC(BindAttribLocation);
|
||||
GR_GL_GET_PROC(BindBuffer);
|
||||
GR_GL_GET_PROC(BindTexture);
|
||||
GR_GL_GET_PROC(BlendColor);
|
||||
GR_GL_GET_PROC(BufferData);
|
||||
GR_GL_GET_PROC(BufferSubData);
|
||||
GR_GL_GET_PROC(ClientActiveTexture);
|
||||
GR_GL_GET_PROC(CompileShader);
|
||||
GR_GL_GET_PROC(CompressedTexImage2D);
|
||||
GR_GL_GET_PROC(CreateProgram);
|
||||
GR_GL_GET_PROC(CreateShader);
|
||||
GR_GL_GET_PROC(DeleteBuffers);
|
||||
GR_GL_GET_PROC(DeleteProgram);
|
||||
GR_GL_GET_PROC(DeleteShader);
|
||||
GR_GL_GET_PROC(DisableVertexAttribArray);
|
||||
GR_GL_GET_PROC(DrawBuffers);
|
||||
GR_GL_GET_PROC(EnableVertexAttribArray);
|
||||
GR_GL_GET_PROC(GenBuffers);
|
||||
GR_GL_GET_PROC(GetBufferParameteriv);
|
||||
GR_GL_GET_PROC(GetProgramInfoLog);
|
||||
GR_GL_GET_PROC(GetProgramiv);
|
||||
GR_GL_GET_PROC(GetShaderInfoLog);
|
||||
GR_GL_GET_PROC(GetShaderiv);
|
||||
GR_GL_GET_PROC(GetUniformLocation);
|
||||
GR_GL_GET_PROC(LinkProgram);
|
||||
GR_GL_GET_PROC(ShaderSource);
|
||||
GR_GL_GET_PROC(StencilFuncSeparate);
|
||||
GR_GL_GET_PROC(StencilMaskSeparate);
|
||||
GR_GL_GET_PROC(StencilOpSeparate);
|
||||
GR_GL_GET_PROC(Uniform1f);
|
||||
GR_GL_GET_PROC(Uniform1i);
|
||||
GR_GL_GET_PROC(Uniform1fv);
|
||||
GR_GL_GET_PROC(Uniform1iv);
|
||||
GR_GL_GET_PROC(Uniform2f);
|
||||
GR_GL_GET_PROC(Uniform2i);
|
||||
GR_GL_GET_PROC(Uniform2fv);
|
||||
GR_GL_GET_PROC(Uniform2iv);
|
||||
GR_GL_GET_PROC(Uniform3f);
|
||||
GR_GL_GET_PROC(Uniform3i);
|
||||
GR_GL_GET_PROC(Uniform3fv);
|
||||
GR_GL_GET_PROC(Uniform3iv);
|
||||
GR_GL_GET_PROC(Uniform4f);
|
||||
GR_GL_GET_PROC(Uniform4i);
|
||||
GR_GL_GET_PROC(Uniform4fv);
|
||||
GR_GL_GET_PROC(Uniform4iv);
|
||||
GR_GL_GET_PROC(UniformMatrix2fv);
|
||||
GR_GL_GET_PROC(UniformMatrix3fv);
|
||||
GR_GL_GET_PROC(UniformMatrix4fv);
|
||||
GR_GL_GET_PROC(UseProgram);
|
||||
GR_GL_GET_PROC(VertexAttrib4fv);
|
||||
GR_GL_GET_PROC(VertexAttribPointer);
|
||||
GR_GL_GET_PROC(BindFragDataLocationIndexed);
|
||||
|
||||
// First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since
|
||||
// GL_ARB_framebuffer_object doesn't use ARB suffix.)
|
||||
if (major >= 3 || has_gl_extension_from_string("GL_ARB_framebuffer_object", extString)) {
|
||||
GR_GL_GET_PROC(GenFramebuffers);
|
||||
GR_GL_GET_PROC(GetFramebufferAttachmentParameteriv);
|
||||
GR_GL_GET_PROC(GetRenderbufferParameteriv);
|
||||
GR_GL_GET_PROC(BindFramebuffer);
|
||||
GR_GL_GET_PROC(FramebufferTexture2D);
|
||||
GR_GL_GET_PROC(CheckFramebufferStatus);
|
||||
GR_GL_GET_PROC(DeleteFramebuffers);
|
||||
GR_GL_GET_PROC(RenderbufferStorage);
|
||||
GR_GL_GET_PROC(GenRenderbuffers);
|
||||
GR_GL_GET_PROC(DeleteRenderbuffers);
|
||||
GR_GL_GET_PROC(FramebufferRenderbuffer);
|
||||
GR_GL_GET_PROC(BindRenderbuffer);
|
||||
GR_GL_GET_PROC(RenderbufferStorageMultisample);
|
||||
GR_GL_GET_PROC(BlitFramebuffer);
|
||||
} else if (has_gl_extension_from_string("GL_EXT_framebuffer_object", extString)) {
|
||||
GR_GL_GET_PROC_SUFFIX(GenFramebuffers, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(BindFramebuffer, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(FramebufferTexture2D, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(CheckFramebufferStatus, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(DeleteFramebuffers, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(RenderbufferStorage, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(GenRenderbuffers, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(DeleteRenderbuffers, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(BindRenderbuffer, EXT);
|
||||
if (has_gl_extension_from_string("GL_EXT_framebuffer_multisample", extString)) {
|
||||
GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT);
|
||||
}
|
||||
if (has_gl_extension_from_string("GL_EXT_framebuffer_blit", extString)) {
|
||||
GR_GL_GET_PROC_SUFFIX(BlitFramebuffer, EXT);
|
||||
}
|
||||
} else {
|
||||
// we must have FBOs
|
||||
return;
|
||||
}
|
||||
GR_GL_GET_PROC(MapBuffer);
|
||||
GR_GL_GET_PROC(UnmapBuffer);
|
||||
|
||||
gDefaultInterface.fBindingsExported = kDesktop_GrGLBinding;
|
||||
|
||||
gDefaultInterfaceInit = true;
|
||||
if (major == 1 && minor < 5) {
|
||||
// We must have array and element_array buffer objects.
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (gDefaultInterfaceInit) {
|
||||
GrGLSetGLInterface(&gDefaultInterface);
|
||||
GrGLInterface* defaultInterface = new GrGLInterface();
|
||||
|
||||
defaultInterface->fNPOTRenderTargetSupport = kProbe_GrGLCapability;
|
||||
defaultInterface->fMinRenderTargetHeight = kProbe_GrGLCapability;
|
||||
defaultInterface->fMinRenderTargetWidth = kProbe_GrGLCapability;
|
||||
|
||||
// Functions that are part of GL 1.1 will return NULL in
|
||||
// wglGetProcAddress
|
||||
defaultInterface->fBlendFunc = glBlendFunc;
|
||||
defaultInterface->fClear = glClear;
|
||||
defaultInterface->fClearColor = glClearColor;
|
||||
defaultInterface->fClearStencil = glClearStencil;
|
||||
defaultInterface->fColor4ub = glColor4ub;
|
||||
defaultInterface->fColorMask = glColorMask;
|
||||
defaultInterface->fColorPointer = glColorPointer;
|
||||
defaultInterface->fCullFace = glCullFace;
|
||||
defaultInterface->fDeleteTextures = glDeleteTextures;
|
||||
defaultInterface->fDepthMask = glDepthMask;
|
||||
defaultInterface->fDisable = glDisable;
|
||||
defaultInterface->fDisableClientState = glDisableClientState;
|
||||
defaultInterface->fDrawArrays = glDrawArrays;
|
||||
defaultInterface->fDrawElements = glDrawElements;
|
||||
defaultInterface->fDrawBuffer = glDrawBuffer;
|
||||
defaultInterface->fEnable = glEnable;
|
||||
defaultInterface->fEnableClientState = glEnableClientState;
|
||||
defaultInterface->fFrontFace = glFrontFace;
|
||||
defaultInterface->fGenTextures = glGenTextures;
|
||||
defaultInterface->fGetError = glGetError;
|
||||
defaultInterface->fGetIntegerv = glGetIntegerv;
|
||||
defaultInterface->fGetString = glGetString;
|
||||
defaultInterface->fGetTexLevelParameteriv = glGetTexLevelParameteriv;
|
||||
defaultInterface->fLineWidth = glLineWidth;
|
||||
defaultInterface->fLoadMatrixf = glLoadMatrixf;
|
||||
defaultInterface->fMatrixMode = glMatrixMode;
|
||||
defaultInterface->fPixelStorei = glPixelStorei;
|
||||
defaultInterface->fPointSize = glPointSize;
|
||||
defaultInterface->fReadBuffer = glReadBuffer;
|
||||
defaultInterface->fReadPixels = glReadPixels;
|
||||
defaultInterface->fScissor = glScissor;
|
||||
defaultInterface->fShadeModel = glShadeModel;
|
||||
defaultInterface->fStencilFunc = glStencilFunc;
|
||||
defaultInterface->fStencilMask = glStencilMask;
|
||||
defaultInterface->fStencilOp = glStencilOp;
|
||||
defaultInterface->fTexImage2D = glTexImage2D;
|
||||
defaultInterface->fTexParameteri = glTexParameteri;
|
||||
defaultInterface->fTexCoordPointer = glTexCoordPointer;
|
||||
defaultInterface->fTexEnvi = glTexEnvi;
|
||||
defaultInterface->fTexSubImage2D = glTexSubImage2D;
|
||||
defaultInterface->fViewport = glViewport;
|
||||
defaultInterface->fVertexPointer = glVertexPointer;
|
||||
|
||||
GR_GL_GET_PROC(ActiveTexture);
|
||||
GR_GL_GET_PROC(AttachShader);
|
||||
GR_GL_GET_PROC(BindAttribLocation);
|
||||
GR_GL_GET_PROC(BindBuffer);
|
||||
GR_GL_GET_PROC(BindTexture);
|
||||
GR_GL_GET_PROC(BlendColor);
|
||||
GR_GL_GET_PROC(BufferData);
|
||||
GR_GL_GET_PROC(BufferSubData);
|
||||
GR_GL_GET_PROC(ClientActiveTexture);
|
||||
GR_GL_GET_PROC(CompileShader);
|
||||
GR_GL_GET_PROC(CompressedTexImage2D);
|
||||
GR_GL_GET_PROC(CreateProgram);
|
||||
GR_GL_GET_PROC(CreateShader);
|
||||
GR_GL_GET_PROC(DeleteBuffers);
|
||||
GR_GL_GET_PROC(DeleteProgram);
|
||||
GR_GL_GET_PROC(DeleteShader);
|
||||
GR_GL_GET_PROC(DisableVertexAttribArray);
|
||||
GR_GL_GET_PROC(DrawBuffers);
|
||||
GR_GL_GET_PROC(EnableVertexAttribArray);
|
||||
GR_GL_GET_PROC(GenBuffers);
|
||||
GR_GL_GET_PROC(GetBufferParameteriv);
|
||||
GR_GL_GET_PROC(GetProgramInfoLog);
|
||||
GR_GL_GET_PROC(GetProgramiv);
|
||||
GR_GL_GET_PROC(GetShaderInfoLog);
|
||||
GR_GL_GET_PROC(GetShaderiv);
|
||||
GR_GL_GET_PROC(GetUniformLocation);
|
||||
GR_GL_GET_PROC(LinkProgram);
|
||||
GR_GL_GET_PROC(ShaderSource);
|
||||
GR_GL_GET_PROC(StencilFuncSeparate);
|
||||
GR_GL_GET_PROC(StencilMaskSeparate);
|
||||
GR_GL_GET_PROC(StencilOpSeparate);
|
||||
GR_GL_GET_PROC(Uniform1f);
|
||||
GR_GL_GET_PROC(Uniform1i);
|
||||
GR_GL_GET_PROC(Uniform1fv);
|
||||
GR_GL_GET_PROC(Uniform1iv);
|
||||
GR_GL_GET_PROC(Uniform2f);
|
||||
GR_GL_GET_PROC(Uniform2i);
|
||||
GR_GL_GET_PROC(Uniform2fv);
|
||||
GR_GL_GET_PROC(Uniform2iv);
|
||||
GR_GL_GET_PROC(Uniform3f);
|
||||
GR_GL_GET_PROC(Uniform3i);
|
||||
GR_GL_GET_PROC(Uniform3fv);
|
||||
GR_GL_GET_PROC(Uniform3iv);
|
||||
GR_GL_GET_PROC(Uniform4f);
|
||||
GR_GL_GET_PROC(Uniform4i);
|
||||
GR_GL_GET_PROC(Uniform4fv);
|
||||
GR_GL_GET_PROC(Uniform4iv);
|
||||
GR_GL_GET_PROC(UniformMatrix2fv);
|
||||
GR_GL_GET_PROC(UniformMatrix3fv);
|
||||
GR_GL_GET_PROC(UniformMatrix4fv);
|
||||
GR_GL_GET_PROC(UseProgram);
|
||||
GR_GL_GET_PROC(VertexAttrib4fv);
|
||||
GR_GL_GET_PROC(VertexAttribPointer);
|
||||
GR_GL_GET_PROC(BindFragDataLocationIndexed);
|
||||
|
||||
// First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since
|
||||
// GL_ARB_framebuffer_object doesn't use ARB suffix.)
|
||||
if (major >= 3 || has_gl_extension_from_string("GL_ARB_framebuffer_object", extString)) {
|
||||
GR_GL_GET_PROC(GenFramebuffers);
|
||||
GR_GL_GET_PROC(GetFramebufferAttachmentParameteriv);
|
||||
GR_GL_GET_PROC(GetRenderbufferParameteriv);
|
||||
GR_GL_GET_PROC(BindFramebuffer);
|
||||
GR_GL_GET_PROC(FramebufferTexture2D);
|
||||
GR_GL_GET_PROC(CheckFramebufferStatus);
|
||||
GR_GL_GET_PROC(DeleteFramebuffers);
|
||||
GR_GL_GET_PROC(RenderbufferStorage);
|
||||
GR_GL_GET_PROC(GenRenderbuffers);
|
||||
GR_GL_GET_PROC(DeleteRenderbuffers);
|
||||
GR_GL_GET_PROC(FramebufferRenderbuffer);
|
||||
GR_GL_GET_PROC(BindRenderbuffer);
|
||||
GR_GL_GET_PROC(RenderbufferStorageMultisample);
|
||||
GR_GL_GET_PROC(BlitFramebuffer);
|
||||
} else if (has_gl_extension_from_string("GL_EXT_framebuffer_object", extString)) {
|
||||
GR_GL_GET_PROC_SUFFIX(GenFramebuffers, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(BindFramebuffer, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(FramebufferTexture2D, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(CheckFramebufferStatus, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(DeleteFramebuffers, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(RenderbufferStorage, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(GenRenderbuffers, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(DeleteRenderbuffers, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT);
|
||||
GR_GL_GET_PROC_SUFFIX(BindRenderbuffer, EXT);
|
||||
if (has_gl_extension_from_string("GL_EXT_framebuffer_multisample", extString)) {
|
||||
GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT);
|
||||
}
|
||||
if (has_gl_extension_from_string("GL_EXT_framebuffer_blit", extString)) {
|
||||
GR_GL_GET_PROC_SUFFIX(BlitFramebuffer, EXT);
|
||||
}
|
||||
} else {
|
||||
// we must have FBOs
|
||||
return;
|
||||
}
|
||||
GR_GL_GET_PROC(MapBuffer);
|
||||
GR_GL_GET_PROC(UnmapBuffer);
|
||||
|
||||
defaultInterface->fBindingsExported = kDesktop_GrGLBinding;
|
||||
|
||||
GrGLSetDefaultGLInterface(defaultInterface)->unref();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,6 +146,7 @@
|
|||
'../gpu/src/GrGLProgram.h',
|
||||
'../gpu/src/GrGLRenderTarget.cpp',
|
||||
'../gpu/src/GrGLRenderTarget.h',
|
||||
'../gpu/src/GrGLStencilBuffer.cpp',
|
||||
'../gpu/src/GrGLStencilBuffer.h',
|
||||
'../gpu/src/GrGLTexture.cpp',
|
||||
'../gpu/src/GrGLTexture.h',
|
||||
|
|
|
@ -153,10 +153,12 @@ public:
|
|||
desc.fWidth = SkScalarRound(win->width());
|
||||
desc.fHeight = SkScalarRound(win->height());
|
||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||
GR_GL_GetIntegerv(GR_GL_STENCIL_BITS, &desc.fStencilBits);
|
||||
GR_GL_GetIntegerv(GR_GL_SAMPLES, &desc.fSampleCnt);
|
||||
const GrGLInterface* gl = GrGLGetDefaultGLInterface();
|
||||
GrAssert(NULL != gl);
|
||||
GR_GL_GetIntegerv(gl, GR_GL_STENCIL_BITS, &desc.fStencilBits);
|
||||
GR_GL_GetIntegerv(gl, GR_GL_SAMPLES, &desc.fSampleCnt);
|
||||
GrGLint buffer;
|
||||
GR_GL_GetIntegerv(GR_GL_FRAMEBUFFER_BINDING, &buffer);
|
||||
GR_GL_GetIntegerv(gl, GR_GL_FRAMEBUFFER_BINDING, &buffer);
|
||||
desc.fPlatformRenderTarget = buffer;
|
||||
|
||||
SkSafeUnref(fGrRenderTarget);
|
||||
|
|
Загрузка…
Ссылка в новой задаче