1 /* 2 * Copyright (c) 2024 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 #ifndef UIEFFECT_FILTER_PIXEL_STRETCH_PARA_H 16 #define UIEFFECT_FILTER_PIXEL_STRETCH_PARA_H 17 18 #include "common/rs_vector4.h" 19 #include "effect/shader_effect.h" 20 #include "filter_para.h" 21 #include "ui_effect/utils.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 constexpr std::pair<float, float> STRETCH_PERCENT_LIMITS {-1.f, 1.f}; // limits for stretch percent 26 27 class PixelStretchPara : public FilterPara { 28 public: PixelStretchPara()29 PixelStretchPara() 30 { 31 this->type_ = FilterPara::ParaType::PIXEL_STRETCH; 32 } 33 ~PixelStretchPara() override = default; 34 SetStretchPercent(const Vector4f & stretchPercent)35 inline void SetStretchPercent(const Vector4f& stretchPercent) 36 { 37 if (UIEffect::IsParaSameSign(stretchPercent)) { 38 stretchPercent_ = UIEffect::GetLimitedPara(stretchPercent, STRETCH_PERCENT_LIMITS); 39 } 40 } 41 GetStretchPercent()42 const Vector4f& GetStretchPercent() const 43 { 44 return stretchPercent_; 45 } 46 SetTileMode(Drawing::TileMode stretchTileMode)47 void SetTileMode(Drawing::TileMode stretchTileMode) 48 { 49 stretchTileMode_ = stretchTileMode; 50 } 51 GetTileMode()52 Drawing::TileMode GetTileMode() const 53 { 54 return stretchTileMode_; 55 } 56 57 private: 58 Vector4f stretchPercent_; 59 Drawing::TileMode stretchTileMode_ = Drawing::TileMode::CLAMP; 60 }; 61 } // namespace Rosen 62 } // namespace OHOS 63 #endif // UIEFFECT_FILTER_PIXEL_STRETCH_PARA_H 64