Commit 22e40449 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Don't use PHYSDEV for metafile helpers.

parent a3368089
......@@ -257,12 +257,11 @@ BOOL METADC_ExtFloodFill( HDC hdc, INT x, INT y, COLORREF color, UINT fill_type
/******************************************************************
* MFDRV_CreateRegion
* metadc_create_region
*
* For explanation of the format of the record see MF_Play_MetaCreateRegion in
* objects/metafile.c
* For explanation of the format of the record see MF_Play_MetaCreateRegion
*/
static INT16 MFDRV_CreateRegion(PHYSDEV dev, HRGN hrgn)
static INT16 metadc_create_region( struct metadc *metadc, HRGN hrgn )
{
DWORD len;
METARECORD *mr;
......@@ -340,7 +339,7 @@ static INT16 MFDRV_CreateRegion(PHYSDEV dev, HRGN hrgn)
mr->rdParm[10] = rgndata->rdh.rcBound.bottom;
mr->rdFunction = META_CREATEREGION;
mr->rdSize = Param - (WORD *)mr;
ret = metadc_record( dev->hdc, mr, mr->rdSize * 2 );
ret = metadc_write_record( metadc, mr, mr->rdSize * 2 );
HeapFree( GetProcessHeap(), 0, mr );
HeapFree( GetProcessHeap(), 0, rgndata );
if(!ret)
......@@ -348,7 +347,7 @@ static INT16 MFDRV_CreateRegion(PHYSDEV dev, HRGN hrgn)
WARN("MFDRV_WriteRecord failed\n");
return -1;
}
return MFDRV_AddHandle( dev, hrgn );
return metadc_add_handle( metadc, hrgn );
}
......@@ -360,7 +359,7 @@ BOOL METADC_PaintRgn( HDC hdc, HRGN hrgn )
struct metadc *mf;
INT16 index;
if (!(mf = get_metadc_ptr( hdc ))) return FALSE;
index = MFDRV_CreateRegion( &mf->dev, hrgn );
index = metadc_create_region( mf, hrgn );
if(index == -1)
return FALSE;
return metadc_param1( hdc, META_PAINTREGION, index );
......@@ -375,7 +374,7 @@ BOOL METADC_InvertRgn( HDC hdc, HRGN hrgn )
struct metadc *mf;
INT16 index;
if (!(mf = get_metadc_ptr( hdc ))) return FALSE;
index = MFDRV_CreateRegion( &mf->dev, hrgn );
index = metadc_create_region( mf, hrgn );
if(index == -1)
return FALSE;
return metadc_param1( hdc, META_INVERTREGION, index );
......@@ -392,10 +391,10 @@ BOOL METADC_FillRgn( HDC hdc, HRGN hrgn, HBRUSH hbrush )
if (!(mf = get_metadc_ptr( hdc ))) return FALSE;
iRgn = MFDRV_CreateRegion( &mf->dev, hrgn );
iRgn = metadc_create_region( mf, hrgn );
if(iRgn == -1)
return FALSE;
iBrush = MFDRV_CreateBrushIndirect( &mf->dev, hbrush );
iBrush = metadc_create_brush( mf, hbrush );
if(!iBrush)
return FALSE;
return metadc_param2( hdc, META_FILLREGION, iRgn, iBrush );
......@@ -418,10 +417,10 @@ BOOL METADC_FrameRgn( HDC hdc, HRGN hrgn, HBRUSH hbrush, INT x, INT y )
INT16 iRgn, iBrush;
if (!(mf = get_metadc_ptr( hdc ))) return FALSE;
iRgn = MFDRV_CreateRegion( &mf->dev, hrgn );
iRgn = metadc_create_region( mf, hrgn );
if(iRgn == -1)
return FALSE;
iBrush = MFDRV_CreateBrushIndirect( &mf->dev, hbrush );
iBrush = metadc_create_brush( mf, hbrush );
if(!iBrush)
return FALSE;
return metadc_param4( hdc, META_FRAMEREGION, iRgn, iBrush, x, y );
......@@ -440,11 +439,11 @@ BOOL METADC_ExtSelectClipRgn( HDC hdc, HRGN hrgn, INT mode )
if (!(metadc = get_metadc_ptr( hdc ))) return FALSE;
if (mode != RGN_COPY) return ERROR;
if (!hrgn) return NULLREGION;
iRgn = MFDRV_CreateRegion( &metadc->dev, hrgn );
iRgn = metadc_create_region( metadc, hrgn );
if(iRgn == -1) return ERROR;
ret = metadc_param1( hdc, META_SELECTOBJECT, iRgn ) ? NULLREGION : ERROR;
metadc_param1( hdc, META_DELETEOBJECT, iRgn );
MFDRV_RemoveHandle( &metadc->dev, iRgn );
metadc_remove_handle( metadc, iRgn );
return ret;
}
......
......@@ -46,9 +46,9 @@ struct metadc
#define HANDLE_LIST_INC 20
extern UINT MFDRV_AddHandle( PHYSDEV dev, HGDIOBJ obj ) DECLSPEC_HIDDEN;
extern BOOL MFDRV_RemoveHandle( PHYSDEV dev, UINT index ) DECLSPEC_HIDDEN;
extern INT16 MFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush ) DECLSPEC_HIDDEN;
extern UINT metadc_add_handle( struct metadc *metadc, HGDIOBJ obj ) DECLSPEC_HIDDEN;
extern BOOL metadc_remove_handle( struct metadc *metadc, UINT index ) DECLSPEC_HIDDEN;
extern INT16 metadc_create_brush( struct metadc *metadc, HBRUSH brush ) DECLSPEC_HIDDEN;
extern struct metadc *get_metadc_ptr( HDC hdc ) DECLSPEC_HIDDEN;
extern BOOL metadc_param0( HDC hdc, short func ) DECLSPEC_HIDDEN;
......
......@@ -34,59 +34,56 @@
WINE_DEFAULT_DEBUG_CHANNEL(metafile);
/******************************************************************
* MFDRV_AddHandle
* metadc_add_handle
*/
UINT MFDRV_AddHandle( PHYSDEV dev, HGDIOBJ obj )
UINT metadc_add_handle( struct metadc *metadc, HGDIOBJ obj )
{
struct metadc *physDev = (struct metadc *)dev;
UINT16 index;
for(index = 0; index < physDev->handles_size; index++)
if(physDev->handles[index] == 0) break;
if(index == physDev->handles_size) {
physDev->handles_size += HANDLE_LIST_INC;
physDev->handles = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
physDev->handles,
physDev->handles_size * sizeof(physDev->handles[0]));
for(index = 0; index < metadc->handles_size; index++)
if(metadc->handles[index] == 0) break;
if(index == metadc->handles_size) {
metadc->handles_size += HANDLE_LIST_INC;
metadc->handles = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
metadc->handles,
metadc->handles_size * sizeof(metadc->handles[0]));
}
physDev->handles[index] = get_full_gdi_handle( obj );
metadc->handles[index] = get_full_gdi_handle( obj );
physDev->cur_handles++;
if(physDev->cur_handles > physDev->mh->mtNoObjects)
physDev->mh->mtNoObjects++;
metadc->cur_handles++;
if(metadc->cur_handles > metadc->mh->mtNoObjects)
metadc->mh->mtNoObjects++;
return index ; /* index 0 is not reserved for metafiles */
}
/******************************************************************
* MFDRV_RemoveHandle
* metadc_remove_handle
*/
BOOL MFDRV_RemoveHandle( PHYSDEV dev, UINT index )
BOOL metadc_remove_handle( struct metadc *metadc, UINT index )
{
struct metadc *physDev = (struct metadc *)dev;
BOOL ret = FALSE;
if (index < physDev->handles_size && physDev->handles[index])
if (index < metadc->handles_size && metadc->handles[index])
{
physDev->handles[index] = 0;
physDev->cur_handles--;
metadc->handles[index] = 0;
metadc->cur_handles--;
ret = TRUE;
}
return ret;
}
/******************************************************************
* MFDRV_FindObject
* metadc_find_object
*/
static INT16 MFDRV_FindObject( PHYSDEV dev, HGDIOBJ obj )
static INT16 metadc_find_object( struct metadc *metadc, HGDIOBJ obj )
{
struct metadc *physDev = (struct metadc *)dev;
INT16 index;
for(index = 0; index < physDev->handles_size; index++)
if(physDev->handles[index] == obj) break;
for (index = 0; index < metadc->handles_size; index++)
if (metadc->handles[index] == obj) break;
if(index == physDev->handles_size) return -1;
if (index == metadc->handles_size) return -1;
return index ;
}
......@@ -101,7 +98,7 @@ void METADC_DeleteObject( HDC hdc, HGDIOBJ obj )
METARECORD mr;
INT16 index;
if ((index = MFDRV_FindObject( &metadc->dev, obj )) < 0) return;
if ((index = metadc_find_object( metadc, obj )) < 0) return;
if (obj == metadc->pen || obj == metadc->brush || obj == metadc->font)
{
WARN( "deleting selected object %p\n", obj );
......@@ -134,10 +131,9 @@ static BOOL metadc_select_object( HDC hdc, INT16 index)
/******************************************************************
* MFDRV_CreateBrushIndirect
* metadc_create_brush
*/
INT16 MFDRV_CreateBrushIndirect(PHYSDEV dev, HBRUSH hBrush )
INT16 metadc_create_brush( struct metadc *metadc, HBRUSH hBrush )
{
DWORD size;
METARECORD *mr;
......@@ -208,12 +204,12 @@ INT16 MFDRV_CreateBrushIndirect(PHYSDEV dev, HBRUSH hBrush )
FIXME("Unknown brush style %x\n", logbrush.lbStyle);
return 0;
}
r = metadc_record( dev->hdc, mr, mr->rdSize * 2 );
r = metadc_write_record( metadc, mr, mr->rdSize * 2 );
HeapFree(GetProcessHeap(), 0, mr);
if( !r )
return -1;
done:
return MFDRV_AddHandle( dev, hBrush );
return metadc_add_handle( metadc, hBrush );
}
......@@ -226,10 +222,10 @@ static HBRUSH METADC_SelectBrush( HDC hdc, HBRUSH hbrush )
INT16 index;
HBRUSH ret;
index = MFDRV_FindObject( &metadc->dev, hbrush );
index = metadc_find_object( metadc, hbrush );
if( index < 0 )
{
index = MFDRV_CreateBrushIndirect( &metadc->dev, hbrush );
index = metadc_create_brush( metadc, hbrush );
if( index < 0 )
return 0;
GDI_hdc_using_object( hbrush, hdc, METADC_DeleteObject );
......@@ -241,10 +237,9 @@ static HBRUSH METADC_SelectBrush( HDC hdc, HBRUSH hbrush )
}
/******************************************************************
* MFDRV_CreateFontIndirect
* metadc_create_font
*/
static UINT16 MFDRV_CreateFontIndirect(PHYSDEV dev, HFONT hFont, LOGFONTW *logfont)
static UINT16 metadc_create_font( struct metadc *metadc, HFONT hFont, LOGFONTW *logfont )
{
char buffer[sizeof(METARECORD) - 2 + sizeof(LOGFONT16)];
METARECORD *mr = (METARECORD *)&buffer;
......@@ -272,9 +267,9 @@ static UINT16 MFDRV_CreateFontIndirect(PHYSDEV dev, HFONT hFont, LOGFONTW *logfo
/* Zero pad the facename buffer, so that we don't write uninitialized data to disk */
memset(font16->lfFaceName + written, 0, LF_FACESIZE - written);
if (!metadc_record( dev->hdc, mr, mr->rdSize * 2))
if (!metadc_write_record( metadc, mr, mr->rdSize * 2 ))
return 0;
return MFDRV_AddHandle( dev, hFont );
return metadc_add_handle( metadc, hFont );
}
......@@ -288,12 +283,12 @@ static HFONT METADC_SelectFont( HDC hdc, HFONT hfont )
INT16 index;
HFONT ret;
index = MFDRV_FindObject( &metadc->dev, hfont );
index = metadc_find_object( metadc, hfont );
if( index < 0 )
{
if (!GetObjectW( hfont, sizeof(font), &font ))
return 0;
index = MFDRV_CreateFontIndirect( &metadc->dev, hfont, &font );
index = metadc_create_font( metadc, hfont, &font );
if( index < 0 )
return 0;
GDI_hdc_using_object( hfont, hdc, METADC_DeleteObject );
......@@ -305,9 +300,9 @@ static HFONT METADC_SelectFont( HDC hdc, HFONT hfont )
}
/******************************************************************
* MFDRV_CreatePenIndirect
* metadc_create_pen
*/
static UINT16 MFDRV_CreatePenIndirect(PHYSDEV dev, HPEN hPen, LOGPEN16 *logpen)
static UINT16 metadc_create_pen( struct metadc *metadc, HPEN hPen, LOGPEN16 *logpen )
{
char buffer[sizeof(METARECORD) - 2 + sizeof(*logpen)];
METARECORD *mr = (METARECORD *)&buffer;
......@@ -315,9 +310,9 @@ static UINT16 MFDRV_CreatePenIndirect(PHYSDEV dev, HPEN hPen, LOGPEN16 *logpen)
mr->rdSize = (sizeof(METARECORD) + sizeof(*logpen) - 2) / 2;
mr->rdFunction = META_CREATEPENINDIRECT;
memcpy(&(mr->rdParm), logpen, sizeof(*logpen));
if (!metadc_record( dev->hdc, mr, mr->rdSize * 2 ))
if (!metadc_write_record( metadc, mr, mr->rdSize * 2 ))
return 0;
return MFDRV_AddHandle( dev, hPen );
return metadc_add_handle( metadc, hPen );
}
......@@ -331,7 +326,7 @@ static HPEN METADC_SelectPen( HDC hdc, HPEN hpen )
INT16 index;
HPEN ret;
index = MFDRV_FindObject( &metadc->dev, hpen );
index = metadc_find_object( metadc, hpen );
if( index < 0 )
{
/* must be an extended pen */
......@@ -363,7 +358,7 @@ static HPEN METADC_SelectPen( HDC hdc, HPEN hpen )
HeapFree( GetProcessHeap(), 0, elp );
}
index = MFDRV_CreatePenIndirect( &metadc->dev, hpen, &logpen );
index = metadc_create_pen( metadc, hpen, &logpen );
if( index < 0 )
return 0;
GDI_hdc_using_object( hpen, hdc, METADC_DeleteObject );
......@@ -378,9 +373,10 @@ static HPEN METADC_SelectPen( HDC hdc, HPEN hpen )
/******************************************************************
* MFDRV_CreatePalette
* metadc_create_palette
*/
static BOOL MFDRV_CreatePalette(PHYSDEV dev, HPALETTE hPalette, LOGPALETTE* logPalette, int sizeofPalette)
static BOOL metadc_create_palette( struct metadc *metadc, HPALETTE hPalette, LOGPALETTE *logPalette,
int sizeofPalette )
{
int index;
BOOL ret;
......@@ -390,7 +386,7 @@ static BOOL MFDRV_CreatePalette(PHYSDEV dev, HPALETTE hPalette, LOGPALETTE* logP
mr->rdSize = (sizeof(METARECORD) + sizeofPalette - sizeof(WORD)) / sizeof(WORD);
mr->rdFunction = META_CREATEPALETTE;
memcpy(&(mr->rdParm), logPalette, sizeofPalette);
if (!metadc_record( dev->hdc, mr, mr->rdSize * sizeof(WORD) ))
if (!metadc_write_record( metadc, mr, mr->rdSize * sizeof(WORD) ))
{
HeapFree(GetProcessHeap(), 0, mr);
return FALSE;
......@@ -399,11 +395,11 @@ static BOOL MFDRV_CreatePalette(PHYSDEV dev, HPALETTE hPalette, LOGPALETTE* logP
mr->rdSize = sizeof(METARECORD) / sizeof(WORD);
mr->rdFunction = META_SELECTPALETTE;
if ((index = MFDRV_AddHandle( dev, hPalette )) == -1) ret = FALSE;
if ((index = metadc_add_handle( metadc, hPalette )) == -1) ret = FALSE;
else
{
*(mr->rdParm) = index;
ret = metadc_record( dev->hdc, mr, mr->rdSize * sizeof(WORD) );
ret = metadc_write_record( metadc, mr, mr->rdSize * sizeof(WORD) );
}
HeapFree(GetProcessHeap(), 0, mr);
return ret;
......@@ -438,7 +434,7 @@ BOOL METADC_SelectPalette( HDC hdc, HPALETTE palette )
GetPaletteEntries( palette, 0, wNumEntries, logPalette->palPalEntry );
ret = MFDRV_CreatePalette( &metadc->dev, palette, logPalette, sizeofPalette );
ret = metadc_create_palette( metadc, palette, logPalette, sizeofPalette );
HeapFree( GetProcessHeap(), 0, logPalette );
return ret;
......
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