1919
2020class GrGLSLSkSLFP : public GrGLSLFragmentProcessor {
2121public:
22- GrGLSLSkSLFP (SkSL::PipelineStageArgs& & args) : fArgs (std::move(args)) {}
22+ GrGLSLSkSLFP (const SkSL::PipelineStageArgs& args) : fArgs (std::move(args)) {}
2323
2424 SkSL::String expandFormatArgs (const SkSL::String& raw,
2525 EmitArgs& args,
@@ -57,6 +57,13 @@ class GrGLSLSkSLFP : public GrGLSLFragmentProcessor {
5757 result += this ->invokeChild (arg.fIndex , args, coords).c_str ();
5858 break ;
5959 }
60+ case SkSL::Compiler::FormatArg::Kind::kChildProcessorWithMatrix : {
61+ SkSL::String coords = this ->expandFormatArgs (arg.fCoords , args,
62+ fmtArg, coordsName);
63+ result += this ->invokeChildWithMatrix (arg.fIndex , args,
64+ coords).c_str ();
65+ break ;
66+ }
6067 case SkSL::Compiler::FormatArg::Kind::kFunctionName :
6168 SkASSERT ((int ) fFunctionNames .size () > arg.fIndex );
6269 result += fFunctionNames [arg.fIndex ].c_str ();
@@ -95,7 +102,8 @@ class GrGLSLSkSLFP : public GrGLSLFragmentProcessor {
95102 // We need to ensure that we call invokeChild on each child FP at least once.
96103 // Any child FP that isn't sampled won't trigger a call otherwise, leading to asserts later.
97104 for (int i = 0 ; i < this ->numChildProcessors (); ++i) {
98- (void )this ->invokeChild (i, args, SkSL::String (" _coords" ));
105+ bool isExplicit = args.fFp .childProcessor (i).isSampledWithExplicitCoords ();
106+ (void )this ->invokeChild (i, args, isExplicit ? SkSL::String (" _coords" ) : " " );
99107 }
100108 for (const auto & f : fArgs .fFunctions ) {
101109 fFunctionNames .emplace_back ();
@@ -181,6 +189,7 @@ GrSkSLFP::GrSkSLFP(sk_sp<const GrShaderCaps> shaderCaps, ShaderErrorHandler* sha
181189 , fName(name)
182190 , fInputs(std::move(inputs)) {
183191 this ->addCoordTransform (&fCoordTransform );
192+ fEffect ->toPipelineStage (fInputs ->data (), fShaderCaps .get (), fShaderErrorHandler , &fArgs );
184193}
185194
186195GrSkSLFP::GrSkSLFP (const GrSkSLFP& other)
@@ -189,7 +198,8 @@ GrSkSLFP::GrSkSLFP(const GrSkSLFP& other)
189198 , fShaderErrorHandler(other.fShaderErrorHandler )
190199 , fEffect(other.fEffect )
191200 , fName(other.fName )
192- , fInputs(other.fInputs ) {
201+ , fInputs(other.fInputs )
202+ , fArgs(other.fArgs ) {
193203 this ->addCoordTransform (&fCoordTransform );
194204}
195205
@@ -198,15 +208,18 @@ const char* GrSkSLFP::name() const {
198208}
199209
200210void GrSkSLFP::addChild (std::unique_ptr<GrFragmentProcessor> child) {
201- child->setSampledWithExplicitCoords ();
211+ int newIndex = this ->numChildProcessors ();
212+ if ((int ) fArgs .fSampleMatrices .size () > newIndex &&
213+ fArgs .fSampleMatrices [newIndex].fKind != SkSL::SampleMatrix::Kind::kNone ) {
214+ child->setSampleMatrix (fArgs .fSampleMatrices [newIndex]);
215+ } else {
216+ child->setSampledWithExplicitCoords ();
217+ }
202218 this ->registerChildProcessor (std::move (child));
203219}
204220
205221GrGLSLFragmentProcessor* GrSkSLFP::onCreateGLSLInstance () const {
206- // Note: This is actually SkSL (again) but with inline format specifiers.
207- SkSL::PipelineStageArgs args;
208- fEffect ->toPipelineStage (fInputs ->data (), fShaderCaps .get (), fShaderErrorHandler , &args);
209- return new GrGLSLSkSLFP (std::move (args));
222+ return new GrGLSLSkSLFP (fArgs );
210223}
211224
212225void GrSkSLFP::onGetGLSLProcessorKey (const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
0 commit comments