#include "xgl.h"
#include "gcstruct.h"
#ifdef MITSHM
void
xglShmPutImage (DrawablePtr pDrawable,
GCPtr pGC,
int depth,
unsigned int format,
int w,
int h,
int sx,
int sy,
int sw,
int sh,
int dx,
int dy,
char *data)
{
ScreenPtr pScreen = pDrawable->pScreen;
PixmapPtr pPixmapHeader = NULL;
PixmapPtr pPixmap;
int saveTarget;
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
if ((format == ZPixmap) || (depth == 1))
{
pPixmap = pPixmapHeader =
GetScratchPixmapHeader (pScreen, w, h, depth,
BitsPerPixel (depth),
PixmapBytePad (w, depth),
(pointer) data);
if (pPixmap)
xglSetPixmapVisual (pPixmap, 0);
}
else
{
pPixmap = (*pScreen->CreatePixmap) (pScreen, sw, sh, depth);
if (pPixmap)
{
GCPtr pScratchGC;
if (!xglAllocatePixmapBits (pPixmap,
XGL_PIXMAP_USAGE_HINT_DEFAULT))
{
(*pScreen->DestroyPixmap) (pPixmap);
return;
}
xglSetPixmapVisual (pPixmap, 0);
pScratchGC = GetScratchGC (depth, pScreen);
if (!pScratchGC)
{
(*pScreen->DestroyPixmap) (pPixmap);
return;
}
ValidateGC ((DrawablePtr) pPixmap, pScratchGC);
(*pGC->ops->PutImage) ((DrawablePtr) pPixmap, pScratchGC, depth,
-sx, -sy, w, h, 0,
(format == XYPixmap) ? XYPixmap : ZPixmap,
data);
FreeScratchGC (pScratchGC);
sx = sy = 0;
}
}
if (!pPixmap)
return;
saveTarget = pPixmapPriv->target;
pPixmapPriv->target = xglPixmapTargetNo;
if (format == XYBitmap)
(*pGC->ops->CopyPlane) ((DrawablePtr) pPixmap, pDrawable, pGC,
sx, sy, sw, sh, dx, dy, 1L);
else
(*pGC->ops->CopyArea) ((DrawablePtr) pPixmap, pDrawable, pGC,
sx, sy, sw, sh, dx, dy);
pPixmapPriv->target = saveTarget;
if (pPixmapHeader)
FreeScratchPixmapHeader (pPixmapHeader);
else
(*pScreen->DestroyPixmap) (pPixmap);
}
#endif