2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Blit the content of a rastport into a bitmap
8 #include <aros/debug.h>
9 #include <proto/graphics.h>
11 #include "graphics_intern.h"
12 #include "gfxfuncsupport.h"
14 /*****************************************************************************
17 #include <clib/graphics_protos.h>
19 AROS_LH9(void, BltRastPortBitMap
,
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
),
33 struct GfxBase
*, GfxBase
, 196, Graphics
)
36 Copies the content of the rast port into the bitmap.
37 Takes cliprects into consideration.
40 srcRastPort - Copy from this RastPort.
41 xSrc, ySrc - This is the upper left corner of the area to copy.
42 destBitMap - Destination BitMap.
43 xDest, yDest - Upper left corner where to place the copy
44 xSize, ySize - The size of the area to copy
45 minterm - How to copy. See BltBitMap() for an explanation.
50 This functions isn't part of AmigaOS3.1
62 *****************************************************************************/
65 struct Layer
* srcLayer
;
72 if (NULL
== (srcLayer
= srcRastPort
->Layer
)) {
74 * Rastport without a layer is a screen.
76 BltBitMap(srcRastPort
->BitMap
,
88 struct BitMap
* srcBM
= srcRastPort
->BitMap
;
89 struct ClipRect
* srcCR
;
90 int area
= xSize
* ySize
;
92 ULONG bltMask
= 0xFFFFFFFF;
94 LockLayerRom(srcLayer
);
95 srcCR
= srcLayer
->ClipRect
;
97 while (NULL
!= srcCR
&&
100 * Is the current cliprect withing the
103 LONG crX0
, crX1
, crY0
, crY1
;
104 /* cr?? have to be coordinates related to the rastport */
105 crX0
= srcCR
->bounds
.MinX
- srcLayer
->bounds
.MinX
;
106 crX1
= srcCR
->bounds
.MaxX
- srcLayer
->bounds
.MinX
;
107 crY0
= srcCR
->bounds
.MinY
- srcLayer
->bounds
.MinY
;
108 crY1
= srcCR
->bounds
.MaxY
- srcLayer
->bounds
.MinY
;
110 /* the only case that must not happen is that
111 this ClipRect is outside the source area. */
113 if (!(crX0
> (xSrc
+xSize
-1) ||
115 crY0
> (ySrc
+ySize
-1) ||
118 ULONG bltSrcX
, bltSrcY
, bltDestX
, bltDestY
, bltWidth
, bltHeight
;
121 /* this cliprect contains bitmap data that need to be copied */
123 * get the pointer to the bitmap structure and fill out
124 * the rectangle structure that shows which part we mean to copy
126 if (NULL
!= srcCR
->BitMap
) {
127 if (0 == (srcLayer
->Flags
& LAYERSUPER
)) {
129 SrcOffsetX
= ALIGN_OFFSET(srcCR
->bounds
.MinX
);
132 bltSrcX
= xSrc
- crX0
+ SrcOffsetX
;
135 bltSrcX
= SrcOffsetX
;
136 bltDestX
= crX0
- xSrc
;
140 bltSrcY
= ySrc
- crY0
;
144 bltDestY
= crY0
- ySrc
;
147 srcBM
= srcCR
->BitMap
;
149 /* with superbitmap */
151 bltSrcX
= xSrc
- srcLayer
->Scroll_X
;
154 bltSrcX
= crX0
- srcLayer
->Scroll_X
;
155 bltDestX
= crX0
- xSrc
;
159 bltSrcY
= ySrc
- srcLayer
->Scroll_Y
;
162 bltSrcY
= crY0
- srcLayer
->Scroll_Y
;
163 bltDestY
= crY0
- ySrc
;
166 srcBM
= srcCR
->BitMap
;
170 /* this part of the layer is not hidden. */
171 /* The source bitmap is the bitmap of the rastport */
172 srcBM
= srcRastPort
->BitMap
;
174 /* xSrc and ySrc are relative to the rastport of the window
175 * or layer - here we have to make them absolute to the
180 bltSrcX
= srcCR
->bounds
.MinX
;
181 bltDestX
= crX0
- xSrc
;
183 bltSrcX
= xSrc
+ srcLayer
->bounds
.MinX
;
188 bltSrcY
= srcCR
->bounds
.MinY
;
189 bltDestY
= crY0
- ySrc
;
191 bltSrcY
= ySrc
+ srcLayer
->bounds
.MinY
;
201 if (crX1
< (xSrc
+xSize
-1))
202 bltWidth
= crX1
- xSrc
- MinX
+ 1;
204 bltWidth
= xSize
- 1 - MinX
+ 1;
211 if (crY1
< (ySrc
+ySize
-1))
212 bltHeight
= crY1
- ySrc
- MinY
+ 1;
214 bltHeight
= ySize
- 1 - MinY
+ 1;
216 if ((0 != (srcLayer
->Flags
& LAYERSIMPLE
) &&
217 (NULL
!= srcCR
->lobs
||
218 0 != (srcCR
->Flags
& CR_NEEDS_NO_CONCEALED_RASTERS
))))
219 useminterm
= 0x0; /* clear this area in the destination */
221 useminterm
= minterm
;
225 * Finally blit from the srcBM to the
239 area
-= (bltWidth
* bltHeight
);
243 UnlockLayerRom(srcLayer
);
245 ReturnVoid("BltRastPortBitMap");
248 } /* BltBitMapRastPort */