Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkShaderUtils.h
Go to the documentation of this file.
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
12
13#include <cstdint>
14#include <functional>
15#include <string>
16
17namespace SkSL { enum class ProgramKind : int8_t; }
18
19namespace SkShaderUtils {
20
21std::string PrettyPrint(const std::string& string);
22
23void VisitLineByLine(const std::string& text,
24 const std::function<void(int lineNumber, const char* lineText)>&);
25
26// Prints shaders one line at the time. This ensures they don't get truncated by the adb log.
27inline void PrintLineByLine(const std::string& text) {
28 VisitLineByLine(text, [](int lineNumber, const char* lineText) {
29 SkDebugf("%4i\t%s\n", lineNumber, lineText);
30 });
31}
32
33// Combines raw shader and error text into an easier-to-read error message with line numbers.
34std::string BuildShaderErrorMessage(const char* shader, const char* errors);
35
36void PrintShaderBanner(SkSL::ProgramKind programKind);
37
38} // namespace SkShaderUtils
39
40#endif
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
std::u16string text
std::string PrettyPrint(const std::string &string)
void VisitLineByLine(const std::string &text, const std::function< void(int lineNumber, const char *lineText)> &visitFn)
void PrintShaderBanner(SkSL::ProgramKind programKind)
std::string BuildShaderErrorMessage(const char *shader, const char *errors)
void PrintLineByLine(const std::string &text)