1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef RUNTIME_SHADER_BUILDER_H 17 #define RUNTIME_SHADER_BUILDER_H 18 19 #include "drawing/engine_adapter/impl_interface/runtime_shader_builder_impl.h" 20 #include "utils/drawing_macros.h" 21 #include "utils/matrix44.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 namespace Drawing { 26 class RuntimeEffect; 27 class DRAWING_API RuntimeShaderBuilder { 28 public: 29 RuntimeShaderBuilder(std::shared_ptr<RuntimeEffect> runtimeEffect) noexcept; 30 virtual ~RuntimeShaderBuilder() = default; 31 32 std::shared_ptr<ShaderEffect> MakeShader(const Matrix* localMatrix, bool isOpaque); 33 std::shared_ptr<Image> MakeImage(GPUContext* gpuContext, 34 const Matrix* localMatrix, ImageInfo resultInfo, bool mipmapped); 35 36 void SetChild(const std::string& name, std::shared_ptr<ShaderEffect> shader); 37 void SetUniform(const std::string& name, float val); 38 void SetUniform(const std::string& name, float x, float y); 39 void SetUniform(const std::string& name, float x, float y, float z); 40 void SetUniform(const std::string& name, float x, float y, float width, float height); 41 void SetUniform(const std::string& name, const float values[], size_t size); 42 void SetUniform(const std::string& name, const Matrix& uniformMatrix33); 43 void SetUniform(const std::string& name, const Matrix44& uniformMatrix44); 44 void SetUniformVec4(const std::string& name, float x, float y, float z, float w); 45 private: 46 std::shared_ptr<RuntimeShaderBuilderImpl> impl_; 47 }; 48 } // namespace Drawing 49 } // namespace Rosen 50 } // namespace OHOS 51 #endif // RUNTIMR_SHADER_BUILDER_H