mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 12:54:13 +00:00
gdi32: Specify an initial allocation size for paths to avoid some reallocations.
This commit is contained in:
parent
c2491ccc2d
commit
79691e7afa
1 changed files with 11 additions and 10 deletions
|
@ -125,7 +125,7 @@ void free_gdi_path( struct gdi_path *path )
|
||||||
HeapFree( GetProcessHeap(), 0, path );
|
HeapFree( GetProcessHeap(), 0, path );
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct gdi_path *alloc_gdi_path(void)
|
static struct gdi_path *alloc_gdi_path( int count )
|
||||||
{
|
{
|
||||||
struct gdi_path *path = HeapAlloc( GetProcessHeap(), 0, sizeof(*path) );
|
struct gdi_path *path = HeapAlloc( GetProcessHeap(), 0, sizeof(*path) );
|
||||||
|
|
||||||
|
@ -134,8 +134,9 @@ static struct gdi_path *alloc_gdi_path(void)
|
||||||
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
|
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
path->points = HeapAlloc( GetProcessHeap(), 0, NUM_ENTRIES_INITIAL * sizeof(*path->points) );
|
count = max( NUM_ENTRIES_INITIAL, count );
|
||||||
path->flags = HeapAlloc( GetProcessHeap(), 0, NUM_ENTRIES_INITIAL * sizeof(*path->flags) );
|
path->points = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*path->points) );
|
||||||
|
path->flags = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*path->flags) );
|
||||||
if (!path->points || !path->flags)
|
if (!path->points || !path->flags)
|
||||||
{
|
{
|
||||||
free_gdi_path( path );
|
free_gdi_path( path );
|
||||||
|
@ -143,7 +144,7 @@ static struct gdi_path *alloc_gdi_path(void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
path->count = 0;
|
path->count = 0;
|
||||||
path->allocated = NUM_ENTRIES_INITIAL;
|
path->allocated = count;
|
||||||
path->newStroke = TRUE;
|
path->newStroke = TRUE;
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -352,7 +353,7 @@ static struct gdi_path *PATH_FlattenPath(const struct gdi_path *pPath)
|
||||||
struct gdi_path *new_path;
|
struct gdi_path *new_path;
|
||||||
INT srcpt;
|
INT srcpt;
|
||||||
|
|
||||||
if (!(new_path = alloc_gdi_path())) return NULL;
|
if (!(new_path = alloc_gdi_path( pPath->count ))) return NULL;
|
||||||
|
|
||||||
for(srcpt = 0; srcpt < pPath->count; srcpt++) {
|
for(srcpt = 0; srcpt < pPath->count; srcpt++) {
|
||||||
switch(pPath->flags[srcpt] & ~PT_CLOSEFIGURE) {
|
switch(pPath->flags[srcpt] & ~PT_CLOSEFIGURE) {
|
||||||
|
@ -1810,7 +1811,7 @@ static struct gdi_path *PATH_WidenPath(DC *dc)
|
||||||
else
|
else
|
||||||
pStrokes = HeapReAlloc(GetProcessHeap(), 0, pStrokes, numStrokes * sizeof(*pStrokes));
|
pStrokes = HeapReAlloc(GetProcessHeap(), 0, pStrokes, numStrokes * sizeof(*pStrokes));
|
||||||
if(!pStrokes) return NULL;
|
if(!pStrokes) return NULL;
|
||||||
pStrokes[numStrokes - 1] = alloc_gdi_path();
|
pStrokes[numStrokes - 1] = alloc_gdi_path(0);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case PT_LINETO:
|
case PT_LINETO:
|
||||||
case (PT_LINETO | PT_CLOSEFIGURE):
|
case (PT_LINETO | PT_CLOSEFIGURE):
|
||||||
|
@ -1828,11 +1829,11 @@ static struct gdi_path *PATH_WidenPath(DC *dc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pNewPath = alloc_gdi_path();
|
pNewPath = alloc_gdi_path( flat_path->count );
|
||||||
|
|
||||||
for(i = 0; i < numStrokes; i++) {
|
for(i = 0; i < numStrokes; i++) {
|
||||||
pUpPath = alloc_gdi_path();
|
pUpPath = alloc_gdi_path( pStrokes[i]->count );
|
||||||
pDownPath = alloc_gdi_path();
|
pDownPath = alloc_gdi_path( pStrokes[i]->count );
|
||||||
|
|
||||||
for(j = 0; j < pStrokes[i]->count; j++) {
|
for(j = 0; j < pStrokes[i]->count; j++) {
|
||||||
/* Beginning or end of the path if not closed */
|
/* Beginning or end of the path if not closed */
|
||||||
|
@ -2094,7 +2095,7 @@ BOOL nulldrv_BeginPath( PHYSDEV dev )
|
||||||
{
|
{
|
||||||
DC *dc = get_nulldrv_dc( dev );
|
DC *dc = get_nulldrv_dc( dev );
|
||||||
struct path_physdev *physdev;
|
struct path_physdev *physdev;
|
||||||
struct gdi_path *path = alloc_gdi_path();
|
struct gdi_path *path = alloc_gdi_path(0);
|
||||||
|
|
||||||
if (!path) return FALSE;
|
if (!path) return FALSE;
|
||||||
if (!path_driver.pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL ))
|
if (!path_driver.pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL ))
|
||||||
|
|
Loading…
Reference in a new issue