gdi32: init_dib_info() can no longer fail, and no longer requires freeing.
This commit is contained in:
parent
d357392b8b
commit
cae4ef81e6
@ -881,7 +881,7 @@ DWORD dibdrv_GetImage( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *info,
|
|||||||
if (!bmp) return ERROR_INVALID_HANDLE;
|
if (!bmp) return ERROR_INVALID_HANDLE;
|
||||||
if (!init_dib_info_from_bitmapobj( &stand_alone, bmp, 0 ))
|
if (!init_dib_info_from_bitmapobj( &stand_alone, bmp, 0 ))
|
||||||
{
|
{
|
||||||
ret = ERROR_BAD_FORMAT;
|
ret = ERROR_OUTOFMEMORY;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
dib = &stand_alone;
|
dib = &stand_alone;
|
||||||
@ -909,12 +909,7 @@ DWORD dibdrv_GetImage( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *info,
|
|||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (hbitmap)
|
if (hbitmap) GDI_ReleaseObj( hbitmap );
|
||||||
{
|
|
||||||
if (dib) free_dib_info( dib );
|
|
||||||
GDI_ReleaseObj( hbitmap );
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -984,7 +979,7 @@ DWORD dibdrv_PutImage( PHYSDEV dev, HBITMAP hbitmap, HRGN clip, BITMAPINFO *info
|
|||||||
if (!bmp) return ERROR_INVALID_HANDLE;
|
if (!bmp) return ERROR_INVALID_HANDLE;
|
||||||
if (!init_dib_info_from_bitmapobj( &stand_alone, bmp, 0 ))
|
if (!init_dib_info_from_bitmapobj( &stand_alone, bmp, 0 ))
|
||||||
{
|
{
|
||||||
ret = ERROR_BAD_FORMAT;
|
ret = ERROR_OUTOFMEMORY;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
dib = &stand_alone;
|
dib = &stand_alone;
|
||||||
@ -1029,10 +1024,7 @@ DWORD dibdrv_PutImage( PHYSDEV dev, HBITMAP hbitmap, HRGN clip, BITMAPINFO *info
|
|||||||
ret = execute_rop( pdev, &dst->visrect, &src_dib, &src->visrect, clip, rop );
|
ret = execute_rop( pdev, &dst->visrect, &src_dib, &src->visrect, clip, rop );
|
||||||
}
|
}
|
||||||
|
|
||||||
free_dib_info( &src_dib );
|
|
||||||
|
|
||||||
if (saved_clip) restore_clipping_region( pdev, saved_clip );
|
if (saved_clip) restore_clipping_region( pdev, saved_clip );
|
||||||
|
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
update_format:
|
update_format:
|
||||||
@ -1042,12 +1034,7 @@ update_format:
|
|||||||
ret = ERROR_BAD_FORMAT;
|
ret = ERROR_BAD_FORMAT;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (hbitmap)
|
if (hbitmap) GDI_ReleaseObj( hbitmap );
|
||||||
{
|
|
||||||
if (dib) free_dib_info( dib );
|
|
||||||
GDI_ReleaseObj( hbitmap );
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1059,7 +1046,6 @@ DWORD dibdrv_BlendImage( PHYSDEV dev, BITMAPINFO *info, const struct gdi_image_b
|
|||||||
{
|
{
|
||||||
dibdrv_physdev *pdev = get_dibdrv_pdev( dev );
|
dibdrv_physdev *pdev = get_dibdrv_pdev( dev );
|
||||||
dib_info src_dib;
|
dib_info src_dib;
|
||||||
DWORD ret;
|
|
||||||
|
|
||||||
TRACE( "%p %p\n", dev, info );
|
TRACE( "%p %p\n", dev, info );
|
||||||
|
|
||||||
@ -1077,11 +1063,7 @@ DWORD dibdrv_BlendImage( PHYSDEV dev, BITMAPINFO *info, const struct gdi_image_b
|
|||||||
|
|
||||||
init_dib_info_from_bitmapinfo( &src_dib, info, bits->ptr, 0 );
|
init_dib_info_from_bitmapinfo( &src_dib, info, bits->ptr, 0 );
|
||||||
src_dib.bits.is_copy = bits->is_copy;
|
src_dib.bits.is_copy = bits->is_copy;
|
||||||
|
return blend_rect( &pdev->dib, &dst->visrect, &src_dib, &src->visrect, pdev->clip, blend );
|
||||||
ret = blend_rect( &pdev->dib, &dst->visrect, &src_dib, &src->visrect, pdev->clip, blend );
|
|
||||||
|
|
||||||
free_dib_info( &src_dib );
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
update_format:
|
update_format:
|
||||||
if (blend.AlphaFormat & AC_SRC_ALPHA) /* source alpha requires A8R8G8B8 format */
|
if (blend.AlphaFormat & AC_SRC_ALPHA) /* source alpha requires A8R8G8B8 format */
|
||||||
@ -1220,10 +1202,8 @@ DWORD stretch_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bit
|
|||||||
dst->x, dst->y, dst->width, dst->height, wine_dbgstr_rect(&dst->visrect),
|
dst->x, dst->y, dst->width, dst->height, wine_dbgstr_rect(&dst->visrect),
|
||||||
src->x, src->y, src->width, src->height, wine_dbgstr_rect(&src->visrect));
|
src->x, src->y, src->width, src->height, wine_dbgstr_rect(&src->visrect));
|
||||||
|
|
||||||
if ( !init_dib_info_from_bitmapinfo( &src_dib, src_info, src_bits, 0 ) )
|
init_dib_info_from_bitmapinfo( &src_dib, src_info, src_bits, 0 );
|
||||||
return ERROR_BAD_FORMAT;
|
init_dib_info_from_bitmapinfo( &dst_dib, dst_info, dst_bits, 0 );
|
||||||
if ( !init_dib_info_from_bitmapinfo( &dst_dib, dst_info, dst_bits, 0 ) )
|
|
||||||
return ERROR_BAD_FORMAT;
|
|
||||||
|
|
||||||
/* v */
|
/* v */
|
||||||
ret = calc_1d_stretch_params( dst->y, dst->height, dst->visrect.top, dst->visrect.bottom,
|
ret = calc_1d_stretch_params( dst->y, dst->height, dst->visrect.top, dst->visrect.bottom,
|
||||||
@ -1324,10 +1304,8 @@ DWORD blend_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bitbl
|
|||||||
{
|
{
|
||||||
dib_info src_dib, dst_dib;
|
dib_info src_dib, dst_dib;
|
||||||
|
|
||||||
if (!init_dib_info_from_bitmapinfo( &src_dib, src_info, src_bits, 0 ) )
|
init_dib_info_from_bitmapinfo( &src_dib, src_info, src_bits, 0 );
|
||||||
return ERROR_BAD_FORMAT;
|
init_dib_info_from_bitmapinfo( &dst_dib, dst_info, dst_bits, default_color_table );
|
||||||
if (!init_dib_info_from_bitmapinfo( &dst_dib, dst_info, dst_bits, default_color_table ) )
|
|
||||||
return ERROR_BAD_FORMAT;
|
|
||||||
|
|
||||||
return blend_rect( &dst_dib, &dst->visrect, &src_dib, &src->visrect, NULL, blend );
|
return blend_rect( &dst_dib, &dst->visrect, &src_dib, &src->visrect, NULL, blend );
|
||||||
}
|
}
|
||||||
@ -1344,7 +1322,7 @@ DWORD gradient_bitmapinfo( const BITMAPINFO *info, void *bits, TRIVERTEX *vert_a
|
|||||||
DWORD ret = ERROR_SUCCESS;
|
DWORD ret = ERROR_SUCCESS;
|
||||||
HRGN tmp_rgn = 0;
|
HRGN tmp_rgn = 0;
|
||||||
|
|
||||||
if (!init_dib_info_from_bitmapinfo( &dib, info, bits, default_color_table )) return ERROR_BAD_FORMAT;
|
init_dib_info_from_bitmapinfo( &dib, info, bits, default_color_table );
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ static void init_bit_fields(dib_info *dib, const DWORD *bit_fields)
|
|||||||
calc_shift_and_len(dib->blue_mask, &dib->blue_shift, &dib->blue_len);
|
calc_shift_and_len(dib->blue_mask, &dib->blue_shift, &dib->blue_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL init_dib_info(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD *bit_fields,
|
static void init_dib_info(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD *bit_fields,
|
||||||
const RGBQUAD *color_table, void *bits, enum dib_info_flags flags)
|
const RGBQUAD *color_table, void *bits, enum dib_info_flags flags)
|
||||||
{
|
{
|
||||||
dib->bit_count = bi->biBitCount;
|
dib->bit_count = bi->biBitCount;
|
||||||
@ -134,10 +134,6 @@ static BOOL init_dib_info(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD
|
|||||||
case 1:
|
case 1:
|
||||||
dib->funcs = &funcs_1;
|
dib->funcs = &funcs_1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
TRACE("bpp %d not supported, will forward to graphics driver.\n", dib->bit_count);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (color_table && bi->biClrUsed)
|
if (color_table && bi->biClrUsed)
|
||||||
@ -155,14 +151,11 @@ static BOOL init_dib_info(dib_info *dib, const BITMAPINFOHEADER *bi, const DWORD
|
|||||||
dib->color_table = NULL;
|
dib->color_table = NULL;
|
||||||
dib->color_table_size = 0;
|
dib->color_table_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL init_dib_info_from_bitmapinfo(dib_info *dib, const BITMAPINFO *info, void *bits, enum dib_info_flags flags)
|
void init_dib_info_from_bitmapinfo(dib_info *dib, const BITMAPINFO *info, void *bits, enum dib_info_flags flags)
|
||||||
{
|
{
|
||||||
return init_dib_info( dib, &info->bmiHeader, (const DWORD *)info->bmiColors,
|
init_dib_info( dib, &info->bmiHeader, (const DWORD *)info->bmiColors, info->bmiColors, bits, flags );
|
||||||
info->bmiColors, bits, flags );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL init_dib_info_from_bitmapobj(dib_info *dib, BITMAPOBJ *bmp, enum dib_info_flags flags)
|
BOOL init_dib_info_from_bitmapobj(dib_info *dib, BITMAPOBJ *bmp, enum dib_info_flags flags)
|
||||||
@ -179,10 +172,11 @@ BOOL init_dib_info_from_bitmapobj(dib_info *dib, BITMAPOBJ *bmp, enum dib_info_f
|
|||||||
bmp->bitmap.bmHeight * width_bytes );
|
bmp->bitmap.bmHeight * width_bytes );
|
||||||
if (!bmp->bitmap.bmBits) return FALSE;
|
if (!bmp->bitmap.bmBits) return FALSE;
|
||||||
}
|
}
|
||||||
return init_dib_info_from_bitmapinfo( dib, &info, bmp->bitmap.bmBits, flags );
|
init_dib_info_from_bitmapinfo( dib, &info, bmp->bitmap.bmBits, flags );
|
||||||
}
|
}
|
||||||
return init_dib_info( dib, &bmp->dib->dsBmih, bmp->dib->dsBitfields,
|
else init_dib_info( dib, &bmp->dib->dsBmih, bmp->dib->dsBitfields,
|
||||||
bmp->color_table, bmp->dib->dsBm.bmBits, flags );
|
bmp->color_table, bmp->dib->dsBm.bmBits, flags );
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clear_dib_info(dib_info *dib)
|
static void clear_dib_info(dib_info *dib)
|
||||||
@ -227,10 +221,8 @@ DWORD convert_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bit
|
|||||||
dib_info src_dib, dst_dib;
|
dib_info src_dib, dst_dib;
|
||||||
DWORD ret;
|
DWORD ret;
|
||||||
|
|
||||||
if ( !init_dib_info_from_bitmapinfo( &src_dib, src_info, src_bits, default_color_table ) )
|
init_dib_info_from_bitmapinfo( &src_dib, src_info, src_bits, default_color_table );
|
||||||
return ERROR_BAD_FORMAT;
|
init_dib_info_from_bitmapinfo( &dst_dib, dst_info, dst_bits, default_color_table );
|
||||||
if ( !init_dib_info_from_bitmapinfo( &dst_dib, dst_info, dst_bits, default_color_table ) )
|
|
||||||
return ERROR_BAD_FORMAT;
|
|
||||||
|
|
||||||
__TRY
|
__TRY
|
||||||
{
|
{
|
||||||
@ -336,7 +328,6 @@ static BOOL dibdrv_DeleteDC( PHYSDEV dev )
|
|||||||
TRACE("(%p)\n", dev);
|
TRACE("(%p)\n", dev);
|
||||||
DeleteObject(pdev->clip);
|
DeleteObject(pdev->clip);
|
||||||
free_pattern_brush(pdev);
|
free_pattern_brush(pdev);
|
||||||
free_dib_info(&pdev->dib);
|
|
||||||
HeapFree( GetProcessHeap(), 0, pdev );
|
HeapFree( GetProcessHeap(), 0, pdev );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -365,15 +356,19 @@ static HBITMAP dibdrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
|
|||||||
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSelectBitmap );
|
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSelectBitmap );
|
||||||
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
|
||||||
BITMAPOBJ *bmp = GDI_GetObjPtr( bitmap, OBJ_BITMAP );
|
BITMAPOBJ *bmp = GDI_GetObjPtr( bitmap, OBJ_BITMAP );
|
||||||
|
dib_info dib;
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", dev, bitmap);
|
TRACE("(%p, %p)\n", dev, bitmap);
|
||||||
|
|
||||||
if (!bmp) return 0;
|
if (!bmp) return 0;
|
||||||
|
|
||||||
free_dib_info(&pdev->dib);
|
if(!init_dib_info_from_bitmapobj(&dib, bmp, default_color_table))
|
||||||
|
{
|
||||||
|
GDI_ReleaseObj( bitmap );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pdev->dib = dib;
|
||||||
pdev->defer = 0;
|
pdev->defer = 0;
|
||||||
if(!init_dib_info_from_bitmapobj(&pdev->dib, bmp, default_color_table))
|
|
||||||
pdev->defer |= DEFER_FORMAT;
|
|
||||||
|
|
||||||
GDI_ReleaseObj( bitmap );
|
GDI_ReleaseObj( bitmap );
|
||||||
|
|
||||||
return next->funcs->pSelectBitmap( next, bitmap );
|
return next->funcs->pSelectBitmap( next, bitmap );
|
||||||
|
@ -111,7 +111,6 @@ typedef struct dibdrv_physdev
|
|||||||
struct intensity_range glyph_intensities[17];
|
struct intensity_range glyph_intensities[17];
|
||||||
} dibdrv_physdev;
|
} dibdrv_physdev;
|
||||||
|
|
||||||
#define DEFER_FORMAT 1
|
|
||||||
#define DEFER_PEN 2
|
#define DEFER_PEN 2
|
||||||
#define DEFER_BRUSH 4
|
#define DEFER_BRUSH 4
|
||||||
|
|
||||||
@ -224,8 +223,7 @@ extern void get_rop_codes(INT rop, struct rop_codes *codes) DECLSPEC_HIDDEN;
|
|||||||
extern void calc_and_xor_masks(INT rop, DWORD color, DWORD *and, DWORD *xor) DECLSPEC_HIDDEN;
|
extern void calc_and_xor_masks(INT rop, DWORD color, DWORD *and, DWORD *xor) DECLSPEC_HIDDEN;
|
||||||
extern void update_brush_rop( dibdrv_physdev *pdev, INT rop ) DECLSPEC_HIDDEN;
|
extern void update_brush_rop( dibdrv_physdev *pdev, INT rop ) DECLSPEC_HIDDEN;
|
||||||
extern void reset_dash_origin(dibdrv_physdev *pdev) DECLSPEC_HIDDEN;
|
extern void reset_dash_origin(dibdrv_physdev *pdev) DECLSPEC_HIDDEN;
|
||||||
extern BOOL init_dib_info_from_bitmapinfo(dib_info *dib, const BITMAPINFO *info, void *bits,
|
extern void init_dib_info_from_bitmapinfo(dib_info *dib, const BITMAPINFO *info, void *bits, enum dib_info_flags flags) DECLSPEC_HIDDEN;
|
||||||
enum dib_info_flags flags) DECLSPEC_HIDDEN;
|
|
||||||
extern BOOL init_dib_info_from_bitmapobj(dib_info *dib, BITMAPOBJ *bmp, enum dib_info_flags flags) DECLSPEC_HIDDEN;
|
extern BOOL init_dib_info_from_bitmapobj(dib_info *dib, BITMAPOBJ *bmp, enum dib_info_flags flags) DECLSPEC_HIDDEN;
|
||||||
extern void free_dib_info(dib_info *dib) DECLSPEC_HIDDEN;
|
extern void free_dib_info(dib_info *dib) DECLSPEC_HIDDEN;
|
||||||
extern void free_pattern_brush(dibdrv_physdev *pdev) DECLSPEC_HIDDEN;
|
extern void free_pattern_brush(dibdrv_physdev *pdev) DECLSPEC_HIDDEN;
|
||||||
@ -252,10 +250,10 @@ static inline int edge_coord( int y, int x1, int y1, int x2, int y2 )
|
|||||||
|
|
||||||
static inline BOOL defer_pen(dibdrv_physdev *pdev)
|
static inline BOOL defer_pen(dibdrv_physdev *pdev)
|
||||||
{
|
{
|
||||||
return pdev->defer & (DEFER_FORMAT | DEFER_PEN);
|
return pdev->defer & DEFER_PEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL defer_brush(dibdrv_physdev *pdev)
|
static inline BOOL defer_brush(dibdrv_physdev *pdev)
|
||||||
{
|
{
|
||||||
return pdev->defer & (DEFER_FORMAT | DEFER_BRUSH);
|
return pdev->defer & DEFER_BRUSH;
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ BOOL render_aa_text_bitmapinfo( HDC hdc, BITMAPINFO *info, struct gdi_image_bits
|
|||||||
|
|
||||||
assert( info->bmiHeader.biBitCount > 8 ); /* mono and indexed formats don't support anti-aliasing */
|
assert( info->bmiHeader.biBitCount > 8 ); /* mono and indexed formats don't support anti-aliasing */
|
||||||
|
|
||||||
if (!init_dib_info_from_bitmapinfo( &dib, info, bits->ptr, 0 )) return FALSE;
|
init_dib_info_from_bitmapinfo( &dib, info, bits->ptr, 0 );
|
||||||
|
|
||||||
fg = make_rgb_colorref( hdc, &dib, GetTextColor( hdc ), &got_pixel, &fg_pixel);
|
fg = make_rgb_colorref( hdc, &dib, GetTextColor( hdc ), &got_pixel, &fg_pixel);
|
||||||
if (!got_pixel) fg_pixel = dib.funcs->colorref_to_pixel( &dib, fg );
|
if (!got_pixel) fg_pixel = dib.funcs->colorref_to_pixel( &dib, fg );
|
||||||
@ -325,7 +325,6 @@ BOOL render_aa_text_bitmapinfo( HDC hdc, BITMAPINFO *info, struct gdi_image_bits
|
|||||||
y += metrics.gmCellIncY;
|
y += metrics.gmCellIncY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free_dib_info( &dib );
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1541,8 +1541,6 @@ static BOOL select_pattern_brush( dibdrv_physdev *pdev, BOOL *needs_reselect )
|
|||||||
|
|
||||||
pdev->brush_dib.funcs->convert_to(&pdev->brush_dib, &pattern, &rect);
|
pdev->brush_dib.funcs->convert_to(&pdev->brush_dib, &pattern, &rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
free_dib_info( &pattern );
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user