1 /*
2  * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3  *           (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
4  *
5  * This file is part of lsp-plugins
6  * Created on: 13 авг. 2017 г.
7  *
8  * lsp-plugins is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * any later version.
12  *
13  * lsp-plugins is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with lsp-plugins. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef UI_TK_UTIL_LSPSURFACE_H_
23 #define UI_TK_UTIL_LSPSURFACE_H_
24 
25 namespace lsp
26 {
27     namespace tk
28     {
29         class LSPSurface: public ISurface
30         {
31             protected:
32                 ws::ISurface       *pS;
33                 ssize_t             nX;
34                 ssize_t             nY;
35 
36             public:
37                 explicit LSPSurface(ISurface *ws, ssize_t dx = 0, ssize_t dy = 0);
38                 virtual ~LSPSurface();
39 
40             public:
41                 virtual ISurface *create(size_t width, size_t height);
42 
43                 virtual IGradient *linear_gradient(float x0, float y0, float x1, float y1);
44 
45                 virtual IGradient *radial_gradient
46                 (
47                     float cx0, float cy0, float r0,
48                     float cx1, float cy1, float r1
49                 );
50 
51                 virtual void destroy();
52 
53                 virtual void begin();
54 
55                 virtual void end();
56 
57             public:
58                 virtual void draw(ISurface *s, float x, float y);
59 
60                 virtual void fill_rect(float left, float top, float width, float height, const Color &color);
61 
62                 virtual void fill_rect(float left, float top, float width, float height, IGradient *g);
63 
64                 virtual void wire_rect(float left, float top, float width, float height, float line_width, const Color &color);
65 
66                 virtual void wire_round_rect(float left, float top, float width, float height, float radius, size_t mask, float line_width, const Color &color);
67 
68                 virtual void wire_round_rect(float left, float top, float width, float height, float radius, size_t mask, float line_width, IGradient *g);
69 
70                 virtual void fill_round_rect(float left, float top, float width, float height, float radius, size_t mask, const Color &color);
71 
72                 virtual void fill_round_rect(float left, float top, float width, float height, float radius, size_t mask, IGradient *g);
73 
74                 virtual void full_rect(float left, float top, float width, float height, float line_width, const Color &color);
75 
76                 virtual void fill_round_rect(float left, float top, float width, float height, float radius, const Color &color);
77 
78                 virtual void fill_round_rect(float left, float top, float width, float height, float radius, IGradient *g);
79 
80                 virtual void fill_sector(float cx, float cy, float radius, float angle1, float angle2, const Color &color);
81 
82                 virtual void fill_triangle(float x0, float y0, float x1, float y1, float x2, float y2, IGradient *g);
83 
84                 virtual void fill_triangle(float x0, float y0, float x1, float y1, float x2, float y2, const Color &color);
85 
86                 virtual bool get_font_parameters(const Font &f, font_parameters_t *fp);
87 
88                 virtual bool get_text_parameters(const Font &f, text_parameters_t *tp, const char *text);
89 
90                 virtual void clear(const Color &color);
91 
92                 virtual void clear_rgb(uint32_t color);
93 
94                 virtual void clear_rgba(uint32_t color);
95 
96                 virtual void out_text(const Font &f, float x, float y, const char *text, const Color &color);
97 
98                 virtual void out_text_relative(const Font &f, float x, float y, float dx, float dy, const char *text, const Color &color);
99 
100                 virtual void line(float x0, float y0, float x1, float y1, float width, const Color &color);
101 
102                 virtual void parametric_line(float a, float b, float c, float width, const Color &color);
103 
104                 virtual void parametric_line(float a, float b, float c, float left, float right, float top, float bottom, float width, const Color &color);
105 
106                 virtual void wire_arc(float x, float y, float r, float a1, float a2, float width, const Color &color);
107 
108                 virtual void fill_poly(const float *x, const float *y, size_t n, const Color & color);
109 
110                 virtual void wire_poly(const float *x, const float *y, size_t n, float width, const Color & color);
111 
112                 virtual void draw_poly(const float *x, const float *y, size_t n, float width, const Color &fill, const Color &wire);
113 
114                 virtual void fill_circle(float x, float y, float r, const Color & color);
115 
116                 virtual void fill_circle(float x, float y, float r, IGradient *g);
117 
118                 virtual bool get_antialiasing();
119 
120                 virtual bool set_antialiasing(bool set);
121         };
122 
123     } /* namespace tk */
124 } /* namespace lsp */
125 
126 #endif /* UI_TK_UTIL_LSPSURFACE_H_ */
127