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 #ifndef skgpu_ShaderErrorHandler_DEFINED 9 #define skgpu_ShaderErrorHandler_DEFINED 10 11 #include "include/core/SkTypes.h" 12 13 namespace skgpu { 14 /** 15 * Abstract class to report errors when compiling shaders. 16 */ 17 class SK_API ShaderErrorHandler { 18 public: 19 virtual ~ShaderErrorHandler() = default; 20 21 /** 22 * compileError(shader, errors) is kept for backward compatibility with older clients. 23 */ compileError(const char * shader,const char * errors)24 virtual void compileError([[maybe_unused]] const char* shader, 25 [[maybe_unused]] const char* errors) {} compileError(const char * shader,const char * errors,bool shaderWasCached)26 virtual void compileError(const char* shader, 27 const char* errors, 28 [[maybe_unused]] bool shaderWasCached) { 29 // Default implementation. Ignore shaderWasCached. 30 this->compileError(shader, errors); 31 } 32 33 protected: 34 ShaderErrorHandler() = default; 35 ShaderErrorHandler(const ShaderErrorHandler&) = delete; 36 ShaderErrorHandler& operator=(const ShaderErrorHandler&) = delete; 37 }; 38 39 /** 40 * Used when no error handler is set. Will report failures via SkDebugf and asserts. 41 */ 42 ShaderErrorHandler* DefaultShaderErrorHandler(); 43 44 } // namespace skgpu 45 46 #endif // skgpu_ShaderErrorHandler_DEFINED 47