1 /* 2 * Copyright (c) 2021-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 RENDER_SERVICE_CLIENT_CORE_RENDER_RS_SHADER_H 17 #define RENDER_SERVICE_CLIENT_CORE_RENDER_RS_SHADER_H 18 19 #include "common/rs_macros.h" 20 #include "common/rs_rect.h" 21 #include "effect/shader_effect.h" 22 #include "transaction/rs_marshalling_helper.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 class RSB_EXPORT RSShader { 27 public: 28 enum class ShaderType{ 29 DRAWING = 0, 30 DOT_MATRIX, 31 FLOW_LIGHT_SWEEP, 32 }; 33 34 RSShader() = default; 35 virtual ~RSShader() = default; 36 static std::shared_ptr<RSShader> CreateRSShader(); 37 static std::shared_ptr<RSShader> CreateRSShader(const ShaderType& type); 38 static std::shared_ptr<RSShader> CreateRSShader(const std::shared_ptr<Drawing::ShaderEffect>& drShader); 39 40 void SetDrawingShader(const std::shared_ptr<Drawing::ShaderEffect>& drShader); MakeDrawingShader(const RectF & rect,float progress)41 virtual void MakeDrawingShader(const RectF& rect, float progress) {}; 42 virtual const std::shared_ptr<Drawing::ShaderEffect>& GetDrawingShader() const; 43 44 virtual bool Marshalling(Parcel& parcel); 45 virtual bool Unmarshalling(Parcel& parcel, bool& needReset); 46 GetShaderType()47 inline const ShaderType& GetShaderType() const { return type_; } ; 48 49 private: 50 RSShader(const RSShader&) = delete; 51 RSShader(const RSShader&&) = delete; 52 RSShader& operator=(const RSShader&) = delete; 53 RSShader& operator=(const RSShader&&) = delete; 54 55 protected: 56 ShaderType type_ = ShaderType::DRAWING; 57 std::shared_ptr<Drawing::ShaderEffect> drShader_ = nullptr; 58 }; 59 } // namespace Rosen 60 } // namespace OHOS 61 62 #endif // RENDER_SERVICE_CLIENT_CORE_RENDER_RS_SHADER_H 63