implemented TransparentBlt() on 32bpp surfaces, but there are still some clipping issues

svn path=/trunk/; revision=8988
This commit is contained in:
Thomas Bluemel 2004-04-06 17:54:32 +00:00
parent 1bc88e0f77
commit 5424a51107
14 changed files with 388 additions and 81 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: dib.c,v 1.7 2004/03/21 04:17:33 royce Exp $ */ /* $Id: dib.c,v 1.8 2004/04/06 17:54:32 weiden Exp $ */
#include <windows.h> #include <windows.h>
#include <ddk/winddi.h> #include <ddk/winddi.h>
@ -67,6 +67,29 @@ DIB_GetSource(SURFOBJ* SourceSurf, SURFGDI* SourceGDI, ULONG sx, ULONG sy, XLATE
} }
} }
ULONG
DIB_GetOriginalSource(SURFOBJ* SourceSurf, SURFGDI* SourceGDI, ULONG sx, ULONG sy)
{
switch (SourceGDI->BitsPerPixel)
{
case 1:
return DIB_1BPP_GetPixel(SourceSurf, sx, sy);
case 4:
return DIB_4BPP_GetPixel(SourceSurf, sx, sy);
case 8:
return DIB_8BPP_GetPixel(SourceSurf, sx, sy);
case 16:
return DIB_16BPP_GetPixel(SourceSurf, sx, sy);
case 24:
return DIB_24BPP_GetPixel(SourceSurf, sx, sy);
case 32:
return DIB_32BPP_GetPixel(SourceSurf, sx, sy);
default:
DPRINT1("DIB_GetOriginalSource: Unhandled number of bits per pixel in source (%d).\n", SourceGDI->BitsPerPixel);
return(0);
}
}
ULONG ULONG
DIB_DoRop(ULONG Rop, ULONG Dest, ULONG Source, ULONG Pattern) DIB_DoRop(ULONG Rop, ULONG Dest, ULONG Source, ULONG Pattern)
{ {

View file

@ -3,6 +3,7 @@ extern unsigned char altnotmask[2];
#define MASK1BPP(x) (1<<(7-((x)&7))) #define MASK1BPP(x) (1<<(7-((x)&7)))
ULONG DIB_DoRop(ULONG Rop, ULONG Dest, ULONG Source, ULONG Pattern); ULONG DIB_DoRop(ULONG Rop, ULONG Dest, ULONG Source, ULONG Pattern);
ULONG DIB_GetSource(SURFOBJ* SourceSurf, SURFGDI* SourceGDI, ULONG sx, ULONG sy, XLATEOBJ* ColorTranslation); ULONG DIB_GetSource(SURFOBJ* SourceSurf, SURFGDI* SourceGDI, ULONG sx, ULONG sy, XLATEOBJ* ColorTranslation);
ULONG DIB_GetOriginalSource(SURFOBJ* SourceSurf, SURFGDI* SourceGDI, ULONG sx, ULONG sy);
VOID DIB_1BPP_PutPixel(SURFOBJ* SurfObj, LONG x, LONG y, ULONG c); VOID DIB_1BPP_PutPixel(SURFOBJ* SurfObj, LONG x, LONG y, ULONG c);
ULONG DIB_1BPP_GetPixel(SURFOBJ* SurfObj, LONG x, LONG y); ULONG DIB_1BPP_GetPixel(SURFOBJ* SurfObj, LONG x, LONG y);
@ -18,6 +19,10 @@ BOOLEAN DIB_1BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
RECTL* DestRect, RECTL *SourceRect, RECTL* DestRect, RECTL *SourceRect,
POINTL* MaskOrigin, POINTL* BrushOrigin, POINTL* MaskOrigin, POINTL* BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Mode); XLATEOBJ *ColorTranslation, ULONG Mode);
BOOLEAN DIB_1BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PSURFGDI DestGDI, PSURFGDI SourceGDI,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor);
VOID DIB_4BPP_PutPixel(SURFOBJ* SurfObj, LONG x, LONG y, ULONG c); VOID DIB_4BPP_PutPixel(SURFOBJ* SurfObj, LONG x, LONG y, ULONG c);
ULONG DIB_4BPP_GetPixel(SURFOBJ* SurfObj, LONG x, LONG y); ULONG DIB_4BPP_GetPixel(SURFOBJ* SurfObj, LONG x, LONG y);
@ -33,6 +38,10 @@ BOOLEAN DIB_4BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
RECTL* DestRect, RECTL *SourceRect, RECTL* DestRect, RECTL *SourceRect,
POINTL* MaskOrigin, POINTL* BrushOrigin, POINTL* MaskOrigin, POINTL* BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Mode); XLATEOBJ *ColorTranslation, ULONG Mode);
BOOLEAN DIB_4BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PSURFGDI DestGDI, PSURFGDI SourceGDI,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor);
VOID DIB_8BPP_PutPixel(SURFOBJ* SurfObj, LONG x, LONG y, ULONG c); VOID DIB_8BPP_PutPixel(SURFOBJ* SurfObj, LONG x, LONG y, ULONG c);
ULONG DIB_8BPP_GetPixel(SURFOBJ* SurfObj, LONG x, LONG y); ULONG DIB_8BPP_GetPixel(SURFOBJ* SurfObj, LONG x, LONG y);
@ -48,6 +57,10 @@ BOOLEAN DIB_8BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
RECTL* DestRect, RECTL *SourceRect, RECTL* DestRect, RECTL *SourceRect,
POINTL* MaskOrigin, POINTL* BrushOrigin, POINTL* MaskOrigin, POINTL* BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Mode); XLATEOBJ *ColorTranslation, ULONG Mode);
BOOLEAN DIB_8BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PSURFGDI DestGDI, PSURFGDI SourceGDI,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor);
VOID DIB_16BPP_PutPixel(SURFOBJ* SurfObj, LONG x, LONG y, ULONG c); VOID DIB_16BPP_PutPixel(SURFOBJ* SurfObj, LONG x, LONG y, ULONG c);
ULONG DIB_16BPP_GetPixel(SURFOBJ* SurfObj, LONG x, LONG y); ULONG DIB_16BPP_GetPixel(SURFOBJ* SurfObj, LONG x, LONG y);
@ -63,6 +76,10 @@ BOOLEAN DIB_16BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
RECTL* DestRect, RECTL *SourceRect, RECTL* DestRect, RECTL *SourceRect,
POINTL* MaskOrigin, POINTL* BrushOrigin, POINTL* MaskOrigin, POINTL* BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Mode); XLATEOBJ *ColorTranslation, ULONG Mode);
BOOLEAN DIB_16BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PSURFGDI DestGDI, PSURFGDI SourceGDI,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor);
VOID DIB_24BPP_PutPixel(SURFOBJ* SurfObj, LONG x, LONG y, ULONG c); VOID DIB_24BPP_PutPixel(SURFOBJ* SurfObj, LONG x, LONG y, ULONG c);
ULONG DIB_24BPP_GetPixel(SURFOBJ* SurfObj, LONG x, LONG y); ULONG DIB_24BPP_GetPixel(SURFOBJ* SurfObj, LONG x, LONG y);
@ -78,6 +95,10 @@ BOOLEAN DIB_24BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
RECTL* DestRect, RECTL *SourceRect, RECTL* DestRect, RECTL *SourceRect,
POINTL* MaskOrigin, POINTL* BrushOrigin, POINTL* MaskOrigin, POINTL* BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Mode); XLATEOBJ *ColorTranslation, ULONG Mode);
BOOLEAN DIB_24BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PSURFGDI DestGDI, PSURFGDI SourceGDI,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor);
VOID DIB_32BPP_PutPixel(SURFOBJ* SurfObj, LONG x, LONG y, ULONG c); VOID DIB_32BPP_PutPixel(SURFOBJ* SurfObj, LONG x, LONG y, ULONG c);
ULONG DIB_32BPP_GetPixel(SURFOBJ* SurfObj, LONG x, LONG y); ULONG DIB_32BPP_GetPixel(SURFOBJ* SurfObj, LONG x, LONG y);
@ -93,4 +114,8 @@ BOOLEAN DIB_32BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
RECTL* DestRect, RECTL *SourceRect, RECTL* DestRect, RECTL *SourceRect,
POINTL* MaskOrigin, POINTL* BrushOrigin, POINTL* MaskOrigin, POINTL* BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Mode); XLATEOBJ *ColorTranslation, ULONG Mode);
BOOLEAN DIB_32BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PSURFGDI DestGDI, PSURFGDI SourceGDI,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: dib16bpp.c,v 1.22 2004/04/05 21:26:24 navaraf Exp $ */ /* $Id: dib16bpp.c,v 1.23 2004/04/06 17:54:32 weiden Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
@ -602,4 +602,13 @@ BOOLEAN DIB_16BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
return TRUE; return TRUE;
} }
BOOLEAN
DIB_16BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PSURFGDI DestGDI, PSURFGDI SourceGDI,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor)
{
return FALSE;
}
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: dib1bpp.c,v 1.17 2004/04/05 21:26:24 navaraf Exp $ */ /* $Id: dib1bpp.c,v 1.18 2004/04/06 17:54:32 weiden Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
@ -536,4 +536,13 @@ DIB_1BPP_StretchBlt (
return FALSE; return FALSE;
} }
BOOLEAN
DIB_1BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PSURFGDI DestGDI, PSURFGDI SourceGDI,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor)
{
return FALSE;
}
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: dib24bpp.c,v 1.18 2004/04/05 21:26:24 navaraf Exp $ */ /* $Id: dib24bpp.c,v 1.19 2004/04/06 17:54:32 weiden Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
@ -361,4 +361,13 @@ BOOLEAN DIB_24BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
return FALSE; return FALSE;
} }
BOOLEAN
DIB_24BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PSURFGDI DestGDI, PSURFGDI SourceGDI,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor)
{
return FALSE;
}
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: dib32bpp.c,v 1.18 2004/04/05 21:26:24 navaraf Exp $ */ /* $Id: dib32bpp.c,v 1.19 2004/04/06 17:54:32 weiden Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
@ -304,7 +304,7 @@ DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
{ {
ULONG X, Y; ULONG X, Y;
ULONG SourceX, SourceY; ULONG SourceX, SourceY;
ULONG Dest, Source, Pattern; ULONG Dest, Source, Pattern, wd;
PULONG DestBits; PULONG DestBits;
BOOL UsesSource; BOOL UsesSource;
BOOL UsesPattern; BOOL UsesPattern;
@ -359,6 +359,7 @@ DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
DestSurf->pvScan0 + DestSurf->pvScan0 +
(DestRect->left << 2) + (DestRect->left << 2) +
DestRect->top * DestSurf->lDelta); DestRect->top * DestSurf->lDelta);
wd = ((DestRect->right - DestRect->left) << 2) - DestSurf->lDelta;
for (Y = DestRect->top; Y < DestRect->bottom; Y++) for (Y = DestRect->top; Y < DestRect->bottom; Y++)
{ {
@ -390,9 +391,7 @@ DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
SourceY++; SourceY++;
DestBits = (PULONG)( DestBits = (PULONG)(
(ULONG_PTR)DestBits - (ULONG_PTR)DestBits - wd);
((DestRect->right - DestRect->left) << 2) +
DestSurf->lDelta);
} }
if (PatternSurface != NULL) if (PatternSurface != NULL)
@ -567,4 +566,45 @@ BOOLEAN DIB_32BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
return TRUE; return TRUE;
} }
BOOLEAN
DIB_32BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PSURFGDI DestGDI, PSURFGDI SourceGDI,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor)
{
ULONG X, Y;
ULONG SourceX, SourceY, Source, wd;
PULONG DestBits;
SourceY = SourcePoint->y;
DestBits = (PULONG)(DestSurf->pvScan0 +
(DestRect->left << 2) +
DestRect->top * DestSurf->lDelta);
wd = ((DestRect->right - DestRect->left) << 2) - DestSurf->lDelta;
for(Y = DestRect->top; Y < DestRect->bottom; Y++)
{
SourceX = SourcePoint->x;
for(X = DestRect->left; X < DestRect->right; X++, DestBits++, SourceX++)
{
Source = DIB_GetOriginalSource(SourceSurf, SourceGDI, SourceX, SourceY);
if(Source == iTransColor)
{
/* Skip transparent pixels */
continue;
}
if(ColorTranslation)
*DestBits = XLATEOBJ_iXlate(ColorTranslation, Source);
else
*DestBits = Source;
}
SourceY++;
DestBits = (PULONG)((ULONG_PTR)DestBits - wd);
}
return TRUE;
}
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: dib4bpp.c,v 1.24 2004/04/05 21:26:24 navaraf Exp $ */ /* $Id: dib4bpp.c,v 1.25 2004/04/06 17:54:32 weiden Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
@ -413,4 +413,13 @@ BOOLEAN DIB_4BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
return FALSE; return FALSE;
} }
BOOLEAN
DIB_4BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PSURFGDI DestGDI, PSURFGDI SourceGDI,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor)
{
return FALSE;
}
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: dib8bpp.c,v 1.17 2004/04/05 21:26:24 navaraf Exp $ */ /* $Id: dib8bpp.c,v 1.18 2004/04/06 17:54:32 weiden Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
@ -562,4 +562,13 @@ BOOLEAN DIB_8BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
return TRUE; return TRUE;
} }
BOOLEAN
DIB_8BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PSURFGDI DestGDI, PSURFGDI SourceGDI,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor)
{
return FALSE;
}
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: objects.h,v 1.28 2004/02/08 21:37:52 weiden Exp $ /* $Id: objects.h,v 1.29 2004/04/06 17:54:32 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -150,8 +150,8 @@ typedef BOOL STDCALL (*PFN_GradientFill)(SURFOBJ*, CLIPOBJ*, XLATEOBJ*, TRIVERTE
/* Forward declare (circular reference) */ /* Forward declare (circular reference) */
typedef struct _SURFGDI *PSURFGDI; typedef struct _SURFGDI *PSURFGDI;
typedef VOID (*PFN_DIB_PutPixel)(SURFOBJ *, LONG, LONG, ULONG); typedef VOID (*PFN_DIB_PutPixel) (SURFOBJ *, LONG, LONG, ULONG);
typedef ULONG (*PFN_DIB_GetPixel)(SURFOBJ *, LONG, LONG); typedef ULONG (*PFN_DIB_GetPixel) (SURFOBJ *, LONG, LONG);
typedef VOID (*PFN_DIB_HLine) (SURFOBJ *, LONG, LONG, LONG, ULONG); typedef VOID (*PFN_DIB_HLine) (SURFOBJ *, LONG, LONG, LONG, ULONG);
typedef VOID (*PFN_DIB_VLine) (SURFOBJ *, LONG, LONG, LONG, ULONG); typedef VOID (*PFN_DIB_VLine) (SURFOBJ *, LONG, LONG, LONG, ULONG);
typedef BOOLEAN (*PFN_DIB_BitBlt) (SURFOBJ * DestSurf, SURFOBJ * SourceSurf, typedef BOOLEAN (*PFN_DIB_BitBlt) (SURFOBJ * DestSurf, SURFOBJ * SourceSurf,
@ -164,6 +164,9 @@ typedef BOOLEAN (*PFN_DIB_StretchBlt) (SURFOBJ * DestSurf, SURFOBJ * SourceSurf
RECTL * DestRect, RECTL * SourceRect, RECTL * DestRect, RECTL * SourceRect,
POINTL *MaskOrigin, POINTL * BrushOrigin, POINTL *MaskOrigin, POINTL * BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Mode); XLATEOBJ *ColorTranslation, ULONG Mode);
typedef BOOLEAN (*PFN_DIB_TransparentBlt) (SURFOBJ *, SURFOBJ *, PSURFGDI, PSURFGDI,
RECTL* , POINTL *, XLATEOBJ *,ULONG);
typedef struct _SURFGDI { typedef struct _SURFGDI {
ENGOBJ Header; ENGOBJ Header;
@ -197,6 +200,7 @@ typedef struct _SURFGDI {
PFN_DIB_VLine DIB_VLine; PFN_DIB_VLine DIB_VLine;
PFN_DIB_BitBlt DIB_BitBlt; PFN_DIB_BitBlt DIB_BitBlt;
PFN_DIB_StretchBlt DIB_StretchBlt; PFN_DIB_StretchBlt DIB_StretchBlt;
PFN_DIB_TransparentBlt DIB_TransparentBlt;
/* misc */ /* misc */
ULONG PointerStatus; ULONG PointerStatus;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: surface.c,v 1.35 2004/03/20 17:33:10 navaraf Exp $ /* $Id: surface.c,v 1.36 2004/04/06 17:54:32 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -126,6 +126,14 @@ static BOOLEAN Dummy_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
return FALSE; return FALSE;
} }
static BOOLEAN Dummy_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PSURFGDI DestGDI, PSURFGDI SourceGDI,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor)
{
return FALSE;
}
#define SURF_METHOD(c,n) DIB_##c##_##n #define SURF_METHOD(c,n) DIB_##c##_##n
#define SET_SURFGDI(c)\ #define SET_SURFGDI(c)\
@ -134,7 +142,8 @@ static BOOLEAN Dummy_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
SurfGDI->DIB_HLine=SURF_METHOD(c,HLine);\ SurfGDI->DIB_HLine=SURF_METHOD(c,HLine);\
SurfGDI->DIB_VLine=SURF_METHOD(c,VLine);\ SurfGDI->DIB_VLine=SURF_METHOD(c,VLine);\
SurfGDI->DIB_BitBlt=SURF_METHOD(c,BitBlt);\ SurfGDI->DIB_BitBlt=SURF_METHOD(c,BitBlt);\
SurfGDI->DIB_StretchBlt=SURF_METHOD(c,StretchBlt); SurfGDI->DIB_StretchBlt=SURF_METHOD(c,StretchBlt);\
SurfGDI->DIB_TransparentBlt=SURF_METHOD(c,TransparentBlt);
VOID FASTCALL InitializeFuncs(SURFGDI *SurfGDI, ULONG BitmapFormat) VOID FASTCALL InitializeFuncs(SURFGDI *SurfGDI, ULONG BitmapFormat)
{ {
@ -166,6 +175,7 @@ VOID FASTCALL InitializeFuncs(SURFGDI *SurfGDI, ULONG BitmapFormat)
SurfGDI->DIB_VLine = Dummy_VLine; SurfGDI->DIB_VLine = Dummy_VLine;
SurfGDI->DIB_BitBlt = Dummy_BitBlt; SurfGDI->DIB_BitBlt = Dummy_BitBlt;
SurfGDI->DIB_StretchBlt = Dummy_StretchBlt; SurfGDI->DIB_StretchBlt = Dummy_StretchBlt;
SurfGDI->DIB_TransparentBlt = Dummy_TransparentBlt;
break; break;
} }
} }

View file

@ -16,15 +16,15 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: transblt.c,v 1.13 2004/04/03 21:25:20 weiden Exp $ /* $Id: transblt.c,v 1.14 2004/04/06 17:54:32 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* PURPOSE: GDI TransparentBlt Function * PURPOSE: GDI TransparentBlt Function
* FILE: subsys/win32k/eng/transblt.c * FILE: subsys/win32k/eng/transblt.c
* PROGRAMER: Jason Filby * PROGRAMER: Thomas Weidenmueller (w3seek@users.sourceforge.net)
* REVISION HISTORY: * REVISION HISTORY:
* 4/6/2001: Created * 4/6/2004: Created
*/ */
#include <ddk/winddi.h> #include <ddk/winddi.h>
@ -53,21 +53,177 @@ EngTransparentBlt(PSURFOBJ Dest,
PXLATEOBJ ColorTranslation, PXLATEOBJ ColorTranslation,
PRECTL DestRect, PRECTL DestRect,
PRECTL SourceRect, PRECTL SourceRect,
ULONG TransparentColor, ULONG iTransColor,
ULONG Reserved) ULONG Reserved)
{ {
DPRINT1("EngTransparentBlt() unimplemented!\n"); BOOL Ret;
BYTE ClippingType;
INTENG_ENTER_LEAVE EnterLeaveSource, EnterLeaveDest;
SURFOBJ *InputObj, *OutputObj;
SURFGDI *InputGDI, *OutputGDI;
RECTL OutputRect, InputRect;
POINTL Translate, InputPoint;
InputRect.left = 0;
InputRect.right = DestRect->right - DestRect->left;
InputRect.top = 0;
InputRect.bottom = DestRect->bottom - DestRect->top;
if(!IntEngEnter(&EnterLeaveSource, Source, &InputRect, TRUE, &Translate, &InputObj))
{
return FALSE; return FALSE;
}
InputPoint.x = SourceRect->left + Translate.x;
InputPoint.y = SourceRect->top + Translate.y;
InputGDI = (InputObj ? (SURFGDI*)AccessInternalObjectFromUserObject(InputObj) : NULL);
ASSERT(InputGDI);
OutputRect = *DestRect;
if(Clip)
{
if(OutputRect.left < Clip->rclBounds.left)
{
InputRect.left += Clip->rclBounds.left - OutputRect.left;
InputPoint.x += Clip->rclBounds.left - OutputRect.left;
OutputRect.left = Clip->rclBounds.left;
}
if(Clip->rclBounds.right < OutputRect.right)
{
InputRect.right -= OutputRect.right - Clip->rclBounds.right;
OutputRect.right = Clip->rclBounds.right;
}
if(OutputRect.top < Clip->rclBounds.top)
{
InputRect.top += Clip->rclBounds.top - OutputRect.top;
InputPoint.y += Clip->rclBounds.top - OutputRect.top;
OutputRect.top = Clip->rclBounds.top;
}
if(Clip->rclBounds.bottom < OutputRect.bottom)
{
InputRect.bottom -= OutputRect.bottom - Clip->rclBounds.bottom;
OutputRect.bottom = Clip->rclBounds.bottom;
}
}
/* Check for degenerate case: if height or width of OutputRect is 0 pixels there's
nothing to do */
if(OutputRect.right <= OutputRect.left || OutputRect.bottom <= OutputRect.top)
{
IntEngLeave(&EnterLeaveSource);
return TRUE;
}
if(!IntEngEnter(&EnterLeaveDest, Dest, &OutputRect, FALSE, &Translate, &OutputObj))
{
IntEngLeave(&EnterLeaveSource);
return FALSE;
}
OutputRect.left = DestRect->left + Translate.x;
OutputRect.right = DestRect->right + Translate.x;
OutputRect.top = DestRect->top + Translate.y;
OutputRect.bottom = DestRect->bottom + Translate.y;
OutputGDI = (OutputObj ? (SURFGDI*)AccessInternalObjectFromUserObject(OutputObj) : NULL);
ASSERT(OutputGDI);
ClippingType = (Clip ? Clip->iDComplexity : DC_TRIVIAL);
switch(ClippingType)
{
case DC_TRIVIAL:
{
Ret = OutputGDI->DIB_TransparentBlt(OutputObj, InputObj, OutputGDI, InputGDI, &OutputRect,
&InputPoint, ColorTranslation, iTransColor);
break;
}
case DC_RECT:
{
RECTL ClipRect, CombinedRect;
POINTL Pt;
ClipRect.left = Clip->rclBounds.left + Translate.x;
ClipRect.right = Clip->rclBounds.right + Translate.x;
ClipRect.top = Clip->rclBounds.top + Translate.y;
ClipRect.bottom = Clip->rclBounds.bottom + Translate.y;
EngIntersectRect(&CombinedRect, &OutputRect, &ClipRect);
Pt.x = InputPoint.x + CombinedRect.left - OutputRect.left;
Pt.y = InputPoint.y + CombinedRect.top - OutputRect.top;
Ret = OutputGDI->DIB_TransparentBlt(OutputObj, InputObj, OutputGDI, InputGDI, &CombinedRect,
&Pt, ColorTranslation, iTransColor);
break;
}
case DC_COMPLEX:
{
ULONG Direction, i;
RECT_ENUM RectEnum;
BOOL EnumMore;
POINTL Pt;
if(OutputObj == InputObj)
{
if(OutputRect.top < InputPoint.y)
{
Direction = OutputRect.left < (InputPoint.x ? CD_RIGHTDOWN : CD_LEFTDOWN);
}
else
{
Direction = OutputRect.left < (InputPoint.x ? CD_RIGHTUP : CD_LEFTUP);
}
}
else
{
Direction = CD_ANY;
}
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, Direction, 0);
do
{
EnumMore = CLIPOBJ_bEnum(Clip, sizeof(RectEnum), (PVOID)&RectEnum);
for (i = 0; i < RectEnum.c; i++)
{
RECTL ClipRect, CombinedRect;
ClipRect.left = RectEnum.arcl[i].left + Translate.x;
ClipRect.right = RectEnum.arcl[i].right + Translate.x;
ClipRect.top = RectEnum.arcl[i].top + Translate.y;
ClipRect.bottom = RectEnum.arcl[i].bottom + Translate.y;
EngIntersectRect(&CombinedRect, &OutputRect, &ClipRect);
Pt.x = InputPoint.x + CombinedRect.left - OutputRect.left;
Pt.y = InputPoint.y + CombinedRect.top - OutputRect.top;
Ret = OutputGDI->DIB_TransparentBlt(OutputObj, InputObj, OutputGDI, InputGDI, &CombinedRect,
&Pt, ColorTranslation, iTransColor);
if(!Ret)
{
break;
}
}
} while(EnumMore && Ret);
break;
}
default:
{
Ret = FALSE;
break;
}
}
IntEngLeave(&EnterLeaveDest);
IntEngLeave(&EnterLeaveSource);
return Ret;
} }
BOOL FASTCALL BOOL FASTCALL
IntTransparentBlt(PSURFOBJ Dest, IntEngTransparentBlt(PSURFOBJ Dest,
PSURFOBJ Source, PSURFOBJ Source,
PCLIPOBJ Clip, PCLIPOBJ Clip,
PXLATEOBJ ColorTranslation, PXLATEOBJ ColorTranslation,
PRECTL DestRect, PRECTL DestRect,
PRECTL SourceRect, PRECTL SourceRect,
ULONG TransparentColor, ULONG iTransColor,
ULONG Reserved) ULONG Reserved)
{ {
BOOL Ret; BOOL Ret;
@ -115,8 +271,10 @@ IntTransparentBlt(PSURFOBJ Dest,
if(SurfGDIDest->TransparentBlt) if(SurfGDIDest->TransparentBlt)
{ {
IntLockGDIDriver(SurfGDIDest);
Ret = SurfGDIDest->TransparentBlt(Dest, Source, Clip, ColorTranslation, &OutputRect, Ret = SurfGDIDest->TransparentBlt(Dest, Source, Clip, ColorTranslation, &OutputRect,
SourceRect, TransparentColor, Reserved); SourceRect, iTransColor, Reserved);
IntUnLockGDIDriver(SurfGDIDest);
} }
else else
Ret = FALSE; Ret = FALSE;
@ -124,7 +282,7 @@ IntTransparentBlt(PSURFOBJ Dest,
if(!Ret) if(!Ret)
{ {
Ret = EngTransparentBlt(Dest, Source, Clip, ColorTranslation, &OutputRect, Ret = EngTransparentBlt(Dest, Source, Clip, ColorTranslation, &OutputRect,
SourceRect, TransparentColor, Reserved); SourceRect, iTransColor, Reserved);
} }
MouseSafetyOnDrawEnd(Dest, SurfGDIDest); MouseSafetyOnDrawEnd(Dest, SurfGDIDest);

View file

@ -67,4 +67,14 @@ BOOL STDCALL IntEngPolyline(SURFOBJ *DestSurf,
CLIPOBJ* STDCALL IntEngCreateClipRegion(ULONG count, CLIPOBJ* STDCALL IntEngCreateClipRegion(ULONG count,
PRECTL pRect, PRECTL pRect,
RECTL rcBounds); RECTL rcBounds);
BOOL FASTCALL
IntEngTransparentBlt(PSURFOBJ Dest,
PSURFOBJ Source,
PCLIPOBJ Clip,
PXLATEOBJ ColorTranslation,
PRECTL DestRect,
PRECTL SourceRect,
ULONG iTransColor,
ULONG Reserved);
#endif /* _WIN32K_INTENG_H */ #endif /* _WIN32K_INTENG_H */

View file

@ -121,17 +121,5 @@ IntGdiCombineTransform(LPXFORM XFormResult,
LPXFORM xform1, LPXFORM xform1,
LPXFORM xform2); LPXFORM xform2);
/* Bitmap functions */
BOOL FASTCALL
IntTransparentBlt(PSURFOBJ Dest,
PSURFOBJ Source,
PCLIPOBJ Clip,
PXLATEOBJ ColorTranslation,
PRECTL DestRect,
PRECTL SourceRect,
ULONG TransparentColor,
ULONG Reserved);
#endif /* _WIN32K_INTGDI_H */ #endif /* _WIN32K_INTGDI_H */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: bitmaps.c,v 1.67 2004/04/05 21:26:25 navaraf Exp $ */ /* $Id: bitmaps.c,v 1.68 2004/04/06 17:54:32 weiden Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
@ -307,6 +307,12 @@ NtGdiTransparentBlt(
DCSrc = DCDest; DCSrc = DCDest;
} }
/* Offset positions */
xDst += DCDest->w.DCOrgX;
yDst += DCDest->w.DCOrgY;
xSrc += DCSrc->w.DCOrgX;
ySrc += DCSrc->w.DCOrgY;
if(DCDest->w.hPalette) if(DCDest->w.hPalette)
DestPalette = DCDest->w.hPalette; DestPalette = DCDest->w.hPalette;
else else
@ -344,16 +350,15 @@ NtGdiTransparentBlt(
} }
PALETTE_UnlockPalette(SourcePalette); PALETTE_UnlockPalette(SourcePalette);
if((XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalDestMode, PalSrcMode, DestPalette, SourcePalette))) /* Translate Transparent (RGB) Color to the source palette */
if((XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalSrcMode, PAL_RGB, SourcePalette, NULL)))
{ {
/* FIXME - is color translation right? */
TransparentColor = XLATEOBJ_iXlate(XlateObj, (ULONG)TransColor); TransparentColor = XLATEOBJ_iXlate(XlateObj, (ULONG)TransColor);
EngDeleteXlate(XlateObj);
} }
else
{ /* Create the XLATE object to convert colors between source and destination */
/* FIXME - what should be done here? */ XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalDestMode, PalSrcMode, DestPalette, SourcePalette);
TransparentColor = (ULONG)TransColor;
}
SurfDest = (PSURFOBJ)AccessUserObject((ULONG)DCDest->Surface); SurfDest = (PSURFOBJ)AccessUserObject((ULONG)DCDest->Surface);
ASSERT(SurfDest); ASSERT(SurfDest);
@ -371,12 +376,11 @@ NtGdiTransparentBlt(
if((cxDst != cxSrc) || (cyDst != cySrc)) if((cxDst != cxSrc) || (cyDst != cySrc))
{ {
/* FIXME - Create a temporary bitmap and stretchblt it */ DPRINT1("TransparentBlt() does not support stretching at the moment!\n");
DPRINT1("TransparentBlt() does not support stretching!\n");
goto done; goto done;
} }
Ret = IntTransparentBlt(SurfDest, SurfSrc, DCDest->CombinedClip, XlateObj, &rcDest, &rcSrc, Ret = IntEngTransparentBlt(SurfDest, SurfSrc, DCDest->CombinedClip, XlateObj, &rcDest, &rcSrc,
TransparentColor, 0); TransparentColor, 0);
done: done: