BITMAP_DeleteObject /* pDeleteObject */
};
+
+/***********************************************************************
+ * null driver fallback implementations
+ */
+
+LONG CDECL nulldrv_GetBitmapBits( HBITMAP bitmap, void *bits, LONG size )
+{
+ BITMAPOBJ *bmp = GDI_GetObjPtr( bitmap, OBJ_BITMAP );
+
+ if (bmp->bitmap.bmBits) memcpy( bits, bmp->bitmap.bmBits, size );
+ else memset( bits, 0, size );
+ GDI_ReleaseObj( bitmap );
+ return size;
+}
+
+LONG CDECL nulldrv_SetBitmapBits( HBITMAP bitmap, const void *bits, LONG size )
+{
+ BITMAPOBJ *bmp = GDI_GetObjPtr( bitmap, OBJ_BITMAP );
+
+ if (!bmp->bitmap.bmBits)
+ {
+ LONG total = bmp->bitmap.bmHeight * bmp->bitmap.bmWidthBytes; /* alloc enough for entire bitmap */
+ if (!(bmp->bitmap.bmBits = HeapAlloc( GetProcessHeap(), 0, total )))
+ {
+ GDI_ReleaseObj( bitmap );
+ return 0;
+ }
+ if (size < total) memset( (char *)bmp->bitmap.bmBits + size, 0, total - size );
+ }
+ memcpy( bmp->bitmap.bmBits, bits, size );
+ GDI_ReleaseObj( bitmap );
+ return size;
+}
+
+INT CDECL nulldrv_GetDIBits( PHYSDEV dev, HBITMAP bitmap, UINT start, UINT lines, LPVOID bits,
+ BITMAPINFO *info, UINT coloruse )
+{
+ /* FIXME: transfer bits from bmp->bitmap.bmBits */
+ return 0;
+}
+
+INT CDECL nulldrv_SetDIBits( PHYSDEV dev, HBITMAP bitmap, UINT start, UINT lines,
+ const void *bits, const BITMAPINFO *info, UINT coloruse )
+{
+ /* FIXME: transfer bits to bmp->bitmap.bmBits */
+ return 0;
+}
+
/***********************************************************************
* BITMAP_GetWidthBytes
*
bmpobj->size.cy = 0;
bmpobj->bitmap = bm;
bmpobj->bitmap.bmBits = NULL;
- bmpobj->funcs = NULL;
+ bmpobj->funcs = &null_driver;
bmpobj->dib = NULL;
bmpobj->color_table = NULL;
bmpobj->nb_colors = 0;
hbitmap, count, bits, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
1 << bmp->bitmap.bmBitsPixel, height );
- if(bmp->funcs && bmp->funcs->pGetBitmapBits)
- {
- TRACE("Calling device specific BitmapBits\n");
- ret = bmp->funcs->pGetBitmapBits(hbitmap, bits, count);
- } else {
-
- if(!bmp->bitmap.bmBits) {
- TRACE("Bitmap is empty\n");
- memset(bits, 0, count);
- ret = count;
- } else {
- memcpy(bits, bmp->bitmap.bmBits, count);
- ret = count;
- }
-
- }
+ ret = bmp->funcs->pGetBitmapBits( hbitmap, bits, count );
done:
GDI_ReleaseObj( hbitmap );
return ret;
hbitmap, count, bits, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
1 << bmp->bitmap.bmBitsPixel, height );
- if(bmp->funcs && bmp->funcs->pSetBitmapBits) {
-
- TRACE("Calling device specific BitmapBits\n");
- ret = bmp->funcs->pSetBitmapBits(hbitmap, bits, count);
- } else {
-
- if(!bmp->bitmap.bmBits) /* Alloc enough for entire bitmap */
- bmp->bitmap.bmBits = HeapAlloc( GetProcessHeap(), 0, count );
- if(!bmp->bitmap.bmBits) {
- WARN("Unable to allocate bit buffer\n");
- ret = 0;
- } else {
- memcpy(bmp->bitmap.bmBits, bits, count);
- ret = count;
- }
- }
-
+ ret = bmp->funcs->pSetBitmapBits( hbitmap, bits, count );
GDI_ReleaseObj( hbitmap );
return ret;
}
* bitmap is selected into a device to initialize the bitmap function
* table.
*/
-BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, DC *dc )
+BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, PHYSDEV physdev )
{
BITMAPOBJ *bitmap;
- BOOL ret;
+ BOOL ret = TRUE;
/* never set the owner of the stock bitmap since it can be selected in multiple DCs */
if (hbitmap == GetStockObject(DEFAULT_BITMAP)) return TRUE;
if (!(bitmap = GDI_GetObjPtr( hbitmap, OBJ_BITMAP ))) return FALSE;
- ret = TRUE;
- if (!bitmap->funcs) /* not owned by a DC yet */
- {
- if (dc->funcs->pCreateBitmap) ret = dc->funcs->pCreateBitmap( dc->physDev, hbitmap,
- bitmap->bitmap.bmBits );
- if (ret) bitmap->funcs = dc->funcs;
- }
- else if (bitmap->funcs != dc->funcs)
+ if (bitmap->funcs != physdev->funcs)
{
- FIXME( "Trying to select bitmap %p in different DC type\n", hbitmap );
- ret = FALSE;
+ /* we can only change from the null driver to some other driver */
+ if (bitmap->funcs == &null_driver)
+ {
+ if (physdev->funcs->pCreateBitmap)
+ {
+ ret = physdev->funcs->pCreateBitmap( physdev, hbitmap, bitmap->bitmap.bmBits );
+ if (ret) bitmap->funcs = physdev->funcs;
+ }
+ else
+ {
+ WARN( "Trying to select bitmap %p in DC that doesn't support it\n", hbitmap );
+ ret = FALSE;
+ }
+ }
+ else
+ {
+ FIXME( "Trying to select bitmap %p in different DC type\n", hbitmap );
+ ret = FALSE;
+ }
}
GDI_ReleaseObj( hbitmap );
return ret;
goto done;
}
- if (!bitmap->funcs && !BITMAP_SetOwnerDC( handle, dc ))
+ physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
+
+ if (!BITMAP_SetOwnerDC( handle, physdev ))
{
GDI_ReleaseObj( handle );
ret = 0;
goto done;
}
-
- physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
if (!physdev->funcs->pSelectBitmap( physdev, handle ))
{
GDI_ReleaseObj( handle );
funcs = bmp->funcs;
GDI_ReleaseObj( handle );
- if (funcs && funcs->pDeleteBitmap) funcs->pDeleteBitmap( handle );
+ funcs->pDeleteBitmap( handle );
if (!(bmp = free_gdi_handle( handle ))) return FALSE;
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectBrush );
if (brush->logbrush.lbStyle == BS_PATTERN)
- BITMAP_SetOwnerDC( (HBITMAP)brush->logbrush.lbHatch, dc );
+ BITMAP_SetOwnerDC( (HBITMAP)brush->logbrush.lbHatch, physdev );
GDI_inc_ref_count( handle );
GDI_ReleaseObj( handle );
{
DC *dc = get_dc_ptr( hdc );
BOOL delete_hdc = FALSE;
+ PHYSDEV physdev;
BITMAPOBJ *bitmap;
INT result = 0;
return 0;
}
- if (!bitmap->funcs && !BITMAP_SetOwnerDC( hbitmap, dc )) goto done;
+ physdev = GET_DC_PHYSDEV( dc, pSetDIBits );
+ if (BITMAP_SetOwnerDC( hbitmap, physdev ))
+ result = physdev->funcs->pSetDIBits( physdev, hbitmap, startscan, lines, bits, info, coloruse );
- result = lines;
- if (bitmap->funcs)
- {
- if (bitmap->funcs != dc->funcs)
- ERR( "not supported: DDB bitmap %p not belonging to device %p\n", hbitmap, hdc );
- else if (dc->funcs->pSetDIBits)
- result = dc->funcs->pSetDIBits( dc->physDev, hbitmap, startscan, lines,
- bits, info, coloruse );
- }
-
- done:
GDI_ReleaseObj( hbitmap );
release_dc_ptr( dc );
if (delete_hdc) DeleteDC(hdc);
/* Otherwise, get bits from the XImage */
else
{
- if (!bmp->funcs && !BITMAP_SetOwnerDC( hbitmap, dc )) lines = 0;
- else
- {
- if (bmp->funcs && bmp->funcs->pGetDIBits)
- lines = bmp->funcs->pGetDIBits( dc->physDev, hbitmap, startscan,
- lines, bits, info, coloruse );
- else
- lines = 0; /* FIXME: should copy from bmp->bitmap.bmBits */
- }
+ PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGetDIBits );
+ if (!BITMAP_SetOwnerDC( hbitmap, physdev )) lines = 0;
+ else lines = physdev->funcs->pGetDIBits( physdev, hbitmap, startscan,
+ lines, bits, info, coloruse );
}
}
else lines = abs(height);
LONG height;
WORD planes, bpp;
DWORD compr, size;
- DC *dc;
if (!header) return 0;
handle = 0;
}
}
-
- else if (hdc && ((dc = get_dc_ptr( hdc )) != NULL) )
- {
- if (!BITMAP_SetOwnerDC( handle, dc ))
- {
- DeleteObject( handle );
- handle = 0;
- }
- release_dc_ptr( dc );
- }
}
return handle;
return TRUE;
}
+static BOOL CDECL nulldrv_CreateBitmap( PHYSDEV dev, HBITMAP bitmap, LPVOID bits )
+{
+ return TRUE;
+}
+
+static BOOL CDECL nulldrv_DeleteBitmap( HBITMAP bitmap )
+{
+ return TRUE;
+}
+
static BOOL CDECL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
{
return TRUE;
nulldrv_ChoosePixelFormat, /* pChoosePixelFormat */
nulldrv_Chord, /* pChord */
nulldrv_CloseFigure, /* pCloseFigure */
- NULL, /* pCreateBitmap */
+ nulldrv_CreateBitmap, /* pCreateBitmap */
NULL, /* pCreateDC */
NULL, /* pCreateDIBSection */
- NULL, /* pDeleteBitmap */
+ nulldrv_DeleteBitmap, /* pDeleteBitmap */
NULL, /* pDeleteDC */
nulldrv_DeleteObject, /* pDeleteObject */
nulldrv_DescribePixelFormat, /* pDescribePixelFormat */
nulldrv_FlattenPath, /* pFlattenPath */
nulldrv_FrameRgn, /* pFrameRgn */
nulldrv_GdiComment, /* pGdiComment */
- NULL, /* pGetBitmapBits */
+ nulldrv_GetBitmapBits, /* pGetBitmapBits */
NULL, /* pGetCharWidth */
- NULL, /* pGetDIBits */
+ nulldrv_GetDIBits, /* pGetDIBits */
NULL, /* pGetDeviceCaps */
nulldrv_GetDeviceGammaRamp, /* pGetDeviceGammaRamp */
nulldrv_GetICMProfile, /* pGetICMProfile */
nulldrv_SelectPalette, /* pSelectPalette */
nulldrv_SelectPen, /* pSelectPen */
nulldrv_SetArcDirection, /* pSetArcDirection */
- NULL, /* pSetBitmapBits */
+ nulldrv_SetBitmapBits, /* pSetBitmapBits */
nulldrv_SetBkColor, /* pSetBkColor */
nulldrv_SetBkMode, /* pSetBkMode */
nulldrv_SetDCBrushColor, /* pSetDCBrushColor */
nulldrv_SetDCPenColor, /* pSetDCPenColor */
NULL, /* pSetDIBColorTable */
- NULL, /* pSetDIBits */
+ nulldrv_SetDIBits, /* pSetDIBits */
NULL, /* pSetDIBitsToDevice */
nulldrv_SetDeviceClipping, /* pSetDeviceClipping */
nulldrv_SetDeviceGammaRamp, /* pSetDeviceGammaRamp */
/* bitmap.c */
extern HBITMAP BITMAP_CopyBitmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN;
-extern BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, DC *dc ) DECLSPEC_HIDDEN;
+extern BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, PHYSDEV physdev ) DECLSPEC_HIDDEN;
extern INT BITMAP_GetWidthBytes( INT bmWidth, INT bpp ) DECLSPEC_HIDDEN;
/* clipping.c */
extern BOOL CDECL nulldrv_FillRgn( PHYSDEV dev, HRGN rgn, HBRUSH brush ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_FlattenPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_FrameRgn( PHYSDEV dev, HRGN rgn, HBRUSH brush, INT width, INT height ) DECLSPEC_HIDDEN;
+extern LONG CDECL nulldrv_GetBitmapBits( HBITMAP bitmap, void *bits, LONG size ) DECLSPEC_HIDDEN;
+extern INT CDECL nulldrv_GetDIBits( PHYSDEV dev, HBITMAP bitmap, UINT start, UINT lines, LPVOID bits, BITMAPINFO *info, UINT coloruse ) DECLSPEC_HIDDEN;
extern COLORREF CDECL nulldrv_GetNearestColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern INT CDECL nulldrv_IntersectClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_InvertRgn( PHYSDEV dev, HRGN rgn ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_ScaleViewportExtEx( PHYSDEV dev, INT x_num, INT x_denom, INT y_num, INT y_denom, SIZE *size ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_ScaleWindowExtEx( PHYSDEV dev, INT x_num, INT x_denom, INT y_num, INT y_denom, SIZE *size ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_SelectClipPath( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
+extern LONG CDECL nulldrv_SetBitmapBits( HBITMAP bitmap, const void *bits, LONG size ) DECLSPEC_HIDDEN;
+extern INT CDECL nulldrv_SetDIBits( PHYSDEV dev, HBITMAP bitmap, UINT start, UINT lines, const void *bits, const BITMAPINFO *info, UINT coloruse ) DECLSPEC_HIDDEN;
extern INT CDECL nulldrv_SetMapMode( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_SetViewportExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_SetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN;