2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
8 #include <aros/debug.h>
9 #include <proto/graphics.h>
10 #include <proto/oop.h>
11 #include "graphics_intern.h"
12 #include "gfxfuncsupport.h"
13 #include <hardware/blit.h>
15 struct bltmask_render_data
17 struct render_special_info rsi
;
19 OOP_Object
*srcbm_obj
;
21 HIDDT_ColorModel src_colmod
;
25 BOOL samebitmapformat
;
28 static ULONG
bltmask_render(APTR bltmask_rd
, LONG srcx
, LONG srcy
,
29 OOP_Object
*dstbm_obj
, OOP_Object
*dst_gc
,
30 LONG x1
, LONG y1
, LONG x2
, LONG y2
, struct GfxBase
*GfxBase
);
32 /*****************************************************************************
35 #include <clib/graphics_protos.h>
37 AROS_LH10(void, BltMaskBitMapRastPort
,
40 AROS_LHA(struct BitMap
*, srcBitMap
, A0
),
41 AROS_LHA(LONG
, xSrc
, D0
),
42 AROS_LHA(LONG
, ySrc
, D1
),
43 AROS_LHA(struct RastPort
*, destRP
, A1
),
44 AROS_LHA(LONG
, xDest
, D2
),
45 AROS_LHA(LONG
, yDest
, D3
),
46 AROS_LHA(LONG
, xSize
, D4
),
47 AROS_LHA(LONG
, ySize
, D5
),
48 AROS_LHA(ULONG
, minterm
, D6
),
49 AROS_LHA(PLANEPTR
, bltMask
, A2
),
52 struct GfxBase
*, GfxBase
, 106, Graphics
)
71 27-11-96 digulla automatically created from
72 graphics_lib.fd and clib/graphics_protos.h
74 *****************************************************************************/
77 AROS_LIBBASE_EXT_DECL(struct GfxBase
*,GfxBase
)
79 struct bltmask_render_data brd
;
81 HIDDT_DrawMode old_drmd
;
85 struct TagItem gc_tags
[] =
87 { aHidd_GC_DrawMode
, 0UL },
91 EnterFunc(bug("BltMaskBitMapRastPort(%d %d %d, %d, %d, %d)\n"
92 , xSrc
, ySrc
, xDest
, yDest
, xSize
, ySize
));
99 if ((xSize
< 1) || (ySize
< 1)) return;
101 if (!OBTAIN_DRIVERDATA(destRP
, GfxBase
))
104 brd
.minterm
= minterm
;
105 brd
.srcbm_obj
= OBTAIN_HIDD_BM(srcBitMap
);
106 if (NULL
== brd
.srcbm_obj
)
108 RELEASE_DRIVERDATA(destRP
, GfxBase
);
112 brd
.srcbm
= srcBitMap
;
115 /* The mask has always the same size as the source bitmap */
116 brd
.mask_bpr
= 2 * WIDTH_TO_WORDS(GetBitMapAttr(srcBitMap
, BMA_WIDTH
));
118 OOP_GetAttr(brd
.srcbm_obj
, aHidd_BitMap_PixFmt
, (IPTR
*)&brd
.srcpf
);
122 OOP_GetAttr(brd
.srcpf
, aHidd_PixFmt_ColorModel
, &attr
);
123 brd
.src_colmod
= (HIDDT_ColorModel
)attr
;
126 gc
= GetDriverData(destRP
)->dd_GC
;
127 OOP_GetAttr(gc
, aHidd_GC_DrawMode
, &old_drmd
);
129 gc_tags
[0].ti_Data
= vHidd_GC_DrawMode_Copy
;
130 OOP_SetAttrs(gc
, gc_tags
);
134 rr
.MaxX
= xDest
+ xSize
- 1;
135 rr
.MaxY
= yDest
+ ySize
- 1;
140 do_render_func(destRP
, &src
, &rr
, bltmask_render
, &brd
, TRUE
, GfxBase
);
142 RELEASE_HIDD_BM(brd
.srcbm_obj
, srcBitMap
);
144 gc_tags
[0].ti_Data
= old_drmd
;
145 OOP_SetAttrs(gc
, gc_tags
);
147 RELEASE_DRIVERDATA(destRP
, GfxBase
);
149 ReturnVoid("BltBitMapRastPort");
153 } /* BltMaskBitMapRastPort */
155 /****************************************************************************************/
157 static ULONG
bltmask_render(APTR bltmask_rd
, LONG srcx
, LONG srcy
,
158 OOP_Object
*dstbm_obj
, OOP_Object
*dst_gc
,
159 LONG x1
, LONG y1
, LONG x2
, LONG y2
, struct GfxBase
*GfxBase
)
161 struct bltmask_render_data
*brd
;
163 HIDDT_ColorModel dest_colmod
;
164 HIDDT_Pixel
*pixtab
= NULL
;
165 ULONG x
, y
, width
, height
;
166 LONG lines_done
, lines_per_step
, doing_lines
;
167 BOOL pal_to_true
= FALSE
;
170 height
= y2
- y1
+ 1;
172 OOP_GetAttr(dstbm_obj
, aHidd_BitMap_PixFmt
, (IPTR
*)&dest_pf
);
176 OOP_GetAttr(dest_pf
, aHidd_PixFmt_ColorModel
, &attr
);
177 dest_colmod
= (HIDDT_ColorModel
)attr
;
180 brd
= (struct bltmask_render_data
*)bltmask_rd
;
181 if ((brd
->src_colmod
== vHidd_ColorModel_Palette
) && (dest_colmod
== vHidd_ColorModel_Palette
))
184 else if ((brd
->src_colmod
== vHidd_ColorModel_Palette
) && (dest_colmod
== vHidd_ColorModel_TrueColor
))
186 pixtab
= IS_HIDD_BM(brd
->srcbm
) ? HIDD_BM_PIXTAB(brd
->srcbm
) : NULL
;
187 if (!pixtab
) pixtab
= IS_HIDD_BM(brd
->rsi
.curbm
) ? HIDD_BM_PIXTAB(brd
->rsi
.curbm
) : NULL
;
191 D(bug("BltMaskBitMapRastPort could not retrieve pixel table for blit from palette to truecolor bitmap"));
192 return width
* height
;
197 else if ((brd
->src_colmod
== vHidd_ColorModel_TrueColor
) && (dest_colmod
== vHidd_ColorModel_TrueColor
))
199 if (brd
->srcpf
!= dest_pf
)
201 D(bug("BltMaskBitMapRastPort not supporting blit between truecolor bitmaps of different formats yet"));
202 return width
* height
;
205 else if ((brd
->src_colmod
== vHidd_ColorModel_TrueColor
) && (dest_colmod
== vHidd_ColorModel_Palette
))
207 D(bug("BltMaskBitMapRastPort from truecolor bitmap to palette bitmap not supported!"));
208 return width
* height
;
211 lines_per_step
= (NUMPIX
/ (width
* 2 * sizeof(HIDDT_Pixel
)));
214 UBYTE
*srcbuf
, *destbuf
;
218 srcbuf
= (UBYTE
*)PrivGBase(GfxBase
)->pixel_buf
;
220 destbuf
+= lines_per_step
* width
* sizeof(HIDDT_Pixel
);
222 for(lines_done
= 0; lines_done
!= height
; lines_done
+= doing_lines
)
224 HIDDT_Pixel
*srcpixelbuf
;
225 HIDDT_Pixel
*destpixelbuf
;
228 doing_lines
= lines_per_step
;
229 if (lines_done
+ doing_lines
> height
) doing_lines
= height
- lines_done
;
231 HIDD_BM_GetImage(brd
->srcbm_obj
,
233 width
* sizeof(HIDDT_Pixel
),
234 srcx
, srcy
+ lines_done
,
236 vHidd_StdPixFmt_Native32
);
238 HIDD_BM_GetImage(dstbm_obj
,
240 width
* sizeof(HIDDT_Pixel
),
243 vHidd_StdPixFmt_Native32
);
245 mask
= &brd
->mask
[COORD_TO_BYTEIDX(0, srcy
+ lines_done
, brd
->mask_bpr
)];
247 srcpixelbuf
= (HIDDT_Pixel
*)srcbuf
;
248 destpixelbuf
= (HIDDT_Pixel
*)destbuf
;
252 case (ABC
|ABNC
|ANBC
): /* (ABC|ABNC|ANBC) if copy source and blit thru mask */
255 for(y
= 0; y
< doing_lines
; y
++)
257 for(x
= 0; x
< width
; x
++)
259 if (mask
[XCOORD_TO_BYTEIDX(srcx
+ x
)] & XCOORD_TO_MASK(srcx
+ x
))
261 *destpixelbuf
= pixtab
[*srcpixelbuf
];
266 mask
+= brd
->mask_bpr
;
271 for(y
= 0; y
< doing_lines
; y
++)
273 for(x
= 0; x
< width
; x
++)
275 if (mask
[XCOORD_TO_BYTEIDX(srcx
+ x
)] & XCOORD_TO_MASK(srcx
+ x
))
277 *destpixelbuf
= *srcpixelbuf
;
282 mask
+= brd
->mask_bpr
;
287 case ANBC
: /* (ANBC) if invert source and blit thru mask */
288 D(bug("BltMaskBitMapRastPort does not support ANBC minterm yet"));
292 D(bug("BltMaskBitMapRastPort: minterm 0x%x not handled.\n", brd
->minterm
));
294 } /* switch(brd->minterm) */
296 HIDD_BM_PutImage(dstbm_obj
,
299 width
* sizeof(HIDDT_Pixel
),
302 vHidd_StdPixFmt_Native32
);
304 } /* for(lines_done = 0; lines_done != height; lines_done += doing_lines) */
308 } /* if (lines_per_step) */
311 /* urk :-( pixelbuffer too small to hold two lines) */
313 D(bug("BltMaskBitMapRastPort found pixelbuffer to be too small"));
316 return width
* height
;
319 /****************************************************************************************/