2 Copyright © 1995-2001, 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
)
50 29-10-95 digulla automatically created from
51 graphics_lib.fd and clib/graphics_protos.h
53 *****************************************************************************/
56 AROS_LIBBASE_EXT_DECL(struct GfxBase
*,GfxBase
)
60 struct Layer
*L
= rp
->Layer
;
61 struct BitMap
*bm
= rp
->BitMap
;
62 struct Rectangle rp_clip_rectangle
;
63 BOOL have_rp_cliprectangle
;
65 if (!OBTAIN_DRIVERDATA(rp
, GfxBase
))
68 FIX_GFXCOORD(xCenter
);
69 FIX_GFXCOORD(yCenter
);
73 /* bug("driver_DrawEllipse(%d %d %d %d)\n", xCenter, yCenter, a, b);
74 */ gc
= GetDriverData(rp
)->dd_GC
;
76 rr
.MinX
= xCenter
- a
;
77 rr
.MinY
= yCenter
- b
;
78 rr
.MaxX
= xCenter
+ a
;
79 rr
.MaxY
= yCenter
+ b
;
83 /* No layer, probably a screen, but may be a user inited bitmap */
86 bm_obj
= OBTAIN_HIDD_BM(bm
);
89 /* No need for clipping */
90 HIDD_BM_DrawEllipse(bm_obj
, gc
95 RELEASE_HIDD_BM(bm_obj
, bm
);
104 struct Rectangle torender
, intersect
;
111 xrel
= L
->bounds
.MinX
;
112 yrel
= L
->bounds
.MinY
;
114 xCenter
-= L
->Scroll_X
;
115 yCenter
-= L
->Scroll_Y
;
117 have_rp_cliprectangle
= GetRPClipRectangleForLayer(rp
, L
, &rp_clip_rectangle
, GfxBase
);
119 torender
.MinX
= rr
.MinX
+ xrel
- L
->Scroll_X
;
120 torender
.MinY
= rr
.MinY
+ yrel
- L
->Scroll_Y
;
121 torender
.MaxX
= rr
.MaxX
+ xrel
- L
->Scroll_X
;
122 torender
.MaxY
= rr
.MaxY
+ yrel
- L
->Scroll_Y
;
124 for (;NULL
!= CR
; CR
= CR
->Next
)
126 D(bug("Cliprect (%d, %d, %d, %d), lobs=%p\n",
127 CR
->bounds
.MinX
, CR
->bounds
.MinY
, CR
->bounds
.MaxX
, CR
->bounds
.MaxY
,
130 /* Does this cliprect intersect with area to rectfill ? */
131 if (_AndRectRect(&CR
->bounds
, &torender
, &intersect
))
133 if (!have_rp_cliprectangle
|| _AndRectRect(&rp_clip_rectangle
, &intersect
, &intersect
))
135 if (NULL
== CR
->lobs
)
138 /* Set clip rectangle */
139 /* bug("Setting cliprect: %d %d %d %d : layerrel: %d %d %d %d\n"
145 , intersect.MinX - xrel
146 , intersect.MinY - yrel
147 , intersect.MaxX - xrel
148 , intersect.MaxY - yrel
151 HIDD_GC_SetClipRect(gc
158 bm_obj
= OBTAIN_HIDD_BM(bm
);
161 HIDD_BM_DrawEllipse(bm_obj
169 RELEASE_HIDD_BM(bm_obj
, bm
);
172 HIDD_GC_UnsetClipRect(gc
);
178 /* Render into offscreen cliprect bitmap */
179 if (L
->Flags
& LAYERSIMPLE
)
181 else if (L
->Flags
& LAYERSUPER
)
183 D(bug("do_render_func(): Superbitmap not handled yet\n"));
187 LONG bm_rel_minx
, bm_rel_miny
, bm_rel_maxx
, bm_rel_maxy
;
188 LONG layer_rel_x
, layer_rel_y
;
190 layer_rel_x
= intersect
.MinX
- xrel
;
191 layer_rel_y
= intersect
.MinY
- yrel
;
193 bm_rel_minx
= intersect
.MinX
- CR
->bounds
.MinX
;
194 bm_rel_miny
= intersect
.MinY
- CR
->bounds
.MinY
;
195 bm_rel_maxx
= intersect
.MaxX
- CR
->bounds
.MinX
;
196 bm_rel_maxy
= intersect
.MaxY
- CR
->bounds
.MinY
;
198 HIDD_GC_SetClipRect(gc
199 , bm_rel_minx
+ ALIGN_OFFSET(CR
->bounds
.MinX
)
201 , bm_rel_maxx
+ ALIGN_OFFSET(CR
->bounds
.MinX
)
205 bm_obj
= OBTAIN_HIDD_BM(CR
->BitMap
);
208 HIDD_BM_DrawEllipse(bm_obj
210 , bm_rel_minx
- (layer_rel_x
- xCenter
) + ALIGN_OFFSET(CR
->bounds
.MinX
)
211 , bm_rel_miny
- (layer_rel_y
- yCenter
)
216 RELEASE_HIDD_BM(bm_obj
, CR
->BitMap
);
219 HIDD_GC_UnsetClipRect(gc
);
222 } /* if (CR->lobs == NULL) */
224 } /* if it also intersects with possible rastport clip rectangle */
226 } /* if (cliprect intersects with area to render into) */
228 } /* for (each cliprect in the layer) */
232 } /* if (rp->Layer) */
234 RELEASE_DRIVERDATA(rp
, GfxBase
);