Commit 0dd55c44 authored by Alexandre Julliard's avatar Alexandre Julliard

Removed some direct accesses to GDI internal pen/brush/font

structures.
parent 231162ef
......@@ -5,10 +5,7 @@
*/
#include "bitmap.h"
#include "brush.h"
#include "font.h"
#include "gdi.h"
#include "pen.h"
#include "ttydrv.h"
#include "debugtools.h"
......@@ -23,11 +20,11 @@ extern BOOL TTYDRV_DC_BITMAP_DeleteObject(HBITMAP hbitmap, BITMAPOBJ *bitmap);
/***********************************************************************
* TTYDRV_DC_BRUSH_SelectObject
*/
static HBRUSH TTYDRV_DC_BRUSH_SelectObject(DC *dc, HBRUSH hbrush, BRUSHOBJ *brush)
static HBRUSH TTYDRV_DC_BRUSH_SelectObject(DC *dc, HBRUSH hbrush)
{
HBRUSH hPreviousBrush;
TRACE("(%p, 0x%04x, %p)\n", dc, hbrush, brush);
TRACE("(%p, 0x%04x)\n", dc, hbrush);
hPreviousBrush = dc->hBrush;
dc->hBrush = hbrush;
......@@ -38,11 +35,11 @@ static HBRUSH TTYDRV_DC_BRUSH_SelectObject(DC *dc, HBRUSH hbrush, BRUSHOBJ *brus
/***********************************************************************
* TTYDRV_DC_FONT_SelectObject
*/
static HFONT TTYDRV_DC_FONT_SelectObject(DC* dc, HFONT hfont, FONTOBJ *font)
static HFONT TTYDRV_DC_FONT_SelectObject(DC* dc, HFONT hfont)
{
HFONT hPreviousFont;
TRACE("(%p, 0x%04x, %p)\n", dc, hfont, font);
TRACE("(%p, 0x%04x)\n", dc, hfont);
hPreviousFont = dc->hFont;
dc->hFont = hfont;
......@@ -53,11 +50,11 @@ static HFONT TTYDRV_DC_FONT_SelectObject(DC* dc, HFONT hfont, FONTOBJ *font)
/***********************************************************************
* TTYDRV_DC_PEN_SelectObject
*/
static HPEN TTYDRV_DC_PEN_SelectObject(DC *dc, HBRUSH hpen, PENOBJ *pen)
static HPEN TTYDRV_DC_PEN_SelectObject(DC *dc, HBRUSH hpen)
{
HPEN hPreviousPen;
TRACE("(%p, 0x%04x, %p)\n", dc, hpen, pen);
TRACE("(%p, 0x%04x)\n", dc, hpen);
hPreviousPen = dc->hPen;
dc->hPen = hpen;
......@@ -81,13 +78,13 @@ HGDIOBJ TTYDRV_DC_SelectObject(DC *dc, HGDIOBJ handle)
result = TTYDRV_DC_BITMAP_SelectObject(dc, handle, (BITMAPOBJ *) ptr);
break;
case BRUSH_MAGIC:
result = TTYDRV_DC_BRUSH_SelectObject(dc, handle, (BRUSHOBJ *) ptr);
result = TTYDRV_DC_BRUSH_SelectObject(dc, handle);
break;
case FONT_MAGIC:
result = TTYDRV_DC_FONT_SelectObject(dc, handle, (FONTOBJ *) ptr);
result = TTYDRV_DC_FONT_SelectObject(dc, handle);
break;
case PEN_MAGIC:
result = TTYDRV_DC_PEN_SelectObject(dc, handle, (PENOBJ *) ptr);
result = TTYDRV_DC_PEN_SelectObject(dc, handle);
break;
case REGION_MAGIC:
/* FIXME: Shouldn't be handled here */
......
......@@ -6,9 +6,7 @@
*/
#include "psdrv.h"
#include "brush.h"
#include "debugtools.h"
#include "gdi.h"
#include "winbase.h"
DEFAULT_DEBUG_CHANNEL(psdrv);
......@@ -16,35 +14,36 @@ DEFAULT_DEBUG_CHANNEL(psdrv);
/***********************************************************************
* PSDRV_BRUSH_SelectObject
*/
HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush, BRUSHOBJ * brush )
HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush )
{
LOGBRUSH logbrush;
HBRUSH prevbrush = dc->hBrush;
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
if (!GetObjectA( hbrush, sizeof(logbrush), &logbrush )) return 0;
TRACE("hbrush = %08x\n", hbrush);
dc->hBrush = hbrush;
switch(brush->logbrush.lbStyle) {
switch(logbrush.lbStyle) {
case BS_SOLID:
PSDRV_CreateColor(physDev, &physDev->brush.color,
brush->logbrush.lbColor);
PSDRV_CreateColor(physDev, &physDev->brush.color, logbrush.lbColor);
break;
case BS_NULL:
break;
case BS_HATCHED:
PSDRV_CreateColor(physDev, &physDev->brush.color,
brush->logbrush.lbColor);
PSDRV_CreateColor(physDev, &physDev->brush.color, logbrush.lbColor);
break;
case BS_PATTERN:
FIXME("Unsupported brush style %d\n", brush->logbrush.lbStyle);
FIXME("Unsupported brush style %d\n", logbrush.lbStyle);
break;
default:
FIXME("Unrecognized brush style %d\n", brush->logbrush.lbStyle);
FIXME("Unrecognized brush style %d\n", logbrush.lbStyle);
break;
}
......@@ -60,16 +59,17 @@ HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush, BRUSHOBJ * brush )
*/
static BOOL PSDRV_SetBrush(DC *dc)
{
LOGBRUSH logbrush;
BOOL ret = TRUE;
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->hBrush, BRUSH_MAGIC );
if(!brush) {
if (!GetObjectA( dc->hBrush, sizeof(logbrush), &logbrush ))
{
ERR("Can't get BRUSHOBJ\n");
return FALSE;
}
switch (brush->logbrush.lbStyle) {
switch (logbrush.lbStyle) {
case BS_SOLID:
case BS_HATCHED:
PSDRV_WriteSetColor(dc, &physDev->brush.color);
......@@ -84,7 +84,6 @@ static BOOL PSDRV_SetBrush(DC *dc)
}
physDev->brush.set = TRUE;
GDI_ReleaseObj( dc->hBrush );
return TRUE;
}
......@@ -123,16 +122,17 @@ static BOOL PSDRV_Clip(DC *dc, BOOL EO)
*/
BOOL PSDRV_Brush(DC *dc, BOOL EO)
{
LOGBRUSH logbrush;
BOOL ret = TRUE;
BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->hBrush, BRUSH_MAGIC );
PSDRV_PDEVICE *physDev = dc->physDev;
if(!brush) {
if (!GetObjectA( dc->hBrush, sizeof(logbrush), &logbrush ))
{
ERR("Can't get BRUSHOBJ\n");
return FALSE;
}
switch (brush->logbrush.lbStyle) {
switch (logbrush.lbStyle) {
case BS_SOLID:
PSDRV_SetBrush(dc);
PSDRV_WriteGSave(dc);
......@@ -143,7 +143,7 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
case BS_HATCHED:
PSDRV_SetBrush(dc);
switch(brush->logbrush.lbHatch) {
switch(logbrush.lbHatch) {
case HS_VERTICAL:
case HS_CROSS:
PSDRV_WriteGSave(dc);
......@@ -151,7 +151,7 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
PSDRV_WriteHatch(dc);
PSDRV_WriteStroke(dc);
PSDRV_WriteGRestore(dc);
if(brush->logbrush.lbHatch == HS_VERTICAL)
if(logbrush.lbHatch == HS_VERTICAL)
break;
/* else fallthrough for HS_CROSS */
......@@ -172,7 +172,7 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
PSDRV_WriteHatch(dc);
PSDRV_WriteStroke(dc);
PSDRV_WriteGRestore(dc);
if(brush->logbrush.lbHatch == HS_FDIAGONAL)
if(logbrush.lbHatch == HS_FDIAGONAL)
break;
/* else fallthrough for HS_DIAGCROSS */
......@@ -199,12 +199,11 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
{
BITMAP bm;
BYTE *bits;
GetObjectA(brush->logbrush.lbHatch, sizeof(BITMAP), &bm);
GetObjectA(logbrush.lbHatch, sizeof(BITMAP), &bm);
TRACE("BS_PATTERN %dx%d %d bpp\n", bm.bmWidth, bm.bmHeight,
bm.bmBitsPixel);
bits = HeapAlloc(PSDRV_Heap, 0, bm.bmWidthBytes * bm.bmHeight);
GetBitmapBits(brush->logbrush.lbHatch,
bm.bmWidthBytes * bm.bmHeight, bits);
GetBitmapBits(logbrush.lbHatch, bm.bmWidthBytes * bm.bmHeight, bits);
if(physDev->pi->ppd->LanguageLevel > 1) {
PSDRV_WriteGSave(dc);
......@@ -223,8 +222,6 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
ret = FALSE;
break;
}
GDI_ReleaseObj( dc->hBrush );
return ret;
}
......
......@@ -9,7 +9,6 @@
#include "winspool.h"
#include "psdrv.h"
#include "debugtools.h"
#include "gdi.h"
#include "winerror.h"
DEFAULT_DEBUG_CHANNEL(psdrv);
......@@ -18,34 +17,34 @@ DEFAULT_DEBUG_CHANNEL(psdrv);
/***********************************************************************
* PSDRV_FONT_SelectObject
*/
HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont,
FONTOBJ *font )
HFONT PSDRV_FONT_SelectObject( DC * dc, HFONT hfont )
{
LOGFONTW lf;
HFONT16 prevfont = dc->hFont;
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
LOGFONTW *lf = &(font->logfont);
BOOL bd = FALSE, it = FALSE;
AFMLISTENTRY *afmle;
AFM *afm;
FONTFAMILY *family;
char FaceName[LF_FACESIZE];
if (!GetObjectW( hfont, sizeof(lf), &lf )) return 0;
TRACE("FaceName = %s Height = %ld Italic = %d Weight = %ld\n",
debugstr_w(lf->lfFaceName), lf->lfHeight, lf->lfItalic,
lf->lfWeight);
debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic,
lf.lfWeight);
dc->hFont = hfont;
if(lf->lfItalic)
if(lf.lfItalic)
it = TRUE;
if(lf->lfWeight > 550)
if(lf.lfWeight > 550)
bd = TRUE;
WideCharToMultiByte(CP_ACP, 0, lf->lfFaceName, -1,
WideCharToMultiByte(CP_ACP, 0, lf.lfFaceName, -1,
FaceName, sizeof(FaceName), NULL, NULL);
if(FaceName[0] == '\0') {
switch(lf->lfPitchAndFamily & 0xf0) {
switch(lf.lfPitchAndFamily & 0xf0) {
case FF_DONTCARE:
break;
case FF_ROMAN:
......@@ -65,7 +64,7 @@ HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont,
}
if(FaceName[0] == '\0') {
switch(lf->lfPitchAndFamily & 0x0f) {
switch(lf.lfPitchAndFamily & 0x0f) {
case VARIABLE_PITCH:
strcpy(FaceName, "Times");
break;
......@@ -138,7 +137,7 @@ HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont,
afm = afmle->afm;
physDev->font.afm = afm;
physDev->font.tm.tmHeight = INTERNAL_YWSTODS(dc, lf->lfHeight);
physDev->font.tm.tmHeight = INTERNAL_YWSTODS(dc, lf.lfHeight);
if(physDev->font.tm.tmHeight < 0) {
physDev->font.tm.tmHeight *= - (afm->FullAscender - afm->Descender) /
(afm->Ascender - afm->Descender);
......@@ -147,7 +146,7 @@ HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont,
physDev->font.size = physDev->font.tm.tmHeight * 1000.0 /
(afm->FullAscender - afm->Descender);
physDev->font.scale = physDev->font.size / 1000.0;
physDev->font.escapement = lf->lfEscapement;
physDev->font.escapement = lf.lfEscapement;
physDev->font.tm.tmAscent = afm->FullAscender * physDev->font.scale;
physDev->font.tm.tmDescent = -afm->Descender * physDev->font.scale;
physDev->font.tm.tmInternalLeading = (afm->FullAscender - afm->Ascender)
......@@ -160,8 +159,8 @@ HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont,
physDev->font.scale;
physDev->font.tm.tmWeight = afm->Weight;
physDev->font.tm.tmItalic = afm->ItalicAngle != 0.0;
physDev->font.tm.tmUnderlined = lf->lfUnderline;
physDev->font.tm.tmStruckOut = lf->lfStrikeOut;
physDev->font.tm.tmUnderlined = lf.lfUnderline;
physDev->font.tm.tmStruckOut = lf.lfStrikeOut;
physDev->font.tm.tmFirstChar = 32;
physDev->font.tm.tmLastChar = 251;
physDev->font.tm.tmDefaultChar = 128;
......
......@@ -6,10 +6,6 @@
*/
#include "psdrv.h"
#include "font.h"
#include "pen.h"
#include "brush.h"
#include "bitmap.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(psdrv);
......@@ -17,8 +13,7 @@ DEFAULT_DEBUG_CHANNEL(psdrv);
/***********************************************************************
* PSDRV_BITMAP_SelectObject
*/
static HBITMAP16 PSDRV_BITMAP_SelectObject( DC * dc, HBITMAP16 hbitmap,
BITMAPOBJ * bmp )
static HBITMAP PSDRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap )
{
FIXME("stub\n");
return 0;
......@@ -30,33 +25,32 @@ static HBITMAP16 PSDRV_BITMAP_SelectObject( DC * dc, HBITMAP16 hbitmap,
*/
HGDIOBJ PSDRV_SelectObject( DC *dc, HGDIOBJ handle )
{
GDIOBJHDR * ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
HGDIOBJ ret = 0;
if (!ptr) return 0;
TRACE("hdc=%04x %04x\n", dc->hSelf, handle );
switch(GDIMAGIC(ptr->wMagic))
switch(GetObjectType( handle ))
{
case PEN_MAGIC:
ret = PSDRV_PEN_SelectObject( dc, handle, (PENOBJ *)ptr );
case OBJ_PEN:
ret = PSDRV_PEN_SelectObject( dc, handle );
break;
case BRUSH_MAGIC:
ret = PSDRV_BRUSH_SelectObject( dc, handle, (BRUSHOBJ *)ptr );
case OBJ_BRUSH:
ret = PSDRV_BRUSH_SelectObject( dc, handle );
break;
case BITMAP_MAGIC:
ret = PSDRV_BITMAP_SelectObject( dc, handle, (BITMAPOBJ *)ptr );
case OBJ_BITMAP:
ret = PSDRV_BITMAP_SelectObject( dc, handle );
break;
case FONT_MAGIC:
ret = PSDRV_FONT_SelectObject( dc, handle, (FONTOBJ *)ptr );
case OBJ_FONT:
ret = PSDRV_FONT_SelectObject( dc, handle );
break;
case REGION_MAGIC:
case OBJ_REGION:
ret = (HGDIOBJ)SelectClipRgn( dc->hSelf, handle );
break;
case 0: /* invalid handle */
break;
default:
ERR("Unknown object magic %04x\n", GDIMAGIC(ptr->wMagic));
ERR("Unknown object type %ld\n", GetObjectType(handle) );
break;
}
GDI_ReleaseObj( handle );
return ret;
}
......@@ -5,7 +5,6 @@
*
*/
#include "pen.h"
#include "psdrv.h"
#include "debugtools.h"
......@@ -20,20 +19,24 @@ static char PEN_alternate[] = "1";
/***********************************************************************
* PSDRV_PEN_SelectObject
*/
extern HPEN PSDRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen )
HPEN PSDRV_PEN_SelectObject( DC * dc, HPEN hpen )
{
LOGPEN logpen;
HPEN prevpen = dc->hPen;
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
TRACE("hpen = %08x colour = %08lx\n", hpen, pen->logpen.lopnColor);
if (!GetObjectA( hpen, sizeof(logpen), &logpen )) return 0;
TRACE("hpen = %08x colour = %08lx\n", hpen, logpen.lopnColor);
dc->hPen = hpen;
physDev->pen.width = INTERNAL_XWSTODS(dc, pen->logpen.lopnWidth.x);
physDev->pen.width = INTERNAL_XWSTODS(dc, logpen.lopnWidth.x);
if(physDev->pen.width < 0)
physDev->pen.width = -physDev->pen.width;
PSDRV_CreateColor(physDev, &physDev->pen.color, pen->logpen.lopnColor);
physDev->pen.style = pen->logpen.lopnStyle & PS_STYLE_MASK;
PSDRV_CreateColor(physDev, &physDev->pen.color, logpen.lopnColor);
physDev->pen.style = logpen.lopnStyle & PS_STYLE_MASK;
switch(physDev->pen.style) {
case PS_DASH:
......
......@@ -8,9 +8,7 @@
*/
#include "windef.h"
#include "wingdi.h"
#include "font.h"
#include "pen.h"
#include "brush.h"
#include "gdi.h"
#include "wine/wingdi16.h"
#include "winspool.h"
......@@ -293,10 +291,9 @@ extern BOOL PSDRV_AddAFMtoList(FONTFAMILY **head, AFM *afm);
extern void PSDRV_FreeAFMList( FONTFAMILY *head );
extern BOOL WINAPI PSDRV_Init(HINSTANCE hinst, DWORD reason, LPVOID reserved);
extern HFONT16 PSDRV_FONT_SelectObject( DC *dc, HFONT16 hfont, FONTOBJ *font);
extern HPEN PSDRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen );
extern HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush,
BRUSHOBJ * brush );
extern HFONT PSDRV_FONT_SelectObject( DC *dc, HFONT hfont );
extern HPEN PSDRV_PEN_SelectObject( DC * dc, HPEN hpen );
extern HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush );
extern BOOL PSDRV_Brush(DC *dc, BOOL EO);
extern BOOL PSDRV_SetFont( DC *dc );
......
......@@ -9,10 +9,7 @@
#include <string.h>
#include "bitmap.h"
#include "brush.h"
#include "font.h"
#include "enhmetafiledrv.h"
#include "pen.h"
#include "debugtools.h"
#include "heap.h"
......@@ -33,9 +30,11 @@ static HBITMAP EMFDRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap )
DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush )
{
DWORD index = 0;
BRUSHOBJ *brushObj = (BRUSHOBJ *)GDI_GetObjPtr( hBrush, BRUSH_MAGIC );
LOGBRUSH logbrush;
switch (brushObj->logbrush.lbStyle) {
if (!GetObjectA( hBrush, sizeof(logbrush), &logbrush )) return 0;
switch (logbrush.lbStyle) {
case BS_SOLID:
case BS_HATCHED:
case BS_NULL:
......@@ -44,7 +43,7 @@ DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush )
emr.emr.iType = EMR_CREATEBRUSHINDIRECT;
emr.emr.nSize = sizeof(emr);
emr.ihBrush = index = EMFDRV_AddHandleDC( dc );
emr.lb = brushObj->logbrush;
emr.lb = logbrush;
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
index = 0;
......@@ -54,7 +53,7 @@ DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush )
{
EMRCREATEDIBPATTERNBRUSHPT *emr;
DWORD bmSize, biSize, size;
BITMAPINFO *info = GlobalLock16(brushObj->logbrush.lbHatch);
BITMAPINFO *info = GlobalLock16(logbrush.lbHatch);
if (info->bmiHeader.biCompression)
bmSize = info->bmiHeader.biSizeImage;
......@@ -62,14 +61,14 @@ DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush )
bmSize = DIB_GetDIBImageBytes(info->bmiHeader.biWidth,
info->bmiHeader.biHeight,
info->bmiHeader.biBitCount);
biSize = DIB_BitmapInfoSize(info, LOWORD(brushObj->logbrush.lbColor));
biSize = DIB_BitmapInfoSize(info, LOWORD(logbrush.lbColor));
size = sizeof(EMRCREATEDIBPATTERNBRUSHPT) + biSize + bmSize;
emr = HeapAlloc( GetProcessHeap(), 0, size );
if(!emr) break;
emr->emr.iType = EMR_CREATEDIBPATTERNBRUSHPT;
emr->emr.nSize = size;
emr->ihBrush = index = EMFDRV_AddHandleDC( dc );
emr->iUsage = LOWORD(brushObj->logbrush.lbColor);
emr->iUsage = LOWORD(logbrush.lbColor);
emr->offBmi = sizeof(EMRCREATEDIBPATTERNBRUSHPT);
emr->cbBmi = biSize;
emr->offBits = sizeof(EMRCREATEDIBPATTERNBRUSHPT) + biSize;
......@@ -79,19 +78,18 @@ DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush )
if(!EMFDRV_WriteRecord( dc, &emr->emr ))
index = 0;
HeapFree( GetProcessHeap(), 0, emr );
GlobalUnlock16(brushObj->logbrush.lbHatch);
GlobalUnlock16(logbrush.lbHatch);
}
break;
case BS_PATTERN:
FIXME("Unsupported style %x\n",
brushObj->logbrush.lbStyle);
logbrush.lbStyle);
break;
default:
FIXME("Unknown style %x\n", brushObj->logbrush.lbStyle);
FIXME("Unknown style %x\n", logbrush.lbStyle);
break;
}
GDI_ReleaseObj( hBrush );
return index;
}
......@@ -141,13 +139,14 @@ static HBRUSH EMFDRV_BRUSH_SelectObject(DC *dc, HBRUSH hBrush )
static BOOL EMFDRV_CreateFontIndirect(DC *dc, HFONT hFont )
{
DWORD index = 0;
FONTOBJ *fontObj = (FONTOBJ *)GDI_GetObjPtr( hFont, FONT_MAGIC );
EMREXTCREATEFONTINDIRECTW emr;
int i;
if (!GetObjectW( hFont, sizeof(emr.elfw.elfLogFont), &emr.elfw.elfLogFont )) return 0;
emr.emr.iType = EMR_EXTCREATEFONTINDIRECTW;
emr.emr.nSize = (sizeof(emr) + 3) / 4 * 4;
emr.ihFont = index = EMFDRV_AddHandleDC( dc );
memcpy( &(emr.elfw.elfLogFont), &(fontObj->logfont), sizeof(LOGFONTW) );
emr.elfw.elfFullName[0] = '\0';
emr.elfw.elfStyle[0] = '\0';
emr.elfw.elfVersion = 0;
......@@ -170,7 +169,6 @@ static BOOL EMFDRV_CreateFontIndirect(DC *dc, HFONT hFont )
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
index = 0;
GDI_ReleaseObj( hFont );
return index;
}
......@@ -223,17 +221,16 @@ static HFONT EMFDRV_FONT_SelectObject( DC * dc, HFONT hFont )
static HPEN EMFDRV_CreatePenIndirect(DC *dc, HPEN hPen )
{
EMRCREATEPEN emr;
PENOBJ *penObj = (PENOBJ *)GDI_GetObjPtr( hPen, PEN_MAGIC );
DWORD index = 0;
if (!GetObjectA( hPen, sizeof(emr.lopn), &emr.lopn )) return 0;
emr.emr.iType = EMR_CREATEPEN;
emr.emr.nSize = sizeof(emr);
emr.ihPen = index = EMFDRV_AddHandleDC( dc );
emr.lopn = penObj->logpen;
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
index = 0;
GDI_ReleaseObj( hPen );
return index;
}
......
......@@ -9,21 +9,18 @@
#include <string.h>
#include "bitmap.h"
#include "brush.h"
#include "font.h"
#include "metafiledrv.h"
#include "pen.h"
#include "debugtools.h"
#include "heap.h"
DEFAULT_DEBUG_CHANNEL(metafile);
DECLARE_DEBUG_CHANNEL(gdi);
/***********************************************************************
* MFDRV_BITMAP_SelectObject
*/
static HBITMAP16 MFDRV_BITMAP_SelectObject( DC * dc, HBITMAP16 hbitmap,
BITMAPOBJ * bmp )
static HBITMAP MFDRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap )
{
return 0;
}
......@@ -38,19 +35,21 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
INT16 index = -1;
DWORD size;
METARECORD *mr;
BRUSHOBJ *brushObj = (BRUSHOBJ *)GDI_GetObjPtr( hBrush, BRUSH_MAGIC );
if(!brushObj) return -1;
switch(brushObj->logbrush.lbStyle) {
LOGBRUSH logbrush;
if (!GetObjectA( hBrush, sizeof(logbrush), &logbrush )) return -1;
switch(logbrush.lbStyle)
{
case BS_SOLID:
case BS_NULL:
case BS_HATCHED:
{
LOGBRUSH16 lb16;
lb16.lbStyle = brushObj->logbrush.lbStyle;
lb16.lbColor = brushObj->logbrush.lbColor;
lb16.lbHatch = brushObj->logbrush.lbHatch;
lb16.lbStyle = logbrush.lbStyle;
lb16.lbColor = logbrush.lbColor;
lb16.lbHatch = logbrush.lbHatch;
size = sizeof(METARECORD) + sizeof(LOGBRUSH16) - 2;
mr = HeapAlloc( GetProcessHeap(), 0, size );
mr->rdSize = size / 2;
......@@ -65,7 +64,7 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
BITMAPINFO *info;
DWORD bmSize;
GetObjectA(brushObj->logbrush.lbHatch, sizeof(bm), &bm);
GetObjectA(logbrush.lbHatch, sizeof(bm), &bm);
if(bm.bmBitsPixel != 1 || bm.bmPlanes != 1) {
FIXME("Trying to store a colour pattern brush\n");
goto done;
......@@ -91,7 +90,7 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
info->bmiHeader.biBitCount = 1;
bits = ((BYTE *)info) + sizeof(BITMAPINFO) + sizeof(RGBQUAD);
GetDIBits(dc->hSelf, brushObj->logbrush.lbHatch, 0, bm.bmHeight,
GetDIBits(dc->hSelf, logbrush.lbHatch, 0, bm.bmHeight,
bits, info, DIB_RGB_COLORS);
*(DWORD *)info->bmiColors = 0;
*(DWORD *)(info->bmiColors + 1) = 0xffffff;
......@@ -103,27 +102,26 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
BITMAPINFO *info;
DWORD bmSize, biSize;
info = GlobalLock16((HGLOBAL16)brushObj->logbrush.lbHatch);
info = GlobalLock16((HGLOBAL16)logbrush.lbHatch);
if (info->bmiHeader.biCompression)
bmSize = info->bmiHeader.biSizeImage;
else
bmSize = DIB_GetDIBImageBytes(info->bmiHeader.biWidth,
info->bmiHeader.biHeight,
info->bmiHeader.biBitCount);
biSize = DIB_BitmapInfoSize(info,
LOWORD(brushObj->logbrush.lbColor));
biSize = DIB_BitmapInfoSize(info, LOWORD(logbrush.lbColor));
size = sizeof(METARECORD) + biSize + bmSize + 2;
mr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if(!mr) goto done;
mr->rdFunction = META_DIBCREATEPATTERNBRUSH;
mr->rdSize = size / 2;
*(mr->rdParm) = brushObj->logbrush.lbStyle;
*(mr->rdParm + 1) = LOWORD(brushObj->logbrush.lbColor);
*(mr->rdParm) = logbrush.lbStyle;
*(mr->rdParm + 1) = LOWORD(logbrush.lbColor);
memcpy(mr->rdParm + 2, info, biSize + bmSize);
break;
}
default:
FIXME("Unkonwn brush style %x\n", brushObj->logbrush.lbStyle);
FIXME("Unkonwn brush style %x\n", logbrush.lbStyle);
return -1;
}
index = MFDRV_AddHandleDC( dc );
......@@ -131,7 +129,6 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
index = -1;
HeapFree(GetProcessHeap(), 0, mr);
done:
GDI_ReleaseObj( hBrush );
return index;
}
......@@ -139,8 +136,7 @@ done:
/***********************************************************************
* MFDRV_BRUSH_SelectObject
*/
static HBRUSH MFDRV_BRUSH_SelectObject( DC *dc, HBRUSH hbrush,
BRUSHOBJ * brush )
static HBRUSH MFDRV_BRUSH_SelectObject( DC *dc, HBRUSH hbrush )
{
INT16 index;
METARECORD mr;
......@@ -181,12 +177,12 @@ static BOOL MFDRV_CreateFontIndirect(DC *dc, HFONT16 hFont, LOGFONT16 *logfont)
/***********************************************************************
* MFDRV_FONT_SelectObject
*/
static HFONT16 MFDRV_FONT_SelectObject( DC * dc, HFONT16 hfont,
FONTOBJ * font )
static HFONT MFDRV_FONT_SelectObject( DC * dc, HFONT hfont )
{
HFONT16 prevHandle = dc->hFont;
LOGFONT16 lf16;
FONT_LogFontWTo16(&(font->logfont), &lf16);
if (!GetObject16( hfont, sizeof(lf16), &lf16 )) return 0;
if (MFDRV_CreateFontIndirect(dc, hfont, &lf16))
return prevHandle;
return 0;
......@@ -218,18 +214,13 @@ static BOOL MFDRV_CreatePenIndirect(DC *dc, HPEN16 hPen, LOGPEN16 *logpen)
/***********************************************************************
* MFDRV_PEN_SelectObject
*/
static HPEN MFDRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen )
static HPEN MFDRV_PEN_SelectObject( DC * dc, HPEN hpen )
{
LOGPEN16 logpen;
HPEN prevHandle = dc->hPen;
logpen.lopnStyle = pen->logpen.lopnStyle;
logpen.lopnWidth.x = pen->logpen.lopnWidth.x;
logpen.lopnWidth.y = pen->logpen.lopnWidth.y;
logpen.lopnColor = pen->logpen.lopnColor;
if (!GetObject16( hpen, sizeof(logpen), &logpen )) return 0;
if (MFDRV_CreatePenIndirect( dc, hpen, &logpen )) return prevHandle;
return 0;
}
......@@ -239,32 +230,15 @@ static HPEN MFDRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen )
*/
HGDIOBJ MFDRV_SelectObject( DC *dc, HGDIOBJ handle )
{
GDIOBJHDR * ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
HGDIOBJ ret = 0;
TRACE("hdc=%04x %04x\n", dc->hSelf, handle );
if (!ptr) return 0;
TRACE_(gdi)("hdc=%04x %04x\n", dc->hSelf, handle );
switch(GDIMAGIC(ptr->wMagic))
switch(GetObjectType( handle ))
{
case PEN_MAGIC:
ret = MFDRV_PEN_SelectObject( dc, handle, (PENOBJ *)ptr );
break;
case BRUSH_MAGIC:
ret = MFDRV_BRUSH_SelectObject( dc, handle, (BRUSHOBJ *)ptr );
break;
case BITMAP_MAGIC:
ret = MFDRV_BITMAP_SelectObject( dc, handle, (BITMAPOBJ *)ptr );
break;
case FONT_MAGIC:
ret = MFDRV_FONT_SelectObject( dc, handle, (FONTOBJ *)ptr );
break;
case REGION_MAGIC:
ret = (HGDIOBJ)SelectClipRgn( dc->hSelf, handle );
break;
case OBJ_PEN: return MFDRV_PEN_SelectObject( dc, handle );
case OBJ_BRUSH: return MFDRV_BRUSH_SelectObject( dc, handle );
case OBJ_BITMAP: return MFDRV_BITMAP_SelectObject( dc, handle );
case OBJ_FONT: return MFDRV_FONT_SelectObject( dc, handle );
case OBJ_REGION: return (HGDIOBJ)SelectClipRgn( dc->hSelf, handle );
}
GDI_ReleaseObj( handle );
return ret;
return 0;
}
......@@ -5,26 +5,22 @@
*/
#include <stdlib.h>
#include "brush.h"
#include "win16drv.h"
#include "heap.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(win16drv);
HBRUSH WIN16DRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush,
BRUSHOBJ * brush )
HBRUSH WIN16DRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush )
{
WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
HBRUSH16 prevHandle = dc->hBrush;
int nSize;
LOGBRUSH16 lBrush16;
dc->hBrush = hbrush;
lBrush16.lbStyle = brush->logbrush.lbStyle;
lBrush16.lbColor = brush->logbrush.lbColor;
lBrush16.lbHatch = brush->logbrush.lbHatch;
LOGBRUSH16 lBrush16;
if (!GetObject16( hbrush, sizeof(lBrush16), &lBrush16 )) return 0;
dc->hBrush = hbrush;
if ( physDev->BrushInfo )
{
TRACE("UnRealizing BrushInfo\n");
......
......@@ -72,17 +72,18 @@ BOOL WIN16DRV_GetTextMetrics( DC *dc, TEXTMETRICW *metrics )
return TRUE;
}
HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font)
HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont)
{
WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
HPEN prevHandle = dc->hFont;
int nSize;
dc->hFont = hfont;
if (!GetObject16( hfont, sizeof(physDev->lf), &physDev->lf )) return 0;
TRACE("WIN16DRV_FONT_SelectObject %s h=%ld\n",
debugstr_w(font->logfont.lfFaceName), font->logfont.lfHeight);
dc->hFont = hfont;
TRACE("WIN16DRV_FONT_SelectObject %s h=%d\n",
debugstr_a(physDev->lf.lfFaceName), physDev->lf.lfHeight);
if( physDev->FontInfo )
{
......@@ -92,7 +93,6 @@ HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font)
physDev->FontInfo, 0);
}
FONT_LogFontWTo16(&font->logfont, &physDev->lf);
nSize = PRTDRV_RealizeObject (physDev->segptrPDEVICE, DRVOBJ_FONT,
&physDev->lf, 0, 0);
......
......@@ -9,10 +9,6 @@
#include <stdlib.h>
#include <stdio.h>
#include "bitmap.h"
#include "brush.h"
#include "font.h"
#include "pen.h"
#include "win16drv.h"
#include "debugtools.h"
......@@ -20,45 +16,22 @@
DEFAULT_DEBUG_CHANNEL(gdi);
extern HBITMAP WIN16DRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap,
BITMAPOBJ * bmp );
extern HBRUSH WIN16DRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush,
BRUSHOBJ * brush );
extern HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont,
FONTOBJ * font );
extern HPEN WIN16DRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen );
/***********************************************************************
* WIN16DRV_SelectObject
*/
HGDIOBJ WIN16DRV_SelectObject( DC *dc, HGDIOBJ handle )
{
GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
HGDIOBJ ret = 0;
if (!ptr) return 0;
TRACE("hdc=%04x %04x\n", dc->hSelf, handle );
switch(GDIMAGIC(ptr->wMagic))
switch(GetObjectType( handle ))
{
case PEN_MAGIC:
ret = WIN16DRV_PEN_SelectObject( dc, handle, (PENOBJ *)ptr );
break;
case BRUSH_MAGIC:
ret = WIN16DRV_BRUSH_SelectObject( dc, handle, (BRUSHOBJ *)ptr );
break;
case BITMAP_MAGIC:
FIXME("WIN16DRV_SelectObject for BITMAP not implemented\n");
ret = 1;
break;
case FONT_MAGIC:
ret = WIN16DRV_FONT_SelectObject( dc, handle, (FONTOBJ *)ptr );
break;
case REGION_MAGIC:
ret = (HGDIOBJ)SelectClipRgn( dc->hSelf, handle );
break;
case OBJ_PEN: return WIN16DRV_PEN_SelectObject( dc, handle );
case OBJ_BRUSH: return WIN16DRV_BRUSH_SelectObject( dc, handle );
case OBJ_FONT: return WIN16DRV_FONT_SelectObject( dc, handle );
case OBJ_REGION: return (HGDIOBJ)SelectClipRgn( dc->hSelf, handle );
case OBJ_BITMAP:
FIXME("BITMAP not implemented\n");
return 1;
}
GDI_ReleaseObj( handle );
return ret;
return 0;
}
......@@ -4,7 +4,6 @@
* Copyright 1997 John Harvey
*/
#include "pen.h"
#include "win16drv.h"
#include "heap.h"
#include "debugtools.h"
......@@ -14,18 +13,16 @@ DEFAULT_DEBUG_CHANNEL(win16drv);
/***********************************************************************
* PEN_SelectObject
*/
HPEN WIN16DRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen )
HPEN WIN16DRV_PEN_SelectObject( DC * dc, HPEN hpen )
{
WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
HPEN prevHandle = dc->hPen;
int nSize;
LOGPEN16 lPen16;
if (!GetObject16( hpen, sizeof(lPen16), &lPen16 )) return 0;
dc->hPen = hpen;
TRACE("In WIN16DRV_PEN_SelectObject\n");
lPen16.lopnStyle = pen->logpen.lopnStyle;
lPen16.lopnWidth.x = pen->logpen.lopnWidth.x;
lPen16.lopnWidth.y = pen->logpen.lopnWidth.y;
lPen16.lopnColor = pen->logpen.lopnColor;
if ( physDev->PenInfo )
{
......
......@@ -236,6 +236,10 @@ extern DWORD WIN16DRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice,
LPCSTR lpszPort, WORD fwCapability,
LPSTR lpszOutput, LPDEVMODEA lpdm);
extern HBRUSH WIN16DRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush );
extern HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont );
extern HPEN WIN16DRV_PEN_SelectObject( DC * dc, HPEN hpen );
/*
* Wine 16bit driver global variables
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment