added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / rom / graphics / eraserect.c
blobffbb8f68ba5a1d47e15f4a467f9db67029776b09
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$ $Log
5 Desc: Graphics function EraseRect()
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include "graphics_intern.h"
10 #include <graphics/rastport.h>
11 #include <aros/asmcall.h>
12 #include <utility/hooks.h>
13 #include <proto/oop.h>
14 #include "gfxfuncsupport.h"
16 struct layerhookmsg
18 struct Layer *Layer;
19 WORD MinX, MinY, MaxX, MaxY;
20 LONG OffsetX, OffsetY;
23 struct eraserect_render_data
25 struct render_special_info rsi;
26 struct RastPort *origrp;
27 struct RastPort *fakerp;
30 static void calllayerhook(struct Hook *h, struct RastPort *rp,
31 struct layerhookmsg *msg, struct GfxBase * GfxBase);
34 static ULONG eraserect_render(APTR err_data, LONG srcx, LONG srcy,
35 OOP_Object *dstbm_obj, OOP_Object *gc,
36 LONG x1, LONG y1, LONG x2, LONG y2,
37 struct GfxBase *GfxBase);
39 /*****************************************************************************
41 NAME */
42 #include <graphics/rastport.h>
43 #include <proto/graphics.h>
45 AROS_LH5(void, EraseRect,
47 /* SYNOPSIS */
48 AROS_LHA(struct RastPort *, rp, A1),
49 AROS_LHA(LONG , xMin, D0),
50 AROS_LHA(LONG , yMin, D1),
51 AROS_LHA(LONG , xMax, D2),
52 AROS_LHA(LONG , yMax, D3),
54 /* LOCATION */
55 struct GfxBase *, GfxBase, 135, Graphics)
57 /* FUNCTION
58 Fill a rectangular area with the current BackFill hook.
59 If layered the BackFill hook is used.
60 If non-layered the region is cleared.
62 INPUTS
63 rp - destination RastPort
64 xMin,yMin - upper left corner
65 xMax,YMax - lower right corner
67 RESULT
69 NOTES
71 EXAMPLE
73 BUGS
75 SEE ALSO
77 INTERNALS
79 HISTORY
80 29-10-95 digulla automatically created from
81 graphics_lib.fd and clib/graphics_protos.h
83 *****************************************************************************/
85 AROS_LIBFUNC_INIT
87 struct eraserect_render_data errd;
88 struct Rectangle rr;
90 EnterFunc(bug("EraseRect(%d, %d, %d, %d)\n", xMin, yMin, xMax, yMax));
92 if (!OBTAIN_DRIVERDATA(rp, GfxBase))
93 ReturnVoid("EraseRect(No driverdata)");
95 errd.origrp = rp;
96 errd.fakerp = NULL;
98 rr.MinX = xMin;
99 rr.MinY = yMin;
100 rr.MaxX = xMax;
101 rr.MaxY = yMax;
103 do_render_func(rp, NULL, &rr, eraserect_render, &errd, TRUE, GfxBase);
105 if (NULL != errd.fakerp)
106 FreeRastPort(errd.fakerp);
108 RELEASE_DRIVERDATA(rp, GfxBase);
110 ReturnVoid("EraseRect");
112 AROS_LIBFUNC_EXIT
114 } /* EraseRect */
116 /****************************************************************************************/
118 static void calllayerhook(struct Hook *h, struct RastPort *rp,
119 struct layerhookmsg *msg, struct GfxBase * GfxBase)
121 struct BitMap *bm = rp->BitMap;
122 OOP_Object *gc;
124 if (!OBTAIN_DRIVERDATA(rp, GfxBase))
125 return;
127 gc = GetDriverData(rp)->dd_GC;
129 if(h == LAYERS_BACKFILL)
131 OOP_Object *bm_obj;
133 bm_obj = OBTAIN_HIDD_BM(bm);
134 if (NULL != bm_obj)
137 HIDDT_DrawMode old_drmd;
138 IPTR old_fg;
140 struct TagItem gc_tags[] =
142 {aHidd_GC_Foreground, 0UL },
143 {aHidd_GC_DrawMode , vHidd_GC_DrawMode_Copy},
144 {TAG_DONE }
147 OOP_GetAttr(gc, aHidd_GC_DrawMode, &old_drmd);
148 OOP_GetAttr(gc, aHidd_GC_Foreground, &old_fg);
150 gc_tags[0].ti_Data = BM_PIXEL(rp->BitMap, 0);
152 OOP_SetAttrs(gc, gc_tags);
154 /* Cliprect not obscured, so we may render directly into the display */
155 HIDD_BM_FillRect(bm_obj
156 , gc
157 , msg->MinX, msg->MinY
158 , msg->MaxX, msg->MaxY
161 gc_tags[0].ti_Data = old_fg;
162 gc_tags[1].ti_Data = old_drmd;
164 OOP_SetAttrs(gc, gc_tags);
166 RELEASE_HIDD_BM(bm_obj, bm);
168 } /* if (NULL != bm_obj)*/
170 } /* if(h == LAYERS_BACKFILL) */
171 else if (h != LAYERS_NOBACKFILL)
173 /* Call user specified hook */
174 AROS_UFC3(void, h->h_Entry,
175 AROS_UFCA(struct Hook *, h, A0),
176 AROS_UFCA(struct RastPort *, rp, A2),
177 AROS_UFCA(struct layerhookmsg *, msg, A1)
181 RELEASE_DRIVERDATA(rp, GfxBase);
184 /****************************************************************************************/
186 static ULONG eraserect_render(APTR err_data, LONG srcx, LONG srcy,
187 OOP_Object *dstbm_obj, OOP_Object *gc,
188 LONG x1, LONG y1, LONG x2, LONG y2,
189 struct GfxBase *GfxBase)
192 struct layerhookmsg msg;
193 struct eraserect_render_data *errd;
194 struct RastPort *rp;
196 errd = (struct eraserect_render_data *)err_data;
198 rp = errd->origrp;
200 msg.Layer = rp->Layer;
201 msg.MinX = x1;
202 msg.MinY = y1;
203 msg.MaxX = x2;
204 msg.MaxY = y2;
206 #warning What should these be set to ?
207 msg.OffsetX = 0;
208 msg.OffsetY = 0;
210 if (NULL != msg.Layer)
212 struct RastPort *rp = NULL;
214 if (!errd->rsi.onscreen)
216 if (NULL == errd->fakerp)
217 errd->fakerp = CreateRastPort();
218 if (NULL == errd->fakerp)
219 return 0;
221 rp = errd->fakerp;
222 rp->BitMap = errd->rsi.curbm;
225 else
227 rp = errd->origrp;
230 calllayerhook(msg.Layer->BackFill, rp, &msg, GfxBase);
233 return 0;
236 /****************************************************************************************/