common scene: complete scene tranfsormation feature.
[platform/core/graphics/tizenvg.git] / src / lib / sw_engine / tvgSwCommon.h
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *               http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  *
16  */
17 #ifndef _TVG_SW_COMMON_H_
18 #define _TVG_SW_COMMON_H_
19
20 #include "tvgCommon.h"
21
22 using namespace tvg;
23
24 constexpr auto SW_CURVE_TYPE_POINT = 0;
25 constexpr auto SW_CURVE_TYPE_CUBIC = 1;
26 constexpr auto SW_OUTLINE_FILL_WINDING = 0;
27 constexpr auto SW_OUTLINE_FILL_EVEN_ODD = 1;
28
29 using SwCoord = signed long;
30
31 struct SwPoint
32 {
33     SwCoord x, y;
34
35     SwPoint operator+(const SwPoint& rhs) const {
36         return {x + rhs.x, y + rhs.y};
37     }
38
39     SwPoint operator-(const SwPoint& rhs) const {
40         return {x - rhs.x, y - rhs.y};
41     }
42
43     bool operator==(const SwPoint& rhs ) const {
44         return (x == rhs.x && y == rhs.y);
45     }
46
47     bool operator!=(const SwPoint& rhs) const {
48         return (x != rhs.x || y != rhs.y);
49     }
50 };
51
52 struct SwSize
53 {
54     SwCoord w, h;
55 };
56
57 struct SwOutline
58 {
59     size_t*     cntrs;            //the contour end points
60     size_t      cntrsCnt;         //number of contours in glyph
61     size_t      reservedCntrsCnt;
62     SwPoint*    pts;              //the outline's points
63     size_t      ptsCnt;           //number of points in the glyph
64     size_t      reservedPtsCnt;
65     uint8_t*    types;            //curve type
66     uint8_t     fillMode;         //outline fill mode
67 };
68
69 struct SwSpan
70 {
71     int16_t x, y;
72     uint16_t len;
73     uint8_t coverage;
74 };
75
76 struct SwRleData
77 {
78     SwSpan *spans;
79     size_t alloc;
80     size_t size;
81 };
82
83 struct SwBBox
84 {
85     SwPoint min, max;
86 };
87
88 struct SwShape
89 {
90     SwOutline*   outline;
91     SwRleData*   rle;
92     SwBBox       bbox;
93 };
94
95 void shapeReset(SwShape& sdata);
96 bool shapeGenOutline(const Shape& shape, SwShape& sdata);
97 void shapeDelOutline(SwShape& sdata);
98 bool shapeGenRle(const Shape& shape, SwShape& sdata, const SwSize& clip);
99 void shapeTransformOutline(const Shape& shape, SwShape& sdata, const RenderTransform& transform);
100 SwRleData* rleRender(const SwShape& sdata, const SwSize& clip);
101
102 bool rasterShape(Surface& surface, SwShape& sdata, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
103
104 #endif /* _TVG_SW_COMMON_H_ */