1 /* 2 * Copyright 2019 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkShaderUtils_DEFINED 9 #define SkShaderUtils_DEFINED 10 11 #include <functional> 12 13 #include "include/private/SkSLProgramKind.h" 14 #include "include/private/SkSLString.h" 15 16 namespace SkShaderUtils { 17 18 std::string PrettyPrint(const std::string& string); 19 20 void VisitLineByLine(const std::string& text, 21 const std::function<void(int lineNumber, const char* lineText)>&); 22 23 // Prints shaders one line at the time. This ensures they don't get truncated by the adb log. PrintLineByLine(const std::string & text)24inline void PrintLineByLine(const std::string& text) { 25 VisitLineByLine(text, [](int lineNumber, const char* lineText) { 26 SkDebugf("%4i\t%s\n", lineNumber, lineText); 27 }); 28 } 29 30 // Combines raw shader and error text into an easier-to-read error message with line numbers. 31 std::string BuildShaderErrorMessage(const char* shader, const char* errors); 32 33 void PrintShaderBanner(SkSL::ProgramKind programKind); 34 35 } // namespace SkShaderUtils 36 37 #endif 38