Brian Osman | ac9be9d | 2019-05-01 10:29:34 -0400 | [diff] [blame] | 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 GrShaderUtils_DEFINED |
| 9 | #define GrShaderUtils_DEFINED |
| 10 | |
| 11 | #include "include/core/SkTypes.h" |
Brian Osman | 5e7fbfd | 2019-05-03 13:13:35 -0400 | [diff] [blame] | 12 | #include "include/gpu/GrContextOptions.h" |
Brian Osman | ac9be9d | 2019-05-01 10:29:34 -0400 | [diff] [blame] | 13 | #include "src/sksl/SkSLString.h" |
Robert Phillips | 797831c | 2020-11-20 22:35:55 +0000 | [diff] [blame^] | 14 | #include "src/sksl/ir/SkSLProgram.h" |
Brian Osman | ac9be9d | 2019-05-01 10:29:34 -0400 | [diff] [blame] | 15 | |
| 16 | namespace GrShaderUtils { |
| 17 | |
| 18 | SkSL::String PrettyPrint(const SkSL::String& string); |
Chris Dalton | 7791298 | 2019-12-16 11:18:13 -0700 | [diff] [blame] | 19 | |
| 20 | void VisitLineByLine(const SkSL::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. |
| 24 | inline void PrintLineByLine(const SkSL::String& text) { |
| 25 | VisitLineByLine(text, [](int lineNumber, const char* lineText) { |
| 26 | SkDebugf("%4i\t%s\n", lineNumber, lineText); |
| 27 | }); |
| 28 | } |
| 29 | |
Brian Osman | 5e7fbfd | 2019-05-03 13:13:35 -0400 | [diff] [blame] | 30 | GrContextOptions::ShaderErrorHandler* DefaultShaderErrorHandler(); |
Brian Osman | ac9be9d | 2019-05-01 10:29:34 -0400 | [diff] [blame] | 31 | |
Robert Phillips | 797831c | 2020-11-20 22:35:55 +0000 | [diff] [blame^] | 32 | void PrintShaderBanner(SkSL::Program::Kind programKind); |
| 33 | |
John Stiles | a6841be | 2020-08-06 14:11:56 -0400 | [diff] [blame] | 34 | } // namespace GrShaderUtils |
Brian Osman | ac9be9d | 2019-05-01 10:29:34 -0400 | [diff] [blame] | 35 | |
| 36 | #endif |