use a default prefs value incase the prefssetup fails. dispose of extension_PrefsData...
[AROS.git] / rom / graphics / bltmaskbitmaprastport.c
blob659db76ec9a757804209d5e4a797fdc115687094
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <proto/graphics.h>
11 #include <proto/oop.h>
13 #include "graphics_intern.h"
14 #include "gfxfuncsupport.h"
15 #include "graphics_driver.h"
17 /****************************************************************************************/
19 struct bltmask_render_data
21 struct render_special_info rsi;
22 struct BitMap *srcbm;
23 OOP_Object *srcbm_obj;
24 PLANEPTR mask;
27 static ULONG bltmask_render(APTR bltmask_rd, WORD srcx, WORD srcy,
28 OOP_Object *dstbm_obj, OOP_Object *dst_gc,
29 struct Rectangle *rect, struct GfxBase *GfxBase)
31 struct bltmask_render_data *brd = bltmask_rd;
32 WORD width = rect->MaxX - rect->MinX + 1;
33 WORD height = rect->MaxY - rect->MinY + 1;
34 OOP_Object *gfxhidd;
35 BOOL ok;
37 gfxhidd = SelectDriverObject(brd->srcbm, dstbm_obj, GfxBase);
38 ok = HIDD_Gfx_CopyBoxMasked(gfxhidd, brd->srcbm_obj, srcx, srcy, dstbm_obj, rect->MinX, rect->MinY, width, height, brd->mask, dst_gc);
40 return ok ? width * height : 0;
43 /*****************************************************************************
45 NAME */
46 #include <clib/graphics_protos.h>
48 AROS_LH10(void, BltMaskBitMapRastPort,
50 /* SYNOPSIS */
51 AROS_LHA(struct BitMap *, srcBitMap, A0),
52 AROS_LHA(WORD , xSrc, D0),
53 AROS_LHA(WORD , ySrc, D1),
54 AROS_LHA(struct RastPort *, destRP, A1),
55 AROS_LHA(WORD , xDest, D2),
56 AROS_LHA(WORD , yDest, D3),
57 AROS_LHA(WORD , xSize, D4),
58 AROS_LHA(WORD , ySize, D5),
59 AROS_LHA(ULONG , minterm, D6),
60 AROS_LHA(PLANEPTR , bltMask, A2),
62 /* LOCATION */
63 struct GfxBase *, GfxBase, 106, Graphics)
65 /* FUNCTION
66 Copies a part of a bitmap to another bitmap with using a mask.
68 INPUTS
69 srcBitMap - Copy from this bitmap.
70 xSrc, ySrc - This is the upper left corner of the area to copy.
71 destRP - Destination RastPort.
72 xDest, yDest - Upper left corner where to place the copy
73 xSize, ySize - The size of the area to copy
74 minterm - How to copy. See BltBitMap() for an explanation.
75 bltMask - The mask bitplane must be of the same size as the source bitmap.
77 RESULT
78 TRUE.
80 NOTES
82 EXAMPLE
84 BUGS
86 SEE ALSO
87 ClipBlit()
89 INPUTS
91 RESULT
93 NOTES
95 INTERNALS
97 HISTORY
98 27-11-96 digulla automatically created from
99 graphics_lib.fd and clib/graphics_protos.h
101 *****************************************************************************/
103 AROS_LIBFUNC_INIT
105 struct bltmask_render_data brd;
106 struct Rectangle rr;
107 OOP_Object *gc;
108 Point src;
110 EnterFunc(bug("BltMaskBitMapRastPort(%p (%d*%d), %d*%d, %p, %d*%d, %d*%d, %02x, %p)\n",
111 srcBitMap, srcBitMap->BytesPerRow, srcBitMap->Rows, xSrc, ySrc,
112 destRP, xDest, yDest, xSize, ySize, minterm, bltMask));
114 FIX_GFXCOORD(xSrc);
115 FIX_GFXCOORD(ySrc);
116 FIX_GFXCOORD(xDest);
117 FIX_GFXCOORD(yDest);
119 if ((xSize < 1) || (ySize < 1)) return;
121 brd.srcbm_obj = OBTAIN_HIDD_BM(srcBitMap);
122 if (NULL == brd.srcbm_obj)
124 return;
127 brd.srcbm = srcBitMap;
128 brd.mask = bltMask;
130 gc = GetDriverData(destRP, GfxBase);
131 GC_DRMD(gc) = MINTERM_TO_GCDRMD(minterm);
133 rr.MinX = xDest;
134 rr.MinY = yDest;
135 rr.MaxX = xDest + xSize - 1;
136 rr.MaxY = yDest + ySize - 1;
138 src.x = xSrc;
139 src.y = ySrc;
141 do_render_with_gc(destRP, &src, &rr, bltmask_render, &brd, gc, TRUE, TRUE, GfxBase);
143 RELEASE_HIDD_BM(brd.srcbm_obj, srcBitMap);
144 ReturnVoid("BltBitMapRastPort");
146 AROS_LIBFUNC_EXIT
148 } /* BltMaskBitMapRastPort */