diff options
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrGpu.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 7 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCreateNullInterface.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLInterface.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLNoOpInterface.cpp | 9 | ||||
-rw-r--r-- | src/gpu/gl/GrGLNoOpInterface.h | 6 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgram.cpp | 7 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramDesc.cpp | 9 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramDesc.h | 3 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramEffects.cpp | 42 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramEffects.h | 32 | ||||
-rw-r--r-- | src/gpu/gl/GrGLShaderBuilder.cpp | 8 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.cpp | 121 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.h | 26 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL_program.cpp | 24 | ||||
-rw-r--r-- | src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/debug/GrGLCreateDebugInterface.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp | 2 |
22 files changed, 117 insertions, 199 deletions
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index bac9288543..c051f91242 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -323,7 +323,6 @@ public: void getPathStencilSettingsForFillType(SkPath::FillType fill, GrStencilSettings* outStencilSettings); -protected: enum DrawType { kDrawPoints_DrawType, kDrawLines_DrawType, @@ -333,6 +332,7 @@ protected: kDrawPaths_DrawType, }; +protected: DrawType PrimTypeToDrawType(GrPrimitiveType type) { switch (type) { case kTriangles_GrPrimitiveType: diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index e20f932f0e..bbf9b2a425 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -45,7 +45,6 @@ void GrGLCaps::reset() { fVertexArrayObjectSupport = false; fUseNonVBOVertexAndIndexDynamicData = false; fIsCoreProfile = false; - fFixedFunctionSupport = false; fFullClearIsFree = false; fDropsTileOnZeroDivide = false; fMapSubSupport = false; @@ -84,7 +83,6 @@ GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) { fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport; fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicData; fIsCoreProfile = caps.fIsCoreProfile; - fFixedFunctionSupport = caps.fFixedFunctionSupport; fFullClearIsFree = caps.fFullClearIsFree; fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide; fMapSubSupport = caps.fMapSubSupport; @@ -120,7 +118,6 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT); } if (!fIsCoreProfile) { - fFixedFunctionSupport = true; GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_COORDS, &fMaxFixedFunctionTextureCoords); // Sanity check SkASSERT(fMaxFixedFunctionTextureCoords > 0 && fMaxFixedFunctionTextureCoords < 128); @@ -327,7 +324,6 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { fMaxRenderTargetSize = SkTMin(fMaxTextureSize, fMaxRenderTargetSize); fPathRenderingSupport = ctxInfo.hasExtension("GL_NV_path_rendering"); - SkASSERT(!fPathRenderingSupport || fFixedFunctionSupport); fGpuTracingSupport = ctxInfo.hasExtension("GL_EXT_debug_marker"); @@ -657,13 +653,12 @@ SkString GrGLCaps::dump() const { GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBType + 1); r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); - r.appendf("Fixed Function Support: %s\n", (fFixedFunctionSupport ? "YES" : "NO")); r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); r.appendf("FB Fetch Type: %s\n", kFBFetchTypeStr[fFBFetchType]); r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType]); r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); - if (fFixedFunctionSupport) { + if (!fIsCoreProfile) { r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTextureCoords); } r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 1ba21ec72f..2269cae8ff 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -253,7 +253,6 @@ public: bool isCoreProfile() const { return fIsCoreProfile; } - bool fixedFunctionSupport() const { return fFixedFunctionSupport; } bool fullClearIsFree() const { return fFullClearIsFree; } @@ -341,7 +340,6 @@ private: bool fVertexArrayObjectSupport : 1; bool fUseNonVBOVertexAndIndexDynamicData : 1; bool fIsCoreProfile : 1; - bool fFixedFunctionSupport : 1; bool fFullClearIsFree : 1; bool fDropsTileOnZeroDivide : 1; bool fMapSubSupport : 1; diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp index 391aea27f4..92a0ba252e 100644 --- a/src/gpu/gl/GrGLCreateNullInterface.cpp +++ b/src/gpu/gl/GrGLCreateNullInterface.cpp @@ -346,8 +346,6 @@ const GrGLInterface* GrGLCreateNullInterface() { functions->fStencilMaskSeparate = noOpGLStencilMaskSeparate; functions->fStencilOp = noOpGLStencilOp; functions->fStencilOpSeparate = noOpGLStencilOpSeparate; - functions->fTexGenfv = noOpGLTexGenfv; - functions->fTexGeni = noOpGLTexGeni; functions->fTexImage2D = noOpGLTexImage2D; functions->fTexParameteri = noOpGLTexParameteri; functions->fTexParameteriv = noOpGLTexParameteriv; diff --git a/src/gpu/gl/GrGLInterface.cpp b/src/gpu/gl/GrGLInterface.cpp index bfffdfb192..8aaa02e86b 100644 --- a/src/gpu/gl/GrGLInterface.cpp +++ b/src/gpu/gl/GrGLInterface.cpp @@ -293,9 +293,7 @@ bool GrGLInterface::validate() const { if (!isCoreProfile) { if (NULL == fFunctions.fLoadIdentity || NULL == fFunctions.fLoadMatrixf || - NULL == fFunctions.fMatrixMode || - NULL == fFunctions.fTexGenfv || - NULL == fFunctions.fTexGeni) { + NULL == fFunctions.fMatrixMode) { RETURN_FALSE_INTERFACE } } diff --git a/src/gpu/gl/GrGLNoOpInterface.cpp b/src/gpu/gl/GrGLNoOpInterface.cpp index de38f6aaa6..be8ac58e6f 100644 --- a/src/gpu/gl/GrGLNoOpInterface.cpp +++ b/src/gpu/gl/GrGLNoOpInterface.cpp @@ -219,15 +219,6 @@ 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, diff --git a/src/gpu/gl/GrGLNoOpInterface.h b/src/gpu/gl/GrGLNoOpInterface.h index b5b681fec3..597225cbe3 100644 --- a/src/gpu/gl/GrGLNoOpInterface.h +++ b/src/gpu/gl/GrGLNoOpInterface.h @@ -165,12 +165,6 @@ 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); diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 6e9878a919..9b997c85ec 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -229,10 +229,11 @@ void GrGLProgram::setData(GrDrawState::BlendOptFlags blendOpts, fCoverageEffects->setData(fGpu, fUniformManager, coverageStages); - // TexGen state applies to the the fixed function vertex shader. For custom shaders, it's - // ignored, so we don't need to change the texgen settings in that case. + // PathTexGen state applies to the the fixed function vertex shader. For + // custom shaders, it's ignored, so we don't need to change the texgen + // settings in that case. if (!fHasVertexShader) { - fGpu->flushTexGenSettings(fNumTexCoordSets); + fGpu->flushPathTexGenSettings(fNumTexCoordSets); } } diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp index b6029fe4ee..4039eaf95c 100644 --- a/src/gpu/gl/GrGLProgramDesc.cpp +++ b/src/gpu/gl/GrGLProgramDesc.cpp @@ -37,7 +37,7 @@ inline GrGLEffect::EffectKey get_key_and_update_stats(const GrEffectStage& stage } } void GrGLProgramDesc::Build(const GrDrawState& drawState, - bool isPoints, + GrGpu::DrawType drawType, GrDrawState::BlendOptFlags blendOpts, GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff, @@ -113,7 +113,10 @@ void GrGLProgramDesc::Build(const GrDrawState& drawState, int currEffectKey = 0; bool readsDst = false; bool readFragPosition = false; - bool hasVertexCode = false; + // We use vertexshader-less shader programs only when drawing paths. + bool hasVertexCode = !(GrGpu::kDrawPath_DrawType == drawType || + GrGpu::kDrawPaths_DrawType == drawType); + if (!skipColor) { for (int s = firstEffectiveColorStage; s < drawState.numColorStages(); ++s) { effectKeys[currEffectKey++] = @@ -132,7 +135,7 @@ void GrGLProgramDesc::Build(const GrDrawState& drawState, } header->fHasVertexCode = hasVertexCode || requiresLocalCoordAttrib; - header->fEmitsPointSize = isPoints; + header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; // Currently the experimental GS will only work with triangle prims (and it doesn't do anything // other than pass through values from the VS to the FS anyway). diff --git a/src/gpu/gl/GrGLProgramDesc.h b/src/gpu/gl/GrGLProgramDesc.h index 9116fdf66f..9165f4eb8b 100644 --- a/src/gpu/gl/GrGLProgramDesc.h +++ b/src/gpu/gl/GrGLProgramDesc.h @@ -11,6 +11,7 @@ #include "GrGLEffect.h" #include "GrDrawState.h" #include "GrGLShaderBuilder.h" +#include "GrGpu.h" class GrGpuGL; @@ -64,7 +65,7 @@ public: * be treated as color stages in the output. */ static void Build(const GrDrawState&, - bool isPoints, + GrGpu::DrawType drawType, GrDrawState::BlendOptFlags, GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff, diff --git a/src/gpu/gl/GrGLProgramEffects.cpp b/src/gpu/gl/GrGLProgramEffects.cpp index 3bcf759b7f..1695a8e3cf 100644 --- a/src/gpu/gl/GrGLProgramEffects.cpp +++ b/src/gpu/gl/GrGLProgramEffects.cpp @@ -469,7 +469,7 @@ void GrGLVertexProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, //////////////////////////////////////////////////////////////////////////////// -void GrGLTexGenProgramEffects::emitEffect(GrGLFragmentOnlyShaderBuilder* builder, +void GrGLPathTexGenProgramEffects::emitEffect(GrGLFragmentOnlyShaderBuilder* builder, const GrEffectStage& stage, EffectKey key, const char* outColor, @@ -481,7 +481,7 @@ void GrGLTexGenProgramEffects::emitEffect(GrGLFragmentOnlyShaderBuilder* builder SkSTArray<4, TextureSampler> samplers(effect->numTextures()); SkASSERT(0 == stage.getVertexAttribIndexCount()); - this->setupTexGen(builder, effect, key, &coords); + this->setupPathTexGen(builder, effect, key, &coords); this->emitSamplers(builder, effect, &samplers); GrGLEffect* glEffect = effect->getFactory().createGLInstance(drawEffect); @@ -498,7 +498,7 @@ void GrGLTexGenProgramEffects::emitEffect(GrGLFragmentOnlyShaderBuilder* builder builder->fsCodeAppend("\t}\n"); } -void GrGLTexGenProgramEffects::setupTexGen(GrGLFragmentOnlyShaderBuilder* builder, +void GrGLPathTexGenProgramEffects::setupPathTexGen(GrGLFragmentOnlyShaderBuilder* builder, const GrEffectRef& effect, EffectKey effectKey, TransformedCoordsArray* outCoords) { @@ -516,7 +516,7 @@ void GrGLTexGenProgramEffects::setupTexGen(GrGLFragmentOnlyShaderBuilder* builde } } -void GrGLTexGenProgramEffects::setData(GrGpuGL* gpu, +void GrGLPathTexGenProgramEffects::setData(GrGpuGL* gpu, const GrGLUniformManager& uniformManager, const GrEffectStage* effectStages[]) { int numEffects = fGLEffects.count(); @@ -525,12 +525,12 @@ void GrGLTexGenProgramEffects::setData(GrGpuGL* gpu, for (int e = 0; e < numEffects; ++e) { GrDrawEffect drawEffect(*effectStages[e], false); fGLEffects[e]->setData(uniformManager, drawEffect); - this->setTexGenState(gpu, drawEffect, e); + this->setPathTexGenState(gpu, drawEffect, e); this->bindTextures(gpu, *drawEffect.effect(), e); } } -void GrGLTexGenProgramEffects::setTexGenState(GrGpuGL* gpu, +void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu, const GrDrawEffect& drawEffect, int effectIdx) { EffectKey totalKey = fTransforms[effectIdx].fTransformKey; @@ -542,7 +542,9 @@ void GrGLTexGenProgramEffects::setTexGenState(GrGpuGL* gpu, SkASSERT(get_transform_matrix(drawEffect, t).isIdentity()); GrGLfloat identity[] = {1, 0, 0, 0, 1, 0}; - gpu->enableTexGen(texCoordIndex++, GrGpuGL::kST_TexGenComponents, identity); + gpu->enablePathTexGen(texCoordIndex++, + GrGpuGL::kST_PathTexGenComponents, + identity); break; } case kTrans_MatrixType: { @@ -550,17 +552,23 @@ void GrGLTexGenProgramEffects::setTexGenState(GrGpuGL* gpu, get_transform_translation(drawEffect, t, &tx, &ty); GrGLfloat translate[] = {1, 0, tx, 0, 1, ty}; - gpu->enableTexGen(texCoordIndex++, GrGpuGL::kST_TexGenComponents, translate); + gpu->enablePathTexGen(texCoordIndex++, + GrGpuGL::kST_PathTexGenComponents, + translate); break; } case kNoPersp_MatrixType: { const SkMatrix& transform = get_transform_matrix(drawEffect, t); - gpu->enableTexGen(texCoordIndex++, GrGpuGL::kST_TexGenComponents, transform); + gpu->enablePathTexGen(texCoordIndex++, + GrGpuGL::kST_PathTexGenComponents, + transform); break; } case kGeneral_MatrixType: { const SkMatrix& transform = get_transform_matrix(drawEffect, t); - gpu->enableTexGen(texCoordIndex++, GrGpuGL::kSTR_TexGenComponents, transform); + gpu->enablePathTexGen(texCoordIndex++, + GrGpuGL::kSTR_PathTexGenComponents, + transform); break; } default: @@ -569,18 +577,18 @@ void GrGLTexGenProgramEffects::setTexGenState(GrGpuGL* gpu, } } -GrGLTexGenProgramEffectsBuilder::GrGLTexGenProgramEffectsBuilder( +GrGLPathTexGenProgramEffectsBuilder::GrGLPathTexGenProgramEffectsBuilder( GrGLFragmentOnlyShaderBuilder* builder, int reserveCount) : fBuilder(builder) - , fProgramEffects(SkNEW_ARGS(GrGLTexGenProgramEffects, (reserveCount))) { + , fProgramEffects(SkNEW_ARGS(GrGLPathTexGenProgramEffects, (reserveCount))) { } -void GrGLTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, - GrGLProgramEffects::EffectKey key, - const char* outColor, - const char* inColor, - int stageIndex) { +void GrGLPathTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, + GrGLProgramEffects::EffectKey key, + const char* outColor, + const char* inColor, + int stageIndex) { SkASSERT(NULL != fProgramEffects.get()); fProgramEffects->emitEffect(fBuilder, stage, key, outColor, inColor, stageIndex); } diff --git a/src/gpu/gl/GrGLProgramEffects.h b/src/gpu/gl/GrGLProgramEffects.h index 3320891b37..0f38cdbe64 100644 --- a/src/gpu/gl/GrGLProgramEffects.h +++ b/src/gpu/gl/GrGLProgramEffects.h @@ -237,19 +237,19 @@ private: //////////////////////////////////////////////////////////////////////////////// /** - * This is a GrGLProgramEffects implementation that does coord transforms with the the built-in GL - * TexGen functionality. + * This is a GrGLProgramEffects implementation that does coord transforms with + * the the NV_path_rendering PathTexGen functionality. */ -class GrGLTexGenProgramEffects : public GrGLProgramEffects { +class GrGLPathTexGenProgramEffects : public GrGLProgramEffects { public: virtual void setData(GrGpuGL*, const GrGLUniformManager&, const GrEffectStage* effectStages[]) SK_OVERRIDE; private: - friend class GrGLTexGenProgramEffectsBuilder; + friend class GrGLPathTexGenProgramEffectsBuilder; - GrGLTexGenProgramEffects(int reserveCount) + GrGLPathTexGenProgramEffects(int reserveCount) : INHERITED(reserveCount) , fTransforms(reserveCount) { } @@ -273,15 +273,15 @@ private: * types are appended to the TransformedCoordsArray* object, which is in turn passed to the * effect's emitCode() function. */ - void setupTexGen(GrGLFragmentOnlyShaderBuilder*, - const GrEffectRef&, - EffectKey, - TransformedCoordsArray*); + void setupPathTexGen(GrGLFragmentOnlyShaderBuilder*, + const GrEffectRef&, + EffectKey, + TransformedCoordsArray*); /** - * Helper for setData(). Sets the TexGen state for each transform in an effect. + * Helper for setData(). Sets the PathTexGen state for each transform in an effect. */ - void setTexGenState(GrGpuGL*, const GrDrawEffect&, int effectIdx); + void setPathTexGenState(GrGpuGL*, const GrDrawEffect&, int effectIdx); struct Transforms { Transforms(EffectKey transformKey, int texCoordIndex) @@ -296,12 +296,12 @@ private: }; /** - * This class is used to construct a GrGLTexGenProgramEffects* object. + * This class is used to construct a GrGLPathTexGenProgramEffects* object. */ -class GrGLTexGenProgramEffectsBuilder : public GrGLProgramEffectsBuilder { +class GrGLPathTexGenProgramEffectsBuilder : public GrGLProgramEffectsBuilder { public: - GrGLTexGenProgramEffectsBuilder(GrGLFragmentOnlyShaderBuilder*, int reserveCount); - virtual ~GrGLTexGenProgramEffectsBuilder() { } + GrGLPathTexGenProgramEffectsBuilder(GrGLFragmentOnlyShaderBuilder*, int reserveCount); + virtual ~GrGLPathTexGenProgramEffectsBuilder() { } virtual void emitEffect(const GrEffectStage&, GrGLProgramEffects::EffectKey, @@ -317,7 +317,7 @@ public: private: GrGLFragmentOnlyShaderBuilder* fBuilder; - SkAutoTDelete<GrGLTexGenProgramEffects> fProgramEffects; + SkAutoTDelete<GrGLPathTexGenProgramEffects> fProgramEffects; typedef GrGLProgramEffectsBuilder INHERITED; }; diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp index f20d9368a7..b72e23f9ba 100644 --- a/src/gpu/gl/GrGLShaderBuilder.cpp +++ b/src/gpu/gl/GrGLShaderBuilder.cpp @@ -970,7 +970,6 @@ GrGLFragmentOnlyShaderBuilder::GrGLFragmentOnlyShaderBuilder(GrGpuGL* gpu, , fNumTexCoordSets(0) { SkASSERT(!desc.getHeader().fHasVertexCode); - SkASSERT(gpu->glCaps().fixedFunctionSupport()); SkASSERT(gpu->glCaps().pathRenderingSupport()); SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fColorInput); SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fCoverageInput); @@ -989,11 +988,12 @@ GrGLProgramEffects* GrGLFragmentOnlyShaderBuilder::createAndEmitEffects( int effectCnt, GrGLSLExpr4* inOutFSColor) { - GrGLTexGenProgramEffectsBuilder texGenEffectsBuilder(this, effectCnt); - this->INHERITED::createAndEmitEffects(&texGenEffectsBuilder, + GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, + effectCnt); + this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, effectStages, effectKeys, effectCnt, inOutFSColor); - return texGenEffectsBuilder.finish(); + return pathTexGenEffectsBuilder.finish(); } diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index a2a6ac3b3b..f24a38fcec 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -120,7 +120,7 @@ GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) fCaps.reset(SkRef(ctx.caps())); fHWBoundTextures.reset(this->glCaps().maxFragmentTextureUnits()); - fHWTexGenSettings.reset(this->glCaps().maxFixedFunctionTextureCoords()); + fHWPathTexGenSettings.reset(this->glCaps().maxFixedFunctionTextureCoords()); GrGLClearErr(fGLContext.interface()); if (gPrintStartupSpew) { @@ -300,30 +300,21 @@ void GrGpuGL::onResetContext(uint32_t resetBits) { fHWBoundRenderTarget = NULL; } - if (resetBits & (kFixedFunction_GrGLBackendState | kPathRendering_GrGLBackendState)) { - if (this->glCaps().fixedFunctionSupport()) { + if (resetBits & kPathRendering_GrGLBackendState) { + if (this->caps()->pathRenderingSupport()) { fHWProjectionMatrixState.invalidate(); // we don't use the model view matrix. GL_CALL(MatrixMode(GR_GL_MODELVIEW)); GL_CALL(LoadIdentity()); for (int i = 0; i < this->glCaps().maxFixedFunctionTextureCoords(); ++i) { - 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)); - if (this->caps()->pathRenderingSupport()) { - GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); - } - fHWTexGenSettings[i].fMode = GR_GL_NONE; - fHWTexGenSettings[i].fNumComponents = 0; + GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); + fHWPathTexGenSettings[i].fMode = GR_GL_NONE; + fHWPathTexGenSettings[i].fNumComponents = 0; } - fHWActiveTexGenSets = 0; - } - if (this->caps()->pathRenderingSupport()) { - fHWPathStencilSettings.invalidate(); + fHWActivePathTexGenSets = 0; } + fHWPathStencilSettings.invalidate(); } // we assume these values @@ -2230,7 +2221,7 @@ void GrGpuGL::setProjectionMatrix(const SkMatrix& matrix, const SkISize& renderTargetSize, GrSurfaceOrigin renderTargetOrigin) { - SkASSERT(this->glCaps().fixedFunctionSupport()); + SkASSERT(this->glCaps().pathRenderingSupport()); if (renderTargetOrigin == fHWProjectionMatrixState.fRenderTargetOrigin && renderTargetSize == fHWProjectionMatrixState.fRenderTargetSize && @@ -2248,109 +2239,81 @@ void GrGpuGL::setProjectionMatrix(const SkMatrix& matrix, GL_CALL(LoadMatrixf(glMatrix)); } -void GrGpuGL::enableTexGen(int unitIdx, - TexGenComponents components, - const GrGLfloat* coefficients) { - SkASSERT(this->glCaps().fixedFunctionSupport()); - SkASSERT(components >= kS_TexGenComponents && components <= kSTR_TexGenComponents); +void GrGpuGL::enablePathTexGen(int unitIdx, + PathTexGenComponents components, + const GrGLfloat* coefficients) { + SkASSERT(this->glCaps().pathRenderingSupport()); + SkASSERT(components >= kS_PathTexGenComponents && + components <= kSTR_PathTexGenComponents); SkASSERT(this->glCaps().maxFixedFunctionTextureCoords() >= unitIdx); - if (GR_GL_OBJECT_LINEAR == fHWTexGenSettings[unitIdx].fMode && - components == fHWTexGenSettings[unitIdx].fNumComponents && - !memcmp(coefficients, fHWTexGenSettings[unitIdx].fCoefficients, + if (GR_GL_OBJECT_LINEAR == fHWPathTexGenSettings[unitIdx].fMode && + components == fHWPathTexGenSettings[unitIdx].fNumComponents && + !memcmp(coefficients, fHWPathTexGenSettings[unitIdx].fCoefficients, 3 * components * sizeof(GrGLfloat))) { return; } this->setTextureUnit(unitIdx); - if (GR_GL_OBJECT_LINEAR != fHWTexGenSettings[unitIdx].fMode) { - for (int i = 0; i < 4; i++) { - GL_CALL(TexGeni(GR_GL_S + i, GR_GL_TEXTURE_GEN_MODE, GR_GL_OBJECT_LINEAR)); - } - fHWTexGenSettings[unitIdx].fMode = GR_GL_OBJECT_LINEAR; - } - - for (int i = fHWTexGenSettings[unitIdx].fNumComponents; i < components; i++) { - GL_CALL(Enable(GR_GL_TEXTURE_GEN_S + i)); - } - for (int i = components; i < fHWTexGenSettings[unitIdx].fNumComponents; i++) { - GL_CALL(Disable(GR_GL_TEXTURE_GEN_S + i)); - } - fHWTexGenSettings[unitIdx].fNumComponents = components; - - for (int i = 0; i < components; i++) { - GrGLfloat plane[] = {coefficients[0 + 3 * i], - coefficients[1 + 3 * i], - 0, - coefficients[2 + 3 * i]}; - GL_CALL(TexGenfv(GR_GL_S + i, GR_GL_OBJECT_PLANE, plane)); - } + fHWPathTexGenSettings[unitIdx].fNumComponents = components; + GL_CALL(PathTexGen(GR_GL_TEXTURE0 + unitIdx, + GR_GL_OBJECT_LINEAR, + components, + coefficients)); - if (this->caps()->pathRenderingSupport()) { - GL_CALL(PathTexGen(GR_GL_TEXTURE0 + unitIdx, - GR_GL_OBJECT_LINEAR, - components, - coefficients)); - } - - memcpy(fHWTexGenSettings[unitIdx].fCoefficients, coefficients, + memcpy(fHWPathTexGenSettings[unitIdx].fCoefficients, coefficients, 3 * components * sizeof(GrGLfloat)); } -void GrGpuGL::enableTexGen(int unitIdx, TexGenComponents components, const SkMatrix& matrix) { +void GrGpuGL::enablePathTexGen(int unitIdx, PathTexGenComponents components, + const SkMatrix& matrix) { GrGLfloat coefficients[3 * 3]; - SkASSERT(this->glCaps().fixedFunctionSupport()); - SkASSERT(components >= kS_TexGenComponents && components <= kSTR_TexGenComponents); + SkASSERT(this->glCaps().pathRenderingSupport()); + SkASSERT(components >= kS_PathTexGenComponents && + components <= kSTR_PathTexGenComponents); coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]); coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]); coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]); - if (components >= kST_TexGenComponents) { + if (components >= kST_PathTexGenComponents) { coefficients[3] = SkScalarToFloat(matrix[SkMatrix::kMSkewY]); coefficients[4] = SkScalarToFloat(matrix[SkMatrix::kMScaleY]); coefficients[5] = SkScalarToFloat(matrix[SkMatrix::kMTransY]); } - if (components >= kSTR_TexGenComponents) { + if (components >= kSTR_PathTexGenComponents) { coefficients[6] = SkScalarToFloat(matrix[SkMatrix::kMPersp0]); coefficients[7] = SkScalarToFloat(matrix[SkMatrix::kMPersp1]); coefficients[8] = SkScalarToFloat(matrix[SkMatrix::kMPersp2]); } - enableTexGen(unitIdx, components, coefficients); + enablePathTexGen(unitIdx, components, coefficients); } -void GrGpuGL::flushTexGenSettings(int numUsedTexCoordSets) { - SkASSERT(this->glCaps().fixedFunctionSupport()); +void GrGpuGL::flushPathTexGenSettings(int numUsedTexCoordSets) { + SkASSERT(this->glCaps().pathRenderingSupport()); SkASSERT(this->glCaps().maxFixedFunctionTextureCoords() >= numUsedTexCoordSets); - // Only write the inactive tex gens, since active tex gens were written - // when they were enabled. + // Only write the inactive path tex gens, since active path tex gens were + // written when they were enabled. SkDEBUGCODE( for (int i = 0; i < numUsedTexCoordSets; i++) { - SkASSERT(0 != fHWTexGenSettings[i].fNumComponents); + SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents); } ); - for (int i = numUsedTexCoordSets; i < fHWActiveTexGenSets; i++) { - SkASSERT(0 != fHWTexGenSettings[i].fNumComponents); + for (int i = numUsedTexCoordSets; i < fHWActivePathTexGenSets; i++) { + SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents); this->setTextureUnit(i); - for (int j = 0; j < fHWTexGenSettings[i].fNumComponents; j++) { - GL_CALL(Disable(GR_GL_TEXTURE_GEN_S + j)); - } - - if (this->caps()->pathRenderingSupport()) { - GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); - } - - fHWTexGenSettings[i].fNumComponents = 0; + GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); + fHWPathTexGenSettings[i].fNumComponents = 0; } - fHWActiveTexGenSets = numUsedTexCoordSets; + fHWActivePathTexGenSets = numUsedTexCoordSets; } void GrGpuGL::flushMiscFixedFunctionState() { diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h index d75c36601c..f548af5f6a 100644 --- a/src/gpu/gl/GrGpuGL.h +++ b/src/gpu/gl/GrGpuGL.h @@ -42,22 +42,22 @@ public: virtual void discard(GrRenderTarget*) SK_OVERRIDE; - // Used by GrGLProgram and GrGLTexGenProgramEffects to configure OpenGL state. + // Used by GrGLProgram and GrGLPathTexGenProgramEffects to configure OpenGL + // state. void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture); void setProjectionMatrix(const SkMatrix& matrix, const SkISize& renderTargetSize, GrSurfaceOrigin renderTargetOrigin); - enum TexGenComponents { - kS_TexGenComponents = 1, - kST_TexGenComponents = 2, - kSTR_TexGenComponents = 3 + enum PathTexGenComponents { + kS_PathTexGenComponents = 1, + kST_PathTexGenComponents = 2, + kSTR_PathTexGenComponents = 3 }; - void enableTexGen(int unitIdx, TexGenComponents, const GrGLfloat* coefficients); - void enableTexGen(int unitIdx, TexGenComponents, const SkMatrix& matrix); - void flushTexGenSettings(int numUsedTexCoordSets); + void enablePathTexGen(int unitIdx, PathTexGenComponents, const GrGLfloat* coefficients); + void enablePathTexGen(int unitIdx, PathTexGenComponents, const SkMatrix& matrix); + void flushPathTexGenSettings(int numUsedTexCoordSets); bool shouldUseFixedFunctionTexturing() const { - return this->glCaps().fixedFunctionSupport() && - this->glCaps().pathRenderingSupport(); + return this->glCaps().pathRenderingSupport(); } bool programUnitTest(int maxStages); @@ -446,13 +446,13 @@ private: GrRenderTarget* fHWBoundRenderTarget; SkTArray<GrTexture*, true> fHWBoundTextures; - struct TexGenData { + struct PathTexGenData { GrGLenum fMode; GrGLint fNumComponents; GrGLfloat fCoefficients[3 * 3]; }; - int fHWActiveTexGenSets; - SkTArray<TexGenData, true> fHWTexGenSettings; + int fHWActivePathTexGenSets; + SkTArray<PathTexGenData, true> fHWPathTexGenSettings; ///@} // we record what stencil format worked last time to hopefully exit early diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp index 10f10393e3..0a7bb0e39a 100644 --- a/src/gpu/gl/GrGpuGL_program.cpp +++ b/src/gpu/gl/GrGpuGL_program.cpp @@ -233,7 +233,7 @@ bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC SkSTArray<8, const GrEffectStage*, true> coverageStages; GrGLProgramDesc desc; GrGLProgramDesc::Build(this->getDrawState(), - kDrawPoints_DrawType == type, + type, blendOpts, srcCoeff, dstCoeff, @@ -343,27 +343,7 @@ void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) { GrGLAttribArrayState* attribState = fHWGeometryState.bindArrayAndBuffersToDraw(this, vbuf, ibuf); - if (!fCurrentProgram->hasVertexShader()) { - int posIdx = this->getDrawState().positionAttributeIndex(); - const GrVertexAttrib* vertexAttrib = this->getDrawState().getVertexAttribs() + posIdx; - GrVertexAttribType attribType = vertexAttrib->fType; - SkASSERT(!GrGLAttribTypeToLayout(attribType).fNormalized); - SkASSERT(GrGLAttribTypeToLayout(attribType).fCount == 2); - - // Attrib at location 0 is defined to be bound to vertex in fixed-function pipe. Asserts - // above should make sure position attribute goes to location 0 when below code is executed. - - attribState->set(this, - 0, - vbuf, - GrGLAttribTypeToLayout(attribType).fCount, - GrGLAttribTypeToLayout(attribType).fType, - GrGLAttribTypeToLayout(attribType).fNormalized, - stride, - reinterpret_cast<GrGLvoid*>( - vertexOffsetInBytes + vertexAttrib->fOffset)); - attribState->disableUnusedArrays(this, 1); - } else { + if (fCurrentProgram->hasVertexShader()) { int vertexAttribCount = this->getDrawState().getVertexAttribCount(); uint32_t usedAttribArraysMask = 0; const GrVertexAttrib* vertexAttrib = this->getDrawState().getVertexAttribs(); diff --git a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp index aa5b224306..2f055cb240 100644 --- a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp +++ b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp @@ -325,8 +325,6 @@ static GrGLInterface* create_desktop_interface(GrGLVersion version, functions->fStencilMaskSeparate = (GrGLStencilMaskSeparateProc) eglGetProcAddress("glStencilMaskSeparate"); functions->fStencilOp = (GrGLStencilOpProc) eglGetProcAddress("glStencilOp"); functions->fStencilOpSeparate = (GrGLStencilOpSeparateProc) eglGetProcAddress("glStencilOpSeparate"); - functions->fTexGenfv = (GrGLTexGenfvProc) eglGetProcAddress("glTexGenfv"); - functions->fTexGeni = (GrGLTexGeniProc) eglGetProcAddress("glTexGeni"); functions->fTexImage2D = (GrGLTexImage2DProc) eglGetProcAddress("glTexImage2D"); functions->fTexParameteri = (GrGLTexParameteriProc) eglGetProcAddress("glTexParameteri"); functions->fTexParameteriv = (GrGLTexParameterivProc) eglGetProcAddress("glTexParameteriv"); diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp index cbfbb266c5..d985d87f98 100644 --- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp +++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp @@ -865,8 +865,6 @@ const GrGLInterface* GrGLCreateDebugInterface() { functions->fStencilMaskSeparate = noOpGLStencilMaskSeparate; functions->fStencilOp = noOpGLStencilOp; functions->fStencilOpSeparate = noOpGLStencilOpSeparate; - functions->fTexGenfv = noOpGLTexGenfv; - functions->fTexGeni = noOpGLTexGeni; functions->fTexImage2D = noOpGLTexImage2D; functions->fTexParameteri = noOpGLTexParameteri; functions->fTexParameteriv = noOpGLTexParameteriv; diff --git a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp index 04898d1110..17d08b10d0 100644 --- a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp +++ b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp @@ -139,8 +139,6 @@ const GrGLInterface* GrGLCreateNativeInterface() { GET_PROC(StencilMaskSeparate); GET_PROC(StencilOp); GET_PROC(StencilOpSeparate); - GET_PROC(TexGenfv); - GET_PROC(TexGeni); GET_PROC(TexImage2D); GET_PROC(TexParameteri); GET_PROC(TexParameteriv); diff --git a/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp b/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp index fd8be26fe9..24218b02a7 100644 --- a/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp +++ b/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp @@ -133,8 +133,6 @@ const GrGLInterface* GrGLCreateMesaInterface() { GR_GL_GET_PROC(StencilMaskSeparate); GR_GL_GET_PROC(StencilOp); GR_GL_GET_PROC(StencilOpSeparate); - 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); diff --git a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp index 93807637fb..d47cc61203 100644 --- a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp +++ b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp @@ -131,8 +131,6 @@ const GrGLInterface* GrGLCreateNativeInterface() { functions->fStencilOp = glStencilOp; GR_GL_GET_PROC(StencilOpSeparate); functions->fTexImage2D = glTexImage2D; - functions->fTexGenfv = glTexGenfv; - functions->fTexGeni = glTexGeni; functions->fTexParameteri = glTexParameteri; functions->fTexParameteriv = glTexParameteriv; if (glVer >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) { diff --git a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp index 9a237825e9..c5c80bc406 100644 --- a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp +++ b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp @@ -113,8 +113,6 @@ const GrGLInterface* GrGLCreateNativeInterface() { SET_PROC(StencilFunc) SET_PROC(StencilMask) SET_PROC(StencilOp) - SET_PROC(TexGenfv) - SET_PROC(TexGeni) SET_PROC(TexImage2D) SET_PROC(TexParameteri) SET_PROC(TexParameteriv) |