1 /* 2 * Copyright (c) 2021 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 FOUNDATION_ACE_FRAMEWORKS_CORE_LAYERS_TRANSFORM_LAYER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_LAYERS_TRANSFORM_LAYER_H 18 19 #include "base/geometry/matrix4.h" 20 #include "core/pipeline/layers/offset_layer.h" 21 #include "core/pipeline/layers/scene_builder.h" 22 23 namespace OHOS::Ace::Flutter { 24 25 class TransformLayer : public OffsetLayer { DECLARE_ACE_TYPE(TransformLayer,OffsetLayer)26 DECLARE_ACE_TYPE(TransformLayer, OffsetLayer) 27 public: 28 TransformLayer(const Matrix4& matrix, double x, double y) : OffsetLayer(x, y), matrix_(matrix) {} 29 ~TransformLayer() override = default; 30 31 void Update(const Matrix4& matrix); 32 void AddToScene(SceneBuilder& builder, double x, double y) override; 33 void Dump() override; 34 35 void SetFilter(const SkPaint& paint); 36 void SetOpacityLayer(int32_t alpha); 37 GetMatrix4()38 const Matrix4& GetMatrix4() const 39 { 40 return matrix_; 41 } 42 43 private: 44 Matrix4 matrix_; 45 std::optional<int32_t> alpha_ = std::nullopt; 46 std::optional<SkPaint> filterPaint_ = std::nullopt; 47 }; 48 49 } // namespace OHOS::Ace::Flutter 50 51 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_LAYERS_TRANSFORM_LAYER_H 52