5 #include "../vgavideo/vgavideo.h"
10 // RGBtoULONG (eng/xlate.c) will be faster than RtlCopyMemory?
12 // Note: All of our BitBlt ops expect to be working with 4BPP data
14 typedef BOOL (*PFN_VGABlt
)(SURFOBJ
*, SURFOBJ
*, SURFOBJ
*, XLATEOBJ
*,
15 RECTL
*, POINTL
*, POINTL
*,
16 BRUSHOBJ
*, POINTL
*, ROP4
);
19 SURFOBJ
*Dest
, SURFOBJ
*Source
, SURFOBJ
*Mask
, XLATEOBJ
*ColorTranslation
,
20 RECTL
*DestRect
, POINTL
*SourcePoint
, POINTL
*MaskPoint
,
21 BRUSHOBJ
*Brush
, POINTL
*BrushPoint
, ROP4 rop4
)
23 LONG i
, j
, dx
, dy
, alterx
, altery
, idxColor
, RGBulong
= 0, c8
;
24 BYTE
*GDIpos
, *initial
, *tMask
, *lMask
;
27 GDIpos
= Source
->pvBits
/* +
28 SourcePoint->y * Source->lDelta + (SourcePoint->x >> 1) */ ;
31 dx
= DestRect
->right
- DestRect
->left
;
32 dy
= DestRect
->bottom
- DestRect
->top
;
34 alterx
= abs(SourcePoint
->x
- DestRect
->left
);
35 altery
= abs(SourcePoint
->y
- DestRect
->top
);
37 // FIXME: ColorTranslation will never be null. We must always map the colors (see PCGPE's bmp.txt)
39 if(ColorTranslation
== NULL
)
44 if(rop4
== 0xAACC) { // no source, just paint the brush according to the mask
53 if((*lMask
& maskbit
[c8
]) != 0)
54 vgaPutPixel(DestRect
->left
+ i
, DestRect
->top
+ j
, Brush
->iSolidColor
);
56 if(c8
== 8) { lMask
++; c8
=0; }
58 tMask
+= Mask
->lDelta
;
63 DIB_BltToVGA(DestRect
->left
, DestRect
->top
, dx
, dy
, Source
->pvBits
, Source
->lDelta
);
67 // Perform color translation
68 for(j
=SourcePoint
->y
; j
<SourcePoint
->y
+dy
; j
++)
72 for(i
=SourcePoint
->x
; i
<SourcePoint
->x
+dx
; i
++)
74 idxColor
= XLATEOBJ_iXlate(ColorTranslation
, *GDIpos
);
75 vgaPutPixel(i
+alterx
, j
+altery
, idxColor
);
78 GDIpos
= initial
+ Source
->lDelta
;
84 SURFOBJ
*Dest
, SURFOBJ
*Source
, SURFOBJ
*Mask
, XLATEOBJ
*ColorTranslation
,
85 RECTL
*DestRect
, POINTL
*SourcePoint
, POINTL
*MaskPoint
,
86 BRUSHOBJ
*Brush
, POINTL
*BrushPoint
, ROP4 rop4
)
88 LONG i
, j
, dx
, dy
, RGBulong
;
89 BYTE
*GDIpos
, *initial
, idxColor
;
91 // Used by the temporary DFB
94 PSURFOBJ TargetBitmapSurf
;
95 HBITMAP hTargetBitmap
;
99 // FIXME: Optimize to retrieve entire bytes at a time (see /display/vgavideo/vgavideo.c:vgaGetByte)
101 GDIpos
= Dest
->pvBits
/* + (DestRect->top * Dest->lDelta) + (DestRect->left >> 1) */ ;
102 dx
= DestRect
->right
- DestRect
->left
;
103 dy
= DestRect
->bottom
- DestRect
->top
;
105 if(ColorTranslation
== NULL
)
107 // Prepare a Dest Dev Target and copy from the DFB to the DIB
108 DestDevSurf
.NextScan
= Dest
->lDelta
;
109 DestDevSurf
.StartBmp
= Dest
->pvScan0
;
111 DIB_BltFromVGA(SourcePoint
->x
, SourcePoint
->y
, dx
, dy
, Dest
->pvBits
, Dest
->lDelta
);
115 for(j
=SourcePoint
->y
; j
<SourcePoint
->y
+dy
; j
++)
118 for(i
=SourcePoint
->x
; i
<SourcePoint
->x
+dx
; i
++)
120 *GDIpos
= XLATEOBJ_iXlate(ColorTranslation
, vgaGetPixel(i
, j
));
123 GDIpos
= initial
+ Dest
->lDelta
;
129 SURFOBJ
*Dest
, SURFOBJ
*Source
, SURFOBJ
*Mask
, XLATEOBJ
*ColorTranslation
,
130 RECTL
*DestRect
, POINTL
*SourcePoint
, POINTL
*MaskPoint
,
131 BRUSHOBJ
*Brush
, POINTL
*BrushPoint
, ROP4 rop4
)
133 // Do DFBs need color translation??
137 SURFOBJ
*Dest
, SURFOBJ
*Source
, SURFOBJ
*Mask
, XLATEOBJ
*ColorTranslation
,
138 RECTL
*DestRect
, POINTL
*SourcePoint
, POINTL
*MaskPoint
,
139 BRUSHOBJ
*Brush
, POINTL
*BrushPoint
, ROP4 rop4
)
141 // Do DFBs need color translation??
145 SURFOBJ
*Dest
, SURFOBJ
*Source
, SURFOBJ
*Mask
, XLATEOBJ
*ColorTranslation
,
146 RECTL
*DestRect
, POINTL
*SourcePoint
, POINTL
*MaskPoint
,
147 BRUSHOBJ
*Brush
, POINTL
*BrushPoint
, ROP4 rop4
)
149 // FIXME: Use fast blts instead of get and putpixels
151 int i
, j
, dx
, dy
, alterx
, altery
, BltDirection
;
155 dx
= DestRect
->right
- DestRect
->left
;
156 dy
= DestRect
->bottom
- DestRect
->top
;
158 alterx
= abs(SourcePoint
->x
- DestRect
->left
);
159 altery
= abs(SourcePoint
->y
- DestRect
->top
);
161 // Determine bltting direction
162 // FIXME: should we perhaps make this an EngXxx function? Determining
163 // direction is probably used whenever the surfaces are the same (not
165 if (SourcePoint
->y
>= DestRect
->top
)
167 if (SourcePoint
->x
>= DestRect
->left
)
169 BltDirection
= CD_RIGHTDOWN
;
173 BltDirection
= CD_LEFTDOWN
;
178 if (SourcePoint
->x
>= DestRect
->left
)
180 BltDirection
= CD_RIGHTUP
;
184 BltDirection
= CD_LEFTUP
;
188 // Do the VGA to VGA BitBlt
189 // FIXME: Right now we're only doing CN_LEFTDOWN and we're using slow
190 // get and put pixel routines
192 for(j
=SourcePoint
->y
; j
<SourcePoint
->y
+dy
; j
++)
194 for(i
=SourcePoint
->x
; i
<SourcePoint
->x
+dx
; i
++)
196 vgaPutPixel(i
+alterx
, j
+altery
, vgaGetPixel(i
, j
));
205 DrvBitBlt(SURFOBJ
*Dest
,
209 XLATEOBJ
*ColorTranslation
,
219 PFN_VGABlt BltOperation
;
224 SourceType
= STYPE_BITMAP
;
226 SourceType
= Source
->iType
;
228 DPRINT("VGADDIBitBlt: Dest->pvScan0: %08x\n", Dest
->pvScan0
);
230 // Determine the bltbit operation
232 if((SourceType
== STYPE_BITMAP
) && (Dest
->iType
== STYPE_DEVICE
))
235 BltOperation
= DIBtoVGA
;
237 if((SourceType
== STYPE_DEVICE
) && (Dest
->iType
== STYPE_BITMAP
))
240 BltOperation
= VGAtoDIB
;
242 if((SourceType
== STYPE_DEVICE
) && (Dest
->iType
== STYPE_DEVICE
))
245 BltOperation
= VGAtoVGA
;
247 if((SourceType
== STYPE_DEVBITMAP
) && (Dest
->iType
== STYPE_DEVICE
))
250 BltOperation
= DFBtoVGA
;
252 if((SourceType
== STYPE_DEVICE
) && (Dest
->iType
== STYPE_DEVBITMAP
))
255 BltOperation
= VGAtoDFB
;
258 DPRINT("VGA:bitblt.c: Can't handle requested BitBlt operation (source:%u dest:%u)\n", SourceType
, Dest
->iType
);
259 // Cannot handle given surfaces for VGA BitBlt
263 // Perform the necessary operatings according to the clipping
267 BltOperation(Dest
, Source
, Mask
, ColorTranslation
, DestRect
,
268 SourcePoint
, MaskPoint
, Brush
, BrushPoint
, rop4
);
271 switch(Clip
->iMode
) {
275 if (Clip
->iDComplexity
== DC_RECT
)
277 // FIXME: Intersect clip rectangle
279 BltOperation(Dest
, Source
, Mask
, ColorTranslation
,
280 DestRect
, SourcePoint
, MaskPoint
, Brush
, BrushPoint
, rop4
);
283 // Enumerate all the rectangles and draw them
285 /* CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_ANY,
289 EnumMore = CLIPOBJ_bEnum(Clip, sizeof(RectEnum), (PVOID) &RectEnum);
290 // FIXME: Calc new source point (diff between new & old destrects?)
292 VGADDIFillSolid(Dest, Srouce, Mask,
293 &RectEnum.arcl[0], NewSourcePoint);
295 } while (EnumMore); */