Flutter Engine
The Flutter Engine
Classes | Functions
SkShaderUtils Namespace Reference

Classes

class  GLSLPrettyPrint
 

Functions

std::string PrettyPrint (const std::string &string)
 
void VisitLineByLine (const std::string &text, const std::function< void(int lineNumber, const char *lineText)> &visitFn)
 
std::string BuildShaderErrorMessage (const char *shader, const char *errors)
 
void PrintShaderBanner (SkSL::ProgramKind programKind)
 
void PrintLineByLine (const std::string &text)
 

Function Documentation

◆ BuildShaderErrorMessage()

std::string SkShaderUtils::BuildShaderErrorMessage ( const char *  shader,
const char *  errors 
)

Definition at line 256 of file SkShaderUtils.cpp.

256 {
257 std::string abortText{"Shader compilation error\n"
258 "------------------------\n"};
259 VisitLineByLine(shader, [&](int lineNumber, const char* lineText) {
260 SkSL::String::appendf(&abortText, "%4i\t%s\n", lineNumber, lineText);
261 });
262 SkSL::String::appendf(&abortText, "Errors:\n%s", errors);
263 return abortText;
264}
std::string void appendf(std::string *str, const char *fmt,...) SK_PRINTF_LIKE(2
Definition: SkSLString.cpp:92
void VisitLineByLine(const std::string &text, const std::function< void(int lineNumber, const char *lineText)> &visitFn)

◆ PrettyPrint()

std::string SkShaderUtils::PrettyPrint ( const std::string &  string)

Definition at line 242 of file SkShaderUtils.cpp.

242 {
244 return pp.prettify(string);
245}
std::string prettify(const std::string &string)

◆ PrintLineByLine()

void SkShaderUtils::PrintLineByLine ( const std::string &  text)
inline

Definition at line 27 of file SkShaderUtils.h.

27 {
28 VisitLineByLine(text, [](int lineNumber, const char* lineText) {
29 SkDebugf("%4i\t%s\n", lineNumber, lineText);
30 });
31}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
std::u16string text

◆ PrintShaderBanner()

void SkShaderUtils::PrintShaderBanner ( SkSL::ProgramKind  programKind)

Definition at line 266 of file SkShaderUtils.cpp.

266 {
267 const char* typeName = "Unknown";
269 typeName = "Vertex";
271 typeName = "Fragment";
272 }
273 SkDebugf("---- %s shader ----------------------------------------------------\n", typeName);
274}
string programKind
Definition: minify_sksl.py:40
static bool IsVertex(ProgramKind kind)
static bool IsFragment(ProgramKind kind)

◆ VisitLineByLine()

void SkShaderUtils::VisitLineByLine ( const std::string &  text,
const std::function< void(int lineNumber, const char *lineText)> &  visitFn 
)

Definition at line 247 of file SkShaderUtils.cpp.

248 {
251 for (int i = 0; i < lines.size(); ++i) {
252 visitFn(i + 1, lines[i].c_str());
253 }
254}
void SkStrSplit(const char *str, const char *delimiters, SkStrSplitMode splitMode, TArray< SkString > *out)
@ kStrict_SkStrSplitMode
Definition: SkStringUtils.h:47