New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / graphics / drawellipse.c
blobdb8aff1d6de31b19ef8b7b5d5844c17d02c26492
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$ $Log
5 Desc: Graphics function DrawEllipse
6 Lang: english
7 */
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 /*****************************************************************************
17 NAME */
18 #include <graphics/rastport.h>
19 #include <proto/graphics.h>
21 AROS_LH5(void, DrawEllipse,
23 /* SYNOPSIS */
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),
30 /* LOCATION */
31 struct GfxBase *, GfxBase, 30, Graphics)
33 /* FUNCTION
35 INPUTS
37 RESULT
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
47 INTERNALS
49 HISTORY
50 29-10-95 digulla automatically created from
51 graphics_lib.fd and clib/graphics_protos.h
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
56 AROS_LIBBASE_EXT_DECL(struct GfxBase *,GfxBase)
58 struct Rectangle rr;
59 OOP_Object *gc;
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))
66 return;
68 FIX_GFXCOORD(xCenter);
69 FIX_GFXCOORD(yCenter);
70 FIX_GFXCOORD(a);
71 FIX_GFXCOORD(b);
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;
81 if (NULL == L)
83 /* No layer, probably a screen, but may be a user inited bitmap */
84 OOP_Object *bm_obj;
86 bm_obj = OBTAIN_HIDD_BM(bm);
87 if (bm_obj)
89 /* No need for clipping */
90 HIDD_BM_DrawEllipse(bm_obj, gc
91 , xCenter, yCenter
92 , a, b
95 RELEASE_HIDD_BM(bm_obj, bm);
99 else
101 struct ClipRect *CR;
102 WORD xrel;
103 WORD yrel;
104 struct Rectangle torender, intersect;
105 OOP_Object *bm_obj;
107 LockLayerRom(L);
109 CR = L->ClipRect;
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,
128 CR->lobs));
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"
140 , intersect.MinX
141 , intersect.MinY
142 , intersect.MaxX
143 , intersect.MaxY
145 , intersect.MinX - xrel
146 , intersect.MinY - yrel
147 , intersect.MaxX - xrel
148 , intersect.MaxY - yrel
151 HIDD_GC_SetClipRect(gc
152 , intersect.MinX
153 , intersect.MinY
154 , intersect.MaxX
155 , intersect.MaxY
158 bm_obj = OBTAIN_HIDD_BM(bm);
159 if (bm_obj)
161 HIDD_BM_DrawEllipse(bm_obj
162 , gc
163 , xCenter + xrel
164 , yCenter + yrel
169 RELEASE_HIDD_BM(bm_obj, bm);
172 HIDD_GC_UnsetClipRect(gc);
176 else
178 /* Render into offscreen cliprect bitmap */
179 if (L->Flags & LAYERSIMPLE)
180 continue;
181 else if (L->Flags & LAYERSUPER)
183 D(bug("do_render_func(): Superbitmap not handled yet\n"));
185 else
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)
200 , bm_rel_miny
201 , bm_rel_maxx + ALIGN_OFFSET(CR->bounds.MinX)
202 , bm_rel_maxy
205 bm_obj = OBTAIN_HIDD_BM(CR->BitMap);
206 if (bm_obj)
208 HIDD_BM_DrawEllipse(bm_obj
209 , gc
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) */
230 UnlockLayerRom(L);
232 } /* if (rp->Layer) */
234 RELEASE_DRIVERDATA(rp, GfxBase);
236 AROS_LIBFUNC_EXIT
238 } /* DrawEllipse */