1996-10-23 16:59:13 +00:00
|
|
|
/*
|
1998-01-18 18:01:49 +00:00
|
|
|
* X11DRV clipping functions
|
1996-10-23 16:59:13 +00:00
|
|
|
*
|
1998-01-18 18:01:49 +00:00
|
|
|
* Copyright 1998 Huw Davies
|
2002-03-09 23:29:33 +00: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
|
1996-10-23 16:59:13 +00:00
|
|
|
*/
|
|
|
|
|
1999-02-04 11:11:01 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
1996-10-23 16:59:13 +00:00
|
|
|
#include <stdio.h>
|
2000-04-25 19:55:35 +00:00
|
|
|
|
1996-10-23 16:59:13 +00:00
|
|
|
#include "x11drv.h"
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
1996-10-23 16:59:13 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
|
1999-04-19 14:56:29 +00:00
|
|
|
|
1996-10-23 16:59:13 +00:00
|
|
|
/***********************************************************************
|
2002-05-25 22:16:12 +00:00
|
|
|
* X11DRV_GetRegionData
|
1998-01-18 18:01:49 +00:00
|
|
|
*
|
2002-05-25 22:16:12 +00:00
|
|
|
* Calls GetRegionData on the given region and converts the rectangle
|
|
|
|
* array to XRectangle format. The returned buffer must be freed by
|
|
|
|
* caller using HeapFree(GetProcessHeap(),...).
|
|
|
|
* If hdc_lptodp is not 0, the rectangles are converted through LPtoDP.
|
1996-10-23 16:59:13 +00:00
|
|
|
*/
|
2002-05-25 22:16:12 +00:00
|
|
|
RGNDATA *X11DRV_GetRegionData( HRGN hrgn, HDC hdc_lptodp )
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2002-05-25 22:16:12 +00:00
|
|
|
RGNDATA *data;
|
|
|
|
DWORD size;
|
2004-08-11 23:45:34 +00:00
|
|
|
unsigned int i;
|
2002-05-25 22:16:12 +00:00
|
|
|
RECT *rect, tmp;
|
|
|
|
XRectangle *xrect;
|
2002-03-28 22:22:05 +00:00
|
|
|
|
2002-05-25 22:16:12 +00:00
|
|
|
if (!(size = GetRegionData( hrgn, 0, NULL ))) return NULL;
|
|
|
|
if (sizeof(XRectangle) > sizeof(RECT))
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2002-05-25 22:16:12 +00:00
|
|
|
/* add extra size for XRectangle array */
|
|
|
|
int count = (size - sizeof(RGNDATAHEADER)) / sizeof(RECT);
|
|
|
|
size += count * (sizeof(XRectangle) - sizeof(RECT));
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|
2002-05-25 22:16:12 +00:00
|
|
|
if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return NULL;
|
|
|
|
if (!GetRegionData( hrgn, size, data ))
|
1996-10-23 16:59:13 +00:00
|
|
|
{
|
2002-05-25 22:16:12 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
|
|
|
return NULL;
|
|
|
|
}
|
1998-01-18 18:01:49 +00:00
|
|
|
|
2002-05-25 22:16:12 +00:00
|
|
|
rect = (RECT *)data->Buffer;
|
|
|
|
xrect = (XRectangle *)data->Buffer;
|
|
|
|
if (hdc_lptodp) /* map to device coordinates */
|
|
|
|
{
|
|
|
|
LPtoDP( hdc_lptodp, (POINT *)rect, data->rdh.nCount * 2 );
|
|
|
|
for (i = 0; i < data->rdh.nCount; i++)
|
|
|
|
{
|
|
|
|
if (rect[i].right < rect[i].left)
|
|
|
|
{
|
|
|
|
INT tmp = rect[i].right;
|
|
|
|
rect[i].right = rect[i].left;
|
|
|
|
rect[i].left = tmp;
|
|
|
|
}
|
|
|
|
if (rect[i].bottom < rect[i].top)
|
|
|
|
{
|
|
|
|
INT tmp = rect[i].bottom;
|
|
|
|
rect[i].bottom = rect[i].top;
|
|
|
|
rect[i].top = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-01-18 18:01:49 +00:00
|
|
|
|
2002-05-25 22:16:12 +00:00
|
|
|
if (sizeof(XRectangle) > sizeof(RECT))
|
|
|
|
{
|
2004-12-22 17:16:03 +00:00
|
|
|
int j;
|
2002-05-25 22:16:12 +00:00
|
|
|
/* need to start from the end */
|
2004-12-22 17:16:03 +00:00
|
|
|
for (j = data->rdh.nCount-1; j >= 0; j--)
|
1998-01-18 18:01:49 +00:00
|
|
|
{
|
2004-12-22 17:16:03 +00:00
|
|
|
tmp = rect[j];
|
|
|
|
xrect[j].x = tmp.left;
|
|
|
|
xrect[j].y = tmp.top;
|
|
|
|
xrect[j].width = tmp.right - tmp.left;
|
|
|
|
xrect[j].height = tmp.bottom - tmp.top;
|
1998-01-18 18:01:49 +00:00
|
|
|
}
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|
1998-01-18 18:01:49 +00:00
|
|
|
else
|
2002-05-25 22:16:12 +00:00
|
|
|
{
|
|
|
|
for (i = 0; i < data->rdh.nCount; i++)
|
|
|
|
{
|
|
|
|
tmp = rect[i];
|
|
|
|
xrect[i].x = tmp.left;
|
|
|
|
xrect[i].y = tmp.top;
|
|
|
|
xrect[i].width = tmp.right - tmp.left;
|
|
|
|
xrect[i].height = tmp.bottom - tmp.top;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
1998-01-18 18:01:49 +00:00
|
|
|
|
|
|
|
|
2002-05-25 22:16:12 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_SetDeviceClipping
|
|
|
|
*/
|
2004-02-13 20:26:27 +00:00
|
|
|
void X11DRV_SetDeviceClipping( X11DRV_PDEVICE *physDev, HRGN vis_rgn, HRGN clip_rgn )
|
2002-05-25 22:16:12 +00:00
|
|
|
{
|
|
|
|
RGNDATA *data;
|
1998-01-18 18:01:49 +00:00
|
|
|
|
2004-02-13 20:26:27 +00:00
|
|
|
CombineRgn( physDev->region, vis_rgn, clip_rgn, clip_rgn ? RGN_AND : RGN_COPY );
|
|
|
|
if (!(data = X11DRV_GetRegionData( physDev->region, 0 ))) return;
|
|
|
|
|
2003-11-21 05:41:56 +00:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XSetClipRectangles( gdi_display, physDev->gc, physDev->org.x, physDev->org.y,
|
|
|
|
(XRectangle *)data->Buffer, data->rdh.nCount, YXBanded );
|
|
|
|
wine_tsx11_unlock();
|
2002-05-25 22:16:12 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
1996-10-23 16:59:13 +00:00
|
|
|
}
|