Fix IO memory access .. SB128 driver makes noises in VMWare - CMI is untested (Curren...
[AROS.git] / rom / graphics / bltbitmaprastport.c
blob4ed77631e559d495465cab2d2a86581e32c81ac6
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include <proto/oop.h>
10 #include "graphics_intern.h"
11 #include "gfxfuncsupport.h"
13 struct bitmap_render_data
15 struct render_special_info rsi;
16 ULONG minterm;
17 struct BitMap *srcbm;
18 OOP_Object *srcbm_obj;
22 static ULONG bitmap_render(APTR bitmap_rd, LONG srcx, LONG srcy,
23 OOP_Object *dstbm_obj, OOP_Object *dst_gc,
24 LONG x1, LONG y1, LONG x2, LONG y2, struct GfxBase *GfxBase);
26 /*****************************************************************************
28 NAME */
29 #include <proto/graphics.h>
31 AROS_LH9 (void, BltBitMapRastPort,
33 /* SYNOPSIS */
34 AROS_LHA(struct BitMap *, srcBitMap, A0),
35 AROS_LHA(LONG , xSrc, D0),
36 AROS_LHA(LONG , ySrc, D1),
37 AROS_LHA(struct RastPort *, destRP, A1),
38 AROS_LHA(LONG , xDest, D2),
39 AROS_LHA(LONG , yDest, D3),
40 AROS_LHA(LONG , xSize, D4),
41 AROS_LHA(LONG , ySize, D5),
42 AROS_LHA(ULONG , minterm, D6),
44 /* LOCATION */
45 struct GfxBase *, GfxBase, 101, Graphics)
47 /* FUNCTION
48 Moves part of a bitmap around or into another bitmap.
50 INPUTS
51 srcBitMap - Copy from this bitmap.
52 xSrc, ySrc - This is the upper left corner of the area to copy.
53 destRP - Destination RastPort.
54 xDest, yDest - Upper left corner where to place the copy
55 xSize, ySize - The size of the area to copy
56 minterm - How to copy. See BltBitMap() for an explanation.
58 RESULT
59 TRUE.
61 NOTES
62 If special hardware is available, this function will use it.
64 EXAMPLE
66 BUGS
68 SEE ALSO
69 ClipBlit()
71 INPUTS
73 RESULT
75 NOTES
77 INTERNALS
79 *****************************************************************************/
81 AROS_LIBFUNC_INIT
83 struct bitmap_render_data brd;
84 struct Rectangle rr;
85 HIDDT_DrawMode old_drmd;
86 OOP_Object *gc;
87 Point src;
89 struct TagItem gc_tags[] =
91 { aHidd_GC_DrawMode , 0UL },
92 { TAG_DONE }
95 EnterFunc(bug("BltBitMapRastPort(%d %d %d, %d, %d, %d)\n"
96 , xSrc, ySrc, xDest, yDest, xSize, ySize));
98 if (!OBTAIN_DRIVERDATA(destRP, GfxBase))
99 return;
101 FIX_GFXCOORD(xSrc);
102 FIX_GFXCOORD(ySrc);
103 FIX_GFXCOORD(xDest);
104 FIX_GFXCOORD(yDest);
106 brd.minterm = minterm;
107 brd.srcbm_obj = OBTAIN_HIDD_BM(srcBitMap);
108 if (NULL == brd.srcbm_obj)
110 RELEASE_DRIVERDATA(destRP, GfxBase);
111 return;
114 brd.srcbm = srcBitMap;
116 gc = GetDriverData(destRP)->dd_GC;
117 OOP_GetAttr(gc, aHidd_GC_DrawMode, &old_drmd);
119 gc_tags[0].ti_Data = MINTERM_TO_GCDRMD(minterm);
120 OOP_SetAttrs(gc, gc_tags);
122 rr.MinX = xDest;
123 rr.MinY = yDest;
124 rr.MaxX = xDest + xSize - 1;
125 rr.MaxY = yDest + ySize - 1;
127 src.x = xSrc;
128 src.y = ySrc;
130 do_render_func(destRP, &src, &rr, bitmap_render, &brd, TRUE, TRUE, GfxBase);
132 RELEASE_HIDD_BM(brd.srcbm_obj, srcBitMap);
134 gc_tags[0].ti_Data = old_drmd;
135 OOP_SetAttrs(gc, gc_tags);
137 RELEASE_DRIVERDATA(destRP, GfxBase);
139 ReturnVoid("BltBitMapRastPort");
141 AROS_LIBFUNC_EXIT
143 } /* BltBitMapRastPort */
145 /****************************************************************************************/
147 static ULONG bitmap_render(APTR bitmap_rd, LONG srcx, LONG srcy,
148 OOP_Object *dstbm_obj, OOP_Object *dst_gc,
149 LONG x1, LONG y1, LONG x2, LONG y2, struct GfxBase *GfxBase)
151 struct bitmap_render_data *brd;
152 ULONG width, height;
153 struct monitor_driverdata *driver;
154 OOP_Object *gfxhidd, *dest_gfxhidd;
156 width = x2 - x1 + 1;
157 height = y2 - y1 + 1;
159 brd = (struct bitmap_render_data *)bitmap_rd;
161 // D(bug("bitmap_render(%p, %d, %d, %p, %p, %d, %d, %d, %d, %p)\n"
162 // , bitmap_rd, srcx, srcy, dstbm_obj, dst_gc, x1, y1, x2, y2, GfxBase));
165 * Select the appropriate driver.
166 * Selection rules are described in BltBitMap() code. This is the same, except destination
167 * is represented by object, not by struct BitMap.
169 driver = GET_BM_DRIVERDATA(brd->srcbm);
170 gfxhidd = driver->gfxhidd;
171 OOP_GetAttr(dstbm_obj, aHidd_BitMap_GfxHidd, (IPTR *)&dest_gfxhidd);
173 if (driver == (struct monitor_driverdata *)CDD(GfxBase))
175 gfxhidd = dest_gfxhidd;
177 else if (OOP_OCLASS(dest_gfxhidd) == CDD(GfxBase)->fakegfxclass)
179 gfxhidd = dest_gfxhidd;
182 /* Get some info on the colormaps. We have to make sure
183 that we have the appropriate mapping tables set.
186 if (!int_bltbitmap(brd->srcbm
187 , brd->srcbm_obj
188 , srcx, srcy
189 , brd->rsi.curbm
190 , dstbm_obj
191 , x1, y1
192 , x2 - x1 + 1, y2 - y1 + 1
193 , brd->minterm
194 , gfxhidd
195 , dst_gc
196 , GfxBase
198 return 0;
200 return width * height;
203 /****************************************************************************************/