1999-07-18 20:34:45 +02:00
|
|
|
/*
|
|
|
|
* PostScript clipping functions
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Copyright 1999 Luc Tourangau
|
1999-07-18 20:34:45 +02:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-07-18 20:34:45 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "psdrv.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-07-25 13:14:47 +02:00
|
|
|
#include "winbase.h"
|
1999-07-18 20:34:45 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
|
1999-07-18 20:34:45 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PSDRV_SetDeviceClipping
|
|
|
|
*/
|
2004-02-13 21:26:27 +01:00
|
|
|
void PSDRV_SetDeviceClipping( PSDRV_PDEVICE *physDev, HRGN vis_rgn, HRGN clip_rgn )
|
2003-05-19 21:06:47 +02:00
|
|
|
{
|
|
|
|
/* We could set a dirty flag here to speed up PSDRV_SetClip */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PSDRV_SetClip
|
|
|
|
*
|
|
|
|
* The idea here is that every graphics operation should bracket
|
|
|
|
* output in PSDRV_SetClip/ResetClip calls. The clip path outside
|
|
|
|
* these calls will be empty; the reason for this is that it is
|
|
|
|
* impossible in PostScript to cleanly make the clip path larger than
|
|
|
|
* the current one. Also Photoshop assumes that despite having set a
|
|
|
|
* small clip area in the printer dc that it can still write raw
|
|
|
|
* PostScript to the driver and expect this code not to be clipped.
|
|
|
|
*/
|
|
|
|
void PSDRV_SetClip( PSDRV_PDEVICE *physDev )
|
1999-07-18 20:34:45 +02:00
|
|
|
{
|
|
|
|
CHAR szArrayName[] = "clippath";
|
1999-07-25 13:14:47 +02:00
|
|
|
DWORD size;
|
2002-06-25 01:40:54 +02:00
|
|
|
RGNDATA *rgndata = NULL;
|
|
|
|
HRGN hrgn = CreateRectRgn(0,0,0,0);
|
|
|
|
BOOL empty;
|
1999-07-25 13:14:47 +02:00
|
|
|
|
2002-10-19 01:48:57 +02:00
|
|
|
TRACE("hdc=%p\n", physDev->hdc);
|
1999-07-25 13:14:47 +02:00
|
|
|
|
2004-05-18 22:42:09 +02:00
|
|
|
if(physDev->pathdepth) {
|
|
|
|
TRACE("inside a path, so not clipping\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2002-06-25 01:40:54 +02:00
|
|
|
empty = !GetClipRgn(physDev->hdc, hrgn);
|
1999-07-25 13:14:47 +02:00
|
|
|
|
2002-06-25 01:40:54 +02:00
|
|
|
if(!empty) {
|
|
|
|
size = GetRegionData(hrgn, 0, NULL);
|
|
|
|
if(!size) {
|
|
|
|
ERR("Invalid region\n");
|
|
|
|
goto end;
|
|
|
|
}
|
1999-10-13 15:58:45 +02:00
|
|
|
|
2002-06-25 01:40:54 +02:00
|
|
|
rgndata = HeapAlloc( GetProcessHeap(), 0, size );
|
|
|
|
if(!rgndata) {
|
|
|
|
ERR("Can't allocate buffer\n");
|
|
|
|
goto end;
|
|
|
|
}
|
1999-07-18 20:34:45 +02:00
|
|
|
|
2002-06-25 01:40:54 +02:00
|
|
|
GetRegionData(hrgn, size, rgndata);
|
1999-07-18 20:34:45 +02:00
|
|
|
|
2003-05-19 21:06:47 +02:00
|
|
|
PSDRV_WriteGSave(physDev);
|
|
|
|
|
2002-06-25 01:40:54 +02:00
|
|
|
/* check for NULL region */
|
|
|
|
if (rgndata->rdh.nCount == 0)
|
1999-07-18 20:34:45 +02:00
|
|
|
{
|
2002-06-25 01:40:54 +02:00
|
|
|
/* set an empty clip path. */
|
|
|
|
PSDRV_WriteRectClip(physDev, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
/* optimize when it is a simple region */
|
|
|
|
else if (rgndata->rdh.nCount == 1)
|
|
|
|
{
|
|
|
|
RECT *pRect = (RECT *)rgndata->Buffer;
|
|
|
|
|
|
|
|
PSDRV_WriteRectClip(physDev, pRect->left, pRect->top,
|
|
|
|
pRect->right - pRect->left,
|
1999-07-18 20:34:45 +02:00
|
|
|
pRect->bottom - pRect->top);
|
|
|
|
}
|
2002-06-25 01:40:54 +02:00
|
|
|
else
|
|
|
|
{
|
2004-09-22 04:46:38 +02:00
|
|
|
UINT i;
|
2002-06-25 01:40:54 +02:00
|
|
|
RECT *pRect = (RECT *)rgndata->Buffer;
|
1999-10-13 15:58:45 +02:00
|
|
|
|
2002-06-25 01:40:54 +02:00
|
|
|
PSDRV_WriteArrayDef(physDev, szArrayName, rgndata->rdh.nCount * 4);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-06-25 01:40:54 +02:00
|
|
|
for (i = 0; i < rgndata->rdh.nCount; i++, pRect++)
|
|
|
|
{
|
|
|
|
PSDRV_WriteArrayPut(physDev, szArrayName, i * 4,
|
|
|
|
pRect->left);
|
|
|
|
PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 1,
|
|
|
|
pRect->top);
|
|
|
|
PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 2,
|
|
|
|
pRect->right - pRect->left);
|
|
|
|
PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 3,
|
|
|
|
pRect->bottom - pRect->top);
|
|
|
|
}
|
|
|
|
PSDRV_WriteRectClip2(physDev, szArrayName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end:
|
|
|
|
if(rgndata) HeapFree( GetProcessHeap(), 0, rgndata );
|
|
|
|
DeleteObject(hrgn);
|
1999-07-18 20:34:45 +02:00
|
|
|
}
|
2003-05-19 21:06:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PSDRV_ResetClip
|
|
|
|
*/
|
|
|
|
void PSDRV_ResetClip( PSDRV_PDEVICE *physDev )
|
|
|
|
{
|
|
|
|
HRGN hrgn = CreateRectRgn(0,0,0,0);
|
|
|
|
BOOL empty;
|
|
|
|
|
2004-05-18 22:42:09 +02:00
|
|
|
empty = !GetClipRgn(physDev->hdc, hrgn);
|
|
|
|
if(!empty && !physDev->pathdepth)
|
|
|
|
PSDRV_WriteGRestore(physDev);
|
2003-05-19 21:06:47 +02:00
|
|
|
DeleteObject(hrgn);
|
|
|
|
}
|