diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index 497f9389f..2405679c0 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -615,7 +615,7 @@ enum GrGLBackendState { kStencil_GrGLBackendState = 1 << 6, kPixelStore_GrGLBackendState = 1 << 7, kProgram_GrGLBackendState = 1 << 8, - kPathStencil_GrGLBackendState = 1 << 9, + kFixedFunction_GrGLBackendState = 1 << 9, kMisc_GrGLBackendState = 1 << 10, kALL_GrGLBackendState = 0xffff }; diff --git a/include/gpu/gl/GrGLFunctions.h b/include/gpu/gl/GrGLFunctions.h index b30ef3ad4..b949d1d39 100644 --- a/include/gpu/gl/GrGLFunctions.h +++ b/include/gpu/gl/GrGLFunctions.h @@ -61,6 +61,7 @@ extern "C" { typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLClearProc)(GrGLbitfield mask); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLClearColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLClearStencilProc)(GrGLint s); + typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLClientActiveTextureProc)(GrGLenum texture); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLColorMaskProc)(GrGLboolean red, GrGLboolean green, GrGLboolean blue, GrGLboolean alpha); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLCompileShaderProc)(GrGLuint shader); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLCompressedTexImage2DProc)(GrGLenum target, GrGLint level, GrGLenum internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLsizei imageSize, const GrGLvoid* data); @@ -78,12 +79,14 @@ extern "C" { typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDeleteVertexArraysProc)(GrGLsizei n, const GrGLuint *arrays); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDepthMaskProc)(GrGLboolean flag); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDisableProc)(GrGLenum cap); + typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDisableClientStateProc)(GrGLenum cap); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDisableVertexAttribArrayProc)(GrGLuint index); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDrawArraysProc)(GrGLenum mode, GrGLint first, GrGLsizei count); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDrawBufferProc)(GrGLenum mode); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDrawBuffersProc)(GrGLsizei n, const GrGLenum* bufs); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDrawElementsProc)(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLEnableProc)(GrGLenum cap); + typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLEnableClientStateProc)(GrGLenum cap); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLEnableVertexAttribArrayProc)(GrGLuint index); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLEndQueryProc)(GrGLenum target); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLFinishProc)(); @@ -140,6 +143,9 @@ extern "C" { typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLStencilMaskSeparateProc)(GrGLenum face, GrGLuint mask); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLStencilOpProc)(GrGLenum fail, GrGLenum zfail, GrGLenum zpass); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLStencilOpSeparateProc)(GrGLenum face, GrGLenum fail, GrGLenum zfail, GrGLenum zpass); + typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexGenfProc)(GrGLenum coord, GrGLenum pname, GrGLfloat param); + typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexGenfvProc)(GrGLenum coord, GrGLenum pname, const GrGLfloat* params); + typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexGeniProc)(GrGLenum coord, GrGLenum pname, GrGLint param); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexImage2DProc)(GrGLenum target, GrGLint level, GrGLint internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLenum format, GrGLenum type, const GrGLvoid* pixels); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexParameteriProc)(GrGLenum target, GrGLenum pname, GrGLint param); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexParameterivProc)(GrGLenum target, GrGLenum pname, const GrGLint* params); @@ -169,6 +175,7 @@ extern "C" { typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLUseProgramProc)(GrGLuint program); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLVertexAttrib4fvProc)(GrGLuint indx, const GrGLfloat* values); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLVertexAttribPointerProc)(GrGLuint indx, GrGLint size, GrGLenum type, GrGLboolean normalized, GrGLsizei stride, const GrGLvoid* ptr); + typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLVertexPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLViewportProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height); // Experimental: Functions for GL_NV_path_rendering. These will be diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h index 3b388f5b2..4f2e3c4b4 100644 --- a/include/gpu/gl/GrGLInterface.h +++ b/include/gpu/gl/GrGLInterface.h @@ -159,6 +159,7 @@ public: GLPtr fClear; GLPtr fClearColor; GLPtr fClearStencil; + GLPtr fClientActiveTexture; GLPtr fColorMask; GLPtr fCompileShader; GLPtr fCompressedTexImage2D; @@ -176,12 +177,14 @@ public: GLPtr fDeleteVertexArrays; GLPtr fDepthMask; GLPtr fDisable; + GLPtr fDisableClientState; GLPtr fDisableVertexAttribArray; GLPtr fDrawArrays; GLPtr fDrawBuffer; GLPtr fDrawBuffers; GLPtr fDrawElements; GLPtr fEnable; + GLPtr fEnableClientState; GLPtr fEnableVertexAttribArray; GLPtr fEndQuery; GLPtr fFinish; @@ -234,6 +237,9 @@ public: GLPtr fStencilMaskSeparate; GLPtr fStencilOp; GLPtr fStencilOpSeparate; + GLPtr fTexGenf; + GLPtr fTexGenfv; + GLPtr fTexGeni; GLPtr fTexImage2D; GLPtr fTexParameteri; GLPtr fTexParameteriv; @@ -263,6 +269,7 @@ public: GLPtr fUseProgram; GLPtr fVertexAttrib4fv; GLPtr fVertexAttribPointer; + GLPtr fVertexPointer; GLPtr fViewport; // Experimental: Functions for GL_NV_path_rendering. These will be diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index e2ecfd71f..a6740cc51 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -29,6 +29,7 @@ void GrGLCaps::reset() { fMaxFragmentUniformVectors = 0; fMaxVertexAttributes = 0; fMaxFragmentTextureUnits = 0; + fMaxFixedFunctionTextureCoords = 0; fRGBA8RenderbufferSupport = false; fBGRAFormatSupport = false; fBGRAIsInternalFormat = false; @@ -61,6 +62,7 @@ GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) { fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors; fMaxVertexAttributes = caps.fMaxVertexAttributes; fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits; + fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords; fMSFBOType = caps.fMSFBOType; fCoverageAAType = caps.fCoverageAAType; fMSAACoverageModes = caps.fMSAACoverageModes; @@ -109,6 +111,16 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { GrGLint max; GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max); fMaxFragmentUniformVectors = max / 4; + if (version >= GR_GL_VER(3, 2)) { + GrGLint profileMask; + GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask); + fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT); + } + if (!fIsCoreProfile) { + GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_COORDS, &fMaxFixedFunctionTextureCoords); + // Sanity check + SkASSERT(fMaxFixedFunctionTextureCoords > 0 && fMaxFixedFunctionTextureCoords < 128); + } } GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes); GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUnits); @@ -210,12 +222,6 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { fUseNonVBOVertexAndIndexDynamicData = true; } - if (kDesktop_GrGLBinding == binding && version >= GR_GL_VER(3, 2)) { - GrGLint profileMask; - GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask); - fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT); - } - fDiscardFBSupport = ctxInfo.hasExtension("GL_EXT_discard_framebuffer"); if (kDesktop_GrGLBinding == binding) { diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 0b625a5a3..79251b264 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -221,6 +221,9 @@ public: /// maximum number of texture units accessible in the fragment shader. int maxFragmentTextureUnits() const { return fMaxFragmentTextureUnits; } + /// maximum number of fixed-function texture coords, or zero if no fixed-function. + int maxFixedFunctionTextureCoords() const { return fMaxFixedFunctionTextureCoords; } + /// ES requires an extension to support RGBA8 in RenderBufferStorage bool rgba8RenderbufferSupport() const { return fRGBA8RenderbufferSupport; } @@ -336,6 +339,7 @@ private: int fMaxFragmentUniformVectors; int fMaxVertexAttributes; int fMaxFragmentTextureUnits; + int fMaxFixedFunctionTextureCoords; MSFBOType fMSFBOType; CoverageAAType fCoverageAAType; diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp index d080cce83..c169b1ce3 100644 --- a/src/gpu/gl/GrGLCreateNullInterface.cpp +++ b/src/gpu/gl/GrGLCreateNullInterface.cpp @@ -100,6 +100,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE nullGLBeginQuery(GrGLenum target, GrGLuint id) {} GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindAttribLocation(GrGLuint program, GrGLuint index, const char* name) {} GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindTexture(GrGLenum target, GrGLuint texture) {} GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindVertexArray(GrGLuint id) {} +GrGLvoid GR_GL_FUNCTION_TYPE nullGLClientActiveTexture(GrGLenum) {} GrGLvoid GR_GL_FUNCTION_TYPE nullGLGenBuffers(GrGLsizei n, GrGLuint* ids) { @@ -281,6 +282,7 @@ const GrGLInterface* GrGLCreateNullInterface() { interface->fClear = noOpGLClear; interface->fClearColor = noOpGLClearColor; interface->fClearStencil = noOpGLClearStencil; + interface->fClientActiveTexture = nullGLClientActiveTexture; interface->fColorMask = noOpGLColorMask; interface->fCompileShader = noOpGLCompileShader; interface->fCompressedTexImage2D = noOpGLCompressedTexImage2D; @@ -296,12 +298,14 @@ const GrGLInterface* GrGLCreateNullInterface() { interface->fDeleteVertexArrays = noOpGLDeleteIds; interface->fDepthMask = noOpGLDepthMask; interface->fDisable = noOpGLDisable; + interface->fDisableClientState = noOpGLDisableClientState; interface->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray; interface->fDrawArrays = noOpGLDrawArrays; interface->fDrawBuffer = noOpGLDrawBuffer; interface->fDrawBuffers = noOpGLDrawBuffers; interface->fDrawElements = noOpGLDrawElements; interface->fEnable = noOpGLEnable; + interface->fEnableClientState = noOpGLEnableClientState; interface->fEnableVertexAttribArray = noOpGLEnableVertexAttribArray; interface->fEndQuery = noOpGLEndQuery; interface->fFinish = noOpGLFinish; @@ -328,8 +332,11 @@ const GrGLInterface* GrGLCreateNullInterface() { interface->fGetStringi = noOpGLGetStringi; interface->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv; interface->fGetUniformLocation = noOpGLGetUniformLocation; + interface->fLoadIdentity = noOpGLLoadIdentity; + interface->fLoadMatrixf = noOpGLLoadMatrixf; interface->fLineWidth = noOpGLLineWidth; interface->fLinkProgram = noOpGLLinkProgram; + interface->fMatrixMode = noOpGLMatrixMode; interface->fPixelStorei = nullGLPixelStorei; interface->fQueryCounter = noOpGLQueryCounter; interface->fReadBuffer = noOpGLReadBuffer; @@ -342,6 +349,9 @@ const GrGLInterface* GrGLCreateNullInterface() { interface->fStencilMaskSeparate = noOpGLStencilMaskSeparate; interface->fStencilOp = noOpGLStencilOp; interface->fStencilOpSeparate = noOpGLStencilOpSeparate; + interface->fTexGenf = noOpGLTexGenf; + interface->fTexGenfv = noOpGLTexGenfv; + interface->fTexGeni = noOpGLTexGeni; interface->fTexImage2D = noOpGLTexImage2D; interface->fTexParameteri = noOpGLTexParameteri; interface->fTexParameteriv = noOpGLTexParameteriv; @@ -370,6 +380,7 @@ const GrGLInterface* GrGLCreateNullInterface() { interface->fUseProgram = nullGLUseProgram; interface->fVertexAttrib4fv = noOpGLVertexAttrib4fv; interface->fVertexAttribPointer = noOpGLVertexAttribPointer; + interface->fVertexPointer = noOpGLVertexPointer; interface->fViewport = nullGLViewport; interface->fBindFramebuffer = nullGLBindFramebuffer; interface->fBindRenderbuffer = nullGLBindRenderbuffer; diff --git a/src/gpu/gl/GrGLDefines.h b/src/gpu/gl/GrGLDefines.h index 2ab957081..a84395326 100644 --- a/src/gpu/gl/GrGLDefines.h +++ b/src/gpu/gl/GrGLDefines.h @@ -439,6 +439,7 @@ #define GR_GL_TEXTURE31 0x84DF #define GR_GL_ACTIVE_TEXTURE 0x84E0 #define GR_GL_MAX_TEXTURE_UNITS 0x84E2 +#define GR_GL_MAX_TEXTURE_COORDS 0x8871 /* TextureWrapMode */ #define GR_GL_REPEAT 0x2901 @@ -464,6 +465,8 @@ #define GR_GL_TEXTURE_ENV_COLOR 0x2201 #define GR_GL_TEXTURE_GEN_S 0x0C60 #define GR_GL_TEXTURE_GEN_T 0x0C61 +#define GR_GL_TEXTURE_GEN_R 0x0C62 +#define GR_GL_TEXTURE_GEN_Q 0x0C63 #define GR_GL_TEXTURE_GEN_MODE 0x2500 #define GR_GL_TEXTURE_BORDER_COLOR 0x1004 #define GR_GL_TEXTURE_WIDTH 0x1000 diff --git a/src/gpu/gl/GrGLInterface.cpp b/src/gpu/gl/GrGLInterface.cpp index a5ddd9f83..38a7f9d7f 100644 --- a/src/gpu/gl/GrGLInterface.cpp +++ b/src/gpu/gl/GrGLInterface.cpp @@ -44,6 +44,16 @@ bool GrGLInterface::validate(GrGLBinding binding) const { return false; } + bool isCoreProfile = false; + if (kDesktop_GrGLBinding == binding) { + if (NULL == this->fGetIntegerv) { + return false; + } + GrGLint profileMask = 0; + fGetIntegerv(GR_GL_CONTEXT_PROFILE_MASK, &profileMask); + isCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT); + } + // functions that are always required if (NULL == fActiveTexture || NULL == fAttachShader || @@ -199,14 +209,19 @@ bool GrGLInterface::validate(GrGLBinding binding) const { return false; } } - // The below two blocks are checks for functions used with - // GL_NV_path_rendering. We're not enforcing that they be non-NULL - // because they aren't actually called at this time. - if (false && - (NULL == fMatrixMode || - NULL == fLoadIdentity || - NULL == fLoadMatrixf)) { - return false; + if (!isCoreProfile) { + if (NULL == fClientActiveTexture || + NULL == fDisableClientState || + NULL == fEnableClientState || + NULL == fLoadIdentity || + NULL == fLoadMatrixf || + NULL == fMatrixMode || + NULL == fTexGenf || + NULL == fTexGenfv || + NULL == fTexGeni || + NULL == fVertexPointer) { + return false; + } } if (false && extensions.has("GL_NV_path_rendering")) { if (NULL == fPathCommands || diff --git a/src/gpu/gl/GrGLNoOpInterface.cpp b/src/gpu/gl/GrGLNoOpInterface.cpp index db7b8e3ca..0641af85d 100644 --- a/src/gpu/gl/GrGLNoOpInterface.cpp +++ b/src/gpu/gl/GrGLNoOpInterface.cpp @@ -119,6 +119,9 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDepthMask(GrGLboolean flag) { GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDisable(GrGLenum cap) { } +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDisableClientState(GrGLenum) { +} + GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDisableVertexAttribArray(GrGLuint index) { } @@ -143,6 +146,9 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawElements(GrGLenum mode, GrGLvoid GR_GL_FUNCTION_TYPE noOpGLEnable(GrGLenum cap) { } +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLEnableClientState(GrGLenum cap) { +} + GrGLvoid GR_GL_FUNCTION_TYPE noOpGLEnableVertexAttribArray(GrGLuint index) { } @@ -164,6 +170,15 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLineWidth(GrGLfloat width) { GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLinkProgram(GrGLuint program) { } +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLoadIdentity() { +} + +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLoadMatrixf(const GrGLfloat*) { +} + +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLMatrixMode(GrGLenum) { +} + GrGLvoid GR_GL_FUNCTION_TYPE noOpGLQueryCounter(GrGLuint id, GrGLenum target) { } @@ -210,6 +225,15 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilOpSeparate(GrGLenum face, GrGLenum zpass) { } +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexGenf(GrGLenum, GrGLenum, float) { +} + +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexGenfv(GrGLenum, GrGLenum, const float*) { +} + +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexGeni(GrGLenum, GrGLenum, GrGLint) { +} + GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexImage2D(GrGLenum target, GrGLint level, GrGLint internalformat, @@ -361,6 +385,9 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttribPointer(GrGLuint indx, const GrGLvoid* ptr) { } +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexPointer(GrGLint, GrGLenum, GrGLsizei, const GrGLvoid*) { +} + GrGLvoid GR_GL_FUNCTION_TYPE noOpGLViewport(GrGLint x, GrGLint y, GrGLsizei width, @@ -458,6 +485,9 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetIntegerv(GrGLenum pname, GrGLint* params) case GR_GL_MAX_TEXTURE_IMAGE_UNITS: *params = 8; break; + case GR_GL_MAX_TEXTURE_COORDS: + *params = 8; + break; case GR_GL_MAX_VERTEX_UNIFORM_VECTORS: *params = kDefaultMaxVertexUniformVectors; break; diff --git a/src/gpu/gl/GrGLNoOpInterface.h b/src/gpu/gl/GrGLNoOpInterface.h index 0451e9cce..8fe9b44ea 100644 --- a/src/gpu/gl/GrGLNoOpInterface.h +++ b/src/gpu/gl/GrGLNoOpInterface.h @@ -70,6 +70,8 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDepthMask(GrGLboolean flag); GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDisable(GrGLenum cap); +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDisableClientState(GrGLenum); + GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDisableVertexAttribArray(GrGLuint index); GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawArrays(GrGLenum mode, GrGLint first, GrGLsizei count); @@ -86,6 +88,8 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawElements(GrGLenum mode, GrGLvoid GR_GL_FUNCTION_TYPE noOpGLEnable(GrGLenum cap); +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLEnableClientState(GrGLenum cap); + GrGLvoid GR_GL_FUNCTION_TYPE noOpGLEnableVertexAttribArray(GrGLuint index); GrGLvoid GR_GL_FUNCTION_TYPE noOpGLEndQuery(GrGLenum target); @@ -96,10 +100,16 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLFlush(); GrGLvoid GR_GL_FUNCTION_TYPE noOpGLFrontFace(GrGLenum mode); +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLoadIdentity(); + +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLoadMatrixf(const GrGLfloat*); + GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLineWidth(GrGLfloat width); GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLinkProgram(GrGLuint program); +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLMatrixMode(GrGLenum); + GrGLvoid GR_GL_FUNCTION_TYPE noOpGLQueryCounter(GrGLuint id, GrGLenum target); @@ -159,6 +169,12 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexStorage2D(GrGLenum target, GrGLsizei width, GrGLsizei height); +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexGenf(GrGLenum, GrGLenum, GrGLfloat); + +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexGenfv(GrGLenum, GrGLenum, const GrGLfloat*); + +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexGeni(GrGLenum, GrGLenum, GrGLint); + GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDiscardFramebuffer(GrGLenum target, GrGLsizei numAttachments, const GrGLenum* attachments); @@ -261,6 +277,8 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttribPointer(GrGLuint indx, GrGLsizei stride, const GrGLvoid* ptr); +GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexPointer(GrGLint, GrGLenum, GrGLsizei, const GrGLvoid*); + GrGLvoid GR_GL_FUNCTION_TYPE noOpGLViewport(GrGLint x, GrGLint y, GrGLsizei width, diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 3b7df4977..94a1306e6 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -333,9 +333,9 @@ void GrGpuGL::onResetContext(uint32_t resetBits) { fHWAAState.invalidate(); } - // invalid + fHWActiveTextureUnitIdx = -1; // invalid + if (resetBits & kTextureBinding_GrGLBackendState) { - fHWActiveTextureUnitIdx = -1; for (int s = 0; s < fHWBoundTextures.count(); ++s) { fHWBoundTextures[s] = NULL; } @@ -364,12 +364,31 @@ void GrGpuGL::onResetContext(uint32_t resetBits) { fHWBoundRenderTarget = NULL; } - if (resetBits & kPathStencil_GrGLBackendState) { - fHWPathStencilMatrixState.invalidate(); - if (this->caps()->pathStencilingSupport()) { - // we don't use the model view matrix. - GL_CALL(MatrixMode(GR_GL_MODELVIEW)); - GL_CALL(LoadIdentity()); + if (resetBits & kFixedFunction_GrGLBackendState && + kDesktop_GrGLBinding == this->glBinding() && + !this->glCaps().isCoreProfile()) { + + fHWProjectionMatrixState.invalidate(); + // we don't use the model view matrix. + GL_CALL(MatrixMode(GR_GL_MODELVIEW)); + GL_CALL(LoadIdentity()); + + // When we use fixed function vertex processing we always use the vertex array + // and none of the other arrays. + GL_CALL(EnableClientState(GR_GL_VERTEX_ARRAY)); + GL_CALL(DisableClientState(GR_GL_NORMAL_ARRAY)); + GL_CALL(DisableClientState(GR_GL_COLOR_ARRAY)); + GL_CALL(DisableClientState(GR_GL_INDEX_ARRAY)); + GL_CALL(DisableClientState(GR_GL_EDGE_FLAG_ARRAY)); + for (int i = 0; i < this->glCaps().maxFixedFunctionTextureCoords(); ++i) { + GL_CALL(ClientActiveTexture(GR_GL_TEXTURE0 + i)); + GL_CALL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY)); + + GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + i)); + GL_CALL(Disable(GR_GL_TEXTURE_GEN_S)); + GL_CALL(Disable(GR_GL_TEXTURE_GEN_T)); + GL_CALL(Disable(GR_GL_TEXTURE_GEN_Q)); + GL_CALL(Disable(GR_GL_TEXTURE_GEN_R)); } } diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h index 672df4233..1d1cdc575 100644 --- a/src/gpu/gl/GrGpuGL.h +++ b/src/gpu/gl/GrGpuGL.h @@ -417,7 +417,7 @@ private: } fHWAAState; - GrGLProgram::MatrixState fHWPathStencilMatrixState; + GrGLProgram::MatrixState fHWProjectionMatrixState; GrStencilSettings fHWStencilSettings; TriState fHWStencilTestEnabled; diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp index 3f58c1bf7..2b1795d0e 100644 --- a/src/gpu/gl/GrGpuGL_program.cpp +++ b/src/gpu/gl/GrGpuGL_program.cpp @@ -209,9 +209,9 @@ void GrGpuGL::flushPathStencilMatrix() { size.set(rt->width(), rt->height()); const SkMatrix& vm = this->getDrawState().getViewMatrix(); - if (fHWPathStencilMatrixState.fRenderTargetOrigin != rt->origin() || - !fHWPathStencilMatrixState.fViewMatrix.cheapEqualTo(viewMatrix) || - fHWPathStencilMatrixState.fRenderTargetSize!= size) { + if (fHWProjectionMatrixState.fRenderTargetOrigin != rt->origin() || + !fHWProjectionMatrixState.fViewMatrix.cheapEqualTo(viewMatrix) || + fHWProjectionMatrixState.fRenderTargetSize!= size) { // rescale the coords from skia's "device" coords to GL's normalized coords, // and perform a y-flip if required. SkMatrix m; @@ -249,9 +249,9 @@ void GrGpuGL::flushPathStencilMatrix() { }; GL_CALL(MatrixMode(GR_GL_PROJECTION)); GL_CALL(LoadMatrixf(mv)); - fHWPathStencilMatrixState.fViewMatrix = vm; - fHWPathStencilMatrixState.fRenderTargetSize = size; - fHWPathStencilMatrixState.fRenderTargetOrigin = rt->origin(); + fHWProjectionMatrixState.fViewMatrix = vm; + fHWProjectionMatrixState.fRenderTargetSize = size; + fHWProjectionMatrixState.fRenderTargetOrigin = rt->origin(); } } diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp index d517aa86c..2ccd15847 100644 --- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp +++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp @@ -32,6 +32,13 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLActiveTexture(GrGLenum texture) { GrDebugGL::getInstance()->setCurTextureUnit(texture); } +GrGLvoid GR_GL_FUNCTION_TYPE debugGLClientActiveTexture(GrGLenum texture) { + + // Ganesh offsets the texture unit indices + texture -= GR_GL_TEXTURE0; + GrAlwaysAssert(texture < GrDebugGL::getInstance()->getMaxTextureUnits()); +} + //////////////////////////////////////////////////////////////////////////////// GrGLvoid GR_GL_FUNCTION_TYPE debugGLAttachShader(GrGLuint programID, GrGLuint shaderID) { @@ -801,6 +808,7 @@ const GrGLInterface* GrGLCreateDebugInterface() { interface->fClear = noOpGLClear; interface->fClearColor = noOpGLClearColor; interface->fClearStencil = noOpGLClearStencil; + interface->fClientActiveTexture = debugGLClientActiveTexture; interface->fColorMask = noOpGLColorMask; interface->fCompileShader = noOpGLCompileShader; interface->fCompressedTexImage2D = noOpGLCompressedTexImage2D; @@ -816,12 +824,14 @@ const GrGLInterface* GrGLCreateDebugInterface() { interface->fDeleteVertexArrays = debugGLDeleteVertexArrays; interface->fDepthMask = noOpGLDepthMask; interface->fDisable = noOpGLDisable; + interface->fDisableClientState = noOpGLDisableClientState; interface->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray; interface->fDrawArrays = noOpGLDrawArrays; interface->fDrawBuffer = noOpGLDrawBuffer; interface->fDrawBuffers = noOpGLDrawBuffers; interface->fDrawElements = noOpGLDrawElements; interface->fEnable = noOpGLEnable; + interface->fEnableClientState = noOpGLEnableClientState; interface->fEnableVertexAttribArray = noOpGLEnableVertexAttribArray; interface->fEndQuery = noOpGLEndQuery; interface->fFinish = noOpGLFinish; @@ -848,8 +858,11 @@ const GrGLInterface* GrGLCreateDebugInterface() { interface->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv; interface->fGetUniformLocation = noOpGLGetUniformLocation; interface->fGenVertexArrays = debugGLGenVertexArrays; + interface->fLoadIdentity = noOpGLLoadIdentity; + interface->fLoadMatrixf = noOpGLLoadMatrixf; interface->fLineWidth = noOpGLLineWidth; interface->fLinkProgram = noOpGLLinkProgram; + interface->fMatrixMode = noOpGLMatrixMode; interface->fPixelStorei = debugGLPixelStorei; interface->fQueryCounter = noOpGLQueryCounter; interface->fReadBuffer = noOpGLReadBuffer; @@ -862,6 +875,9 @@ const GrGLInterface* GrGLCreateDebugInterface() { interface->fStencilMaskSeparate = noOpGLStencilMaskSeparate; interface->fStencilOp = noOpGLStencilOp; interface->fStencilOpSeparate = noOpGLStencilOpSeparate; + interface->fTexGenf = noOpGLTexGenf; + interface->fTexGenfv = noOpGLTexGenfv; + interface->fTexGeni = noOpGLTexGeni; interface->fTexImage2D = noOpGLTexImage2D; interface->fTexParameteri = noOpGLTexParameteri; interface->fTexParameteriv = noOpGLTexParameteriv; @@ -890,6 +906,7 @@ const GrGLInterface* GrGLCreateDebugInterface() { interface->fUseProgram = debugGLUseProgram; interface->fVertexAttrib4fv = noOpGLVertexAttrib4fv; interface->fVertexAttribPointer = noOpGLVertexAttribPointer; + interface->fVertexPointer = noOpGLVertexPointer; interface->fViewport = noOpGLViewport; interface->fBindFramebuffer = debugGLBindFramebuffer; interface->fBindRenderbuffer = debugGLBindRenderbuffer; diff --git a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp index eb0e87e18..ba0adadce 100644 --- a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp +++ b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp @@ -84,6 +84,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { GET_PROC(Clear); GET_PROC(ClearColor); GET_PROC(ClearStencil); + GET_PROC(ClientActiveTexture); GET_PROC(ColorMask); GET_PROC(CompileShader); GET_PROC(CompressedTexImage2D); @@ -98,12 +99,14 @@ const GrGLInterface* GrGLCreateNativeInterface() { GET_PROC(DeleteTextures); GET_PROC(DepthMask); GET_PROC(Disable); + GET_PROC(DisableClientState); GET_PROC(DisableVertexAttribArray); GET_PROC(DrawArrays); GET_PROC(DrawBuffer); GET_PROC(DrawBuffers); GET_PROC(DrawElements); GET_PROC(Enable); + GET_PROC(EnableClientState); GET_PROC(EnableVertexAttribArray); GET_PROC(EndQuery); GET_PROC(Finish); @@ -141,6 +144,9 @@ const GrGLInterface* GrGLCreateNativeInterface() { GET_PROC(StencilMaskSeparate); GET_PROC(StencilOp); GET_PROC(StencilOpSeparate); + GET_PROC(TexGenf); + GET_PROC(TexGenfv); + GET_PROC(TexGeni); GET_PROC(TexImage2D); GET_PROC(TexParameteri); GET_PROC(TexParameteriv); @@ -174,6 +180,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { GET_PROC(UseProgram); GET_PROC(VertexAttrib4fv); GET_PROC(VertexAttribPointer); + GET_PROC(VertexPointer); GET_PROC(Viewport); if (ver >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) { diff --git a/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp b/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp index 1ffcbcdec..31f88d5e9 100644 --- a/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp +++ b/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp @@ -63,6 +63,7 @@ const GrGLInterface* GrGLCreateMesaInterface() { GR_GL_GET_PROC(Clear); GR_GL_GET_PROC(ClearColor); GR_GL_GET_PROC(ClearStencil); + GR_GL_GET_PROC(ClientActiveTexture); GR_GL_GET_PROC(ColorMask); GR_GL_GET_PROC(CompileShader); GR_GL_GET_PROC(CompressedTexImage2D); @@ -77,12 +78,14 @@ const GrGLInterface* GrGLCreateMesaInterface() { GR_GL_GET_PROC(DeleteTextures); GR_GL_GET_PROC(DepthMask); GR_GL_GET_PROC(Disable); + GR_GL_GET_PROC(DisableClientState); GR_GL_GET_PROC(DisableVertexAttribArray); GR_GL_GET_PROC(DrawArrays); GR_GL_GET_PROC(DrawBuffer); GR_GL_GET_PROC(DrawBuffers); GR_GL_GET_PROC(DrawElements); GR_GL_GET_PROC(Enable); + GR_GL_GET_PROC(EnableClientState); GR_GL_GET_PROC(EnableVertexAttribArray); GR_GL_GET_PROC(EndQuery); GR_GL_GET_PROC(Finish); @@ -116,6 +119,9 @@ const GrGLInterface* GrGLCreateMesaInterface() { GR_GL_GET_PROC(GetUniformLocation); GR_GL_GET_PROC(LineWidth); GR_GL_GET_PROC(LinkProgram); + GR_GL_GET_PROC(LoadIdentity); + GR_GL_GET_PROC(LoadMatrixf); + GR_GL_GET_PROC(MatrixMode); GR_GL_GET_PROC(MapBuffer); GR_GL_GET_PROC(PixelStorei); GR_GL_GET_PROC(ReadBuffer); @@ -128,6 +134,9 @@ const GrGLInterface* GrGLCreateMesaInterface() { GR_GL_GET_PROC(StencilMaskSeparate); GR_GL_GET_PROC(StencilOp); GR_GL_GET_PROC(StencilOpSeparate); + GR_GL_GET_PROC(TexGenf); + GR_GL_GET_PROC(TexGenfv); + GR_GL_GET_PROC(TexGeni); GR_GL_GET_PROC(TexImage2D) GR_GL_GET_PROC(TexParameteri); GR_GL_GET_PROC(TexParameteriv); @@ -159,6 +168,7 @@ const GrGLInterface* GrGLCreateMesaInterface() { GR_GL_GET_PROC(UseProgram); GR_GL_GET_PROC(VertexAttrib4fv); GR_GL_GET_PROC(VertexAttribPointer); + GR_GL_GET_PROC(VertexPointer); GR_GL_GET_PROC(Viewport); if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) { diff --git a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp index 5820b8e78..1b44900b1 100644 --- a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp +++ b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp @@ -63,6 +63,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { interface->fClear = glClear; interface->fClearColor = glClearColor; interface->fClearStencil = glClearStencil; + interface->fClientActiveTexture = glClientActiveTexture; interface->fColorMask = glColorMask; GR_GL_GET_PROC(CompileShader); interface->fCompressedTexImage2D = glCompressedTexImage2D; @@ -77,12 +78,14 @@ const GrGLInterface* GrGLCreateNativeInterface() { interface->fDeleteTextures = glDeleteTextures; interface->fDepthMask = glDepthMask; interface->fDisable = glDisable; + interface->fDisableClientState = glDisableClientState; GR_GL_GET_PROC(DisableVertexAttribArray); interface->fDrawArrays = glDrawArrays; interface->fDrawBuffer = glDrawBuffer; GR_GL_GET_PROC(DrawBuffers); interface->fDrawElements = glDrawElements; interface->fEnable = glEnable; + interface->fEnableClientState = glEnableClientState; GR_GL_GET_PROC(EnableVertexAttribArray); GR_GL_GET_PROC(EndQuery); interface->fFinish = glFinish; @@ -132,6 +135,9 @@ const GrGLInterface* GrGLCreateNativeInterface() { interface->fStencilOp = glStencilOp; GR_GL_GET_PROC(StencilOpSeparate); interface->fTexImage2D = glTexImage2D; + interface->fTexGenf = glTexGenf; + interface->fTexGenfv = glTexGenfv; + interface->fTexGeni = glTexGeni; interface->fTexParameteri = glTexParameteri; interface->fTexParameteriv = glTexParameteriv; if (glVer >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) { @@ -163,6 +169,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { GR_GL_GET_PROC(UseProgram); GR_GL_GET_PROC(VertexAttrib4fv); GR_GL_GET_PROC(VertexAttribPointer); + GR_GL_GET_PROC(VertexPointer); interface->fViewport = glViewport; GR_GL_GET_PROC(BindFragDataLocationIndexed); diff --git a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp index 53b1eddd0..e6f1d1f81 100644 --- a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp +++ b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp @@ -97,10 +97,12 @@ const GrGLInterface* GrGLCreateNativeInterface() { SET_PROC(DeleteTextures) SET_PROC(DepthMask) SET_PROC(Disable) + SET_PROC(DisableClientState) SET_PROC(DrawArrays) SET_PROC(DrawElements) SET_PROC(DrawBuffer) SET_PROC(Enable) + SET_PROC(EnableClientState) SET_PROC(FrontFace) SET_PROC(Finish) SET_PROC(Flush) @@ -120,6 +122,9 @@ const GrGLInterface* GrGLCreateNativeInterface() { SET_PROC(StencilFunc) SET_PROC(StencilMask) SET_PROC(StencilOp) + SET_PROC(TexGenf) + SET_PROC(TexGenfv) + SET_PROC(TexGeni) SET_PROC(TexImage2D) SET_PROC(TexParameteri) SET_PROC(TexParameteriv) @@ -130,6 +135,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { } SET_PROC(TexSubImage2D) SET_PROC(Viewport) + SET_PROC(VertexPointer) WGL_SET_PROC(ActiveTexture); WGL_SET_PROC(AttachShader); @@ -139,6 +145,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { WGL_SET_PROC(BindFragDataLocation); WGL_SET_PROC(BufferData); WGL_SET_PROC(BufferSubData); + WGL_SET_PROC(ClientActiveTexture); WGL_SET_PROC(CompileShader); WGL_SET_PROC(CompressedTexImage2D); WGL_SET_PROC(CreateProgram);