Commit c582edbc authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Return a RGNDATA from add_extra_clipping_region and avoid changing the physdev region.

parent fd7b94bc
......@@ -1902,7 +1902,7 @@ DWORD X11DRV_PutImage( PHYSDEV dev, HBITMAP hbitmap, HRGN clip, BITMAPINFO *info
}
else
{
HRGN saved_region = 0;
RGNDATA *saved_region = NULL;
if (clip) saved_region = add_extra_clipping_region( physdev, clip );
X11DRV_LockDIBSection( physdev, DIB_Status_GdiMod );
......@@ -1939,7 +1939,7 @@ DWORD X11DRV_PutImage( PHYSDEV dev, HBITMAP hbitmap, HRGN clip, BITMAPINFO *info
}
X11DRV_UnlockDIBSection( physdev, !ret );
if (saved_region) restore_clipping_region( physdev, saved_region );
restore_clipping_region( physdev, saved_region );
}
image->data = NULL;
}
......
......@@ -185,18 +185,12 @@ RGNDATA *X11DRV_GetRegionData( HRGN hrgn, HDC hdc_lptodp )
}
static void update_x11_clipping( X11DRV_PDEVICE *physDev )
static void update_x11_clipping( X11DRV_PDEVICE *physDev, const RGNDATA *data )
{
RGNDATA *data;
if (!(data = X11DRV_GetRegionData( physDev->region, 0 ))) return;
wine_tsx11_lock();
XSetClipRectangles( gdi_display, physDev->gc, physDev->dc_rect.left, physDev->dc_rect.top,
(XRectangle *)data->Buffer, data->rdh.nCount, YXBanded );
wine_tsx11_unlock();
if (physDev->xrender) X11DRV_XRender_SetDeviceClipping(physDev, data);
HeapFree( GetProcessHeap(), 0, data );
}
/***********************************************************************
......@@ -205,15 +199,24 @@ static void update_x11_clipping( X11DRV_PDEVICE *physDev )
* Temporarily add a region to the current clipping region.
* The returned region must be restored with restore_clipping_region.
*/
HRGN add_extra_clipping_region( X11DRV_PDEVICE *dev, HRGN rgn )
RGNDATA *add_extra_clipping_region( X11DRV_PDEVICE *dev, HRGN rgn )
{
HRGN ret, clip;
RGNDATA *ret, *data;
HRGN clip;
if (!(clip = CreateRectRgn( 0, 0, 0, 0 ))) return 0;
if (!(ret = X11DRV_GetRegionData( dev->region, 0 ))) return NULL;
if (!(clip = CreateRectRgn( 0, 0, 0, 0 )))
{
HeapFree( GetProcessHeap(), 0, ret );
return NULL;
}
CombineRgn( clip, dev->region, rgn, RGN_AND );
ret = dev->region;
dev->region = clip;
update_x11_clipping( dev );
if ((data = X11DRV_GetRegionData( clip, 0 )))
{
update_x11_clipping( dev, data );
HeapFree( GetProcessHeap(), 0, data );
}
DeleteObject( clip );
return ret;
}
......@@ -221,12 +224,11 @@ HRGN add_extra_clipping_region( X11DRV_PDEVICE *dev, HRGN rgn )
/***********************************************************************
* restore_clipping_region
*/
void restore_clipping_region( X11DRV_PDEVICE *dev, HRGN rgn )
void restore_clipping_region( X11DRV_PDEVICE *dev, RGNDATA *data )
{
if (!rgn) return;
DeleteObject( dev->region );
dev->region = rgn;
update_x11_clipping( dev );
if (!data) return;
update_x11_clipping( dev, data );
HeapFree( GetProcessHeap(), 0, data );
}
......@@ -235,10 +237,13 @@ void restore_clipping_region( X11DRV_PDEVICE *dev, HRGN rgn )
*/
void X11DRV_SetDeviceClipping( PHYSDEV dev, HRGN vis_rgn, HRGN clip_rgn )
{
RGNDATA *data;
X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
CombineRgn( physDev->region, vis_rgn, clip_rgn, clip_rgn ? RGN_AND : RGN_COPY );
update_x11_clipping( physDev );
if ((data = X11DRV_GetRegionData( physDev->region, 0 ))) update_x11_clipping( physDev, data );
HeapFree( GetProcessHeap(), 0, data );
}
......
......@@ -41,6 +41,7 @@ BOOL X11DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
const RECT *lprect, LPCWSTR wstr, UINT count, const INT *lpDx )
{
X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
RGNDATA *saved_region = NULL;
unsigned int i;
fontObject* pfo;
XFontStruct* font;
......@@ -48,7 +49,6 @@ BOOL X11DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
XChar2b *str2b = NULL;
BOOL dibUpdateFlag = FALSE;
BOOL result = TRUE;
HRGN saved_region = 0;
if (!X11DRV_SetupGCForText( physDev )) return TRUE;
......@@ -98,7 +98,10 @@ BOOL X11DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
/* Draw the text (count > 0 verified) */
if (!(str2b = X11DRV_cptable[pfo->fi->cptable].punicode_to_char2b( pfo, wstr, count )))
goto FAIL;
{
result = FALSE;
goto END;
}
wine_tsx11_lock();
XSetForeground( gdi_display, physDev->gc, physDev->textPixel );
......@@ -116,8 +119,11 @@ BOOL X11DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
XTextItem16 *items;
items = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XTextItem16) );
if(items == NULL) goto FAIL;
if(items == NULL)
{
result = FALSE;
goto END;
}
items[0].chars = str2b;
items[0].delta = 0;
items[0].nchars = 1;
......@@ -167,17 +173,11 @@ BOOL X11DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
}
}
}
HeapFree( GetProcessHeap(), 0, str2b );
if (saved_region) restore_clipping_region( physDev, saved_region );
goto END;
FAIL:
HeapFree( GetProcessHeap(), 0, str2b );
result = FALSE;
END:
HeapFree( GetProcessHeap(), 0, str2b );
if (dibUpdateFlag) X11DRV_UnlockDIBSection( physDev, TRUE );
restore_clipping_region( physDev, saved_region );
return result;
}
......
......@@ -280,8 +280,8 @@ extern X_PHYSBITMAP *X11DRV_init_phys_bitmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN;
extern Pixmap X11DRV_get_pixmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN;
extern RGNDATA *X11DRV_GetRegionData( HRGN hrgn, HDC hdc_lptodp ) DECLSPEC_HIDDEN;
extern HRGN add_extra_clipping_region( X11DRV_PDEVICE *dev, HRGN rgn ) DECLSPEC_HIDDEN;
extern void restore_clipping_region( X11DRV_PDEVICE *dev, HRGN rgn ) DECLSPEC_HIDDEN;
extern RGNDATA *add_extra_clipping_region( X11DRV_PDEVICE *dev, HRGN rgn ) DECLSPEC_HIDDEN;
extern void restore_clipping_region( X11DRV_PDEVICE *dev, RGNDATA *data ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_SetupGCForPatBlt( X11DRV_PDEVICE *physDev, GC gc, BOOL fMapColors ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_SetupGCForBrush( X11DRV_PDEVICE *physDev ) DECLSPEC_HIDDEN;
......
......@@ -1948,7 +1948,7 @@ BOOL xrenderdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
gsCacheEntryFormat *formatEntry;
BOOL retv = FALSE;
int textPixel, backgroundPixel;
HRGN saved_region = 0;
RGNDATA *saved_region = NULL;
BOOL disable_antialias = FALSE;
AA_Type aa_type = AA_None;
unsigned int idx;
......@@ -1957,7 +1957,7 @@ BOOL xrenderdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
if (!physdev->x11dev->has_gdi_font)
{
dev = GET_NEXT_PHYSDEV( dev, pExtTextOut );
dev->funcs->pExtTextOut( dev, x, y, flags, lprect, wstr, count, lpDx );
return dev->funcs->pExtTextOut( dev, x, y, flags, lprect, wstr, count, lpDx );
}
if(is_dib_with_colortable( physdev->x11dev ))
......@@ -2266,7 +2266,7 @@ BOOL xrenderdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
}
LeaveCriticalSection(&xrender_cs);
if (saved_region) restore_clipping_region( physdev->x11dev, saved_region );
restore_clipping_region( physdev->x11dev, saved_region );
retv = TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment