• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_COMPONENTS_TRANSFORM_FLUTTER_RENDER_TRANSFORM_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TRANSFORM_FLUTTER_RENDER_TRANSFORM_H
18 
19 #include "core/components/transform/render_transform.h"
20 #include "core/pipeline/base/flutter_render_context.h"
21 #include "core/pipeline/layers/transform_layer.h"
22 
23 namespace OHOS::Ace {
24 
25 class FlutterRenderTransform final : public RenderTransform {
26     DECLARE_ACE_TYPE(FlutterRenderTransform, RenderTransform);
27 
28 public:
29     FlutterRenderTransform() = default;
30     ~FlutterRenderTransform() override = default;
31     RenderLayer GetRenderLayer() override;
32     void Paint(RenderContext& context, const Offset& offset) override;
33     void OnGlobalPositionChanged() override;
34 
IsRepaintBoundary()35     bool IsRepaintBoundary() const override
36     {
37         return true;
38     }
39 
40     bool HasEffectiveTransform() const override;
41 
42     Point GetTransformPoint(const Point& point) override;
43     Rect GetTransformRect(const Rect& rect) override;
44 
45     void UpdateTransformLayer() override;
46 
47     void Mirror(const Offset& center, const Offset& global) override;
48 
49 private:
50     Matrix4 GetEffectiveTransform(const Offset& offset);
51     void UpdateTransformByGlobalOffset();
52     bool CheckNeedPaint() const;
53 
54     RefPtr<Flutter::TransformLayer> layer_;
55 };
56 
57 } // namespace OHOS::Ace
58 
59 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TRANSFORM_FLUTTER_RENDER_TRANSFORM_H
60