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
98 HIDD_BM_UpdateRect(bm_obj
, xCenter
- a
, yCenter
- b
, a
+ a
, b
+ b
);
100 RELEASE_HIDD_BM(bm_obj
, bm
);
109 struct Rectangle torender
, intersect
;
116 xrel
= L
->bounds
.MinX
;
117 yrel
= L
->bounds
.MinY
;
119 xCenter
-= L
->Scroll_X
;
120 yCenter
-= L
->Scroll_Y
;
122 have_rp_cliprectangle
= GetRPClipRectangleForLayer(rp
, L
, &rp_clip_rectangle
, GfxBase
);
124 torender
.MinX
= rr
.MinX
+ xrel
- L
->Scroll_X
;
125 torender
.MinY
= rr
.MinY
+ yrel
- L
->Scroll_Y
;
126 torender
.MaxX
= rr
.MaxX
+ xrel
- L
->Scroll_X
;
127 torender
.MaxY
= rr
.MaxY
+ yrel
- L
->Scroll_Y
;
129 for (;NULL
!= CR
; CR
= CR
->Next
)
131 D(bug("Cliprect (%d, %d, %d, %d), lobs=%p\n",
132 CR
->bounds
.MinX
, CR
->bounds
.MinY
, CR
->bounds
.MaxX
, CR
->bounds
.MaxY
,
135 /* Does this cliprect intersect with area to rectfill ? */
136 if (_AndRectRect(&CR
->bounds
, &torender
, &intersect
))
138 if (!have_rp_cliprectangle
|| _AndRectRect(&rp_clip_rectangle
, &intersect
, &intersect
))
140 if (NULL
== CR
->lobs
)
143 /* Set clip rectangle */
144 /* bug("Setting cliprect: %d %d %d %d : layerrel: %d %d %d %d\n"
150 , intersect.MinX - xrel
151 , intersect.MinY - yrel
152 , intersect.MaxX - xrel
153 , intersect.MaxY - yrel
156 HIDD_GC_SetClipRect(gc
163 bm_obj
= OBTAIN_HIDD_BM(bm
);
166 HIDD_BM_DrawEllipse(bm_obj
173 HIDD_BM_UpdateRect(bm_obj
, xCenter
+ xrel
- a
, yCenter
+ yrel
- b
, a
+ a
, b
+ b
);
175 RELEASE_HIDD_BM(bm_obj
, bm
);
178 HIDD_GC_UnsetClipRect(gc
);
184 /* Render into offscreen cliprect bitmap */
185 if (L
->Flags
& LAYERSIMPLE
)
187 else if (L
->Flags
& LAYERSUPER
)
189 D(bug("do_render_func(): Superbitmap not handled yet\n"));
193 LONG bm_rel_minx
, bm_rel_miny
, bm_rel_maxx
, bm_rel_maxy
;
194 LONG layer_rel_x
, layer_rel_y
;
196 layer_rel_x
= intersect
.MinX
- xrel
;
197 layer_rel_y
= intersect
.MinY
- yrel
;
199 bm_rel_minx
= intersect
.MinX
- CR
->bounds
.MinX
;
200 bm_rel_miny
= intersect
.MinY
- CR
->bounds
.MinY
;
201 bm_rel_maxx
= intersect
.MaxX
- CR
->bounds
.MinX
;
202 bm_rel_maxy
= intersect
.MaxY
- CR
->bounds
.MinY
;
204 HIDD_GC_SetClipRect(gc
205 , bm_rel_minx
+ ALIGN_OFFSET(CR
->bounds
.MinX
)
207 , bm_rel_maxx
+ ALIGN_OFFSET(CR
->bounds
.MinX
)
211 bm_obj
= OBTAIN_HIDD_BM(CR
->BitMap
);
214 HIDD_BM_DrawEllipse(bm_obj
216 , bm_rel_minx
- (layer_rel_x
- xCenter
) + ALIGN_OFFSET(CR
->bounds
.MinX
)
217 , bm_rel_miny
- (layer_rel_y
- yCenter
)
221 HIDD_BM_UpdateRect(bm_obj
, bm_rel_minx
- (layer_rel_x
- xCenter
) + ALIGN_OFFSET(CR
->bounds
.MinX
) - a
,
222 bm_rel_miny
- (layer_rel_y
- yCenter
) - b
,
225 RELEASE_HIDD_BM(bm_obj
, CR
->BitMap
);
228 HIDD_GC_UnsetClipRect(gc
);
231 } /* if (CR->lobs == NULL) */
233 } /* if it also intersects with possible rastport clip rectangle */
235 } /* if (cliprect intersects with area to render into) */
237 } /* for (each cliprect in the layer) */
241 } /* if (rp->Layer) */
243 RELEASE_DRIVERDATA(rp
, GfxBase
);