1999-07-18 20:34:45 +02:00
|
|
|
/*
|
|
|
|
* PostScript clipping functions
|
|
|
|
*
|
|
|
|
* Copyright 1999 Luc Tourangau
|
|
|
|
*
|
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 "gdi.h"
|
|
|
|
#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
|
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
VOID PSDRV_SetDeviceClipping( PSDRV_PDEVICE *physDev )
|
1999-07-18 20:34:45 +02:00
|
|
|
{
|
|
|
|
CHAR szArrayName[] = "clippath";
|
1999-07-25 13:14:47 +02:00
|
|
|
DWORD size;
|
|
|
|
RGNDATA *rgndata;
|
2002-03-28 23:22:05 +01:00
|
|
|
DC *dc = physDev->dc;
|
1999-07-25 13:14:47 +02:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
TRACE("hdc=%04x\n", physDev->hdc);
|
1999-07-25 13:14:47 +02:00
|
|
|
|
2000-11-05 03:05:07 +01:00
|
|
|
if (dc->hGCClipRgn == 0) {
|
1999-07-25 13:14:47 +02:00
|
|
|
ERR("Rgn is 0. Please report this.\n");
|
1999-07-18 20:34:45 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-11-05 03:05:07 +01:00
|
|
|
size = GetRegionData(dc->hGCClipRgn, 0, NULL);
|
1999-07-25 13:14:47 +02:00
|
|
|
if(!size) {
|
|
|
|
ERR("Invalid region\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rgndata = HeapAlloc( GetProcessHeap(), 0, size );
|
|
|
|
if(!rgndata) {
|
|
|
|
ERR("Can't allocate buffer\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-11-05 03:05:07 +01:00
|
|
|
GetRegionData(dc->hGCClipRgn, size, rgndata);
|
1999-07-25 13:14:47 +02:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteInitClip(physDev);
|
1999-10-13 15:58:45 +02:00
|
|
|
|
|
|
|
/* check for NULL region */
|
|
|
|
if (rgndata->rdh.nCount == 0)
|
|
|
|
{
|
|
|
|
/* set an empty clip path. */
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteRectClip(physDev, 0, 0, 0, 0);
|
1999-10-13 15:58:45 +02:00
|
|
|
}
|
|
|
|
/* optimize when it is a simple region */
|
|
|
|
else if (rgndata->rdh.nCount == 1)
|
|
|
|
{
|
|
|
|
RECT *pRect = (RECT *)rgndata->Buffer;
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteRectClip(physDev, pRect->left, pRect->top,
|
1999-10-13 15:58:45 +02:00
|
|
|
pRect->right - pRect->left,
|
|
|
|
pRect->bottom - pRect->top);
|
|
|
|
}
|
|
|
|
else
|
1999-07-18 20:34:45 +02:00
|
|
|
{
|
|
|
|
INT i;
|
1999-07-25 13:14:47 +02:00
|
|
|
RECT *pRect = (RECT *)rgndata->Buffer;
|
1999-07-18 20:34:45 +02:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteArrayDef(physDev, szArrayName, rgndata->rdh.nCount * 4);
|
1999-07-18 20:34:45 +02:00
|
|
|
|
1999-07-25 13:14:47 +02:00
|
|
|
for (i = 0; i < rgndata->rdh.nCount; i++, pRect++)
|
1999-07-18 20:34:45 +02:00
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteArrayPut(physDev, szArrayName, i * 4,
|
1999-07-18 20:34:45 +02:00
|
|
|
pRect->left);
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 1,
|
1999-07-18 20:34:45 +02:00
|
|
|
pRect->top);
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 2,
|
1999-07-18 20:34:45 +02:00
|
|
|
pRect->right - pRect->left);
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 3,
|
1999-07-18 20:34:45 +02:00
|
|
|
pRect->bottom - pRect->top);
|
|
|
|
}
|
1999-10-13 15:58:45 +02:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
PSDRV_WriteRectClip2(physDev, szArrayName);
|
1999-07-18 20:34:45 +02:00
|
|
|
}
|
|
|
|
|
1999-07-25 13:14:47 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, rgndata );
|
|
|
|
return;
|
1999-07-18 20:34:45 +02:00
|
|
|
}
|