src/core/SkShaderCodeDictionary.cpp
std::string GenerateImageShaderGlueCode(const std::string& resultName,
                                        int entryIndex,
                                        const SkPaintParamsKey::BlockReader& reader,
                                        const std::string& priorStageOutputName,
                                        const std::vector<std::string>& childNames,
                                        int indent) {
    SkASSERT(childNames.empty());

    std::string samplerName = std::string("sampler_") + std::to_string(entryIndex) + "_0";

    std::string subsetName = reader.entry()->getMangledUniformName(0, entryIndex);
    std::string tmXName = reader.entry()->getMangledUniformName(1, entryIndex);
    std::string tmYName = reader.entry()->getMangledUniformName(2, entryIndex);

    std::string result;

    add_indent(&result, indent);
    SkSL::String::appendf(&result,
                          "float2 coords = %s(%s, %s, %s);",
                          reader.entry()->fStaticFunctionName,
                          subsetName.c_str(),
                          tmXName.c_str(),
                          tmYName.c_str());

    add_indent(&result, indent);
    SkSL::String::appendf(&result,
                          "%s = sample(%s, coords);\n",
                          resultName.c_str(),
                          samplerName.c_str());


    return result;
}
// This is _not_ what we want to do.
// Ideally the "compute_coords" code snippet could just take texture and
// sampler references and do everything. That is going to take more time to figure out though so,
// for the sake of expediency, we're generating custom code to do the sampling.
This is _not_ what we want to do.
Ideally the "compute_coords" code snippet could just take texture and
sampler references and do everything. That is going to take more time to figure out though so,
for the sake of expediency, we're generating custom code to do the sampling.
This is _not_ what we want to do . Ideally the " compute_coords " code snippet could just take texture and sampler references and do everything . That is going to take more time to figure out though so for the sake of expediency we ' re generating custom code to do the sampling .
std::string GenerateImageShaderGlueCode(const std::string& resultName,
                                        int entryIndex,
                                        const SkPaintParamsKey::BlockReader& reader,
                                        const std::string& priorStageOutputName,
                                        const std::vector<std::string>& childNames,
                                        int indent) {
    SkASSERT(childNames.empty());
    std::string samplerName = std::string("sampler_") + std::to_string(entryIndex) + "_0";
    std::string subsetName = reader.entry()->getMangledUniformName(0, entryIndex);
    std::string tmXName = reader.entry()->getMangledUniformName(1, entryIndex);
    std::string tmYName = reader.entry()->getMangledUniformName(2, entryIndex);
    std::string result;
    add_indent(&result, indent);
    SkSL::String::appendf(&result,
                          "float2 coords = %s(%s, %s, %s);",
                          reader.entry()->fStaticFunctionName,
                          subsetName.c_str(),
                          tmXName.c_str(),
                          tmYName.c_str());
    add_indent(&result, indent);
    SkSL::String::appendf(&result,
                          "%s = sample(%s, coords);\n",
                          resultName.c_str(),
                          samplerName.c_str());
    return result;
}
std :: string GenerateImageShaderGlueCode ( const std :: string & resultName , int entryIndex , const SkPaintParamsKey :: BlockReader & reader , const std :: string & priorStageOutputName , const std :: vector < std :: string > & childNames , int indent ) { SkASSERT ( childNames . empty ( ) ) ; std :: string samplerName = std :: string ( " " ) + std :: to_string ( entryIndex ) + " " ; std :: string subsetName = reader . entry ( ) -> getMangledUniformName ( 0 , entryIndex ) ; std :: string tmXName = reader . entry ( ) -> getMangledUniformName ( 1 , entryIndex ) ; std :: string tmYName = reader . entry ( ) -> getMangledUniformName ( 2 , entryIndex ) ; std :: string result ; add_indent ( & result , indent ) ; SkSL :: String :: appendf ( & result , " " , reader . entry ( ) -> fStaticFunctionName , subsetName . c_str ( ) , tmXName . c_str ( ) , tmYName . c_str ( ) ) ; add_indent ( & result , indent ) ; SkSL :: String :: appendf ( & result , " \n " , resultName . c_str ( ) , samplerName . c_str ( ) ) ; return result ; }
This is _not_ what we want to do.
This is _not_ what we want to do .