Fixed missing fprintf argument.
[AROS.git] / rom / graphics / bltrastportbitmap.c
blob7eea5494498ae6a170bc2daf8826e92c5856fcde
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Blit the content of a rastport into a bitmap
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include <proto/graphics.h>
11 #include "graphics_intern.h"
12 #include "gfxfuncsupport.h"
14 /*****************************************************************************
16 NAME */
17 #include <clib/graphics_protos.h>
19 AROS_LH9(void, BltRastPortBitMap,
21 /* SYNOPSIS */
22 AROS_LHA(struct RastPort *, srcRastPort, A0),
23 AROS_LHA(LONG , xSrc , D0),
24 AROS_LHA(LONG , ySrc , D1),
25 AROS_LHA(struct BitMap * , destBitMap , A1),
26 AROS_LHA(LONG , xDest , D2),
27 AROS_LHA(LONG , yDest , D3),
28 AROS_LHA(ULONG , xSize , D4),
29 AROS_LHA(ULONG , ySize , D5),
30 AROS_LHA(ULONG , minterm , D6),
32 /* LOCATION */
33 struct GfxBase *, GfxBase, 196, Graphics)
35 /* FUNCTION
37 Copies the content of the rast port into the bitmap.
38 Takes cliprects into consideration.
39 INPUTS
41 RESULT
43 NOTES
45 EXAMPLE
47 BUGS
49 SEE ALSO
51 INTERNALS
53 HISTORY
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
58 AROS_LIBBASE_EXT_DECL(struct GfxBase *,GfxBase)
59 struct Layer * srcLayer;
61 FIX_GFXCOORD(xSrc);
62 FIX_GFXCOORD(ySrc);
63 FIX_GFXCOORD(xDest);
64 FIX_GFXCOORD(yDest);
66 if (NULL == (srcLayer = srcRastPort->Layer)) {
68 * Rastport without a layer is a screen.
70 BltBitMap(srcRastPort->BitMap,
71 xSrc,
72 ySrc,
73 destBitMap,
74 xDest,
75 yDest,
76 xSize,
77 ySize,
78 minterm,
79 ~0,
80 NULL);
81 } else {
82 struct BitMap * srcBM = srcRastPort->BitMap;
83 struct ClipRect * srcCR;
84 int area = xSize * ySize;
85 UBYTE useminterm = 0;
86 ULONG bltMask = 0xFFFFFFFF;
88 LockLayerRom(srcLayer);
89 srcCR = srcLayer->ClipRect;
91 while (NULL != srcCR &&
92 area > 0) {
94 * Is the current cliprect withing the
95 * required region?
97 LONG crX0, crX1, crY0, crY1;
98 /* cr?? have to be coordinates related to the rastport */
99 crX0 = srcCR->bounds.MinX - srcLayer->bounds.MinX;
100 crX1 = srcCR->bounds.MaxX - srcLayer->bounds.MinX;
101 crY0 = srcCR->bounds.MinY - srcLayer->bounds.MinY;
102 crY1 = srcCR->bounds.MaxY - srcLayer->bounds.MinY;
104 /* the only case that must not happen is that
105 this ClipRect is outside the source area. */
107 if (!(crX0 > (xSrc+xSize-1) ||
108 crX1 < xSrc ||
109 crY0 > (ySrc+ySize-1) ||
110 crY1 < ySrc)) {
111 ULONG MinX, MinY;
112 ULONG bltSrcX, bltSrcY, bltDestX, bltDestY, bltWidth, bltHeight;
113 ULONG SrcOffsetX;
115 /* this cliprect contains bitmap data that need to be copied */
117 * get the pointer to the bitmap structure and fill out
118 * the rectangle structure that shows which part we mean to copy
120 if (NULL != srcCR->BitMap) {
121 if (0 == (srcLayer->Flags & LAYERSUPER)) {
122 /* no superbitmap */
123 SrcOffsetX = ALIGN_OFFSET(srcCR->bounds.MinX);
125 if (xSrc >= crX0) {
126 bltSrcX = xSrc - crX0 + SrcOffsetX;
127 bltDestX = 0;
128 } else {
129 bltSrcX = SrcOffsetX;
130 bltDestX = crX0 - xSrc;
133 if (ySrc > crY0) {
134 bltSrcY = ySrc - crY0;
135 bltDestY = 0;
136 } else {
137 bltSrcY = 0;
138 bltDestY = crY0 - ySrc;
141 srcBM = srcCR->BitMap;
142 } else {
143 /* with superbitmap */
144 if (xSrc >= crX0) {
145 bltSrcX = xSrc - srcLayer->Scroll_X;
146 bltDestX = 0;
147 } else {
148 bltSrcX = crX0 - srcLayer->Scroll_X;
149 bltDestX = crX0 - xSrc;
152 if (ySrc >= crY0) {
153 bltSrcY = ySrc - srcLayer->Scroll_Y;
154 bltDestX = 0;
155 } else {
156 bltSrcY = crY0 - srcLayer->Scroll_Y;
157 bltDestY = crY0 - ySrc;
160 srcBM = srcCR->BitMap;
163 } else {
164 /* this part of the layer is not hidden. */
165 /* The source bitmap is the bitmap of the rastport */
166 srcBM = srcRastPort->BitMap;
168 /* xSrc and ySrc are relative to the rastport of the window
169 * or layer - here we have to make them absolute to the
170 * screen's rastport
173 if (xSrc <= crX0) {
174 bltSrcX = srcCR->bounds.MinX;
175 bltDestX = crX0 - xSrc;
176 } else {
177 bltSrcX = xSrc + srcLayer->bounds.MinX;
178 bltDestX = 0;
181 if (ySrc <= crY0) {
182 bltSrcY = srcCR->bounds.MinY;
183 bltDestY = crY0 - ySrc;
184 } else {
185 bltSrcY = ySrc + srcLayer->bounds.MinY;
186 bltDestY = 0;
190 if (crX0 > xSrc)
191 MinX = crX0 - xSrc;
192 else
193 MinX = 0;
195 if (crX1 < (xSrc+xSize-1))
196 bltWidth = crX1 - xSrc - MinX + 1;
197 else
198 bltWidth = xSize - 1 - MinX + 1;
200 if (crY0 > ySrc)
201 MinY = crY0 - ySrc;
202 else
203 MinY = 0;
205 if (crY1 < (ySrc+ySize-1))
206 bltHeight = crY1 - ySrc - MinY + 1;
207 else
208 bltHeight = ySize - 1 - MinY + 1;
210 if ((0 != (srcLayer->Flags & LAYERSIMPLE) &&
211 (NULL != srcCR->lobs ||
212 0 != (srcCR->Flags & CR_NEEDS_NO_CONCEALED_RASTERS))))
213 useminterm = 0x0; /* clear this area in the destination */
214 else
215 useminterm = minterm;
219 * Finally blit from the srcBM to the
220 * destBM
222 BltBitMap(srcBM,
223 bltSrcX,
224 bltSrcY,
225 destBitMap,
226 bltDestX,
227 bltDestY,
228 bltWidth,
229 bltHeight,
230 useminterm,
231 bltMask,
232 NULL);
233 area -= (bltWidth * bltHeight);
235 srcCR = srcCR->Next;
237 UnlockLayerRom(srcLayer);
239 ReturnVoid("BltRastPortBitMap");
241 AROS_LIBFUNC_EXIT
242 } /* BltBitMapRastPort */