2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Graphics function EraseRect()
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"
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 /*****************************************************************************
42 #include <graphics/rastport.h>
43 #include <proto/graphics.h>
45 AROS_LH5(void, EraseRect
,
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
),
55 struct GfxBase
*, GfxBase
, 135, Graphics
)
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.
63 rp - destination RastPort
64 xMin,yMin - upper left corner
65 xMax,YMax - lower right corner
80 29-10-95 digulla automatically created from
81 graphics_lib.fd and clib/graphics_protos.h
83 *****************************************************************************/
87 struct eraserect_render_data errd
;
90 EnterFunc(bug("EraseRect(%d, %d, %d, %d)\n", xMin
, yMin
, xMax
, yMax
));
92 if (!OBTAIN_DRIVERDATA(rp
, GfxBase
))
93 ReturnVoid("EraseRect(No driverdata)");
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");
116 /****************************************************************************************/
118 static void calllayerhook(struct Hook
*h
, struct RastPort
*rp
,
119 struct layerhookmsg
*msg
, struct GfxBase
* GfxBase
)
121 struct BitMap
*bm
= rp
->BitMap
;
124 if (!OBTAIN_DRIVERDATA(rp
, GfxBase
))
127 gc
= GetDriverData(rp
)->dd_GC
;
129 if(h
== LAYERS_BACKFILL
)
133 bm_obj
= OBTAIN_HIDD_BM(bm
);
137 HIDDT_DrawMode old_drmd
;
140 struct TagItem gc_tags
[] =
142 {aHidd_GC_Foreground
, 0UL },
143 {aHidd_GC_DrawMode
, vHidd_GC_DrawMode_Copy
},
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
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
;
196 errd
= (struct eraserect_render_data
*)err_data
;
200 msg
.Layer
= rp
->Layer
;
206 #warning What should these be set to ?
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
)
222 rp
->BitMap
= errd
->rsi
.curbm
;
230 calllayerhook(msg
.Layer
->BackFill
, rp
, &msg
, GfxBase
);
236 /****************************************************************************************/