Debian Codegraph @

src/utils/SkShaderUtils.h

raw
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 "include/core/SkSpan.h"
12 #include "include/private/base/SkDebug.h"
13
14 #include <cstdint>
15 #include <functional>
16 #include <string>
17
18 namespace SkSL { enum class ProgramKind : int8_t; }
19
20 namespace SkShaderUtils {
21
22 std::string PrettyPrint(const std::string& string);
23
24 void VisitLineByLine(const std::string& text,
25 const std::function<void(int lineNumber, const char* lineText)>&);
26
27 // Prints shaders one line at the time. This ensures they don't get truncated by the adb log.
28 inline void PrintLineByLine(const std::string& text) {
29 VisitLineByLine(text, [](int lineNumber, const char* lineText) {
30 SkDebugf("%4i\t%s\n", lineNumber, lineText);
31 });
32 }
33
34 // Prints binary shaders one line at the time. This ensures they don't get truncated by the adb log.
35 std::string SpirvAsHexStream(SkSpan<const uint32_t> spirv);
36
37 // Combines raw shader and error text into an easier-to-read error message with line numbers.
38 std::string BuildShaderErrorMessage(const char* shader, const char* errors);
39
40 void PrintShaderBanner(SkSL::ProgramKind programKind);
41
42 } // namespace SkShaderUtils
43
44 #endif