22using EmptyFlow . SciterAPI . Enums ;
33using EmptyFlow . SciterAPI . Structs ;
44using System . Numerics ;
5+ using System . Runtime . CompilerServices ;
56using System . Runtime . InteropServices ;
67
78namespace EmptyFlow . SciterAPI {
@@ -12,12 +13,14 @@ public partial class SciterAPIHost {
1213 /// Redraw element.
1314 /// </summary>
1415 /// <param name="element">Element.</param>
16+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
1517 public void RedrawElement ( nint element ) => m_basicApi . SciterUpdateElement ( element , false ) ;
1618
1719 /// <summary>
1820 /// Force rendering element.
1921 /// </summary>
2022 /// <param name="element">Element.</param>
23+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
2124 public void ForceRenderElement ( nint element ) => m_basicApi . SciterUpdateElement ( element , true ) ;
2225
2326 private bool CheckGraphics ( ) {
@@ -64,9 +67,8 @@ public void GraphicsPerformInState ( nint hgfx, Action callback ) {
6467 /// </summary>
6568 /// <param name="hgfx">Pointer on graphics surface.</param>
6669 /// <param name="color">Line color. You need to get color from GraphicsGetColor method.</param>
70+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
6771 public void GraphicsLineColor ( nint hgfx , uint color ) {
68- if ( ! CheckGraphics ( ) ) return ;
69-
7072 m_graphicsApi . gLineColor ( hgfx , color ) ;
7173 }
7274
@@ -80,9 +82,8 @@ public void GraphicsLineColor ( nint hgfx, uint color ) {
8082 /// <param name="y2">Y2 coordinate.</param>
8183 /// <param name="stops">Color stops.</param>
8284 /// <param name="nstops">No idea what is it.</param>
85+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
8386 public void GraphicsLineGradientLinear ( nint hgfx , float x1 , float y1 , float x2 , float y2 , ColorStop [ ] stops , uint nstops ) {
84- if ( ! CheckGraphics ( ) ) return ;
85-
8687 m_graphicsApi . gLineGradientLinear ( hgfx , x1 , y1 , x2 , y2 , stops , nstops ) ;
8788 }
8889
@@ -96,9 +97,8 @@ public void GraphicsLineGradientLinear ( nint hgfx, float x1, float y1, float x2
9697 /// <param name="y2">Y2 coordinate.</param>
9798 /// <param name="stops">Color stops.</param>
9899 /// <param name="nstops">No idea what is it.</param>
100+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
99101 public void GraphicsLineGradientRadial ( nint hgfx , float x1 , float y1 , float x2 , float y2 , ColorStop [ ] stops , uint nstops ) {
100- if ( ! CheckGraphics ( ) ) return ;
101-
102102 m_graphicsApi . gLineGradientRadial ( hgfx , x1 , y1 , x2 , y2 , stops , nstops ) ;
103103 }
104104
@@ -107,9 +107,8 @@ public void GraphicsLineGradientRadial ( nint hgfx, float x1, float y1, float x2
107107 /// </summary>
108108 /// <param name="hgfx">Pointer on graphics surface.</param>
109109 /// <param name="color">Line color. You need to get color from GraphicsGetColor method.</param>
110+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
110111 public void GraphicsFillColor ( nint hgfx , uint color ) {
111- if ( ! CheckGraphics ( ) ) return ;
112-
113112 m_graphicsApi . gFillColor ( hgfx , color ) ;
114113 }
115114
@@ -123,9 +122,8 @@ public void GraphicsFillColor ( nint hgfx, uint color ) {
123122 /// <param name="y2">Y2 coordinate.</param>
124123 /// <param name="stops">Color stops.</param>
125124 /// <param name="nstops">No idea what is it.</param>
125+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
126126 public void GraphicsFillGradientLinear ( nint hgfx , float x1 , float y1 , float x2 , float y2 , ColorStop [ ] stops , uint nstops ) {
127- if ( ! CheckGraphics ( ) ) return ;
128-
129127 m_graphicsApi . gFillGradientLinear ( hgfx , x1 , y1 , x2 , y2 , stops , nstops ) ;
130128 }
131129
@@ -139,9 +137,8 @@ public void GraphicsFillGradientLinear ( nint hgfx, float x1, float y1, float x2
139137 /// <param name="y2">Y2 coordinate.</param>
140138 /// <param name="stops">Color stops.</param>
141139 /// <param name="nstops">No idea what is it.</param>
140+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
142141 public void GraphicsFillGradientRadial ( nint hgfx , float x1 , float y1 , float x2 , float y2 , ColorStop [ ] stops , uint nstops ) {
143- if ( ! CheckGraphics ( ) ) return ;
144-
145142 m_graphicsApi . gFillGradientRadial ( hgfx , x1 , y1 , x2 , y2 , stops , nstops ) ;
146143 }
147144
@@ -150,9 +147,8 @@ public void GraphicsFillGradientRadial ( nint hgfx, float x1, float y1, float x2
150147 /// </summary>
151148 /// <param name="hgfx">Pointer on graphics surface.</param>
152149 /// <param name="width">New width for the line.</param>
150+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
153151 public void GraphicsSetLineWidth ( nint hgfx , float width ) {
154- if ( ! CheckGraphics ( ) ) return ;
155-
156152 m_graphicsApi . gLineWidth ( hgfx , width ) ;
157153 }
158154
@@ -164,12 +160,54 @@ public void GraphicsSetLineWidth ( nint hgfx, float width ) {
164160 /// <param name="y1">Y1 coordinate.</param>
165161 /// <param name="x2">X2 coordinate.</param>
166162 /// <param name="y2">Y2 coordinate.</param>
163+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
167164 public void GraphicsDrawLine ( nint hgfx , float x1 , float y1 , float x2 , float y2 ) {
168- if ( ! CheckGraphics ( ) ) return ;
169-
170165 m_graphicsApi . gLine ( hgfx , x1 , y1 , x2 , y2 ) ;
171166 }
172167
168+ public nint GraphicsPath ( Action < nint > callback ) {
169+ var result = m_graphicsApi . pathCreate ( out var path ) ;
170+ if ( result != GraphInResult . Ok ) return path ;
171+
172+ callback ( path ) ;
173+
174+ m_graphicsApi . pathClosePath ( path ) ;
175+
176+ return nint . Zero ;
177+ }
178+
179+ public bool GraphicsDrawPath ( nint hgfx , nint path , DrawPathMode pathMode ) {
180+ var result = m_graphicsApi . gDrawPath ( hgfx , path , pathMode ) ;
181+ if ( result == GraphInResult . Ok ) return true ;
182+
183+ return false ;
184+ }
185+
186+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
187+ public void GraphicsPathLineTo ( nint path , SciterPoint position , bool relative ) {
188+ m_graphicsApi . pathLineTo ( path , position . X , position . Y , relative ) ;
189+ }
190+
191+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
192+ public void GraphicsPathMoveTo ( nint path , SciterPoint position , bool relative ) {
193+ m_graphicsApi . pathMoveTo ( path , position . X , position . Y , relative ) ;
194+ }
195+
196+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
197+ public void GraphicsPathArcTo ( nint path , SciterPoint position , float angle , SciterPoint radius , bool largeArc , bool clockwise , bool relative ) {
198+ m_graphicsApi . pathArcTo ( path , position . X , position . Y , angle , radius . X , radius . Y , largeArc , clockwise , relative ) ;
199+ }
200+
201+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
202+ public void GraphicsPathQuadraticCurveTo ( nint path , float xc , float yc , float x , float y , bool relative ) {
203+ m_graphicsApi . pathQuadraticCurveTo ( path , xc , yc , x , y , relative ) ;
204+ }
205+
206+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
207+ public void GraphicsPathQuadraticCurveTo ( nint path , float xc1 , float yc1 , float xc2 , float yc2 , float x , float y , bool relative ) {
208+ m_graphicsApi . pathBezierCurveTo ( path , xc1 , yc1 , xc2 , yc2 , x , y , relative ) ;
209+ }
210+
173211 /// <summary>
174212 /// Draws line from x1,y1 to x2,y2 with width and color.
175213 /// </summary>
@@ -179,8 +217,6 @@ public void GraphicsDrawLine ( nint hgfx, float x1, float y1, float x2, float y2
179217 /// <param name="x2">X2 coordinate.</param>
180218 /// <param name="y2">Y2 coordinate.</param>
181219 public void GraphicsDrawLine ( nint hgfx , Vector2 start , Vector2 end , uint color , float width ) {
182- if ( ! CheckGraphics ( ) ) return ;
183-
184220 m_graphicsApi . gLineColor ( hgfx , color ) ;
185221 m_graphicsApi . gLineWidth ( hgfx , width ) ;
186222 m_graphicsApi . gLine ( hgfx , start . X , start . Y , end . X , end . Y ) ;
@@ -194,9 +230,8 @@ public void GraphicsDrawLine ( nint hgfx, Vector2 start, Vector2 end, uint color
194230 /// <param name="y1">Y1 coordinate.</param>
195231 /// <param name="rx">Radius X.</param>
196232 /// <param name="ry">Radius Y.</param>
233+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
197234 public void GraphicsDrawEllipse ( nint hgfx , float x1 , float y1 , float rx , float ry ) {
198- if ( ! CheckGraphics ( ) ) return ;
199-
200235 m_graphicsApi . gEllipse ( hgfx , x1 , y1 , rx , ry ) ;
201236 }
202237
@@ -208,9 +243,8 @@ public void GraphicsDrawEllipse ( nint hgfx, float x1, float y1, float rx, float
208243 /// <param name="y1">Y1 coordinate.</param>
209244 /// <param name="x2">X2 coordinate.</param>
210245 /// <param name="y2">Y2 coordinate.</param>
246+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
211247 public void GraphicsDrawRectangle ( nint hgfx , float x1 , float y1 , float x2 , float y2 ) {
212- if ( ! CheckGraphics ( ) ) return ;
213-
214248 m_graphicsApi . gRectangle ( hgfx , x1 , y1 , x2 , y2 ) ;
215249 }
216250
@@ -223,9 +257,8 @@ public void GraphicsDrawRectangle ( nint hgfx, float x1, float y1, float x2, flo
223257 /// <param name="x2">X2 coordinate.</param>
224258 /// <param name="y2">Y2 coordinate.</param>
225259 /// <param name="radii8">8 pair array.</param>
260+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
226261 public void GraphicsDrawRoundedRectangle ( nint hgfx , float x1 , float y1 , float x2 , float y2 , float [ ] radii8 ) {
227- if ( ! CheckGraphics ( ) ) return ;
228-
229262 m_graphicsApi . gRoundedRectangle ( hgfx , x1 , y1 , x2 , y2 , radii8 ) ;
230263 }
231264
@@ -269,21 +302,17 @@ public void GraphicsReleaseText ( GraphicsTextModel text ) {
269302 /// <param name="y">Y coordinate.</param>
270303 /// <param name="coordinates">Position (1..9).</param>
271304 public void GraphicsDrawText ( nint hgfx , GraphicsTextModel text , Vector2 coordinates , SciterTextPosition position ) {
272- if ( ! CheckGraphics ( ) ) return ;
273-
274305 var graphResult = m_graphicsApi . gDrawText ( hgfx , text . Id , coordinates . X , coordinates . Y , ( uint ) position ) ;
275306 if ( graphResult != GraphInResult . Ok ) Console . WriteLine ( "GraphicsDrawText resulted with error, actual result - " + graphResult ) ;
276307 }
277308
309+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
278310 public void GraphicsDrawImage ( nint hgfx , nint image , float x , float y , float w , float h , uint ix , uint iy , uint iw , uint ih , float opacity ) {
279- if ( ! CheckGraphics ( ) ) return ;
280-
281311 m_graphicsApi . gDrawImage ( hgfx , image , x , y , w , h , ix , iy , iw , ih , opacity ) ;
282312 }
283313
314+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
284315 public void GraphicsDrawImage ( nint hgfx , nint image , Vector2 position , Vector2 size , uint ix , uint iy , uint iw , uint ih , float opacity ) {
285- if ( ! CheckGraphics ( ) ) return ;
286-
287316 m_graphicsApi . gDrawImage ( hgfx , image , position . X , position . Y , position . X , position . Y , ix , iy , iw , ih , opacity ) ;
288317 }
289318
@@ -294,10 +323,9 @@ public void GraphicsDrawImage ( nint hgfx, nint image, Vector2 position, Vector2
294323 /// <param name="g">Green.</param>
295324 /// <param name="b">Blue.</param>
296325 /// <param name="a">Alpha, be default is 255.</param>
326+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
297327 public uint GraphicsGetColor ( uint r , uint g , uint b , uint a = 255 ) {
298- if ( CheckGraphics ( ) ) return m_graphicsApi . RGBA ( r , g , b , a ) ;
299-
300- return 0 ;
328+ return m_graphicsApi . RGBA ( r , g , b , a ) ;
301329 }
302330
303331 }
0 commit comments