2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Graphics function DrawEllipse
8 #include <aros/debug.h>
9 #include <clib/macros.h>
10 #include "graphics_intern.h"
11 #include <graphics/rastport.h>
12 #include "gfxfuncsupport.h"
13 #include "intregions.h"
15 /*****************************************************************************
18 #include <graphics/rastport.h>
19 #include <proto/graphics.h>
21 AROS_LH5(void, DrawEllipse
,
24 AROS_LHA(struct RastPort
*, rp
, A1
),
25 AROS_LHA(LONG
, xCenter
, D0
),
26 AROS_LHA(LONG
, yCenter
, D1
),
27 AROS_LHA(LONG
, a
, D2
),
28 AROS_LHA(LONG
, b
, D3
),
31 struct GfxBase
*, GfxBase
, 30, Graphics
)
37 rp - destination RastPort
38 xCenter,yCenter - coordinate of centerpoint
39 a - radius in x direction
40 b - radius in y direction
55 29-10-95 digulla automatically created from
56 graphics_lib.fd and clib/graphics_protos.h
58 *****************************************************************************/
64 struct Layer
*L
= rp
->Layer
;
65 struct BitMap
*bm
= rp
->BitMap
;
66 struct Rectangle rp_clip_rectangle
;
67 BOOL have_rp_cliprectangle
;
69 if (!OBTAIN_DRIVERDATA(rp
, GfxBase
))
72 FIX_GFXCOORD(xCenter
);
73 FIX_GFXCOORD(yCenter
);
77 /* bug("driver_DrawEllipse(%d %d %d %d)\n", xCenter, yCenter, a, b);
78 */ gc
= GetDriverData(rp
)->dd_GC
;
80 rr
.MinX
= xCenter
- a
;
81 rr
.MinY
= yCenter
- b
;
82 rr
.MaxX
= xCenter
+ a
;
83 rr
.MaxY
= yCenter
+ b
;
87 /* No layer, probably a screen, but may be a user inited bitmap */
90 bm_obj
= OBTAIN_HIDD_BM(bm
);
93 /* No need for clipping */
94 HIDD_BM_DrawEllipse(bm_obj
, gc
99 RELEASE_HIDD_BM(bm_obj
, bm
);
108 struct Rectangle torender
, intersect
;
115 xrel
= L
->bounds
.MinX
;
116 yrel
= L
->bounds
.MinY
;
118 xCenter
-= L
->Scroll_X
;
119 yCenter
-= L
->Scroll_Y
;
121 have_rp_cliprectangle
= GetRPClipRectangleForLayer(rp
, L
, &rp_clip_rectangle
, GfxBase
);
123 torender
.MinX
= rr
.MinX
+ xrel
- L
->Scroll_X
;
124 torender
.MinY
= rr
.MinY
+ yrel
- L
->Scroll_Y
;
125 torender
.MaxX
= rr
.MaxX
+ xrel
- L
->Scroll_X
;
126 torender
.MaxY
= rr
.MaxY
+ yrel
- L
->Scroll_Y
;
128 for (;NULL
!= CR
; CR
= CR
->Next
)
130 D(bug("Cliprect (%d, %d, %d, %d), lobs=%p\n",
131 CR
->bounds
.MinX
, CR
->bounds
.MinY
, CR
->bounds
.MaxX
, CR
->bounds
.MaxY
,
134 /* Does this cliprect intersect with area to rectfill ? */
135 if (_AndRectRect(&CR
->bounds
, &torender
, &intersect
))
137 if (!have_rp_cliprectangle
|| _AndRectRect(&rp_clip_rectangle
, &intersect
, &intersect
))
139 if (NULL
== CR
->lobs
)
142 /* Set clip rectangle */
143 /* bug("Setting cliprect: %d %d %d %d : layerrel: %d %d %d %d\n"
149 , intersect.MinX - xrel
150 , intersect.MinY - yrel
151 , intersect.MaxX - xrel
152 , intersect.MaxY - yrel
155 HIDD_GC_SetClipRect(gc
162 bm_obj
= OBTAIN_HIDD_BM(bm
);
165 HIDD_BM_DrawEllipse(bm_obj
173 RELEASE_HIDD_BM(bm_obj
, bm
);
176 HIDD_GC_UnsetClipRect(gc
);
182 /* Render into offscreen cliprect bitmap */
183 if (L
->Flags
& LAYERSIMPLE
)
185 else if (L
->Flags
& LAYERSUPER
)
187 D(bug("do_render_func(): Superbitmap not handled yet\n"));
191 LONG bm_rel_minx
, bm_rel_miny
, bm_rel_maxx
, bm_rel_maxy
;
192 LONG layer_rel_x
, layer_rel_y
;
194 layer_rel_x
= intersect
.MinX
- xrel
;
195 layer_rel_y
= intersect
.MinY
- yrel
;
197 bm_rel_minx
= intersect
.MinX
- CR
->bounds
.MinX
;
198 bm_rel_miny
= intersect
.MinY
- CR
->bounds
.MinY
;
199 bm_rel_maxx
= intersect
.MaxX
- CR
->bounds
.MinX
;
200 bm_rel_maxy
= intersect
.MaxY
- CR
->bounds
.MinY
;
202 HIDD_GC_SetClipRect(gc
203 , bm_rel_minx
+ ALIGN_OFFSET(CR
->bounds
.MinX
)
205 , bm_rel_maxx
+ ALIGN_OFFSET(CR
->bounds
.MinX
)
209 bm_obj
= OBTAIN_HIDD_BM(CR
->BitMap
);
212 HIDD_BM_DrawEllipse(bm_obj
214 , bm_rel_minx
- (layer_rel_x
- xCenter
) + ALIGN_OFFSET(CR
->bounds
.MinX
)
215 , bm_rel_miny
- (layer_rel_y
- yCenter
)
220 RELEASE_HIDD_BM(bm_obj
, CR
->BitMap
);
223 HIDD_GC_UnsetClipRect(gc
);
226 } /* if (CR->lobs == NULL) */
228 } /* if it also intersects with possible rastport clip rectangle */
230 } /* if (cliprect intersects with area to render into) */
232 } /* for (each cliprect in the layer) */
236 } /* if (rp->Layer) */
238 RELEASE_DRIVERDATA(rp
, GfxBase
);