blob: c41906fe0e5fd1e4d5c1f70557160d8281d3d328 [file] [log] [blame]
Brian Osmanac9be9d2019-05-01 10:29:34 -04001/*
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 Osman5e7fbfd2019-05-03 13:13:35 -040012#include "include/gpu/GrContextOptions.h"
Brian Osmanac9be9d2019-05-01 10:29:34 -040013#include "src/sksl/SkSLString.h"
Robert Phillips797831c2020-11-20 22:35:55 +000014#include "src/sksl/ir/SkSLProgram.h"
Brian Osmanac9be9d2019-05-01 10:29:34 -040015
16namespace GrShaderUtils {
17
18SkSL::String PrettyPrint(const SkSL::String& string);
Chris Dalton77912982019-12-16 11:18:13 -070019
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
Brian Osman5e7fbfd2019-05-03 13:13:35 -040030GrContextOptions::ShaderErrorHandler* DefaultShaderErrorHandler();
Brian Osmanac9be9d2019-05-01 10:29:34 -040031
Robert Phillips797831c2020-11-20 22:35:55 +000032void PrintShaderBanner(SkSL::Program::Kind programKind);
33
John Stilesa6841be2020-08-06 14:11:56 -040034} // namespace GrShaderUtils
Brian Osmanac9be9d2019-05-01 10:29:34 -040035
36#endif