- Fix DC/Bitmap handling

- Fix compiler warnings
- Silence some debug output

svn path=/trunk/; revision=4263
This commit is contained in:
Gé van Geldorp 2003-03-08 13:16:52 +00:00
parent 10283bad30
commit 6fdd94516b
15 changed files with 61 additions and 42 deletions

View file

@ -1,14 +1,15 @@
/*
* entry.c
*
* $Revision: 1.24 $
* $Revision: 1.25 $
* $Author: gvg $
* $Date: 2003/02/25 23:08:52 $
* $Date: 2003/03/08 13:16:52 $
*
*/
#include "gdiinfo.h"
#include "../vgavideo/vgavideo.h"
#define NDEBUG
#include <debug.h>
#define DBG_PREFIX "VGADDI: "

View file

@ -1085,7 +1085,7 @@ EngCreateEvent
HPALETTE STDCALL
EngCreatePalette(IN ULONG Mode,
IN ULONG NumColors,
IN PULONG *Colors,
IN ULONG *Colors,
IN ULONG Red,
IN ULONG Green,
IN ULONG Blue);

View file

@ -48,6 +48,7 @@ int DIB_GetDIBImageBytes (int width, int height, int depth);
int DIB_BitmapInfoSize (const BITMAPINFO * info, WORD coloruse);
INT BITMAP_GetObject(BITMAPOBJ * bmp, INT count, LPVOID buffer);
BOOL Bitmap_InternalDelete( PBITMAPOBJ pBmp );
HBITMAP BitmapToSurf(PBITMAPOBJ BitmapObj);
/* User Entry Points */
BOOL

View file

@ -130,6 +130,11 @@ STDCALL
W32kRectInRegion(HRGN hRgn,
CONST LPRECT rc);
INT
STDCALL
W32kSelectVisRgn(HDC hdc,
HRGN hrgn);
BOOL
STDCALL
W32kSetRectRgn(HRGN hRgn,

View file

@ -12,13 +12,13 @@
#include <include/object.h>
#include "handle.h"
//#define NDEBUG
#define NDEBUG
#include <win32k/debug1.h>
HPALETTE STDCALL
EngCreatePalette(ULONG Mode,
ULONG NumColors,
PULONG *Colors, // FIXME: This was implemented with ULONG *Colors!!
ULONG *Colors,
ULONG Red,
ULONG Green,
ULONG Blue)

View file

@ -175,8 +175,8 @@ static INT CalculateShift(ULONG Mask)
return Shift;
}
XLATEOBJ *EngCreateXlate(USHORT DestPalType, USHORT SourcePalType,
HPALETTE PaletteDest, HPALETTE PaletteSource)
XLATEOBJ *IntEngCreateXlate(USHORT DestPalType, USHORT SourcePalType,
HPALETTE PaletteDest, HPALETTE PaletteSource)
{
// FIXME: Add support for BGR conversions

View file

@ -24,4 +24,9 @@ BOOL STDCALL IntEngBitBlt(SURFOBJ *DestObj,
POINTL *BrushOrigin,
ROP4 rop4);
XLATEOBJ *IntEngCreateXlate(USHORT DestPalType,
USHORT SourcePalType,
HPALETTE PaletteDest,
HPALETTE PaletteSource);
#endif

View file

@ -1,4 +1,4 @@
/* $Id: windc.c,v 1.7 2003/03/08 00:46:14 gvg Exp $
/* $Id: windc.c,v 1.8 2003/03/08 13:16:51 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -13,6 +13,7 @@
#include <ddk/ntddk.h>
#include <win32k/win32k.h>
#include <win32k/region.h>
#include <win32k/userobj.h>
#include <include/class.h>
#include <include/error.h>

View file

@ -1,4 +1,4 @@
/* $Id: window.c,v 1.26 2003/03/07 05:38:02 rcampbell Exp $
/* $Id: window.c,v 1.27 2003/03/08 13:16:51 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -24,7 +24,7 @@
#include <include/msgqueue.h>
#include <include/rect.h>
//#define NDEBUG
#define NDEBUG
#include <debug.h>
/* FUNCTIONS *****************************************************************/

View file

@ -82,7 +82,7 @@ BOOL STDCALL W32kBitBlt(HDC hDCDest,
PalDestGDI = (PPALGDI)AccessInternalObject(DestPalette);
PalSourceGDI = (PPALGDI)AccessInternalObject(SourcePalette);
XlateObj = (PXLATEOBJ)EngCreateXlate(PalDestGDI->Mode, PalSourceGDI->Mode, DestPalette, SourcePalette);
XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalDestGDI->Mode, PalSourceGDI->Mode, DestPalette, SourcePalette);
}
// Perform the bitblt operation

View file

@ -8,7 +8,7 @@
#include <win32k/cliprgn.h>
#include <win32k/coord.h>
// #define NDEBUG
#define NDEBUG
#include <win32k/debug1.h>
VOID
@ -54,7 +54,7 @@ HRGN WINAPI SaveVisRgn(HDC hdc)
return copy;
}
INT WINAPI
INT STDCALL
W32kSelectVisRgn(HDC hdc, HRGN hrgn)
{
int retval;

View file

@ -4,11 +4,14 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <ddk/winddi.h>
#include <win32k/brush.h>
#include <win32k/dc.h>
#include <win32k/color.h>
#include <win32k/pen.h>
#include "../eng/handle.h"
#include <include/inteng.h>
// #define NDEBUG
#define NDEBUG
#include <win32k/debug1.h>
int COLOR_gapStart = 256;
@ -58,12 +61,16 @@ ULONG W32kGetSysColor(int nIndex)
HPEN STDCALL W32kGetSysColorPen(int nIndex)
{
return(W32kCreatePen(PS_SOLID, 1, COLOR_sysPalTemplate[nIndex]));
COLORREF Col;
memcpy(&Col, COLOR_sysPalTemplate + nIndex, sizeof(COLORREF));
return(W32kCreatePen(PS_SOLID, 1, Col));
}
HBRUSH STDCALL W32kGetSysColorBrush(int nIndex)
{
return(W32kCreateSolidBrush(COLOR_sysPalTemplate[nIndex]));
COLORREF Col;
memcpy(&Col, COLOR_sysPalTemplate + nIndex, sizeof(COLORREF));
return(W32kCreateSolidBrush(Col));
}
//forward declarations
@ -331,7 +338,7 @@ UINT STDCALL W32kRealizePalette(HDC hDC)
if(dc->w.flags != DC_MEMORY)
{
// Device managed DC
palPtr->logicalToSystem = EngCreateXlate(sysGDI->Mode, palGDI->Mode, systemPalette, dc->w.hPalette);
palPtr->logicalToSystem = IntEngCreateXlate(sysGDI->Mode, palGDI->Mode, systemPalette, dc->w.hPalette);
}
// GDI_ReleaseObj(dc->w.hPalette);

View file

@ -1,4 +1,4 @@
/* $Id: dc.c,v 1.49 2003/03/06 00:57:44 gvg Exp $
/* $Id: dc.c,v 1.50 2003/03/08 13:16:51 gvg Exp $
*
* DC.C - Device context functions
*
@ -19,6 +19,7 @@
#include <win32k/pen.h>
#include <win32k/text.h>
#include "../eng/handle.h"
#include <include/inteng.h>
#define NDEBUG
#include <win32k/debug1.h>
@ -100,7 +101,6 @@ HDC STDCALL W32kCreateCompatableDC(HDC hDC)
{
PDC NewDC, OrigDC = NULL;
HBITMAP hBitmap;
SIZEL onebyone;
HDC hNewDC;
OrigDC = DC_HandleToPtr(hDC);
@ -137,11 +137,6 @@ HDC STDCALL W32kCreateCompatableDC(HDC hDC)
NewDC->DevInfo = OrigDC->DevInfo;
}
// Create a 1x1 monochrome bitmap surface
onebyone.cx = 1;
onebyone.cy = 1;
NewDC->Surface = EngCreateBitmap(onebyone, 1, BMF_1BPP, 0, NULL);
/* DriverName is copied in the AllocDC routine */
if(OrigDC == NULL) {
NewDC->DeviceDriver = DRIVER_FindMPDriver(NewDC->DriverName);
@ -160,7 +155,7 @@ HDC STDCALL W32kCreateCompatableDC(HDC hDC)
/* Create default bitmap */
if (!(hBitmap = W32kCreateBitmap( 1, 1, 1, 1, NULL )))
{
DC_ReleasePtr( hNewDC );
DC_ReleasePtr( hNewDC );
DC_FreeDC( hNewDC );
return NULL;
}
@ -168,6 +163,7 @@ HDC STDCALL W32kCreateCompatableDC(HDC hDC)
NewDC->w.bitsPerPixel = 1;
NewDC->w.hBitmap = hBitmap;
NewDC->w.hFirstBitmap = hBitmap;
NewDC->Surface = BitmapToSurf(BITMAPOBJ_HandleToPtr(hBitmap));
if(OrigDC != NULL)
{
@ -355,8 +351,10 @@ BOOL STDCALL W32kCreatePrimarySurface(LPCWSTR Driver,
PrimarySurface.Handle =
PrimarySurface.DriverFunctions.EnableSurface(PrimarySurface.PDev);
SurfObj = (PSURFOBJ)AccessUserObject(PrimarySurface.Handle);
SurfObj = (PSURFOBJ)AccessUserObject((ULONG) PrimarySurface.Handle);
SurfObj->dhpdev = PrimarySurface.PDev;
return TRUE;
}
HDC STDCALL W32kCreateDC(LPCWSTR Driver,
@ -367,7 +365,6 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver,
HDC hNewDC;
PDC NewDC;
HDC hDC = NULL;
PSURFOBJ SurfObj;
PSURFGDI SurfGDI;
/* Check for existing DC object */
@ -413,7 +410,7 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver,
/* FIXME: get mode selection information from somewhere */
NewDC->DMW.dmLogPixels = 96;
SurfGDI = (PSURFGDI)AccessInternalObject(PrimarySurface.Handle);
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) PrimarySurface.Handle);
NewDC->DMW.dmBitsPerPel = SurfGDI->BitsPerPixel;
NewDC->DMW.dmPelsWidth = SurfGDI->SurfObj.sizlBitmap.cx;
NewDC->DMW.dmPelsHeight = SurfGDI->SurfObj.sizlBitmap.cy;
@ -497,6 +494,7 @@ BOOL STDCALL W32kDeleteDC(HDC DCHandle)
W32kSelectObject (DCHandle, STOCK_WHITE_BRUSH);
W32kSelectObject (DCHandle, STOCK_SYSTEM_FONT);
DC_LockDC (DCHandle); W32kSelectObject does not recognize stock objects yet */
BITMAPOBJ_ReleasePtr(DCToDelete->w.hBitmap);
if (DCToDelete->w.flags & DC_MEMORY)
{
W32kDeleteObject (DCToDelete->w.hFirstBitmap);
@ -1021,8 +1019,6 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
{
HGDIOBJ objOrg;
BITMAPOBJ *pb;
PSURFOBJ surfobj;
PSURFGDI surfgdi;
PDC dc;
PPENOBJ pen;
PBRUSHOBJ brush;
@ -1046,9 +1042,9 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
dc->w.hPen = hGDIObj;
// Convert the color of the pen to the format of the DC
PalGDI = (PPALGDI)AccessInternalObject(dc->w.hPalette);
PalGDI = (PPALGDI)AccessInternalObject((ULONG) dc->w.hPalette);
if( PalGDI ){
XlateObj = (PXLATEOBJ)EngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
pen = GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC);
if( pen ){
pen->logpen.lopnColor = XLATEOBJ_iXlate(XlateObj, pen->logpen.lopnColor);
@ -1061,9 +1057,9 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
dc->w.hBrush = (HBRUSH) hGDIObj;
// Convert the color of the brush to the format of the DC
PalGDI = (PPALGDI)AccessInternalObject(dc->w.hPalette);
PalGDI = (PPALGDI)AccessInternalObject((ULONG) dc->w.hPalette);
if( PalGDI ){
XlateObj = (PXLATEOBJ)EngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
brush = GDIOBJ_LockObj(dc->w.hBrush, GO_BRUSH_MAGIC);
if( brush ){
brush->iSolidColor = XLATEOBJ_iXlate(XlateObj, brush->logbrush.lbColor);
@ -1080,10 +1076,11 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
if (!(dc->w.flags & DC_MEMORY)) return NULL;
objOrg = (HGDIOBJ)dc->w.hBitmap;
// setup mem dc for drawing into bitmap
pb = BITMAPOBJ_HandleToPtr (hGDIObj);
dc->w.hBitmap = BitmapToSurf(pb);
dc->Surface = dc->w.hBitmap;
/* Release the old bitmap, lock the new one and convert it to a SURF */
BITMAPOBJ_ReleasePtr(objOrg);
dc->w.hBitmap = hGDIObj;
pb = BITMAPOBJ_HandleToPtr(hGDIObj);
dc->Surface = BitmapToSurf(pb);
// if we're working with a DIB, get the palette [fixme: only create if the selected palette is null]
if(pb->dib)
@ -1103,7 +1100,7 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
pb->ColorMap[Index].rgbGreen,
pb->ColorMap[Index].rgbBlue);
}
dc->w.hPalette = EngCreatePalette(PAL_INDEXED, NumColors, ColorMap, 0, 0, 0);
dc->w.hPalette = EngCreatePalette(PAL_INDEXED, NumColors, (ULONG *) ColorMap, 0, 0, 0);
ExFreePool(ColorMap);
} else
if(16 == pb->dib->dsBmih.biBitCount)

View file

@ -5,6 +5,7 @@
#include <win32k/debug.h>
#include "../eng/handle.h"
#include <ntos/minmax.h>
#include <include/inteng.h>
#define NDEBUG
#include <win32k/debug1.h>
@ -132,7 +133,7 @@ INT STDCALL W32kSetDIBits(HDC hDC,
DIB_Palette = BuildDIBPalette(bmi, &DIB_Palette_Type);
// Determine XLATEOBJ for color translation
XlateObj = EngCreateXlate(DDB_Palette_Type, DIB_Palette_Type, DDB_Palette, DIB_Palette);
XlateObj = IntEngCreateXlate(DDB_Palette_Type, DIB_Palette_Type, DDB_Palette, DIB_Palette);
// Zero point
ZeroPoint.x = 0;

View file

@ -3,6 +3,7 @@
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ddk/ntddk.h>
#include <win32k/brush.h>
#include <win32k/dc.h>
#include <win32k/text.h>
#include <win32k/kapi.h>
@ -12,7 +13,7 @@
#include <include/inteng.h>
// #define NDEBUG
#define NDEBUG
#include <win32k/debug1.h>
FT_Library library;
@ -654,7 +655,7 @@ W32kTextOut(HDC hDC,
// Create the brush
PalDestGDI = (PPALGDI)AccessInternalObject(dc->w.hPalette);
XlateObj = (PXLATEOBJ)EngCreateXlate(PalDestGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalDestGDI->Mode, PAL_RGB, dc->w.hPalette, NULL);
hBrush = W32kCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, dc->w.textColor));
Brush = BRUSHOBJ_LockBrush(hBrush);
EngDeleteXlate(XlateObj);