2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Blit the content of a rastport into a bitmap
9 #include <aros/debug.h>
10 #include <proto/graphics.h>
12 #include "graphics_intern.h"
13 #include "gfxfuncsupport.h"
15 void BltRastPortBitMap(struct RastPort
*srcRastPort
, WORD xSrc
, WORD ySrc
,
16 struct BitMap
*destBitMap
, WORD xDest
, WORD yDest
,
17 WORD xSize
, WORD ySize
, ULONG minterm
,
18 struct GfxBase
*GfxBase
)
20 struct Layer
* srcLayer
;
27 if (NULL
== (srcLayer
= srcRastPort
->Layer
)) {
29 * Rastport without a layer is a screen.
31 BltBitMap(srcRastPort
->BitMap
,
43 struct BitMap
* srcBM
= srcRastPort
->BitMap
;
44 struct ClipRect
* srcCR
;
45 int area
= xSize
* ySize
;
47 ULONG bltMask
= 0xFFFFFFFF;
49 LockLayerRom(srcLayer
);
50 srcCR
= srcLayer
->ClipRect
;
52 while (NULL
!= srcCR
&&
55 * Is the current cliprect withing the
58 WORD crX0
, crX1
, crY0
, crY1
;
59 /* cr?? have to be coordinates related to the rastport */
60 crX0
= srcCR
->bounds
.MinX
- srcLayer
->bounds
.MinX
;
61 crX1
= srcCR
->bounds
.MaxX
- srcLayer
->bounds
.MinX
;
62 crY0
= srcCR
->bounds
.MinY
- srcLayer
->bounds
.MinY
;
63 crY1
= srcCR
->bounds
.MaxY
- srcLayer
->bounds
.MinY
;
65 /* the only case that must not happen is that
66 this ClipRect is outside the source area. */
68 if (!(crX0
> (xSrc
+xSize
-1) ||
70 crY0
> (ySrc
+ySize
-1) ||
73 WORD bltSrcX
, bltSrcY
, bltDestX
, bltDestY
, bltWidth
, bltHeight
;
76 /* this cliprect contains bitmap data that need to be copied */
78 * get the pointer to the bitmap structure and fill out
79 * the rectangle structure that shows which part we mean to copy
81 if (NULL
!= srcCR
->BitMap
) {
82 if (0 == (srcLayer
->Flags
& LAYERSUPER
)) {
84 SrcOffsetX
= ALIGN_OFFSET(srcCR
->bounds
.MinX
);
87 bltSrcX
= xSrc
- crX0
+ SrcOffsetX
;
91 bltDestX
= crX0
- xSrc
;
95 bltSrcY
= ySrc
- crY0
;
99 bltDestY
= crY0
- ySrc
;
102 srcBM
= srcCR
->BitMap
;
104 /* with superbitmap */
106 bltSrcX
= xSrc
- srcLayer
->Scroll_X
;
109 bltSrcX
= crX0
- srcLayer
->Scroll_X
;
110 bltDestX
= crX0
- xSrc
;
114 bltSrcY
= ySrc
- srcLayer
->Scroll_Y
;
117 bltSrcY
= crY0
- srcLayer
->Scroll_Y
;
118 bltDestY
= crY0
- ySrc
;
121 srcBM
= srcCR
->BitMap
;
125 /* this part of the layer is not hidden. */
126 /* The source bitmap is the bitmap of the rastport */
127 srcBM
= srcRastPort
->BitMap
;
129 /* xSrc and ySrc are relative to the rastport of the window
130 * or layer - here we have to make them absolute to the
135 bltSrcX
= srcCR
->bounds
.MinX
;
136 bltDestX
= crX0
- xSrc
;
138 bltSrcX
= xSrc
+ srcLayer
->bounds
.MinX
;
143 bltSrcY
= srcCR
->bounds
.MinY
;
144 bltDestY
= crY0
- ySrc
;
146 bltSrcY
= ySrc
+ srcLayer
->bounds
.MinY
;
156 if (crX1
< (xSrc
+xSize
-1))
157 bltWidth
= crX1
- xSrc
- MinX
+ 1;
159 bltWidth
= xSize
- 1 - MinX
+ 1;
166 if (crY1
< (ySrc
+ySize
-1))
167 bltHeight
= crY1
- ySrc
- MinY
+ 1;
169 bltHeight
= ySize
- 1 - MinY
+ 1;
171 if ((0 != (srcLayer
->Flags
& LAYERSIMPLE
) &&
172 (NULL
!= srcCR
->lobs
||
173 0 != (srcCR
->Flags
& CR_NEEDS_NO_CONCEALED_RASTERS
))))
174 useminterm
= 0x0; /* clear this area in the destination */
176 useminterm
= minterm
;
180 * Finally blit from the srcBM to the
194 area
-= (bltWidth
* bltHeight
);
198 UnlockLayerRom(srcLayer
);
200 ReturnVoid("BltRastPortBitMap");