1 /* 2 * Copyright (c) 2025 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_BASE_RS_PIXEL_MAP_SHADER_OBJ_H 17 #define RENDER_SERVICE_BASE_RS_PIXEL_MAP_SHADER_OBJ_H 18 19 #include "common/rs_macros.h" 20 #include "effect/shader_effect_obj.h" 21 #include "effect/shader_effect_lazy.h" 22 #include "pixel_map.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 // Only supports the Drawing NDK interface. 27 class RSB_EXPORT RSPixelMapShaderObj final : public Drawing::ShaderEffectObj { 28 public: 29 static std::shared_ptr<Drawing::ShaderEffectLazy> CreatePixelMapShader( 30 std::shared_ptr<Media::PixelMap> pixelMap, 31 Drawing::TileMode tileX, 32 Drawing::TileMode tileY, 33 const Drawing::SamplingOptions& sampling, 34 const Drawing::Matrix& matrix); 35 static std::shared_ptr<RSPixelMapShaderObj> CreateForUnmarshalling(); 36 ~RSPixelMapShaderObj() override = default; 37 38 #ifdef ROSEN_OHOS 39 bool Marshalling(Parcel& parcel) override; 40 bool Unmarshalling(Parcel& parcel, bool& isValid, int32_t depth = 0) override; 41 #endif 42 std::shared_ptr<void> GenerateBaseObject() override; 43 44 private: 45 RSPixelMapShaderObj(); 46 RSPixelMapShaderObj( 47 std::shared_ptr<Media::PixelMap> pixelMap, 48 Drawing::TileMode tileX, 49 Drawing::TileMode tileY, 50 const Drawing::SamplingOptions& sampling, 51 const Drawing::Matrix& matrix); 52 std::shared_ptr<Media::PixelMap> pixelMap_ = nullptr; 53 Drawing::TileMode tileX_ = Drawing::TileMode::CLAMP; 54 Drawing::TileMode tileY_ = Drawing::TileMode::CLAMP; 55 Drawing::SamplingOptions sampling_; 56 Drawing::Matrix matrix_; 57 }; 58 } // namespace Rosen 59 } // namespace OHOS 60 61 #endif // RENDER_SERVICE_BASE_RS_PIXEL_MAP_SHADER_OBJ_H