summaryrefslogtreecommitdiff
path: root/Xprint/pcl/PclArea.c
diff options
context:
space:
mode:
Diffstat (limited to 'Xprint/pcl/PclArea.c')
-rw-r--r--Xprint/pcl/PclArea.c129
1 files changed, 62 insertions, 67 deletions
diff --git a/Xprint/pcl/PclArea.c b/Xprint/pcl/PclArea.c
index da3107d5a..971506da6 100644
--- a/Xprint/pcl/PclArea.c
+++ b/Xprint/pcl/PclArea.c
@@ -11,7 +11,7 @@
** * Created: 10/23/95
** *
** *********************************************************
-**
+**
********************************************************************/
/*
(c) Copyright 1996 Hewlett-Packard Company
@@ -44,6 +44,7 @@ not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from said
copyright holders.
*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclArea.c,v 1.9 2001/10/28 03:32:54 tsi Exp $ */
#include <stdio.h>
#include <sys/types.h>
@@ -53,6 +54,9 @@ copyright holders.
#include "region.h"
#include "cfb.h"
+#if 1
+#include "cfb32.h"
+#endif
void
PclPutImage(DrawablePtr pDrawable,
@@ -72,10 +76,10 @@ PclPutImage(DrawablePtr pDrawable,
unsigned long oldPlanemask;
unsigned long i;
long bytesPer;
-
+
if( ( w == 0 ) || ( h == 0 ) )
return;
-
+
if( format != XYPixmap )
{
pPixmap = GetScratchPixmapHeader( pDrawable->pScreen,
@@ -85,7 +89,7 @@ PclPutImage(DrawablePtr pDrawable,
depth ), (pointer)pImage );
if( !pPixmap )
return;
-
+
if( format == ZPixmap )
(void)(*pGC->ops->CopyArea)( (DrawablePtr)pPixmap, pDrawable, pGC,
leftPad, 0, w, h, x, y );
@@ -104,7 +108,7 @@ PclPutImage(DrawablePtr pDrawable,
if( !pPixmap )
return;
-
+
depth = pGC->depth;
oldPlanemask = pGC->planemask;
oldFg = pGC->fgPixel;
@@ -113,12 +117,11 @@ PclPutImage(DrawablePtr pDrawable,
gcv[1] = 0;
DoChangeGC( pGC, GCForeground | GCBackground, gcv, 0 );
bytesPer = (long)h * BitmapBytePad( w + leftPad );
-
+
for( i = 1 << (depth-1); i != 0; i >>= 1, pImage += bytesPer )
{
if( i & oldPlanemask )
{
- extern void cfbPutImage(), cfb32PutImage();
gcv[0] = i;
DoChangeGC( pGC, GCPlaneMask, gcv, 0 );
ValidateGC( pDrawable, pGC );
@@ -160,16 +163,16 @@ PclMonoPixmapFragment(FILE *outFile,
{
char *bits, t[80], *row;
int h, w, i;
-
+
/*
* Create a storage area large enough to hold the entire pixmap,
- * then use mfbGetImage to get the appropriate bits.
+ * then use mfbGetImage to get the appropriate bits.
*/
h = y2 - y1;
w = BitmapBytePad( x2 - x1 );
-
+
bits = (char *)xalloc( h * w );
- mfbGetImage( (DrawablePtr)pix, x1, y1, x2 - x1, h,
+ mfbGetImage( (DrawablePtr)pix, x1, y1, x2 - x1, h,
XYPixmap, ~0, bits );
/*
@@ -179,7 +182,7 @@ PclMonoPixmapFragment(FILE *outFile,
*/
sprintf( t, "\033%%0BPU%d,%d;\033%%1A", dstx, dsty );
SEND_PCL( outFile, t );
-
+
/*
* Now, wrap the raster in the appropriate PCL code. Right now,
* it's going to go down the wire without any compression. That
@@ -188,14 +191,14 @@ PclMonoPixmapFragment(FILE *outFile,
sprintf( t, "\033*t300R\033*r%dT\033*r%dS\033*r1A\033*b0M",
h, x2 - x1 );
SEND_PCL( outFile, t );
-
+
sprintf( t, "\033*b%dW", w );
for( row = bits, i = 0; i <= h; i++, row += w )
{
SEND_PCL( outFile, t );
SEND_PCL_COUNT( outFile, row, w );
}
-
+
SEND_PCL( outFile, "\033*rC" );
/*
@@ -216,21 +219,20 @@ PclColorPixmapFragment(FILE *outFile,
{
char *bits, t[80], *row;
int h, w, i;
- extern void cfbGetImage(), cfb32GetImage();
-
+
/*
* Create a storage area large enough to hold the entire pixmap,
- * then use cfbGetImage to get the appropriate bits.
+ * then use cfbGetImage to get the appropriate bits.
*/
h = y2 - y1;
w = PixmapBytePad( x2 - x1, pix->drawable.depth );
-
+
bits = (char *)xalloc( h * w );
if (pix->drawable.depth <= 8)
- cfbGetImage( (DrawablePtr)pix, x1, y1, x2 - x1, h,
+ cfbGetImage( (DrawablePtr)pix, x1, y1, x2 - x1, h,
ZPixmap, ~0, bits );
else if (pix->drawable.depth <= 32)
- cfb32GetImage( (DrawablePtr)pix, x1, y1, x2 - x1, h,
+ cfb32GetImage( (DrawablePtr)pix, x1, y1, x2 - x1, h,
ZPixmap, ~0, bits );
/*
@@ -249,16 +251,16 @@ PclColorPixmapFragment(FILE *outFile,
sprintf( t, "\033*t300R\033*r%dt%ds1A\033*b0M",
h, x2 - x1 );
SEND_PCL( outFile, t );
-
+
sprintf( t, "\033*b%dW", w );
for( row = bits, i = 0; i < h; i++, row += w )
{
SEND_PCL( outFile, t );
SEND_PCL_COUNT( outFile, row, w );
}
-
+
SEND_PCL( outFile, "\033*rC" );
-
+
/*
* Clean things up a bit
*/
@@ -277,22 +279,20 @@ PclCopyArea(DrawablePtr pSrc,
int dsty)
{
PixmapPtr pixSrc = (PixmapPtr)pSrc;
- char t[80];
- FILE *srcFile, *dstFile;
- GC srcGC, dstGC;
+/*
+ FILE *srcFile;
+ GC srcGC;
+*/
+ FILE *dstFile;
+ GC dstGC;
unsigned long valid;
- struct stat statBuf;
- XpContextPtr pCon;
- xRectangle repro;
- PclPixmapPrivPtr pPriv;
RegionPtr drawRegion, region, whole, ret;
BoxRec box;
BoxPtr prect;
int nrect;
void (*doFragment)(FILE *, PixmapPtr, short, short, short, short,
short, short );
- extern RegionPtr mfbCopyArea(), cfbCopyArea(), cfb32CopyArea();
-
+
/*
* Since we don't store any information on a per-window basis, we
* can't copy from a window.
@@ -321,7 +321,7 @@ PclCopyArea(DrawablePtr pSrc,
PclGetDrawablePrivateStuff( pSrc, &srcGC, &valid, &srcFile );
*/
PclGetDrawablePrivateStuff( pDst, &dstGC, &valid, &dstFile );
-
+
/*
* If we're copying to a window, we have to do some actual
* drawing, instead of just handing it off to mfb or cfb. Start
@@ -331,14 +331,11 @@ PclCopyArea(DrawablePtr pSrc,
box.y1 = srcy;
box.x2 = srcx + width;
box.y2 = srcy + height;
- drawRegion = miRegionCreate( &box, 0 );
- miTranslateRegion( drawRegion, dstx, dsty );
-
- region = miRegionCreate( NULL, 0 );
- miIntersect( region, drawRegion,
- ((PclGCPrivPtr)
- (pGC->devPrivates[PclGCPrivateIndex].ptr))
- ->pCompositeClip );
+ drawRegion = REGION_CREATE( pGC->pScreen, &box, 0 );
+ REGION_TRANSLATE( pGC->pScreen, drawRegion, dstx, dsty );
+
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
/*
* Now select the operation to be performed on each box in the
@@ -348,7 +345,7 @@ PclCopyArea(DrawablePtr pSrc,
doFragment = PclMonoPixmapFragment;
else
doFragment = PclColorPixmapFragment;
-
+
/*
* Actually draw each section of the bitmap.
*/
@@ -360,18 +357,18 @@ PclCopyArea(DrawablePtr pSrc,
(*doFragment)( dstFile, (PixmapPtr)pSrc, prect->x1 - dstx,
prect->y1 - dsty, prect->x2 - dstx,
prect->y2 - dsty, prect->x1, prect->y1 );
-
+
nrect--;
prect++;
}
-
+
/*
* Update the destination's GC to the source's GC.
*/
/*
PclSetDrawablePrivateGC( pDst, srcGC );
*/
-
+
/*
* Determine the region that needs to be returned. This is the
* region of the source that falls outside the boundary of the
@@ -381,24 +378,24 @@ PclCopyArea(DrawablePtr pSrc,
box.y1 = 0;
box.x2 = pixSrc->drawable.width;
box.y2 = pixSrc->drawable.height;
- whole = miRegionCreate( &box, 0 );
- ret = miRegionCreate( NULL, 0 );
-
- miTranslateRegion( drawRegion, -dstx, -dsty );
- miSubtract( ret, drawRegion, whole );
-
+ whole = REGION_CREATE( pGC->pScreen, &box, 0 );
+ ret = REGION_CREATE( pGC->pScreen, NULL, 0 );
+
+ REGION_TRANSLATE( pGC->pScreen, drawRegion, -dstx, -dsty );
+ REGION_SUBTRACT( pGC->pScreen, ret, drawRegion, whole );
+
/*
* Clean up the regions
*/
- miRegionDestroy( drawRegion );
- miRegionDestroy( region );
- miRegionDestroy( whole );
-
- if( miRegionNotEmpty( ret ) )
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ REGION_DESTROY( pGC->pScreen, whole );
+
+ if( REGION_NOTEMPTY( pGC->pScreen, ret ) )
return ret;
else
{
- miRegionDestroy( ret );
+ REGION_DESTROY( pGC->pScreen, ret );
return NULL;
}
}
@@ -418,20 +415,19 @@ PclCopyPlane(DrawablePtr pSrc,
RegionPtr reg;
GCPtr scratchGC;
PixmapPtr scratchPix;
- extern RegionPtr mfbCopyPlane(), cfbCopyPlane(), cfb32CopyPlane();
-
+
/*
* Since we don't store PCL on a per-window basis, there's no good
* way to copy from a window.
*/
if( pSrc->type == DRAWABLE_WINDOW )
return NULL;
-
+
/*
* Copying from a pixmap to a pixmap is already implemented by
* mfb/cfb.
*/
- if( pSrc->type == DRAWABLE_PIXMAP &&
+ if( pSrc->type == DRAWABLE_PIXMAP &&
pDst->type == DRAWABLE_PIXMAP )
{
if( pDst->depth == 1 )
@@ -452,7 +448,7 @@ PclCopyPlane(DrawablePtr pSrc,
*/
scratchPix = (*pDst->pScreen->CreatePixmap)( pDst->pScreen, width,
height, pDst->depth );
-
+
scratchGC = GetScratchGC( pDst->depth, pDst->pScreen );
CopyGC( pGC, scratchGC, ~0L );
@@ -474,14 +470,13 @@ PclCopyPlane(DrawablePtr pSrc,
cfb32CopyPlane( pSrc, (DrawablePtr)scratchPix, scratchGC,
srcx, srcy, width, height, 0, 0, plane );
}
-
+
reg = PclCopyArea( (DrawablePtr)scratchPix, pDst, pGC, 0, 0, width,
height, dstx, dsty );
-
+
FreeScratchGC( scratchGC );
-
+
(*pDst->pScreen->DestroyPixmap)( scratchPix );
-
+
return reg;
}
-