2 * Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 #ifndef _TVG_RENDER_H_
23 #define _TVG_RENDER_H_
25 #include "tvgCommon.h"
31 enum RenderUpdateFlag {None = 0, Path = 1, Color = 2, Gradient = 4, Stroke = 8, Transform = 16, Image = 32, GradientStroke = 64, All = 255};
35 //TODO: Union for multiple types
42 using RenderData = void*;
46 CompositeMethod method;
54 void intersect(const RenderRegion& rhs)
58 auto x2 = rhs.x + rhs.w;
59 auto y2 = rhs.y + rhs.h;
61 x = (x > rhs.x) ? x : rhs.x;
62 y = (y > rhs.y) ? y : rhs.y;
63 w = ((x1 < x2) ? x1 : x2) - x;
64 h = ((y1 < y2) ? y1 : y2) - y;
71 struct RenderTransform
73 Matrix m; //3x3 Matrix Elements
76 float degree = 0.0f; //rotation degree
77 float scale = 1.0f; //scale factor
78 bool overriding = false; //user transform?
81 void override(const Matrix& m);
84 RenderTransform(const RenderTransform* lhs, const RenderTransform* rhs);
91 virtual ~RenderMethod() {}
92 virtual RenderData prepare(const Shape& shape, RenderData data, const RenderTransform* transform, uint32_t opacity, Array<RenderData>& clips, RenderUpdateFlag flags) = 0;
93 virtual RenderData prepare(Surface* image, RenderData data, const RenderTransform* transform, uint32_t opacity, Array<RenderData>& clips, RenderUpdateFlag flags) = 0;
94 virtual bool preRender() = 0;
95 virtual bool renderShape(RenderData data) = 0;
96 virtual bool renderImage(RenderData data) = 0;
97 virtual bool postRender() = 0;
98 virtual bool dispose(RenderData data) = 0;
99 virtual RenderRegion region(RenderData data) = 0;
100 virtual RenderRegion viewport() = 0;
101 virtual bool viewport(const RenderRegion& vp) = 0;
103 virtual bool clear() = 0;
104 virtual bool sync() = 0;
106 virtual Compositor* target(const RenderRegion& region) = 0;
107 virtual bool beginComposite(Compositor* cmp, CompositeMethod method, uint32_t opacity) = 0;
108 virtual bool endComposite(Compositor* cmp) = 0;
113 #endif //_TVG_RENDER_H_