Commit aface537 authored by Alexandre Julliard's avatar Alexandre Julliard

Fixed a number of dll separation issues.

parent c895879e
......@@ -23,13 +23,66 @@
#include "winnls.h"
#include "wine/winbase16.h"
#include "win16drv/win16drv.h"
#include "font.h"
#include "gdi.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(win16drv);
static void WIN16DRV_NewTextMetric16ToW(const NEWTEXTMETRIC16 *ptm16, LPNEWTEXTMETRICW ptmW )
{
ptmW->tmHeight = ptm16->tmHeight;
ptmW->tmAscent = ptm16->tmAscent;
ptmW->tmDescent = ptm16->tmDescent;
ptmW->tmInternalLeading = ptm16->tmInternalLeading;
ptmW->tmExternalLeading = ptm16->tmExternalLeading;
ptmW->tmAveCharWidth = ptm16->tmAveCharWidth;
ptmW->tmMaxCharWidth = ptm16->tmMaxCharWidth;
ptmW->tmWeight = ptm16->tmWeight;
ptmW->tmOverhang = ptm16->tmOverhang;
ptmW->tmDigitizedAspectX = ptm16->tmDigitizedAspectX;
ptmW->tmDigitizedAspectY = ptm16->tmDigitizedAspectY;
ptmW->tmFirstChar = ptm16->tmFirstChar;
ptmW->tmLastChar = ptm16->tmLastChar;
ptmW->tmDefaultChar = ptm16->tmDefaultChar;
ptmW->tmBreakChar = ptm16->tmBreakChar;
ptmW->tmItalic = ptm16->tmItalic;
ptmW->tmUnderlined = ptm16->tmUnderlined;
ptmW->tmStruckOut = ptm16->tmStruckOut;
ptmW->tmPitchAndFamily = ptm16->tmPitchAndFamily;
ptmW->tmCharSet = ptm16->tmCharSet;
ptmW->ntmFlags = ptm16->ntmFlags;
ptmW->ntmSizeEM = ptm16->ntmSizeEM;
ptmW->ntmCellHeight = ptm16->ntmCellHeight;
ptmW->ntmAvgWidth = ptm16->ntmAvgWidth;
}
static void WIN16DRV_EnumLogFont16ToW( const ENUMLOGFONT16 *font16, LPENUMLOGFONTW font32 )
{
font32->elfLogFont.lfHeight = font16->elfLogFont.lfHeight;
font32->elfLogFont.lfWidth = font16->elfLogFont.lfWidth;
font32->elfLogFont.lfEscapement = font16->elfLogFont.lfEscapement;
font32->elfLogFont.lfOrientation = font16->elfLogFont.lfOrientation;
font32->elfLogFont.lfWeight = font16->elfLogFont.lfWeight;
font32->elfLogFont.lfItalic = font16->elfLogFont.lfItalic;
font32->elfLogFont.lfUnderline = font16->elfLogFont.lfUnderline;
font32->elfLogFont.lfStrikeOut = font16->elfLogFont.lfStrikeOut;
font32->elfLogFont.lfCharSet = font16->elfLogFont.lfCharSet;
font32->elfLogFont.lfOutPrecision = font16->elfLogFont.lfOutPrecision;
font32->elfLogFont.lfClipPrecision = font16->elfLogFont.lfClipPrecision;
font32->elfLogFont.lfQuality = font16->elfLogFont.lfQuality;
font32->elfLogFont.lfPitchAndFamily = font16->elfLogFont.lfPitchAndFamily;
MultiByteToWideChar( CP_ACP, 0, font16->elfLogFont.lfFaceName, -1,
font32->elfLogFont.lfFaceName, LF_FACESIZE );
font32->elfLogFont.lfFaceName[LF_FACESIZE-1] = 0;
MultiByteToWideChar( CP_ACP, 0, font16->elfFullName, -1, font32->elfFullName, LF_FULLFACESIZE );
font32->elfFullName[LF_FULLFACESIZE-1] = 0;
MultiByteToWideChar( CP_ACP, 0, font16->elfStyle, -1, font32->elfStyle, LF_FACESIZE );
font32->elfStyle[LF_FACESIZE-1] = 0;
}
/***********************************************************************
* WIN16DRV_GetTextExtentPoint
*/
......@@ -69,7 +122,7 @@ BOOL WIN16DRV_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
TRACE("%04x \n", physDev->hdc);
FONT_TextMetric16ToW( &physDev->tm, metrics );
*metrics = physDev->tm;
TRACE(
"H %ld, A %ld, D %ld, Int %ld, Ext %ld, AW %ld, MW %ld, W %ld\n",
......@@ -130,8 +183,7 @@ HFONT WIN16DRV_SelectFont( PHYSDEV dev, HFONT hfont)
#define fi physDev->FontInfo
physDev->tm.tmHeight = YDSTOLS(dc, fi->dfPixHeight);
physDev->tm.tmAscent = YDSTOLS(dc, fi->dfAscent);
physDev->tm.tmDescent = physDev->tm.tmHeight -
physDev->tm.tmAscent;
physDev->tm.tmDescent = physDev->tm.tmHeight - physDev->tm.tmAscent;
physDev->tm.tmInternalLeading = YDSTOLS(dc, fi->dfInternalLeading);
physDev->tm.tmExternalLeading = YDSTOLS(dc, fi->dfExternalLeading);
physDev->tm.tmAveCharWidth = XDSTOLS(dc, fi->dfAvgWidth);
......@@ -151,7 +203,7 @@ HFONT WIN16DRV_SelectFont( PHYSDEV dev, HFONT hfont)
physDev->tm.tmCharSet = fi->dfCharSet;
#undef fi
TRACE("H %d, A %d, D %d, Int %d, Ext %d, AW %d, MW %d, W %d\n",
TRACE("H %ld, A %ld, D %ld, Int %ld, Ext %ld, AW %ld, MW %ld, W %ld\n",
physDev->tm.tmHeight,
physDev->tm.tmAscent,
physDev->tm.tmDescent,
......@@ -236,24 +288,15 @@ WORD WINAPI EnumCallback16(LPENUMLOGFONT16 lpLogFont,
WORD wFontType, LONG lpClientData)
{
ENUMLOGFONTEXW lfW;
ENUMLOGFONTEX16 lf16;
NEWTEXTMETRICEXW tmW;
NEWTEXTMETRICEX16 tm16;
TRACE("In EnumCallback16 plf=%p\n", lpLogFont);
/* we have a ENUMLOGFONT16 which is a subset of ENUMLOGFONTEX16,
so we copy it into one of these and then convert to ENUMLOGFONTEXW */
memset(&lf16, 0, sizeof(lf16));
memcpy(&lf16, lpLogFont, sizeof(*lpLogFont));
FONT_EnumLogFontEx16ToW(&lf16, &lfW);
memset(&lfW, 0, sizeof(lfW));
WIN16DRV_EnumLogFont16ToW(lpLogFont, (ENUMLOGFONTW *)&lfW);
/* and a similar idea for NEWTEXTMETRIC16 */
memset(&tm16, 0, sizeof(tm16));
memcpy(&tm16, lpTextMetrics, sizeof(*lpTextMetrics));
FONT_NewTextMetricEx16ToW(&tm16, &tmW);
memset(&tmW, 0, sizeof(tmW));
WIN16DRV_NewTextMetric16ToW(lpTextMetrics, (NEWTEXTMETRICW *)&tmW);
return (*(((WEPFC *)lpClientData)->proc))( &lfW, &tmW, wFontType,
((WEPFC *)lpClientData)->lp );
......
......@@ -201,7 +201,7 @@ typedef struct
{
SEGPTR segptrPDEVICE; /* PDEVICE used by 16 bit printer drivers */
LOGFONT16 lf; /* Current font details */
TEXTMETRIC16 tm; /* Current font metrics */
TEXTMETRICW tm; /* Current font metrics */
LPFONTINFO16 FontInfo; /* Current font realized by printer driver */
LPLOGBRUSH16 BrushInfo; /* Current brush realized by printer driver */
LPLOGPEN16 PenInfo; /* Current pen realized by printer driver */
......
......@@ -217,9 +217,6 @@ static BOOL process_attach(void)
if ((instance = LoadLibrary16( "USER.EXE" )) < 32) return FALSE;
USER_HeapSel = instance | 7;
/* Global atom table initialisation */
if (!ATOM_Init( USER_HeapSel )) return FALSE;
/* Load the graphics driver */
tweak_init();
if (!load_driver()) return FALSE;
......
......@@ -432,7 +432,7 @@ static void X11DRV_TextExtents_normal( fontObject* pfo, XChar2b* pstr, int count
*pwidth = info.width;
}
static void X11DRV_GetTextMetricsA_normal( fontObject* pfo, LPTEXTMETRICA pTM )
static void X11DRV_GetTextMetricsW_normal( fontObject* pfo, LPTEXTMETRICW pTM )
{
LPIFONTINFO16 pdf = &pfo->fi->df;
......@@ -611,7 +611,7 @@ void X11DRV_TextExtents_dbcs_2fonts( fontObject* pfo, XChar2b* pstr, int count,
*pwidth = width;
}
static void X11DRV_GetTextMetricsA_cp932( fontObject* pfo, LPTEXTMETRICA pTM )
static void X11DRV_GetTextMetricsW_cp932( fontObject* pfo, LPTEXTMETRICW pTM )
{
fontObject* pfo_ansi = XFONT_GetFontObject( pfo->prefobjs[0] );
LPIFONTINFO16 pdf = &pfo->fi->df;
......@@ -691,7 +691,7 @@ const X11DRV_CP X11DRV_cptable[X11DRV_CPTABLE_COUNT] =
X11DRV_TextWidth_normal,
X11DRV_DrawText_normal,
X11DRV_TextExtents_normal,
X11DRV_GetTextMetricsA_normal,
X11DRV_GetTextMetricsW_normal,
},
{ /* UNICODE */
X11DRV_enum_subfont_charset_normal,
......@@ -700,7 +700,7 @@ const X11DRV_CP X11DRV_cptable[X11DRV_CPTABLE_COUNT] =
X11DRV_TextWidth_normal,
X11DRV_DrawText_normal,
X11DRV_TextExtents_normal,
X11DRV_GetTextMetricsA_normal,
X11DRV_GetTextMetricsW_normal,
},
{ /* CP932 */
X11DRV_enum_subfont_charset_cp932,
......@@ -709,7 +709,7 @@ const X11DRV_CP X11DRV_cptable[X11DRV_CPTABLE_COUNT] =
X11DRV_TextWidth_dbcs_2fonts,
X11DRV_DrawText_dbcs_2fonts,
X11DRV_TextExtents_dbcs_2fonts,
X11DRV_GetTextMetricsA_cp932,
X11DRV_GetTextMetricsW_cp932,
},
{ /* CP936 */
X11DRV_enum_subfont_charset_cp936,
......@@ -718,7 +718,7 @@ const X11DRV_CP X11DRV_cptable[X11DRV_CPTABLE_COUNT] =
X11DRV_TextWidth_dbcs_2fonts,
X11DRV_DrawText_dbcs_2fonts,
X11DRV_TextExtents_dbcs_2fonts,
X11DRV_GetTextMetricsA_normal, /* FIXME */
X11DRV_GetTextMetricsW_normal, /* FIXME */
},
{ /* CP949 */
X11DRV_enum_subfont_charset_cp949,
......@@ -727,7 +727,7 @@ const X11DRV_CP X11DRV_cptable[X11DRV_CPTABLE_COUNT] =
X11DRV_TextWidth_dbcs_2fonts,
X11DRV_DrawText_dbcs_2fonts,
X11DRV_TextExtents_dbcs_2fonts,
X11DRV_GetTextMetricsA_normal, /* FIXME */
X11DRV_GetTextMetricsW_normal, /* FIXME */
},
{ /* CP950 */
X11DRV_enum_subfont_charset_cp950,
......@@ -736,7 +736,7 @@ const X11DRV_CP X11DRV_cptable[X11DRV_CPTABLE_COUNT] =
X11DRV_TextWidth_dbcs_2fonts,
X11DRV_DrawText_dbcs_2fonts,
X11DRV_TextExtents_dbcs_2fonts,
X11DRV_GetTextMetricsA_cp932,
X11DRV_GetTextMetricsW_cp932,
},
{ /* SYMBOL */
X11DRV_enum_subfont_charset_normal,
......@@ -745,6 +745,6 @@ const X11DRV_CP X11DRV_cptable[X11DRV_CPTABLE_COUNT] =
X11DRV_TextWidth_normal,
X11DRV_DrawText_normal,
X11DRV_TextExtents_normal,
X11DRV_GetTextMetricsA_normal,
X11DRV_GetTextMetricsW_normal,
}
};
......@@ -134,6 +134,37 @@ XImage *X11DRV_DIB_CreateXImage( int width, int height, int depth )
/***********************************************************************
* DIB_GetBitmapInfo
*
* Get the info from a bitmap header.
* Return 1 for INFOHEADER, 0 for COREHEADER, -1 for error.
*/
static int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width,
int *height, WORD *bpp, WORD *compr )
{
if (header->biSize == sizeof(BITMAPCOREHEADER))
{
BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)header;
*width = core->bcWidth;
*height = core->bcHeight;
*bpp = core->bcBitCount;
*compr = 0;
return 0;
}
if (header->biSize >= sizeof(BITMAPINFOHEADER))
{
*width = header->biWidth;
*height = header->biHeight;
*bpp = header->biBitCount;
*compr = header->biCompression;
return 1;
}
ERR("(%ld): unknown/wrong size for header\n", header->biSize );
return -1;
}
/***********************************************************************
* X11DRV_DIB_GenColorMap
*
* Fills the color map of a bitmap palette. Should not be called
......
......@@ -377,6 +377,27 @@ inline static BOOL is_stock_font( HFONT font )
}
static void FONT_LogFontWTo16( const LOGFONTW* font32, LPLOGFONT16 font16 )
{
font16->lfHeight = font32->lfHeight;
font16->lfWidth = font32->lfWidth;
font16->lfEscapement = font32->lfEscapement;
font16->lfOrientation = font32->lfOrientation;
font16->lfWeight = font32->lfWeight;
font16->lfItalic = font32->lfItalic;
font16->lfUnderline = font32->lfUnderline;
font16->lfStrikeOut = font32->lfStrikeOut;
font16->lfCharSet = font32->lfCharSet;
font16->lfOutPrecision = font32->lfOutPrecision;
font16->lfClipPrecision = font32->lfClipPrecision;
font16->lfQuality = font32->lfQuality;
font16->lfPitchAndFamily = font32->lfPitchAndFamily;
WideCharToMultiByte( CP_ACP, 0, font32->lfFaceName, -1,
font16->lfFaceName, LF_FACESIZE, NULL, NULL );
font16->lfFaceName[LF_FACESIZE-1] = 0;
}
/***********************************************************************
* Checksums
*/
......@@ -3326,17 +3347,17 @@ BOOL X11DRV_EnumDeviceFonts( X11DRV_PDEVICE *physDev, LPLOGFONTW plf,
NEWTEXTMETRICEXW tm;
fontResource* pfr = fontList;
BOOL b, bRet = 0;
LOGFONT16 lf16;
/* don't enumerate x11 fonts if we're using client side fonts */
if (physDev->dc->gdiFont) return FALSE;
FONT_LogFontWTo16(plf, &lf16);
if( lf16.lfFaceName[0] )
if( plf->lfFaceName[0] )
{
char facename[LF_FACESIZE+1];
WideCharToMultiByte( CP_ACP, 0, plf->lfFaceName, -1,
facename, sizeof(facename), NULL, NULL );
/* enum all entries in this resource */
pfr = XFONT_FindFIList( pfr, lf16.lfFaceName );
pfr = XFONT_FindFIList( pfr, facename );
if( pfr )
{
fontInfo* pfi;
......@@ -3346,8 +3367,8 @@ BOOL X11DRV_EnumDeviceFonts( X11DRV_PDEVICE *physDev, LPLOGFONTW plf,
release the crit section, font list will
have to be retraversed on return */
if(lf16.lfCharSet == DEFAULT_CHARSET ||
lf16.lfCharSet == pfi->df.dfCharSet) {
if(plf->lfCharSet == DEFAULT_CHARSET ||
plf->lfCharSet == pfi->df.dfCharSet) {
if( (b = (*proc)( &lf, &tm,
XFONT_GetFontMetric( pfi, &lf, &tm ), lp )) )
bRet = b;
......@@ -3376,13 +3397,10 @@ BOOL X11DRV_EnumDeviceFonts( X11DRV_PDEVICE *physDev, LPLOGFONTW plf,
*/
BOOL X11DRV_GetTextMetrics(X11DRV_PDEVICE *physDev, TEXTMETRICW *metrics)
{
TEXTMETRICA tmA;
if( CHECK_PFONT(physDev->font) )
{
fontObject* pfo = __PFONT(physDev->font);
X11DRV_cptable[pfo->fi->cptable].pGetTextMetricsA( pfo, &tmA );
FONT_TextMetricAToW(&tmA, metrics);
X11DRV_cptable[pfo->fi->cptable].pGetTextMetricsW( pfo, metrics );
return TRUE;
}
return FALSE;
......
......@@ -40,7 +40,6 @@ typedef struct tagBITMAPOBJ
} BITMAPOBJ;
/* objects/bitmap.c */
extern INT BITMAP_GetWidthBytes( INT width, INT depth );
extern HBITMAP BITMAP_CopyBitmap( HBITMAP hbitmap );
extern BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, DC *dc );
......@@ -48,8 +47,6 @@ extern BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, DC *dc );
extern int DIB_GetDIBWidthBytes( int width, int depth );
extern int DIB_GetDIBImageBytes( int width, int height, int depth );
extern int DIB_BitmapInfoSize( const BITMAPINFO * info, WORD coloruse );
extern int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width,
int *height, WORD *bpp, WORD *compr );
extern HBITMAP DIB_CreateDIBSection( HDC hdc, BITMAPINFO *bmi, UINT usage, LPVOID *bits,
HANDLE section, DWORD offset, DWORD ovr_pitch );
extern void DIB_UpdateDIBSection( DC *dc, BOOL toDIB );
......
......@@ -24,18 +24,6 @@
#include "gdi.h"
extern BOOL FONT_Init( UINT16* pTextCaps );
extern void FONT_LogFontATo16( const LOGFONTA* font32, LPLOGFONT16 font16 );
extern void FONT_LogFontWTo16( const LOGFONTW* font32, LPLOGFONT16 font16 );
extern void FONT_LogFont16ToA( const LOGFONT16* font16, LPLOGFONTA font32 );
extern void FONT_LogFont16ToW( const LOGFONT16* font16, LPLOGFONTW font32 );
extern void FONT_TextMetricATo16(const TEXTMETRICA *ptm32, LPTEXTMETRIC16 ptm16 );
extern void FONT_TextMetricWTo16(const TEXTMETRICW *ptm32, LPTEXTMETRIC16 ptm16 );
extern void FONT_TextMetric16ToA(const TEXTMETRIC16 *ptm16, LPTEXTMETRICA ptm32 );
extern void FONT_TextMetric16ToW(const TEXTMETRIC16 *ptm16, LPTEXTMETRICW ptm32 );
extern void FONT_TextMetricAToW(const TEXTMETRICA *ptm32A, LPTEXTMETRICW ptm32W );
extern void FONT_NewTextMetricEx16ToW(const NEWTEXTMETRICEX16*, LPNEWTEXTMETRICEXW);
extern void FONT_EnumLogFontEx16ToW(const ENUMLOGFONTEX16*, LPENUMLOGFONTEXW);
extern LPWSTR FONT_mbtowc(HDC, LPCSTR, INT, INT*, UINT*);
extern INT WineEngAddFontResourceEx(LPCWSTR, DWORD, PVOID);
......
......@@ -453,7 +453,6 @@ extern HMETAFILE16 MF_Create_HMETAFILE16(METAHEADER *mh);
extern METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mr, LPCSTR filename);
/* region.c */
extern HRGN REGION_CropRgn( HRGN hDst, HRGN hSrc, const RECT *lpRect, const POINT *lpPt );
extern BOOL REGION_FrameRgn( HRGN dest, HRGN src, INT x, INT y );
#define WINE_GGO_GRAY16_BITMAP 0x7f
......
......@@ -37,7 +37,4 @@ typedef BOOL (*HANDLERPROC)(LPVOID, LPCVOID);
extern BOOL VIRTUAL_SetFaultHandler(LPCVOID addr, HANDLERPROC proc, LPVOID arg);
extern DWORD VIRTUAL_HandleFault(LPCVOID addr);
/* memory/atom.c */
extern BOOL ATOM_Init( WORD globalTableSel );
#endif /* __WINE_GLOBAL_H */
......@@ -264,7 +264,7 @@ typedef struct tagX11DRV_CP
void (*pTextExtents)( fontObject* pfo, XChar2b* pstr, int count,
int* pdir, int* pascent, int* pdescent,
int* pwidth );
void (*pGetTextMetricsA)( fontObject* pfo, LPTEXTMETRICA pTM );
void (*pGetTextMetricsW)( fontObject* pfo, LPTEXTMETRICW pTM );
} X11DRV_CP;
extern const X11DRV_CP X11DRV_cptable[X11DRV_CPTABLE_COUNT];
......
......@@ -67,19 +67,6 @@ typedef struct
HANDLE16 entries[1];
} ATOMTABLE;
static WORD ATOM_UserDS = 0; /* USER data segment */
/***********************************************************************
* ATOM_Init
*
* Global table initialisation.
*/
BOOL ATOM_Init( WORD globalTableSel )
{
ATOM_UserDS = globalTableSel;
return TRUE;
}
/***********************************************************************
* ATOM_GetTable
......@@ -200,18 +187,6 @@ WORD WINAPI InitAtomTable16( WORD entries )
HANDLE16 handle;
ATOMTABLE *table;
/* We consider the first table to be initialized as the global table.
* This works, as USER (both built-in and native) is the first one to
* register ...
*/
if (!ATOM_UserDS)
{
ATOM_UserDS = CURRENT_DS;
/* return dummy local handle */
return LocalAlloc16( LMEM_FIXED, 1 );
}
/* Allocate the table */
if (!entries) entries = DEFAULT_ATOMTABLE_SIZE; /* sanity check */
......@@ -268,7 +243,6 @@ ATOM WINAPI AddAtom16( LPCSTR str )
len = strlen( buffer );
if (!(table = ATOM_GetTable( TRUE ))) return 0;
if (CURRENT_DS == ATOM_UserDS) return GlobalAddAtomA( str );
hash = ATOM_Hash( table->size, buffer, len );
entry = table->entries[hash];
......@@ -314,7 +288,6 @@ ATOM WINAPI DeleteAtom16( ATOM atom )
WORD hash;
if (atom < MAXINTATOM) return 0; /* Integer atom */
if (CURRENT_DS == ATOM_UserDS) return GlobalDeleteAtom( atom );
TRACE("0x%x\n",atom);
......@@ -352,8 +325,6 @@ ATOM WINAPI FindAtom16( LPCSTR str )
HANDLE16 entry;
int len;
if (CURRENT_DS == ATOM_UserDS) return GlobalFindAtomA( str );
TRACE("%s\n",debugstr_a(str));
if (ATOM_IsIntAtomA( str, &iatom )) return iatom;
......@@ -389,8 +360,6 @@ UINT16 WINAPI GetAtomName16( ATOM atom, LPSTR buffer, INT16 count )
UINT len;
char text[8];
if (CURRENT_DS == ATOM_UserDS) return GlobalGetAtomNameA( atom, buffer, count );
TRACE("%x\n",atom);
if (!count) return 0;
......
......@@ -53,7 +53,7 @@ static const struct gdi_obj_funcs bitmap_funcs =
* Return number of bytes taken by a scanline of 16-bit aligned Windows DDB
* data.
*/
INT BITMAP_GetWidthBytes( INT bmWidth, INT bpp )
static INT BITMAP_GetWidthBytes( INT bmWidth, INT bpp )
{
switch(bpp)
{
......
......@@ -103,7 +103,7 @@ int DIB_BitmapInfoSize( const BITMAPINFO * info, WORD coloruse )
* Return 1 for INFOHEADER, 0 for COREHEADER,
* 4 for V4HEADER, 5 for V5HEADER, -1 for error.
*/
int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width,
static int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width,
int *height, WORD *bpp, WORD *compr )
{
if (header->biSize == sizeof(BITMAPINFOHEADER))
......
......@@ -2754,261 +2754,6 @@ INT WINAPI GetRandomRgn(HDC hDC, HRGN hRgn, DWORD dwCode)
return -1;
}
/***********************************************************************
* REGION_CropAndOffsetRegion
*/
static BOOL REGION_CropAndOffsetRegion(const POINT* off, const RECT *rect, WINEREGION *rgnSrc, WINEREGION* rgnDst)
{
if( !rect ) /* just copy and offset */
{
RECT *xrect;
if( rgnDst == rgnSrc )
{
if( off->x || off->y )
xrect = rgnDst->rects;
else
return TRUE;
}
else
xrect = HeapReAlloc( GetProcessHeap(), 0, rgnDst->rects,
rgnSrc->size * sizeof( RECT ));
if( xrect )
{
INT i;
if( rgnDst != rgnSrc )
memcpy( rgnDst, rgnSrc, sizeof( WINEREGION ));
if( off->x || off->y )
{
for( i = 0; i < rgnDst->numRects; i++ )
{
xrect[i].left = rgnSrc->rects[i].left + off->x;
xrect[i].right = rgnSrc->rects[i].right + off->x;
xrect[i].top = rgnSrc->rects[i].top + off->y;
xrect[i].bottom = rgnSrc->rects[i].bottom + off->y;
}
rgnDst->extents.left += off->x;
rgnDst->extents.right += off->x;
rgnDst->extents.top += off->y;
rgnDst->extents.bottom += off->y;
}
else
memcpy( xrect, rgnSrc->rects, rgnDst->numRects * sizeof(RECT));
rgnDst->rects = xrect;
} else
return FALSE;
}
else if ((rect->left >= rect->right) ||
(rect->top >= rect->bottom) ||
!EXTENTCHECK(rect, &rgnSrc->extents))
{
empty:
if( !rgnDst->rects )
{
rgnDst->rects = HeapAlloc(GetProcessHeap(), 0, RGN_DEFAULT_RECTS * sizeof( RECT ));
if( rgnDst->rects )
rgnDst->size = RGN_DEFAULT_RECTS;
else
return FALSE;
}
TRACE("cropped to empty!\n");
EMPTY_REGION(rgnDst);
}
else /* region box and clipping rect appear to intersect */
{
RECT *lpr;
INT i, j, clipa, clipb;
INT left = rgnSrc->extents.right + off->x;
INT right = rgnSrc->extents.left + off->x;
for( clipa = 0; rgnSrc->rects[clipa].bottom <= rect->top; clipa++ )
; /* skip bands above the clipping rectangle */
for( clipb = clipa; clipb < rgnSrc->numRects; clipb++ )
if( rgnSrc->rects[clipb].top >= rect->bottom )
break; /* and below it */
/* clipa - index of the first rect in the first intersecting band
* clipb - index of the last rect in the last intersecting band
*/
if((rgnDst != rgnSrc) && (rgnDst->size < (i = (clipb - clipa))))
{
rgnDst->rects = HeapReAlloc( GetProcessHeap(), 0,
rgnDst->rects, i * sizeof(RECT));
if( !rgnDst->rects ) return FALSE;
rgnDst->size = i;
}
if( TRACE_ON(region) )
{
REGION_DumpRegion( rgnSrc );
TRACE("\tclipa = %i, clipb = %i\n", clipa, clipb );
}
for( i = clipa, j = 0; i < clipb ; i++ )
{
/* i - src index, j - dst index, j is always <= i for obvious reasons */
lpr = rgnSrc->rects + i;
if( lpr->left < rect->right && lpr->right > rect->left )
{
rgnDst->rects[j].top = lpr->top + off->y;
rgnDst->rects[j].bottom = lpr->bottom + off->y;
rgnDst->rects[j].left = ((lpr->left > rect->left) ? lpr->left : rect->left) + off->x;
rgnDst->rects[j].right = ((lpr->right < rect->right) ? lpr->right : rect->right) + off->x;
if( rgnDst->rects[j].left < left ) left = rgnDst->rects[j].left;
if( rgnDst->rects[j].right > right ) right = rgnDst->rects[j].right;
j++;
}
}
if( j == 0 ) goto empty;
rgnDst->extents.left = left;
rgnDst->extents.right = right;
left = rect->top + off->y;
right = rect->bottom + off->y;
rgnDst->numRects = j--;
for( i = 0; i <= j; i++ ) /* fixup top band */
if( rgnDst->rects[i].top < left )
rgnDst->rects[i].top = left;
else
break;
for( i = j; i >= 0; i-- ) /* fixup bottom band */
if( rgnDst->rects[i].bottom > right )
rgnDst->rects[i].bottom = right;
else
break;
rgnDst->extents.top = rgnDst->rects[0].top;
rgnDst->extents.bottom = rgnDst->rects[j].bottom;
if( TRACE_ON(region) )
{
TRACE("result:\n");
REGION_DumpRegion( rgnDst );
}
}
return TRUE;
}
/***********************************************************************
* REGION_CropRgn
*
*
* hSrc: Region to crop and offset.
* lpRect: Clipping rectangle. Can be NULL (no clipping).
* lpPt: Points to offset the cropped region. Can be NULL (no offset).
*
* hDst: Region to hold the result (a new region is created if it's 0).
* Allowed to be the same region as hSrc in which case everything
* will be done in place, with no memory reallocations.
*
* Returns: hDst if success, 0 otherwise.
*/
HRGN REGION_CropRgn( HRGN hDst, HRGN hSrc, const RECT *lpRect, const POINT *lpPt )
{
/* Optimization of the following generic code:
HRGN h;
if( lpRect )
h = CreateRectRgn( lpRect->left, lpRect->top, lpRect->right, lpRect->bottom );
else
h = CreateRectRgn( 0, 0, 0, 0 );
if( hDst == 0 ) hDst = h;
if( lpRect )
CombineRgn( hDst, hSrc, h, RGN_AND );
else
CombineRgn( hDst, hSrc, 0, RGN_COPY );
if( lpPt )
OffsetRgn( hDst, lpPt->x, lpPt->y );
if( hDst != h )
DeleteObject( h );
return hDst;
*/
RGNOBJ *objSrc = (RGNOBJ *) GDI_GetObjPtr( hSrc, REGION_MAGIC );
if(objSrc)
{
RGNOBJ *objDst;
WINEREGION *rgnDst;
if( hDst )
{
if (!(objDst = (RGNOBJ *) GDI_GetObjPtr( hDst, REGION_MAGIC )))
{
hDst = 0;
goto done;
}
rgnDst = objDst->rgn;
}
else
{
if ((rgnDst = HeapAlloc(GetProcessHeap(), 0, sizeof( WINEREGION ))))
{
rgnDst->size = rgnDst->numRects = 0;
rgnDst->rects = NULL; /* back end will allocate exact number */
}
}
if( rgnDst )
{
POINT pt = { 0, 0 };
if( !lpPt ) lpPt = &pt;
if( lpRect )
TRACE("src %p -> dst %p (%i,%i)-(%i,%i) by (%li,%li)\n", objSrc->rgn, rgnDst,
lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, lpPt->x, lpPt->y );
else
TRACE("src %p -> dst %p by (%li,%li)\n", objSrc->rgn, rgnDst, lpPt->x, lpPt->y );
if( REGION_CropAndOffsetRegion( lpPt, lpRect, objSrc->rgn, rgnDst ) == FALSE )
{
if( hDst ) /* existing rgn */
{
GDI_ReleaseObj(hDst);
hDst = 0;
goto done;
}
goto fail;
}
else if( hDst == 0 )
{
if (!(objDst = GDI_AllocObject( sizeof(RGNOBJ), REGION_MAGIC,
&hDst, &region_funcs )))
{
fail:
if( rgnDst->rects )
HeapFree( GetProcessHeap(), 0, rgnDst->rects );
HeapFree( GetProcessHeap(), 0, rgnDst );
goto done;
}
objDst->rgn = rgnDst;
}
GDI_ReleaseObj(hDst);
}
else hDst = 0;
done:
GDI_ReleaseObj(hSrc);
return hDst;
}
return 0;
}
/***********************************************************************
* GetMetaRgn (GDI32.@)
......
......@@ -62,7 +62,7 @@
#include "winerror.h"
#include "msvcrt/excpt.h"
WINE_DECLARE_DEBUG_CHANNEL(cursor);
WINE_DEFAULT_DEBUG_CHANNEL(cursor);
WINE_DECLARE_DEBUG_CHANNEL(icon);
WINE_DECLARE_DEBUG_CHANNEL(resource);
......@@ -123,6 +123,37 @@ static void *map_fileW( LPCWSTR name )
}
/***********************************************************************
* get_bitmap_width_bytes
*
* Return number of bytes taken by a scanline of 16-bit aligned Windows DDB
* data.
*/
static int get_bitmap_width_bytes( int width, int bpp )
{
switch(bpp)
{
case 1:
return 2 * ((width+15) / 16);
case 4:
return 2 * ((width+3) / 4);
case 24:
width *= 3;
/* fall through */
case 8:
return width + (width & 1);
case 16:
case 15:
return width * 2;
case 32:
return width * 4;
default:
WARN("Unknown depth %d, please report.\n", bpp );
}
return -1;
}
/**********************************************************************
* CURSORICON_FindSharedIcon
*/
......@@ -1157,9 +1188,9 @@ HGLOBAL16 WINAPI CreateCursorIconIndirect16( HINSTANCE16 hInstance,
hInstance = GetExePtr( hInstance ); /* Make it a module handle */
if (!lpXORbits || !lpANDbits || info->bPlanes != 1) return 0;
info->nWidthBytes = BITMAP_GetWidthBytes(info->nWidth,info->bBitsPerPixel);
info->nWidthBytes = get_bitmap_width_bytes(info->nWidth,info->bBitsPerPixel);
sizeXor = info->nHeight * info->nWidthBytes;
sizeAnd = info->nHeight * BITMAP_GetWidthBytes( info->nWidth, 1 );
sizeAnd = info->nHeight * get_bitmap_width_bytes( info->nWidth, 1 );
if (!(handle = GlobalAlloc16( GMEM_MOVEABLE,
sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
return 0;
......@@ -1301,7 +1332,7 @@ BOOL WINAPI DrawIcon( HDC hdc, INT x, INT y, HICON hIcon )
(char *)(ptr+1) );
hXorBits = CreateBitmap( ptr->nWidth, ptr->nHeight, ptr->bPlanes,
ptr->bBitsPerPixel, (char *)(ptr + 1)
+ ptr->nHeight * BITMAP_GetWidthBytes(ptr->nWidth,1) );
+ ptr->nHeight * get_bitmap_width_bytes(ptr->nWidth,1) );
oldFg = SetTextColor( hdc, RGB(0,0,0) );
oldBg = SetBkColor( hdc, RGB(255,255,255) );
......@@ -1345,7 +1376,7 @@ DWORD WINAPI DumpIcon16( SEGPTR pInfo, WORD *lpLen,
if (!info) return 0;
sizeXor = info->nHeight * info->nWidthBytes;
sizeAnd = info->nHeight * BITMAP_GetWidthBytes( info->nWidth, 1 );
sizeAnd = info->nHeight * get_bitmap_width_bytes( info->nWidth, 1 );
if (lpAndBits) *lpAndBits = pInfo + sizeof(CURSORICONINFO);
if (lpXorBits) *lpXorBits = pInfo + sizeof(CURSORICONINFO) + sizeAnd;
if (lpLen) *lpLen = sizeof(CURSORICONINFO) + sizeAnd + sizeXor;
......@@ -1737,7 +1768,7 @@ BOOL WINAPI GetIconInfo(HICON hIcon,PICONINFO iconinfo) {
ciconinfo->bPlanes, ciconinfo->bBitsPerPixel,
(char *)(ciconinfo + 1)
+ ciconinfo->nHeight *
BITMAP_GetWidthBytes (ciconinfo->nWidth,1) );
get_bitmap_width_bytes (ciconinfo->nWidth,1) );
iconinfo->hbmMask = CreateBitmap ( ciconinfo->nWidth, ciconinfo->nHeight,
1, 1, (char *)(ciconinfo + 1));
......@@ -1900,7 +1931,7 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon,
ptr->bPlanes, ptr->bBitsPerPixel,
(char *)(ptr + 1)
+ ptr->nHeight *
BITMAP_GetWidthBytes(ptr->nWidth,1) );
get_bitmap_width_bytes(ptr->nWidth,1) );
hAndBits = CreateBitmap ( ptr->nWidth, ptr->nHeight,
1, 1, (char *)(ptr+1) );
oldFg = SetTextColor( hdc, RGB(0,0,0) );
......@@ -2224,7 +2255,21 @@ HICON WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx,
switch (type)
{
case IMAGE_BITMAP:
return BITMAP_CopyBitmap(hnd);
{
HBITMAP res;
BITMAP bm;
if (!GetObjectW( hnd, sizeof(bm), &bm )) return 0;
bm.bmBits = NULL;
if ((res = CreateBitmapIndirect(&bm)))
{
char *buf = HeapAlloc( GetProcessHeap(), 0, bm.bmWidthBytes * bm.bmHeight );
GetBitmapBits( hnd, bm.bmWidthBytes * bm.bmHeight, buf );
SetBitmapBits( res, bm.bmWidthBytes * bm.bmHeight, buf );
HeapFree( GetProcessHeap(), 0, buf );
}
return res;
}
case IMAGE_ICON:
return CURSORICON_ExtCopy(hnd,type, desiredx, desiredy, flags);
case IMAGE_CURSOR:
......
......@@ -93,6 +93,28 @@ static void add_paint_count( HWND hwnd, int incr )
/***********************************************************************
* crop_rgn
*
* hSrc: Region to crop.
* lpRect: Clipping rectangle.
*
* hDst: Region to hold the result (a new region is created if it's 0).
* Allowed to be the same region as hSrc in which case everything
* will be done in place, with no memory reallocations.
*
* Returns: hDst if success, 0 otherwise.
*/
static HRGN crop_rgn( HRGN hDst, HRGN hSrc, const RECT *rect )
{
HRGN h = CreateRectRgnIndirect( rect );
if (hDst == 0) hDst = h;
CombineRgn( hDst, hSrc, h, RGN_AND );
if (hDst != h) DeleteObject( h );
return hDst;
}
/***********************************************************************
* WIN_HaveToDelayNCPAINT
*
* Currently, in the Wine painting mechanism, the WM_NCPAINT message
......@@ -188,7 +210,10 @@ static HRGN WIN_UpdateNCRgn(WND* wnd, HRGN hRgn, UINT uncFlags )
{
wnd->flags &= ~WIN_NEEDS_NCPAINT;
if( wnd->hrgnUpdate > 1 )
hrgnRet = REGION_CropRgn( hRgn, wnd->hrgnUpdate, NULL, NULL );
{
CombineRgn( hRgn, wnd->hrgnUpdate, 0, RGN_COPY );
hrgnRet = hRgn;
}
else
{
hrgnRet = wnd->hrgnUpdate;
......@@ -229,7 +254,7 @@ static HRGN WIN_UpdateNCRgn(WND* wnd, HRGN hRgn, UINT uncFlags )
* case that places a valid region handle in hClip */
hClip = wnd->hrgnUpdate;
wnd->hrgnUpdate = REGION_CropRgn( hRgn, hClip, &r, NULL );
wnd->hrgnUpdate = crop_rgn( hRgn, hClip, &r );
if( uncFlags & UNC_REGION ) hrgnRet = hClip;
}
......@@ -266,7 +291,10 @@ static HRGN WIN_UpdateNCRgn(WND* wnd, HRGN hRgn, UINT uncFlags )
{
copyrgn:
if( uncFlags & UNC_REGION )
hrgnRet = REGION_CropRgn( hRgn, wnd->hrgnUpdate, NULL, NULL );
{
CombineRgn( hRgn, wnd->hrgnUpdate, 0, RGN_COPY );
hrgnRet = hRgn;
}
}
else
if( wnd->hrgnUpdate == 1 && (uncFlags & UNC_UPDATE) )
......@@ -406,9 +434,9 @@ static void RDW_UpdateRgns( WND* wndPtr, HRGN hRgn, UINT flags, BOOL firstRecurs
CombineRgn( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate, hRgn, RGN_OR );
/* fall through */
case 0:
wndPtr->hrgnUpdate = REGION_CropRgn( wndPtr->hrgnUpdate,
wndPtr->hrgnUpdate = crop_rgn( wndPtr->hrgnUpdate,
wndPtr->hrgnUpdate ? wndPtr->hrgnUpdate : hRgn,
&r, NULL );
&r );
if( !bHadOne )
{
GetRgnBox( wndPtr->hrgnUpdate, &r );
......@@ -735,9 +763,16 @@ BOOL WINAPI RedrawWindow( HWND hwnd, const RECT *rectUpdate,
if( hrgnUpdate )
{
if( wndPtr->hrgnUpdate )
hRgn = REGION_CropRgn( 0, hrgnUpdate, NULL, &pt );
{
hRgn = CreateRectRgn( 0, 0, 0, 0 );
CombineRgn( hRgn, hrgnUpdate, 0, RGN_COPY );
OffsetRgn( hRgn, pt.x, pt.y );
}
else
wndPtr->hrgnUpdate = REGION_CropRgn( 0, hrgnUpdate, &r, &pt );
{
wndPtr->hrgnUpdate = crop_rgn( 0, hrgnUpdate, &r );
OffsetRgn( wndPtr->hrgnUpdate, pt.x, pt.y );
}
}
else if( rectUpdate )
{
......@@ -770,7 +805,8 @@ BOOL WINAPI RedrawWindow( HWND hwnd, const RECT *rectUpdate,
/* In this we cannot leave with zero hRgn */
if( hrgnUpdate )
{
hRgn = REGION_CropRgn( hRgn, hrgnUpdate, &r, &pt );
hRgn = crop_rgn( hRgn, hrgnUpdate, &r );
OffsetRgn( hRgn, pt.x, pt.y );
GetRgnBox( hRgn, &r2 );
if( IsRectEmpty( &r2 ) ) goto END;
}
......
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