1999-08-01 11:21:05 +00:00
|
|
|
/*
|
2003-05-18 17:16:18 +00:00
|
|
|
* ReactOS W32 Subsystem
|
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
2004-02-08 21:37:53 +00:00
|
|
|
/* $Id: surface.c,v 1.31 2004/02/08 21:37:52 weiden Exp $
|
2003-05-18 17:16:18 +00:00
|
|
|
*
|
1999-08-01 11:21:05 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PURPOSE: GDI Driver Surace Functions
|
|
|
|
* FILE: subsys/win32k/eng/surface.c
|
|
|
|
* PROGRAMER: Jason Filby
|
|
|
|
* REVISION HISTORY:
|
|
|
|
* 3/7/1999: Created
|
2001-03-31 15:35:08 +00:00
|
|
|
* 9/11/2000: Updated to handle real pixel packed bitmaps (UPDATE TO DATE COMPLETED)
|
|
|
|
* TESTING TO BE DONE:
|
|
|
|
* - Create a GDI bitmap with all formats, perform all drawing operations on them, render to VGA surface
|
|
|
|
* refer to \test\microwin\src\engine\devdraw.c for info on correct pixel plotting for various formats
|
1999-08-01 11:21:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ddk/winddi.h>
|
2000-04-01 12:31:29 +00:00
|
|
|
#include <win32k/dc.h>
|
2003-08-04 19:57:47 +00:00
|
|
|
#include <win32k/gdiobj.h>
|
2002-06-15 21:44:08 +00:00
|
|
|
#include <include/dib.h>
|
|
|
|
#include <include/object.h>
|
|
|
|
#include <include/paint.h>
|
2002-08-04 09:55:11 +00:00
|
|
|
#include "handle.h"
|
2003-03-04 10:09:01 +00:00
|
|
|
#include "../dib/dib.h"
|
2002-08-04 09:55:11 +00:00
|
|
|
|
2003-02-15 19:16:34 +00:00
|
|
|
#define NDEBUG
|
2002-08-04 09:55:11 +00:00
|
|
|
#include <win32k/debug1.h>
|
1999-08-01 11:21:05 +00:00
|
|
|
|
2003-11-18 18:05:40 +00:00
|
|
|
enum Rle_EscapeCodes
|
|
|
|
{
|
|
|
|
RLE_EOL = 0, /* End of line */
|
|
|
|
RLE_END = 1, /* End of bitmap */
|
|
|
|
RLE_DELTA = 2 /* Delta */
|
|
|
|
};
|
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
INT FASTCALL BitsPerFormat(ULONG Format)
|
1999-08-01 11:21:05 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
switch(Format)
|
|
|
|
{
|
|
|
|
case BMF_1BPP: return 1;
|
|
|
|
case BMF_4BPP:
|
|
|
|
case BMF_4RLE: return 4;
|
|
|
|
case BMF_8BPP:
|
|
|
|
case BMF_8RLE: return 8;
|
|
|
|
case BMF_16BPP: return 16;
|
|
|
|
case BMF_24BPP: return 24;
|
|
|
|
case BMF_32BPP: return 32;
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
ULONG FASTCALL BitmapFormat(WORD Bits, DWORD Compression)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
switch(Compression)
|
|
|
|
{
|
|
|
|
case BI_RGB:
|
|
|
|
switch(Bits)
|
|
|
|
{
|
|
|
|
case 1: return BMF_1BPP;
|
|
|
|
case 4: return BMF_4BPP;
|
|
|
|
case 8: return BMF_8BPP;
|
|
|
|
case 16: return BMF_16BPP;
|
|
|
|
case 24: return BMF_24BPP;
|
|
|
|
case 32: return BMF_32BPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
case BI_RLE4: return BMF_4RLE;
|
|
|
|
case BI_RLE8: return BMF_8RLE;
|
|
|
|
|
|
|
|
default: return 0;
|
|
|
|
}
|
2000-03-17 21:44:02 +00:00
|
|
|
}
|
|
|
|
|
2003-10-30 08:56:38 +00:00
|
|
|
static VOID Dummy_PutPixel(SURFOBJ* SurfObj, LONG x, LONG y, ULONG c)
|
2003-03-04 10:09:01 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-12-21 10:27:10 +00:00
|
|
|
static ULONG Dummy_GetPixel(SURFOBJ* SurfObj, LONG x, LONG y)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-10-30 08:56:38 +00:00
|
|
|
static VOID Dummy_HLine(SURFOBJ* SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
|
2003-03-04 10:09:01 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-10-30 08:56:38 +00:00
|
|
|
static VOID Dummy_VLine(SURFOBJ* SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
|
2003-03-04 10:09:01 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOLEAN Dummy_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
|
|
|
SURFGDI *DestGDI, SURFGDI *SourceGDI,
|
2003-10-30 08:56:38 +00:00
|
|
|
RECTL* DestRect, POINTL *SourcePoint,
|
2003-12-08 18:07:56 +00:00
|
|
|
BRUSHOBJ* BrushObj, POINTL* BrushOrign,
|
2003-07-27 18:37:23 +00:00
|
|
|
XLATEOBJ *ColorTranslation, ULONG Rop4)
|
2003-03-04 10:09:01 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-12-08 18:07:56 +00:00
|
|
|
static BOOLEAN Dummy_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
|
|
|
SURFGDI *DestGDI, SURFGDI *SourceGDI,
|
|
|
|
RECTL* DestRect, RECTL *SourceRect,
|
|
|
|
POINTL* MaskOrigin, POINTL* BrushOrign,
|
|
|
|
XLATEOBJ *ColorTranslation, ULONG Mode)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
#define SURF_METHOD(c,n) DIB_##c##_##n
|
|
|
|
#define SET_SURFGDI(c)\
|
|
|
|
SurfGDI->DIB_PutPixel=SURF_METHOD(c,PutPixel);\
|
2003-12-21 10:27:10 +00:00
|
|
|
SurfGDI->DIB_GetPixel=SURF_METHOD(c,GetPixel);\
|
2003-05-18 17:16:18 +00:00
|
|
|
SurfGDI->DIB_HLine=SURF_METHOD(c,HLine);\
|
|
|
|
SurfGDI->DIB_VLine=SURF_METHOD(c,VLine);\
|
2003-12-08 18:07:56 +00:00
|
|
|
SurfGDI->DIB_BitBlt=SURF_METHOD(c,BitBlt);\
|
|
|
|
SurfGDI->DIB_StretchBlt=SURF_METHOD(c,StretchBlt);
|
2003-05-18 17:16:18 +00:00
|
|
|
|
|
|
|
VOID FASTCALL InitializeFuncs(SURFGDI *SurfGDI, ULONG BitmapFormat)
|
2000-03-17 21:44:02 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
SurfGDI->BitBlt = NULL;
|
2003-12-08 18:07:56 +00:00
|
|
|
SurfGDI->StretchBlt = NULL;
|
2001-03-31 15:35:08 +00:00
|
|
|
SurfGDI->CopyBits = NULL;
|
|
|
|
SurfGDI->CreateDeviceBitmap = NULL;
|
|
|
|
SurfGDI->SetPalette = NULL;
|
2001-05-02 12:33:42 +00:00
|
|
|
SurfGDI->TransparentBlt = NULL;
|
2003-03-04 10:09:01 +00:00
|
|
|
|
|
|
|
switch(BitmapFormat)
|
|
|
|
{
|
2003-05-18 17:16:18 +00:00
|
|
|
case BMF_1BPP: SET_SURFGDI(1BPP) break;
|
|
|
|
case BMF_4BPP: SET_SURFGDI(4BPP) break;
|
|
|
|
case BMF_8BPP: SET_SURFGDI(8BPP) break;
|
|
|
|
case BMF_16BPP: SET_SURFGDI(16BPP) break;
|
|
|
|
case BMF_24BPP: SET_SURFGDI(24BPP) break;
|
|
|
|
case BMF_32BPP: SET_SURFGDI(32BPP) break;
|
2003-03-04 10:09:01 +00:00
|
|
|
case BMF_4RLE:
|
|
|
|
case BMF_8RLE:
|
|
|
|
/* Not supported yet, fall through to unrecognized case */
|
|
|
|
default:
|
|
|
|
DPRINT1("InitializeFuncs: unsupported DIB format %d\n",
|
|
|
|
BitmapFormat);
|
|
|
|
|
2003-12-08 18:07:56 +00:00
|
|
|
SurfGDI->DIB_PutPixel = Dummy_PutPixel;
|
2003-12-21 10:27:10 +00:00
|
|
|
SurfGDI->DIB_GetPixel = Dummy_GetPixel;
|
2003-12-08 18:07:56 +00:00
|
|
|
SurfGDI->DIB_HLine = Dummy_HLine;
|
|
|
|
SurfGDI->DIB_VLine = Dummy_VLine;
|
|
|
|
SurfGDI->DIB_BitBlt = Dummy_BitBlt;
|
|
|
|
SurfGDI->DIB_StretchBlt = Dummy_StretchBlt;
|
2003-03-04 10:09:01 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-03-17 21:44:02 +00:00
|
|
|
}
|
|
|
|
|
2003-07-11 15:59:37 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-06-15 21:44:08 +00:00
|
|
|
HBITMAP STDCALL
|
|
|
|
EngCreateDeviceBitmap(IN DHSURF dhsurf,
|
|
|
|
IN SIZEL Size,
|
|
|
|
IN ULONG Format)
|
2000-03-17 21:44:02 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
HBITMAP NewBitmap;
|
|
|
|
SURFOBJ *SurfObj;
|
2000-03-17 21:44:02 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
NewBitmap = EngCreateBitmap(Size, DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(Format)), Format, 0, NULL);
|
2002-06-15 21:44:08 +00:00
|
|
|
SurfObj = (PVOID)AccessUserObject((ULONG)NewBitmap);
|
2003-10-30 08:56:38 +00:00
|
|
|
SurfObj->dhsurf = dhsurf;
|
2000-10-14 22:42:11 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
return NewBitmap;
|
2000-03-17 21:44:02 +00:00
|
|
|
}
|
|
|
|
|
2003-11-18 18:05:40 +00:00
|
|
|
VOID Decompress4bpp(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta)
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
int y = Size.cy - 1;
|
|
|
|
int c;
|
|
|
|
int length;
|
|
|
|
int width = ((Size.cx+1)/2);
|
|
|
|
int height = Size.cy - 1;
|
|
|
|
BYTE *begin = CompressedBits;
|
|
|
|
BYTE *bits = CompressedBits;
|
|
|
|
BYTE *temp;
|
|
|
|
while (y >= 0)
|
|
|
|
{
|
|
|
|
length = *bits++ / 2;
|
|
|
|
if (length)
|
|
|
|
{
|
|
|
|
c = *bits++;
|
|
|
|
while (length--)
|
|
|
|
{
|
|
|
|
if (x >= width) break;
|
|
|
|
temp = UncompressedBits + (((height - y) * Delta) + x);
|
|
|
|
x++;
|
|
|
|
*temp = c;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
length = *bits++;
|
|
|
|
switch (length)
|
|
|
|
{
|
|
|
|
case RLE_EOL:
|
|
|
|
x = 0;
|
|
|
|
y--;
|
|
|
|
break;
|
|
|
|
case RLE_END:
|
|
|
|
return;
|
|
|
|
case RLE_DELTA:
|
|
|
|
x += (*bits++)/2;
|
|
|
|
y -= (*bits++)/2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
length /= 2;
|
|
|
|
while (length--)
|
|
|
|
{
|
|
|
|
c = *bits++;
|
|
|
|
if (x < width)
|
|
|
|
{
|
|
|
|
temp = UncompressedBits + (((height - y) * Delta) + x);
|
|
|
|
x++;
|
|
|
|
*temp = c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((bits - begin) & 1)
|
|
|
|
bits++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID Decompress8bpp(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta)
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
int y = Size.cy - 1;
|
|
|
|
int c;
|
|
|
|
int length;
|
|
|
|
int width = Size.cx;
|
|
|
|
int height = Size.cy - 1;
|
|
|
|
BYTE *begin = CompressedBits;
|
|
|
|
BYTE *bits = CompressedBits;
|
|
|
|
BYTE *temp;
|
|
|
|
while (y >= 0)
|
|
|
|
{
|
|
|
|
length = *bits++;
|
|
|
|
if (length)
|
|
|
|
{
|
|
|
|
c = *bits++;
|
|
|
|
while (length--)
|
|
|
|
{
|
|
|
|
if (x >= width) break;
|
|
|
|
temp = UncompressedBits + (((height - y) * Delta) + x);
|
|
|
|
x++;
|
|
|
|
*temp = c;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
length = *bits++;
|
|
|
|
switch (length)
|
|
|
|
{
|
|
|
|
case RLE_EOL:
|
|
|
|
x = 0;
|
|
|
|
y--;
|
|
|
|
break;
|
|
|
|
case RLE_END:
|
|
|
|
return;
|
|
|
|
case RLE_DELTA:
|
|
|
|
x += *bits++;
|
|
|
|
y -= *bits++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
while (length--)
|
|
|
|
{
|
|
|
|
c = *bits++;
|
|
|
|
if (x < width)
|
|
|
|
{
|
|
|
|
temp = UncompressedBits + (((height - y) * Delta) + x);
|
|
|
|
x++;
|
|
|
|
*temp = c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((bits - begin) & 1)
|
|
|
|
bits++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-11 15:59:37 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-06-15 21:44:08 +00:00
|
|
|
HBITMAP STDCALL
|
|
|
|
EngCreateBitmap(IN SIZEL Size,
|
|
|
|
IN LONG Width,
|
|
|
|
IN ULONG Format,
|
|
|
|
IN ULONG Flags,
|
|
|
|
IN PVOID Bits)
|
2000-03-17 21:44:02 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
HBITMAP NewBitmap;
|
|
|
|
SURFOBJ *SurfObj;
|
|
|
|
SURFGDI *SurfGDI;
|
2003-11-18 18:05:40 +00:00
|
|
|
PVOID UncompressedBits;
|
|
|
|
ULONG UncompressedFormat;
|
2001-03-31 15:35:08 +00:00
|
|
|
|
2002-08-04 09:55:11 +00:00
|
|
|
NewBitmap = (PVOID)CreateGDIHandle(sizeof(SURFGDI), sizeof(SURFOBJ));
|
|
|
|
if( !ValidEngHandle( NewBitmap ) )
|
|
|
|
return 0;
|
|
|
|
|
2003-03-04 10:09:01 +00:00
|
|
|
SurfObj = (SURFOBJ*) AccessUserObject( (ULONG) NewBitmap );
|
|
|
|
SurfGDI = (SURFGDI*) AccessInternalObject( (ULONG) NewBitmap );
|
2002-08-04 09:55:11 +00:00
|
|
|
ASSERT( SurfObj );
|
|
|
|
ASSERT( SurfGDI );
|
2001-03-31 15:35:08 +00:00
|
|
|
SurfGDI->BitsPerPixel = BitsPerFormat(Format);
|
2003-11-18 18:05:40 +00:00
|
|
|
if (Format == BMF_4RLE) {
|
|
|
|
SurfObj->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(BMF_4BPP));
|
|
|
|
SurfObj->cjBits = SurfObj->lDelta * Size.cy;
|
|
|
|
UncompressedFormat = BMF_4BPP;
|
|
|
|
UncompressedBits = EngAllocMem(FL_ZERO_MEMORY, SurfObj->cjBits, 0);
|
|
|
|
Decompress4bpp(Size, (BYTE *)Bits, (BYTE *)UncompressedBits, SurfObj->lDelta);
|
|
|
|
} else {
|
|
|
|
if (Format == BMF_8RLE) {
|
|
|
|
SurfObj->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(BMF_8BPP));
|
|
|
|
SurfObj->cjBits = SurfObj->lDelta * Size.cy;
|
|
|
|
UncompressedFormat = BMF_8BPP;
|
|
|
|
UncompressedBits = EngAllocMem(FL_ZERO_MEMORY, SurfObj->cjBits, 0);
|
|
|
|
Decompress8bpp(Size, (BYTE *)Bits, (BYTE *)UncompressedBits, SurfObj->lDelta);
|
|
|
|
} else {
|
2001-03-31 15:35:08 +00:00
|
|
|
SurfObj->lDelta = Width;
|
|
|
|
SurfObj->cjBits = SurfObj->lDelta * Size.cy;
|
2003-11-18 18:05:40 +00:00
|
|
|
UncompressedBits = Bits;
|
|
|
|
UncompressedFormat = Format;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(UncompressedBits!=NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2003-11-18 18:05:40 +00:00
|
|
|
SurfObj->pvBits = UncompressedBits;
|
2001-03-31 15:35:08 +00:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
if(Flags & BMF_USERMEM)
|
|
|
|
{
|
|
|
|
SurfObj->pvBits = EngAllocUserMem(SurfObj->cjBits, 0);
|
|
|
|
} else {
|
|
|
|
if(Flags & BMF_NOZEROINIT)
|
2000-03-17 21:44:02 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
SurfObj->pvBits = EngAllocMem(0, SurfObj->cjBits, 0);
|
2000-03-17 21:44:02 +00:00
|
|
|
} else {
|
2001-03-31 15:35:08 +00:00
|
|
|
SurfObj->pvBits = EngAllocMem(FL_ZERO_MEMORY, SurfObj->cjBits, 0);
|
2000-03-17 21:44:02 +00:00
|
|
|
}
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
|
|
|
}
|
2000-03-17 21:44:02 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
SurfObj->dhsurf = 0; // device managed surface
|
|
|
|
SurfObj->hsurf = 0;
|
|
|
|
SurfObj->sizlBitmap = Size;
|
2003-11-18 18:05:40 +00:00
|
|
|
SurfObj->iBitmapFormat = UncompressedFormat;
|
2001-03-31 15:35:08 +00:00
|
|
|
SurfObj->iType = STYPE_BITMAP;
|
2003-03-11 00:21:41 +00:00
|
|
|
SurfObj->fjBitmap = Flags & (BMF_TOPDOWN | BMF_NOZEROINIT);
|
2003-02-25 23:08:54 +00:00
|
|
|
SurfObj->pvScan0 = SurfObj->pvBits;
|
2000-03-17 21:44:02 +00:00
|
|
|
|
2003-11-18 18:05:40 +00:00
|
|
|
InitializeFuncs(SurfGDI, UncompressedFormat);
|
2003-03-04 10:09:01 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
// Use flags to determine bitmap type -- TOP_DOWN or whatever
|
2000-03-17 21:44:02 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
return NewBitmap;
|
2000-03-17 21:44:02 +00:00
|
|
|
}
|
|
|
|
|
2003-07-11 15:59:37 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2002-06-15 21:44:08 +00:00
|
|
|
HSURF STDCALL
|
|
|
|
EngCreateDeviceSurface(IN DHSURF dhsurf,
|
|
|
|
IN SIZEL Size,
|
|
|
|
IN ULONG Format)
|
2000-03-17 21:44:02 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
HSURF NewSurface;
|
|
|
|
SURFOBJ *SurfObj;
|
|
|
|
SURFGDI *SurfGDI;
|
2000-03-17 21:44:02 +00:00
|
|
|
|
2002-08-04 09:55:11 +00:00
|
|
|
NewSurface = (HSURF)CreateGDIHandle(sizeof( SURFGDI ), sizeof( SURFOBJ ));
|
|
|
|
if( !ValidEngHandle( NewSurface ) )
|
|
|
|
return 0;
|
1999-08-01 11:21:05 +00:00
|
|
|
|
2003-03-04 10:09:01 +00:00
|
|
|
SurfObj = (SURFOBJ*) AccessUserObject( (ULONG) NewSurface );
|
|
|
|
SurfGDI = (SURFGDI*) AccessInternalObject( (ULONG) NewSurface );
|
2002-08-04 09:55:11 +00:00
|
|
|
ASSERT( SurfObj );
|
|
|
|
ASSERT( SurfGDI );
|
2000-04-01 12:31:29 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
SurfGDI->BitsPerPixel = BitsPerFormat(Format);
|
|
|
|
SurfObj->dhsurf = dhsurf;
|
2003-10-30 08:56:38 +00:00
|
|
|
SurfObj->hsurf = (HSURF) dhsurf; // FIXME: Is this correct??
|
2001-03-31 15:35:08 +00:00
|
|
|
SurfObj->sizlBitmap = Size;
|
|
|
|
SurfObj->iBitmapFormat = Format;
|
|
|
|
SurfObj->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(Format));
|
|
|
|
SurfObj->iType = STYPE_DEVICE;
|
2000-03-17 21:44:02 +00:00
|
|
|
|
2003-03-04 10:09:01 +00:00
|
|
|
InitializeFuncs(SurfGDI, Format);
|
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
return NewSurface;
|
1999-08-01 11:21:05 +00:00
|
|
|
}
|
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
PFN FASTCALL DriverFunction(DRVENABLEDATA *DED, ULONG DriverFunc)
|
1999-08-01 11:21:05 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
ULONG i;
|
|
|
|
|
|
|
|
for(i=0; i<DED->c; i++)
|
|
|
|
{
|
|
|
|
if(DED->pdrvfn[i].iFunc == DriverFunc)
|
|
|
|
return DED->pdrvfn[i].pfn;
|
|
|
|
}
|
|
|
|
return NULL;
|
1999-08-01 11:21:05 +00:00
|
|
|
}
|
|
|
|
|
2003-07-11 15:59:37 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-06-15 21:44:08 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
EngAssociateSurface(IN HSURF Surface,
|
|
|
|
IN HDEV Dev,
|
|
|
|
IN ULONG Hooks)
|
1999-08-01 11:21:05 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
SURFOBJ *SurfObj;
|
|
|
|
SURFGDI *SurfGDI;
|
2002-09-18 23:56:48 +00:00
|
|
|
GDIDEVICE* Device;
|
2001-03-31 15:35:08 +00:00
|
|
|
|
2002-09-18 23:56:48 +00:00
|
|
|
Device = (GDIDEVICE*)Dev;
|
2001-03-31 15:35:08 +00:00
|
|
|
|
2002-06-15 21:44:08 +00:00
|
|
|
SurfGDI = (PVOID)AccessInternalObject((ULONG)Surface);
|
|
|
|
SurfObj = (PVOID)AccessUserObject((ULONG)Surface);
|
2001-03-31 15:35:08 +00:00
|
|
|
|
|
|
|
// Associate the hdev
|
|
|
|
SurfObj->hdev = Dev;
|
|
|
|
|
|
|
|
// Hook up specified functions
|
2002-09-18 23:56:48 +00:00
|
|
|
if(Hooks & HOOK_BITBLT) SurfGDI->BitBlt = Device->DriverFunctions.BitBlt;
|
|
|
|
if(Hooks & HOOK_TRANSPARENTBLT) SurfGDI->TransparentBlt = Device->DriverFunctions.TransparentBlt;
|
|
|
|
if(Hooks & HOOK_STRETCHBLT) SurfGDI->StretchBlt = (PFN_StretchBlt)Device->DriverFunctions.StretchBlt;
|
|
|
|
if(Hooks & HOOK_TEXTOUT) SurfGDI->TextOut = Device->DriverFunctions.TextOut;
|
|
|
|
if(Hooks & HOOK_PAINT) SurfGDI->Paint = Device->DriverFunctions.Paint;
|
|
|
|
if(Hooks & HOOK_STROKEPATH) SurfGDI->StrokePath = Device->DriverFunctions.StrokePath;
|
|
|
|
if(Hooks & HOOK_FILLPATH) SurfGDI->FillPath = Device->DriverFunctions.FillPath;
|
|
|
|
if(Hooks & HOOK_STROKEANDFILLPATH) SurfGDI->StrokeAndFillPath = Device->DriverFunctions.StrokeAndFillPath;
|
|
|
|
if(Hooks & HOOK_LINETO) SurfGDI->LineTo = Device->DriverFunctions.LineTo;
|
|
|
|
if(Hooks & HOOK_COPYBITS) SurfGDI->CopyBits = Device->DriverFunctions.CopyBits;
|
|
|
|
if(Hooks & HOOK_SYNCHRONIZE) SurfGDI->Synchronize = Device->DriverFunctions.Synchronize;
|
2001-03-31 15:35:08 +00:00
|
|
|
if(Hooks & HOOK_SYNCHRONIZEACCESS) SurfGDI->SynchronizeAccess = TRUE;
|
2004-02-08 21:37:53 +00:00
|
|
|
if(Hooks & HOOK_GRADIENTFILL) SurfGDI->GradientFill = Device->DriverFunctions.GradientFill;
|
2001-03-31 15:35:08 +00:00
|
|
|
|
2002-09-18 23:56:48 +00:00
|
|
|
SurfGDI->CreateDeviceBitmap = Device->DriverFunctions.CreateDeviceBitmap;
|
|
|
|
SurfGDI->SetPalette = Device->DriverFunctions.SetPalette;
|
|
|
|
SurfGDI->MovePointer = Device->DriverFunctions.MovePointer;
|
|
|
|
SurfGDI->SetPointerShape = (PFN_SetPointerShape)Device->DriverFunctions.SetPointerShape;
|
2001-03-31 15:35:08 +00:00
|
|
|
|
2004-01-16 19:32:00 +00:00
|
|
|
SurfGDI->DriverLock = &Device->DriverLock;
|
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
return TRUE;
|
1999-08-01 11:21:05 +00:00
|
|
|
}
|
|
|
|
|
2003-07-11 15:59:37 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-06-15 21:44:08 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
EngDeleteSurface(IN HSURF Surface)
|
1999-08-01 11:21:05 +00:00
|
|
|
{
|
2002-06-15 21:44:08 +00:00
|
|
|
FreeGDIHandle((ULONG)Surface);
|
2001-03-31 15:35:08 +00:00
|
|
|
return TRUE;
|
2000-03-17 21:44:02 +00:00
|
|
|
}
|
|
|
|
|
2003-07-11 15:59:37 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-06-15 21:44:08 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
EngEraseSurface(SURFOBJ *Surface,
|
|
|
|
RECTL *Rect,
|
|
|
|
ULONG iColor)
|
|
|
|
{
|
|
|
|
return FillSolid(Surface, Rect, iColor);
|
|
|
|
}
|
|
|
|
|
2003-07-11 15:59:37 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2002-06-15 21:44:08 +00:00
|
|
|
SURFOBJ * STDCALL
|
|
|
|
EngLockSurface(IN HSURF Surface)
|
2000-03-17 21:44:02 +00:00
|
|
|
{
|
2003-08-04 19:57:47 +00:00
|
|
|
/*
|
|
|
|
* FIXME - don't know if GDIOBJ_LockObj's return value is a SURFOBJ or not...
|
|
|
|
* also, what is HSURF's correct magic #?
|
|
|
|
*/
|
2003-08-28 12:35:59 +00:00
|
|
|
#ifdef TODO
|
2003-08-20 07:45:02 +00:00
|
|
|
GDIOBJ_LockObj ( Surface, GDI_OBJECT_TYPE_DONTCARE );
|
2003-08-28 12:35:59 +00:00
|
|
|
#endif
|
2002-06-15 21:44:08 +00:00
|
|
|
return (SURFOBJ*)AccessUserObject((ULONG)Surface);
|
1999-08-01 11:21:05 +00:00
|
|
|
}
|
2003-02-15 19:16:34 +00:00
|
|
|
|
2003-07-11 15:59:37 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2003-02-15 19:16:34 +00:00
|
|
|
VOID STDCALL
|
|
|
|
EngUnlockSurface(IN SURFOBJ *Surface)
|
|
|
|
{
|
2003-08-04 19:57:47 +00:00
|
|
|
/*
|
|
|
|
* FIXME what is HSURF's correct magic #?
|
|
|
|
*/
|
2003-08-28 12:35:59 +00:00
|
|
|
#ifdef TODO
|
2003-08-20 07:45:02 +00:00
|
|
|
GDIOBJ_UnlockObj ( Surface->hsurf, GDI_OBJECT_TYPE_DONTCARE );
|
2003-08-28 12:35:59 +00:00
|
|
|
#endif
|
2003-02-15 19:16:34 +00:00
|
|
|
}
|
2003-05-18 17:16:18 +00:00
|
|
|
/* EOF */
|