1 /* 2 * Copyright 2021 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 #include "include/gpu/ShaderErrorHandler.h" 9 10 #include "src/utils/SkShaderUtils.h" 11 12 namespace skgpu { 13 DefaultShaderErrorHandler()14ShaderErrorHandler* DefaultShaderErrorHandler() { 15 class DefaultShaderErrorHandler : public ShaderErrorHandler { 16 public: 17 void compileError(const char* shader, const char* errors) override { 18 std::string message = SkShaderUtils::BuildShaderErrorMessage(shader, errors); 19 SkShaderUtils::VisitLineByLine(message, [](int, const char* lineText) { 20 SkDebugf("%s\n", lineText); 21 }); 22 SkDEBUGFAIL("Shader compilation failed!"); 23 } 24 }; 25 26 static DefaultShaderErrorHandler gHandler; 27 return &gHandler; 28 } 29 30 } // namespace SkShaderUtils 31