@@ -17,7 +17,7 @@ namespace OxyPlot.Xamarin.Android
1717 /// <summary>
1818 /// Provides a render context for Android.Graphics.Canvas.
1919 /// </summary>
20- public class CanvasRenderContext : RenderContextBase
20+ public class CanvasRenderContext : ClippingRenderContext
2121 {
2222 /// <summary>
2323 /// The images in use
@@ -96,10 +96,11 @@ public void SetTarget(Canvas c)
9696 /// <param name="fill">The fill color.</param>
9797 /// <param name="stroke">The stroke color.</param>
9898 /// <param name="thickness">The thickness.</param>
99- public override void DrawEllipse ( OxyRect rect , OxyColor fill , OxyColor stroke , double thickness )
99+ public override void DrawEllipse ( OxyRect rect , OxyColor fill , OxyColor stroke , double thickness , EdgeRenderingMode erm )
100100 {
101101 this . paint . Reset ( ) ;
102102 {
103+ bool aliased = this . ShouldUseAntiAliasingForEllipse ( erm ) ;
103104 if ( fill . IsVisible ( ) )
104105 {
105106 this . SetFill ( fill ) ;
@@ -108,7 +109,7 @@ public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, d
108109
109110 if ( stroke . IsVisible ( ) )
110111 {
111- this . SetStroke ( stroke , thickness ) ;
112+ this . SetStroke ( stroke , thickness , aliased : aliased ) ;
112113 this . canvas . DrawOval ( this . Convert ( rect ) , this . paint ) ;
113114 }
114115 }
@@ -122,10 +123,11 @@ public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, d
122123 /// <param name="fill">The fill color.</param>
123124 /// <param name="stroke">The stroke color.</param>
124125 /// <param name="thickness">The stroke thickness.</param>
125- public override void DrawEllipses ( IList < OxyRect > rectangles , OxyColor fill , OxyColor stroke , double thickness )
126+ public override void DrawEllipses ( IList < OxyRect > rectangles , OxyColor fill , OxyColor stroke , double thickness , EdgeRenderingMode erm )
126127 {
127128 this . paint . Reset ( ) ;
128129 {
130+ bool aliased = this . ShouldUseAntiAliasingForEllipse ( erm ) ;
129131 foreach ( var rect in rectangles )
130132 {
131133 if ( fill . IsVisible ( ) )
@@ -136,7 +138,7 @@ public override void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyC
136138
137139 if ( stroke . IsVisible ( ) )
138140 {
139- this . SetStroke ( stroke , thickness ) ;
141+ this . SetStroke ( stroke , thickness , aliased : aliased ) ;
140142 this . canvas . DrawOval ( this . Convert ( rect ) , this . paint ) ;
141143 }
142144 }
@@ -151,13 +153,13 @@ public override void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyC
151153 /// <param name="thickness">The stroke thickness.</param>
152154 /// <param name="dashArray">The dash array.</param>
153155 /// <param name="lineJoin">The line join type.</param>
154- /// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
155- public override void DrawLine ( IList < ScreenPoint > points , OxyColor stroke , double thickness , double [ ] dashArray , LineJoin lineJoin , bool aliased )
156+ public override void DrawLine ( IList < ScreenPoint > points , OxyColor stroke , double thickness , EdgeRenderingMode erm , double [ ] dashArray , LineJoin lineJoin )
156157 {
157158 this . paint . Reset ( ) ;
158159 {
159160 this . path . Reset ( ) ;
160161 {
162+ bool aliased = this . ShouldUseAntiAliasingForLine ( erm , points ) ;
161163 this . SetPath ( points , aliased ) ;
162164 this . SetStroke ( stroke , thickness , dashArray , lineJoin , aliased ) ;
163165 this . canvas . DrawPath ( this . path , this . paint ) ;
@@ -175,10 +177,11 @@ public override void DrawLine(IList<ScreenPoint> points, OxyColor stroke, double
175177 /// <param name="dashArray">The dash array.</param>
176178 /// <param name="lineJoin">The line join type.</param>
177179 /// <param name="aliased">If set to <c>true</c> the shape will be aliased.</param>
178- public override void DrawLineSegments ( IList < ScreenPoint > points , OxyColor stroke , double thickness , double [ ] dashArray , LineJoin lineJoin , bool aliased )
180+ public override void DrawLineSegments ( IList < ScreenPoint > points , OxyColor stroke , double thickness , EdgeRenderingMode erm , double [ ] dashArray , LineJoin lineJoin )
179181 {
180182 this . paint . Reset ( ) ;
181183 {
184+ bool aliased = this . ShouldUseAntiAliasingForLine ( erm , points ) ;
182185 this . SetStroke ( stroke , thickness , dashArray , lineJoin , aliased ) ;
183186 this . pts . Clear ( ) ;
184187 if ( aliased )
@@ -212,12 +215,13 @@ public override void DrawLineSegments(IList<ScreenPoint> points, OxyColor stroke
212215 /// <param name="dashArray">The dash array.</param>
213216 /// <param name="lineJoin">The line join type.</param>
214217 /// <param name="aliased">If set to <c>true</c> the shape will be aliased.</param>
215- public override void DrawPolygon ( IList < ScreenPoint > points , OxyColor fill , OxyColor stroke , double thickness , double [ ] dashArray , LineJoin lineJoin , bool aliased )
218+ public override void DrawPolygon ( IList < ScreenPoint > points , OxyColor fill , OxyColor stroke , double thickness , EdgeRenderingMode erm , double [ ] dashArray , LineJoin lineJoin )
216219 {
217220 this . paint . Reset ( ) ;
218221 {
219222 this . path . Reset ( ) ;
220223 {
224+ bool aliased = this . ShouldUseAntiAliasingForLine ( erm , points ) ;
221225 this . SetPath ( points , aliased ) ;
222226 this . path . Close ( ) ;
223227
@@ -243,20 +247,27 @@ public override void DrawPolygon(IList<ScreenPoint> points, OxyColor fill, OxyCo
243247 /// <param name="fill">The fill color.</param>
244248 /// <param name="stroke">The stroke color.</param>
245249 /// <param name="thickness">The stroke thickness.</param>
246- public override void DrawRectangle ( OxyRect rect , OxyColor fill , OxyColor stroke , double thickness )
250+ public override void DrawRectangle ( OxyRect rect , OxyColor fill , OxyColor stroke , double thickness , EdgeRenderingMode erm )
247251 {
248252 this . paint . Reset ( ) ;
249253 {
254+ bool aliased = this . ShouldUseAntiAliasingForRect ( erm ) ;
250255 if ( fill . IsVisible ( ) )
251256 {
252257 this . SetFill ( fill ) ;
253- this . canvas . DrawRect ( this . ConvertAliased ( rect . Left ) , this . ConvertAliased ( rect . Top ) , this . ConvertAliased ( rect . Right ) , this . ConvertAliased ( rect . Bottom ) , this . paint ) ;
258+ if ( aliased )
259+ this . canvas . DrawRect ( this . ConvertAliased ( rect . Left ) , this . ConvertAliased ( rect . Top ) , this . ConvertAliased ( rect . Right ) , this . ConvertAliased ( rect . Bottom ) , this . paint ) ;
260+ else
261+ this . canvas . DrawRect ( this . Convert ( rect . Left ) , this . Convert ( rect . Top ) , this . Convert ( rect . Right ) , this . Convert ( rect . Bottom ) , this . paint ) ;
254262 }
255263
256264 if ( stroke . IsVisible ( ) )
257265 {
258- this . SetStroke ( stroke , thickness , aliased : true ) ;
259- this . canvas . DrawRect ( this . ConvertAliased ( rect . Left ) , this . ConvertAliased ( rect . Top ) , this . ConvertAliased ( rect . Right ) , this . ConvertAliased ( rect . Bottom ) , this . paint ) ;
266+ this . SetStroke ( stroke , thickness , aliased : aliased ) ;
267+ if ( aliased )
268+ this . canvas . DrawRect ( this . ConvertAliased ( rect . Left ) , this . ConvertAliased ( rect . Top ) , this . ConvertAliased ( rect . Right ) , this . ConvertAliased ( rect . Bottom ) , this . paint ) ;
269+ else
270+ this . canvas . DrawRect ( this . Convert ( rect . Left ) , this . Convert ( rect . Top ) , this . Convert ( rect . Right ) , this . Convert ( rect . Bottom ) , this . paint ) ;
260271 }
261272 }
262273 }
@@ -366,17 +377,16 @@ public override OxySize MeasureText(string text, string fontFamily, double fontS
366377 /// </summary>
367378 /// <param name="rect">The clip rectangle.</param>
368379 /// <returns>True if the clip rectangle was set.</returns>
369- public override bool SetClip ( OxyRect rect )
380+ protected override void SetClip ( OxyRect rect )
370381 {
371382 this . canvas . Save ( ) ;
372383 this . canvas . ClipRect ( this . Convert ( rect ) ) ;
373- return true ;
374384 }
375385
376386 /// <summary>
377387 /// Resets the clip rectangle.
378388 /// </summary>
379- public override void ResetClip ( )
389+ protected override void ResetClip ( )
380390 {
381391 this . canvas . Restore ( ) ;
382392 }
0 commit comments