xref: /third_party/skia/src/gpu/GrShaderUtils.h (revision cb93a386)
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"
12#include "include/gpu/GrContextOptions.h"
13#include "include/private/SkSLProgramKind.h"
14#include "include/private/SkSLString.h"
15
16namespace GrShaderUtils {
17
18SkSL::String PrettyPrint(const SkSL::String& string);
19
20void 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.
24inline 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
30// Combines raw shader and error text into an easier-to-read error message with line numbers.
31SkSL::String BuildShaderErrorMessage(const char* shader, const char* errors);
32
33GrContextOptions::ShaderErrorHandler* DefaultShaderErrorHandler();
34
35void PrintShaderBanner(SkSL::ProgramKind programKind);
36
37}  // namespace GrShaderUtils
38
39#endif
40