diff options
Diffstat (limited to 'src/gpu/effects')
-rw-r--r-- | src/gpu/effects/GrBezierEffect.cpp | 30 | ||||
-rw-r--r-- | src/gpu/effects/GrBezierEffect.h | 44 | ||||
-rw-r--r-- | src/gpu/effects/GrBitmapTextGeoProc.cpp | 23 | ||||
-rw-r--r-- | src/gpu/effects/GrBitmapTextGeoProc.h | 16 | ||||
-rw-r--r-- | src/gpu/effects/GrDistanceFieldGeoProc.cpp | 120 | ||||
-rw-r--r-- | src/gpu/effects/GrDistanceFieldGeoProc.h | 52 | ||||
-rw-r--r-- | src/gpu/effects/GrShadowGeoProc.cpp | 15 | ||||
-rw-r--r-- | src/gpu/effects/GrShadowGeoProc.h | 17 |
8 files changed, 133 insertions, 184 deletions
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp index d68b1bfed6..3dee2f4dab 100644 --- a/src/gpu/effects/GrBezierEffect.cpp +++ b/src/gpu/effects/GrBezierEffect.cpp @@ -79,7 +79,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { GrGLSLVarying v(kFloat4_GrSLType); varyingHandler->addVarying("ConicCoeffs", &v); - vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs().name()); + vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->name()); GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; // Setup pass through color @@ -89,7 +89,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { this->writeOutputPosition(vertBuilder, uniformHandler, gpArgs, - gp.inPosition().name(), + gp.inPosition()->name(), gp.viewMatrix(), &fViewMatrixUniform); @@ -97,7 +97,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gp.inPosition().asShaderVar(), + gp.inPosition()->asShaderVar(), gp.localMatrix(), args.fFPCoordTransformHandler); @@ -219,8 +219,6 @@ void GrGLConicEffect::GenKey(const GrGeometryProcessor& gp, ////////////////////////////////////////////////////////////////////////////// -constexpr GrPrimitiveProcessor::Attribute GrConicEffect::kAttributes[]; - GrConicEffect::~GrConicEffect() {} void GrConicEffect::getGLSLProcessorKey(const GrShaderCaps& caps, @@ -242,7 +240,8 @@ GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t , fUsesLocalCoords(usesLocalCoords) , fCoverageScale(coverage) , fEdgeType(edgeType) { - this->setVertexAttributeCnt(2); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInConicCoeffs = &this->addVertexAttrib("inConicCoeffs", kHalf4_GrVertexAttribType); } ////////////////////////////////////////////////////////////////////////////// @@ -332,7 +331,7 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { GrGLSLVarying v(kHalf4_GrSLType); varyingHandler->addVarying("HairQuadEdge", &v); - vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge().name()); + vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->name()); GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; // Setup pass through color @@ -342,7 +341,7 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { this->writeOutputPosition(vertBuilder, uniformHandler, gpArgs, - gp.inPosition().name(), + gp.inPosition()->name(), gp.viewMatrix(), &fViewMatrixUniform); @@ -350,7 +349,7 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gp.inPosition().asShaderVar(), + gp.inPosition()->asShaderVar(), gp.localMatrix(), args.fFPCoordTransformHandler); @@ -421,8 +420,6 @@ void GrGLQuadEffect::GenKey(const GrGeometryProcessor& gp, ////////////////////////////////////////////////////////////////////////////// -constexpr GrPrimitiveProcessor::Attribute GrQuadEffect::kAttributes[]; - GrQuadEffect::~GrQuadEffect() {} void GrQuadEffect::getGLSLProcessorKey(const GrShaderCaps& caps, @@ -444,7 +441,8 @@ GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co , fUsesLocalCoords(usesLocalCoords) , fCoverageScale(coverage) , fEdgeType(edgeType) { - this->setVertexAttributeCnt(2); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInHairQuadEdge = &this->addVertexAttrib("inHairQuadEdge", kHalf4_GrVertexAttribType); } ////////////////////////////////////////////////////////////////////////////// @@ -546,7 +544,7 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { this->writeOutputPosition(vertBuilder, uniformHandler, gpArgs, - gp.inPosition().name(), + gp.inPosition()->name(), gp.viewMatrix(), &fViewMatrixUniform); @@ -578,7 +576,7 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gp.inPosition().asShaderVar(), + gp.inPosition()->asShaderVar(), args.fFPCoordTransformHandler); GrShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0); @@ -649,8 +647,6 @@ void GrGLCubicEffect::GenKey(const GrGeometryProcessor& gp, ////////////////////////////////////////////////////////////////////////////// -constexpr GrPrimitiveProcessor::Attribute GrCubicEffect::kInPosition; - GrCubicEffect::~GrCubicEffect() {} void GrCubicEffect::getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const { @@ -668,7 +664,7 @@ GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, const Sk , fViewMatrix(viewMatrix) , fDevKLMMatrix(devKLMMatrix) , fEdgeType(edgeType) { - this->setVertexAttributeCnt(1); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); } ////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/effects/GrBezierEffect.h b/src/gpu/effects/GrBezierEffect.h index eebe42a5cd..174470410c 100644 --- a/src/gpu/effects/GrBezierEffect.h +++ b/src/gpu/effects/GrBezierEffect.h @@ -93,8 +93,8 @@ public: const char* name() const override { return "Conic"; } - inline const Attribute& inPosition() const { return kAttributes[0]; } - inline const Attribute& inConicCoeffs() const { return kAttributes[1]; } + inline const Attribute* inPosition() const { return fInPosition; } + inline const Attribute* inConicCoeffs() const { return fInConicCoeffs; } inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType); } inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); } inline GrClipEdgeType getEdgeType() const { return fEdgeType; } @@ -112,16 +112,14 @@ private: GrConicEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrClipEdgeType, const SkMatrix& localMatrix, bool usesLocalCoords); - const Attribute& onVertexAttribute(int i) const override { return kAttributes[i]; } - GrColor fColor; SkMatrix fViewMatrix; SkMatrix fLocalMatrix; bool fUsesLocalCoords; uint8_t fCoverageScale; GrClipEdgeType fEdgeType; - static constexpr Attribute kAttributes[] = {{"inPosition", kFloat2_GrVertexAttribType}, - {"inConicCoeffs", kHalf4_GrVertexAttribType}}; + const Attribute* fInPosition; + const Attribute* fInConicCoeffs; GR_DECLARE_GEOMETRY_PROCESSOR_TEST @@ -177,8 +175,8 @@ public: const char* name() const override { return "Quad"; } - inline const Attribute& inPosition() const { return kAttributes[0]; } - inline const Attribute& inHairQuadEdge() const { return kAttributes[1]; } + inline const Attribute* inPosition() const { return fInPosition; } + inline const Attribute* inHairQuadEdge() const { return fInHairQuadEdge; } inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType); } inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); } inline GrClipEdgeType getEdgeType() const { return fEdgeType; } @@ -196,17 +194,14 @@ private: GrQuadEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrClipEdgeType, const SkMatrix& localMatrix, bool usesLocalCoords); - const Attribute& onVertexAttribute(int i) const override { return kAttributes[i]; } - - GrColor fColor; - SkMatrix fViewMatrix; - SkMatrix fLocalMatrix; - bool fUsesLocalCoords; - uint8_t fCoverageScale; + GrColor fColor; + SkMatrix fViewMatrix; + SkMatrix fLocalMatrix; + bool fUsesLocalCoords; + uint8_t fCoverageScale; GrClipEdgeType fEdgeType; - - static constexpr Attribute kAttributes[] = {{"inPosition", kFloat2_GrVertexAttribType}, - {"inHairQuadEdge", kHalf4_GrVertexAttribType}}; + const Attribute* fInPosition; + const Attribute* fInHairQuadEdge; GR_DECLARE_GEOMETRY_PROCESSOR_TEST @@ -268,7 +263,7 @@ public: const char* name() const override { return "Cubic"; } - inline const Attribute& inPosition() const { return kInPosition; } + inline const Attribute* inPosition() const { return fInPosition; } inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType); } inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); } inline GrClipEdgeType getEdgeType() const { return fEdgeType; } @@ -285,14 +280,11 @@ private: GrCubicEffect(GrColor, const SkMatrix& viewMatrix, const SkMatrix& devKLMMatrix, GrClipEdgeType); - const Attribute& onVertexAttribute(int) const override { return kInPosition; } - - GrColor fColor; - SkMatrix fViewMatrix; - SkMatrix fDevKLMMatrix; + GrColor fColor; + SkMatrix fViewMatrix; + SkMatrix fDevKLMMatrix; GrClipEdgeType fEdgeType; - - static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType}; + const Attribute* fInPosition; GR_DECLARE_GEOMETRY_PROCESSOR_TEST diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index 2594f40ee5..4089555362 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -40,7 +40,7 @@ public: GrGLSLVarying uv(kFloat2_GrSLType); GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType; GrGLSLVarying texIdx(texIdxType); - append_index_uv_varyings(args, btgp.inTextureCoords().name(), atlasSizeInvName, &uv, + append_index_uv_varyings(args, btgp.inTextureCoords()->name(), atlasSizeInvName, &uv, &texIdx, nullptr); GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; @@ -53,13 +53,13 @@ public: } // Setup position - gpArgs->fPositionVar = btgp.inPosition().asShaderVar(); + gpArgs->fPositionVar = btgp.inPosition()->asShaderVar(); // emit transforms this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - btgp.inPosition().asShaderVar(), + btgp.inPosition()->asShaderVar(), btgp.localMatrix(), args.fFPCoordTransformHandler); @@ -129,26 +129,23 @@ GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, , fColor(color) , fLocalMatrix(localMatrix) , fUsesW(usesW) + , fInColor(nullptr) , fMaskFormat(format) { SkASSERT(numActiveProxies <= kMaxTextures); if (usesW) { - fInPosition = {"inPosition", kFloat3_GrVertexAttribType}; + fInPosition = &this->addVertexAttrib("inPosition", kFloat3_GrVertexAttribType); } else { - fInPosition = {"inPosition", kFloat2_GrVertexAttribType}; + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); } - fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType}; - int cnt = 2; bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat || kA565_GrMaskFormat == fMaskFormat; if (hasVertexColor) { - fInColor = {"inColor", kUByte4_norm_GrVertexAttribType}; - ++cnt; + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); } - this->setVertexAttributeCnt(cnt); - + fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kUShort2_GrVertexAttribType); for (int i = 0; i < numActiveProxies; ++i) { SkASSERT(proxies[i]); @@ -157,10 +154,6 @@ GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, } } -const GrPrimitiveProcessor::Attribute& GrBitmapTextGeoProc::onVertexAttribute(int i) const { - return IthInitializedAttribute(i, fInPosition, fInColor, fInTextureCoords); -} - void GrBitmapTextGeoProc::addNewProxies(const sk_sp<GrTextureProxy>* proxies, int numActiveProxies, const GrSamplerState& params) { diff --git a/src/gpu/effects/GrBitmapTextGeoProc.h b/src/gpu/effects/GrBitmapTextGeoProc.h index 5e444977c2..40ba8559e5 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.h +++ b/src/gpu/effects/GrBitmapTextGeoProc.h @@ -36,12 +36,12 @@ public: const char* name() const override { return "Texture"; } - const Attribute& inPosition() const { return fInPosition; } - const Attribute& inColor() const { return fInColor; } - const Attribute& inTextureCoords() const { return fInTextureCoords; } + const Attribute* inPosition() const { return fInPosition; } + const Attribute* inColor() const { return fInColor; } + const Attribute* inTextureCoords() const { return fInTextureCoords; } GrMaskFormat maskFormat() const { return fMaskFormat; } GrColor color() const { return fColor; } - bool hasVertexColor() const { return fInColor.isInitialized(); } + bool hasVertexColor() const { return SkToBool(fInColor); } const SkMatrix& localMatrix() const { return fLocalMatrix; } bool usesW() const { return fUsesW; } @@ -58,15 +58,13 @@ private: const GrSamplerState& params, GrMaskFormat format, const SkMatrix& localMatrix, bool usesW); - const Attribute& onVertexAttribute(int i) const override; - GrColor fColor; SkMatrix fLocalMatrix; bool fUsesW; TextureSampler fTextureSamplers[kMaxTextures]; - Attribute fInPosition; - Attribute fInColor; - Attribute fInTextureCoords; + const Attribute* fInPosition; + const Attribute* fInColor; + const Attribute* fInTextureCoords; GrMaskFormat fMaskFormat; GR_DECLARE_GEOMETRY_PROCESSOR_TEST diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index 4d5d50b8db..5ac73989ee 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -54,13 +54,13 @@ public: varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputColor); // Setup position - gpArgs->fPositionVar = dfTexEffect.inPosition().asShaderVar(); + gpArgs->fPositionVar = dfTexEffect.inPosition()->asShaderVar(); // emit transforms this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - dfTexEffect.inPosition().asShaderVar(), + dfTexEffect.inPosition()->asShaderVar(), dfTexEffect.localMatrix(), args.fFPCoordTransformHandler); @@ -69,7 +69,7 @@ public: GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType; GrGLSLVarying texIdx(texIdxType); GrGLSLVarying st(kFloat2_GrSLType); - append_index_uv_varyings(args, dfTexEffect.inTextureCoords().name(), atlasSizeInvName, &uv, + append_index_uv_varyings(args, dfTexEffect.inTextureCoords()->name(), atlasSizeInvName, &uv, &texIdx, &st); bool isUniformScale = (dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask) == @@ -206,34 +206,32 @@ private: /////////////////////////////////////////////////////////////////////////////// -constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldA8TextGeoProc::kInColor; -constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldA8TextGeoProc::kInTextureCoords; - -GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(const sk_sp<GrTextureProxy>* proxies, - int numProxies, - const GrSamplerState& params, +GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc( + const sk_sp<GrTextureProxy>* proxies, + int numProxies, + const GrSamplerState& params, #ifdef SK_GAMMA_APPLY_TO_A8 - float distanceAdjust, + float distanceAdjust, #endif - uint32_t flags, - const SkMatrix& localMatrix) + uint32_t flags, + const SkMatrix& localMatrix) : INHERITED(kGrDistanceFieldA8TextGeoProc_ClassID) - , fLocalMatrix(localMatrix) - , fFlags(flags & kNonLCD_DistanceFieldEffectMask) #ifdef SK_GAMMA_APPLY_TO_A8 , fDistanceAdjust(distanceAdjust) #endif -{ + , fFlags(flags & kNonLCD_DistanceFieldEffectMask) + , fInColor(nullptr) + , fLocalMatrix(localMatrix) { SkASSERT(numProxies <= kMaxTextures); - SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); + SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); if (flags & kPerspective_DistanceFieldEffectFlag) { - fInPosition = {"inPosition", kFloat3_GrVertexAttribType}; + fInPosition = &this->addVertexAttrib("inPosition", kFloat3_GrVertexAttribType); } else { - fInPosition = {"inPosition", kFloat2_GrVertexAttribType}; + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); } - this->setVertexAttributeCnt(3); - + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); + fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kUShort2_GrVertexAttribType); for (int i = 0; i < numProxies; ++i) { SkASSERT(proxies[i]); @@ -339,8 +337,8 @@ public: GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType; GrGLSLVarying texIdx(texIdxType); GrGLSLVarying st(kFloat2_GrSLType); - append_index_uv_varyings(args, dfPathEffect.inTextureCoords().name(), atlasSizeInvName, &uv, - &texIdx, &st); + append_index_uv_varyings(args, dfPathEffect.inTextureCoords()->name(), atlasSizeInvName, + &uv, &texIdx, &st); // setup pass through color varyingHandler->addPassThroughAttribute(dfPathEffect.inColor(), args.fOutputColor); @@ -350,7 +348,7 @@ public: this->writeOutputPosition(vertBuilder, uniformHandler, gpArgs, - dfPathEffect.inPosition().name(), + dfPathEffect.inPosition()->name(), dfPathEffect.matrix(), &fMatrixUniform); @@ -358,17 +356,17 @@ public: this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - dfPathEffect.inPosition().asShaderVar(), + dfPathEffect.inPosition()->asShaderVar(), args.fFPCoordTransformHandler); } else { // Setup position - this->writeOutputPosition(vertBuilder, gpArgs, dfPathEffect.inPosition().name()); + this->writeOutputPosition(vertBuilder, gpArgs, dfPathEffect.inPosition()->name()); // emit transforms this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - dfPathEffect.inPosition().asShaderVar(), + dfPathEffect.inPosition()->asShaderVar(), dfPathEffect.matrix(), args.fFPCoordTransformHandler); } @@ -501,22 +499,22 @@ private: }; /////////////////////////////////////////////////////////////////////////////// -constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldPathGeoProc::kInPosition; -constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldPathGeoProc::kInColor; -constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldPathGeoProc::kInTextureCoords; - -GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc(const SkMatrix& matrix, - const sk_sp<GrTextureProxy>* proxies, - int numProxies, - const GrSamplerState& params, - uint32_t flags) +GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc( + const SkMatrix& matrix, + const sk_sp<GrTextureProxy>* proxies, + int numProxies, + const GrSamplerState& params, + uint32_t flags) : INHERITED(kGrDistanceFieldPathGeoProc_ClassID) , fMatrix(matrix) - , fFlags(flags & kNonLCD_DistanceFieldEffectMask) { + , fFlags(flags & kNonLCD_DistanceFieldEffectMask) + , fInColor(nullptr) { SkASSERT(numProxies <= kMaxTextures); - SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); - this->setVertexAttributeCnt(3); + SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); + fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kUShort2_GrVertexAttribType); for (int i = 0; i < numProxies; ++i) { SkASSERT(proxies[i]); @@ -550,10 +548,6 @@ GrDistanceFieldPathGeoProc::createGLSLInstance(const GrShaderCaps&) const { return new GrGLDistanceFieldPathGeoProc(); } -const GrPrimitiveProcessor::Attribute& GrDistanceFieldPathGeoProc::onVertexAttribute(int i) const { - return IthAttribute(i, kInPosition, kInColor, kInTextureCoords); -} - /////////////////////////////////////////////////////////////////////////////// GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc); @@ -620,13 +614,13 @@ public: varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputColor); // Setup position - gpArgs->fPositionVar = dfTexEffect.inPosition().asShaderVar(); + gpArgs->fPositionVar = dfTexEffect.inPosition()->asShaderVar(); // emit transforms this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - dfTexEffect.inPosition().asShaderVar(), + dfTexEffect.inPosition()->asShaderVar(), dfTexEffect.localMatrix(), args.fFPCoordTransformHandler); @@ -635,7 +629,7 @@ public: GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType; GrGLSLVarying texIdx(texIdxType); GrGLSLVarying st(kFloat2_GrSLType); - append_index_uv_varyings(args, dfTexEffect.inTextureCoords().name(), atlasSizeInvName, &uv, + append_index_uv_varyings(args, dfTexEffect.inTextureCoords()->name(), atlasSizeInvName, &uv, &texIdx, &st); GrGLSLVarying delta(kFloat_GrSLType); @@ -808,30 +802,27 @@ private: }; /////////////////////////////////////////////////////////////////////////////// - -constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldLCDTextGeoProc::kInColor; -constexpr GrPrimitiveProcessor::Attribute GrDistanceFieldLCDTextGeoProc::kInTextureCoords; - -GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc(const sk_sp<GrTextureProxy>* proxies, - int numProxies, - const GrSamplerState& params, - DistanceAdjust distanceAdjust, - uint32_t flags, - const SkMatrix& localMatrix) +GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc( + const sk_sp<GrTextureProxy>* proxies, + int numProxies, + const GrSamplerState& params, + DistanceAdjust distanceAdjust, + uint32_t flags, + const SkMatrix& localMatrix) : INHERITED(kGrDistanceFieldLCDTextGeoProc_ClassID) - , fLocalMatrix(localMatrix) , fDistanceAdjust(distanceAdjust) - , fFlags(flags & kLCD_DistanceFieldEffectMask) { + , fFlags(flags & kLCD_DistanceFieldEffectMask) + , fLocalMatrix(localMatrix) { SkASSERT(numProxies <= kMaxTextures); - SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_DistanceFieldEffectFlag)); + SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_DistanceFieldEffectFlag)); if (fFlags & kPerspective_DistanceFieldEffectFlag) { - fInPosition = {"inPosition", kFloat3_GrVertexAttribType}; + fInPosition = &this->addVertexAttrib("inPosition", kFloat3_GrVertexAttribType); } else { - fInPosition = {"inPosition", kFloat2_GrVertexAttribType}; + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); } - this->setVertexAttributeCnt(3); - + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); + fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kUShort2_GrVertexAttribType); for (int i = 0; i < numProxies; ++i) { SkASSERT(proxies[i]); @@ -864,11 +855,6 @@ GrGLSLPrimitiveProcessor* GrDistanceFieldLCDTextGeoProc::createGLSLInstance(cons return new GrGLDistanceFieldLCDTextGeoProc(); } -const GrPrimitiveProcessor::Attribute& GrDistanceFieldLCDTextGeoProc::onVertexAttribute( - int i) const { - return IthAttribute(i, fInPosition, kInColor, kInTextureCoords); -} - /////////////////////////////////////////////////////////////////////////////// GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc); diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.h b/src/gpu/effects/GrDistanceFieldGeoProc.h index 71626fa938..5ba19ed5a5 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.h +++ b/src/gpu/effects/GrDistanceFieldGeoProc.h @@ -76,9 +76,9 @@ public: const char* name() const override { return "DistanceFieldA8Text"; } - const Attribute& inPosition() const { return fInPosition; } - const Attribute& inColor() const { return kInColor; } - const Attribute& inTextureCoords() const { return kInTextureCoords; } + const Attribute* inPosition() const { return fInPosition; } + const Attribute* inColor() const { return fInColor; } + const Attribute* inTextureCoords() const { return fInTextureCoords; } const SkMatrix& localMatrix() const { return fLocalMatrix; } #ifdef SK_GAMMA_APPLY_TO_A8 float getDistanceAdjust() const { return fDistanceAdjust; } @@ -100,22 +100,17 @@ private: #endif uint32_t flags, const SkMatrix& localMatrix); - const Attribute& onVertexAttribute(int i) const override { - return IthAttribute(i, fInPosition, kInColor, kInTextureCoords); - } - static constexpr int kMaxTextures = 4; TextureSampler fTextureSamplers[kMaxTextures]; - SkMatrix fLocalMatrix; - Attribute fInPosition; - uint32_t fFlags; #ifdef SK_GAMMA_APPLY_TO_A8 float fDistanceAdjust; #endif - - static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType}; - static constexpr Attribute kInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType}; + uint32_t fFlags; + const Attribute* fInPosition; + const Attribute* fInColor; + const Attribute* fInTextureCoords; + SkMatrix fLocalMatrix; GR_DECLARE_GEOMETRY_PROCESSOR_TEST @@ -144,9 +139,9 @@ public: const char* name() const override { return "DistanceFieldPath"; } - const Attribute& inPosition() const { return kInPosition; } - const Attribute& inColor() const { return kInColor; } - const Attribute& inTextureCoords() const { return kInTextureCoords; } + const Attribute* inPosition() const { return fInPosition; } + const Attribute* inColor() const { return fInColor; } + const Attribute* inTextureCoords() const { return fInTextureCoords; } const SkMatrix& matrix() const { return fMatrix; } uint32_t getFlags() const { return fFlags; } @@ -164,14 +159,12 @@ private: int numActiveProxies, const GrSamplerState&, uint32_t flags); - const Attribute& onVertexAttribute(int i) const override; - SkMatrix fMatrix; // view matrix if perspective, local matrix otherwise TextureSampler fTextureSamplers[kMaxTextures]; uint32_t fFlags; - static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType}; - static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType}; - static constexpr Attribute kInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType}; + const Attribute* fInPosition; + const Attribute* fInColor; + const Attribute* fInTextureCoords; GR_DECLARE_GEOMETRY_PROCESSOR_TEST @@ -216,9 +209,9 @@ public: const char* name() const override { return "DistanceFieldLCDText"; } - const Attribute& inPosition() const { return fInPosition; } - const Attribute& inColor() const { return kInColor; } - const Attribute& inTextureCoords() const { return kInTextureCoords; } + const Attribute* inPosition() const { return fInPosition; } + const Attribute* inColor() const { return fInColor; } + const Attribute* inTextureCoords() const { return fInTextureCoords; } DistanceAdjust getDistanceAdjust() const { return fDistanceAdjust; } uint32_t getFlags() const { return fFlags; } const SkMatrix& localMatrix() const { return fLocalMatrix; } @@ -234,18 +227,15 @@ private: const GrSamplerState& params, DistanceAdjust wa, uint32_t flags, const SkMatrix& localMatrix); - const Attribute& onVertexAttribute(int) const override; - static constexpr int kMaxTextures = 4; TextureSampler fTextureSamplers[kMaxTextures]; - const SkMatrix fLocalMatrix; DistanceAdjust fDistanceAdjust; - Attribute fInPosition; uint32_t fFlags; - - static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType}; - static constexpr Attribute kInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType}; + const Attribute* fInPosition; + const Attribute* fInColor; + const Attribute* fInTextureCoords; + const SkMatrix fLocalMatrix; GR_DECLARE_GEOMETRY_PROCESSOR_TEST diff --git a/src/gpu/effects/GrShadowGeoProc.cpp b/src/gpu/effects/GrShadowGeoProc.cpp index bf78f41c97..52bf287bea 100644 --- a/src/gpu/effects/GrShadowGeoProc.cpp +++ b/src/gpu/effects/GrShadowGeoProc.cpp @@ -33,13 +33,13 @@ public: varyingHandler->addPassThroughAttribute(rsgp.inColor(), args.fOutputColor); // Setup position - this->writeOutputPosition(vertBuilder, gpArgs, rsgp.inPosition().name()); + this->writeOutputPosition(vertBuilder, gpArgs, rsgp.inPosition()->name()); // emit transforms this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - rsgp.inPosition().asShaderVar(), + rsgp.inPosition()->asShaderVar(), args.fFPCoordTransformHandler); fragBuilder->codeAppend("half d = length(shadowParams.xy);"); @@ -62,8 +62,11 @@ private: /////////////////////////////////////////////////////////////////////////////// -GrRRectShadowGeoProc::GrRRectShadowGeoProc() : INHERITED(kGrRRectShadowGeoProc_ClassID) { - this->setVertexAttributeCnt(3); +GrRRectShadowGeoProc::GrRRectShadowGeoProc() +: INHERITED(kGrRRectShadowGeoProc_ClassID) { + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); + fInShadowParams = &this->addVertexAttrib("inShadowParams", kHalf4_GrVertexAttribType); } GrGLSLPrimitiveProcessor* GrRRectShadowGeoProc::createGLSLInstance(const GrShaderCaps&) const { @@ -72,10 +75,6 @@ GrGLSLPrimitiveProcessor* GrRRectShadowGeoProc::createGLSLInstance(const GrShade /////////////////////////////////////////////////////////////////////////////// -constexpr GrPrimitiveProcessor::Attribute GrRRectShadowGeoProc::kInPosition; -constexpr GrPrimitiveProcessor::Attribute GrRRectShadowGeoProc::kInColor; -constexpr GrPrimitiveProcessor::Attribute GrRRectShadowGeoProc::kInShadowParams; - GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrRRectShadowGeoProc); #if GR_TEST_UTILS diff --git a/src/gpu/effects/GrShadowGeoProc.h b/src/gpu/effects/GrShadowGeoProc.h index df3e501c59..0b4baf49b8 100644 --- a/src/gpu/effects/GrShadowGeoProc.h +++ b/src/gpu/effects/GrShadowGeoProc.h @@ -25,9 +25,9 @@ public: const char* name() const override { return "RRectShadow"; } - const Attribute& inPosition() const { return kInPosition; } - const Attribute& inColor() const { return kInColor; } - const Attribute& inShadowParams() const { return kInShadowParams; } + const Attribute* inPosition() const { return fInPosition; } + const Attribute* inColor() const { return fInColor; } + const Attribute* inShadowParams() const { return fInShadowParams; } GrColor color() const { return fColor; } void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {} @@ -37,15 +37,10 @@ public: private: GrRRectShadowGeoProc(); - const Attribute& onVertexAttribute(int i) const override { - return IthAttribute(i, kInPosition, kInColor, kInShadowParams); - } - GrColor fColor; - - static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType}; - static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType}; - static constexpr Attribute kInShadowParams = {"inShadowParams", kHalf4_GrVertexAttribType}; + const Attribute* fInPosition; + const Attribute* fInColor; + const Attribute* fInShadowParams; GR_DECLARE_GEOMETRY_PROCESSOR_TEST |