• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef RENDER_SERVICE_CLIENT_CORE_COMMON_RS_OBJ_ABS_GEOMETRY_H
16 #define RENDER_SERVICE_CLIENT_CORE_COMMON_RS_OBJ_ABS_GEOMETRY_H
17 
18 #include <memory>
19 
20 #include "include/core/SkMatrix.h"
21 #include "include/core/SkPoint.h"
22 
23 #include "common/rs_macros.h"
24 #include "common/rs_matrix3.h"
25 #include "common/rs_obj_geometry.h"
26 #include "common/rs_rect.h"
27 #include "common/rs_vector2.h"
28 
29 namespace OHOS {
30 namespace Rosen {
31 class RSB_EXPORT RSObjAbsGeometry : public RSObjGeometry {
32 public:
33     RSObjAbsGeometry();
34     ~RSObjAbsGeometry() override;
35     void ConcatMatrix(const SkMatrix& matrix);
36     void UpdateMatrix(const std::shared_ptr<RSObjAbsGeometry>& parent, float offsetX, float offsetY);
37 
38     // Using by RenderService
39     void UpdateByMatrixFromSelf();
40 
GetAbsRect()41     const RectI& GetAbsRect() const
42     {
43         return absRect_;
44     }
45     RectI MapAbsRect(const RectF& rect) const;
GetMatrix()46     const SkMatrix& GetMatrix() const
47     {
48         return matrix_;
49     }
50 
GetAbsMatrix()51     const SkMatrix& GetAbsMatrix() const
52     {
53         return absMatrix_;
54     }
55 
56     bool IsPointInHotZone(const float x, const float y) const;
57 
58     bool IsNeedClientCompose() const;
59 
60 private:
61     void UpdateAbsMatrix2D();
62     void UpdateAbsMatrix3D();
63     void SetAbsRect();
64     float GetCross(const SkPoint& p1, const SkPoint& p2, const SkPoint& p) const;
65     Vector2f GetDataRange(float d0, float d1, float d2, float d3) const;
66     bool IsPointInLine(const SkPoint& p1, const SkPoint& p2, const SkPoint& p, const float crossRes) const;
67     RectI absRect_;
68     SkMatrix matrix_;
69     SkMatrix absMatrix_;
70     SkPoint vertices_[4];
71 };
72 } // namespace Rosen
73 } // namespace OHOS
74 #endif // RENDER_SERVICE_CLIENT_CORE_COMMON_RS_OBJ_ABS_GEOMETRY_H
75