2 Copyright © 1995-2001, 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
)
37 Copies the content of the rast port into the bitmap.
38 Takes cliprects into consideration.
55 *****************************************************************************/
58 AROS_LIBBASE_EXT_DECL(struct GfxBase
*,GfxBase
)
59 struct Layer
* srcLayer
;
66 if (NULL
== (srcLayer
= srcRastPort
->Layer
)) {
68 * Rastport without a layer is a screen.
70 BltBitMap(srcRastPort
->BitMap
,
82 struct BitMap
* srcBM
= srcRastPort
->BitMap
;
83 struct ClipRect
* srcCR
;
84 int area
= xSize
* ySize
;
86 ULONG bltMask
= 0xFFFFFFFF;
88 LockLayerRom(srcLayer
);
89 srcCR
= srcLayer
->ClipRect
;
91 while (NULL
!= srcCR
&&
94 * Is the current cliprect withing the
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) ||
109 crY0
> (ySrc
+ySize
-1) ||
112 ULONG bltSrcX
, bltSrcY
, bltDestX
, bltDestY
, bltWidth
, bltHeight
;
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
)) {
123 SrcOffsetX
= ALIGN_OFFSET(srcCR
->bounds
.MinX
);
126 bltSrcX
= xSrc
- crX0
+ SrcOffsetX
;
129 bltSrcX
= SrcOffsetX
;
130 bltDestX
= crX0
- xSrc
;
134 bltSrcY
= ySrc
- crY0
;
138 bltDestY
= crY0
- ySrc
;
141 srcBM
= srcCR
->BitMap
;
143 /* with superbitmap */
145 bltSrcX
= xSrc
- srcLayer
->Scroll_X
;
148 bltSrcX
= crX0
- srcLayer
->Scroll_X
;
149 bltDestX
= crX0
- xSrc
;
153 bltSrcY
= ySrc
- srcLayer
->Scroll_Y
;
156 bltSrcY
= crY0
- srcLayer
->Scroll_Y
;
157 bltDestY
= crY0
- ySrc
;
160 srcBM
= srcCR
->BitMap
;
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
174 bltSrcX
= srcCR
->bounds
.MinX
;
175 bltDestX
= crX0
- xSrc
;
177 bltSrcX
= xSrc
+ srcLayer
->bounds
.MinX
;
182 bltSrcY
= srcCR
->bounds
.MinY
;
183 bltDestY
= crY0
- ySrc
;
185 bltSrcY
= ySrc
+ srcLayer
->bounds
.MinY
;
195 if (crX1
< (xSrc
+xSize
-1))
196 bltWidth
= crX1
- xSrc
- MinX
+ 1;
198 bltWidth
= xSize
- 1 - MinX
+ 1;
205 if (crY1
< (ySrc
+ySize
-1))
206 bltHeight
= crY1
- ySrc
- MinY
+ 1;
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 */
215 useminterm
= minterm
;
219 * Finally blit from the srcBM to the
233 area
-= (bltWidth
* bltHeight
);
237 UnlockLayerRom(srcLayer
);
239 ReturnVoid("BltRastPortBitMap");
242 } /* BltBitMapRastPort */