Moved SetDrawable, StartGraphicsExposures and EndGraphicsExposures

functionality to x11drv escapes so that we don't have to access the DC
structure directly.
This commit is contained in:
Alexandre Julliard 2004-01-14 04:53:11 +00:00
parent 768008fa20
commit 85dcf1e1a0
6 changed files with 134 additions and 146 deletions

View File

@ -441,7 +441,6 @@
################################################################
# Wine dll separation hacks, these will go away, don't use them
#
@ cdecl DC_GetDCPtr(long)
@ cdecl DIB_CreateDIBSection(long ptr long ptr long long long)
@ cdecl GDI_GetObjPtr(long long)
@ cdecl GDI_ReleaseObj(long)

View File

@ -121,104 +121,3 @@ void X11DRV_SetDeviceClipping( X11DRV_PDEVICE *physDev, HRGN hrgn )
wine_tsx11_unlock();
HeapFree( GetProcessHeap(), 0, data );
}
/***********************************************************************
* X11DRV_SetDrawable
*
* Set the drawable, clipping mode and origin for a DC.
*/
void X11DRV_SetDrawable( HDC hdc, Drawable drawable, int mode, const POINT *org,
const POINT *drawable_org )
{
DC *dc = DC_GetDCPtr( hdc );
if (dc)
{
X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
if(physDev->xrender)
X11DRV_XRender_UpdateDrawable( physDev );
physDev->org = *org;
physDev->drawable = drawable;
physDev->drawable_org = *drawable_org;
wine_tsx11_lock();
XSetSubwindowMode( gdi_display, physDev->gc, mode );
wine_tsx11_unlock();
GDI_ReleaseObj( hdc );
}
}
/***********************************************************************
* X11DRV_StartGraphicsExposures
*
* Set the DC in graphics exposures mode
*/
void X11DRV_StartGraphicsExposures( HDC hdc )
{
DC *dc = DC_GetDCPtr( hdc );
if (dc)
{
X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
wine_tsx11_lock();
XSetGraphicsExposures( gdi_display, physDev->gc, True );
wine_tsx11_unlock();
physDev->exposures = 0;
GDI_ReleaseObj( hdc );
}
}
/***********************************************************************
* X11DRV_EndGraphicsExposures
*
* End the graphics exposures mode and process the events
*/
void X11DRV_EndGraphicsExposures( HDC hdc, HRGN hrgn )
{
HRGN tmp = 0;
DC *dc = DC_GetDCPtr( hdc );
if (dc)
{
XEvent event;
X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
SetRectRgn( hrgn, 0, 0, 0, 0 );
wine_tsx11_lock();
XSetGraphicsExposures( gdi_display, physDev->gc, False );
if (physDev->exposures)
{
for (;;)
{
XWindowEvent( gdi_display, physDev->drawable, ~0, &event );
if (event.type == NoExpose) break;
if (event.type == GraphicsExpose)
{
int x = event.xgraphicsexpose.x - physDev->org.x;
int y = event.xgraphicsexpose.y - physDev->org.y;
TRACE( "got %d,%d %dx%d count %d\n",
x, y, event.xgraphicsexpose.width, event.xgraphicsexpose.height,
event.xgraphicsexpose.count );
if (!tmp) tmp = CreateRectRgn( 0, 0, 0, 0 );
SetRectRgn( tmp, x, y,
x + event.xgraphicsexpose.width,
y + event.xgraphicsexpose.height );
CombineRgn( hrgn, hrgn, tmp, RGN_OR );
if (!event.xgraphicsexpose.count) break;
}
else
{
ERR( "got unexpected event %d\n", event.type );
break;
}
}
if (tmp) DeleteObject( tmp );
}
wine_tsx11_unlock();
GDI_ReleaseObj( hdc );
}
}

View File

@ -294,6 +294,77 @@ INT X11DRV_ExtEscape( X11DRV_PDEVICE *physDev, INT escape, INT in_count, LPCVOID
*(Font *)out_data = pfo->fs->fid;
return TRUE;
}
break;
case X11DRV_SET_DRAWABLE:
if (in_count >= sizeof(struct x11drv_escape_set_drawable))
{
struct x11drv_escape_set_drawable *data = (struct x11drv_escape_set_drawable *)in_data;
if(physDev->xrender) X11DRV_XRender_UpdateDrawable( physDev );
physDev->org = data->org;
physDev->drawable = data->drawable;
physDev->drawable_org = data->drawable_org;
wine_tsx11_lock();
XSetSubwindowMode( gdi_display, physDev->gc, data->mode );
wine_tsx11_unlock();
return TRUE;
}
break;
case X11DRV_START_EXPOSURES:
wine_tsx11_lock();
XSetGraphicsExposures( gdi_display, physDev->gc, True );
wine_tsx11_unlock();
physDev->exposures = 0;
return TRUE;
case X11DRV_END_EXPOSURES:
if (out_count >= sizeof(HRGN))
{
HRGN hrgn = 0, tmp = 0;
wine_tsx11_lock();
XSetGraphicsExposures( gdi_display, physDev->gc, False );
if (physDev->exposures)
{
for (;;)
{
XEvent event;
XWindowEvent( gdi_display, physDev->drawable, ~0, &event );
if (event.type == NoExpose) break;
if (event.type == GraphicsExpose)
{
int x = event.xgraphicsexpose.x - physDev->org.x;
int y = event.xgraphicsexpose.y - physDev->org.y;
TRACE( "got %d,%d %dx%d count %d\n", x, y,
event.xgraphicsexpose.width,
event.xgraphicsexpose.height,
event.xgraphicsexpose.count );
if (!tmp) tmp = CreateRectRgn( 0, 0, 0, 0 );
SetRectRgn( tmp, x, y,
x + event.xgraphicsexpose.width,
y + event.xgraphicsexpose.height );
if (hrgn) CombineRgn( hrgn, hrgn, tmp, RGN_OR );
else
{
hrgn = tmp;
tmp = 0;
}
if (!event.xgraphicsexpose.count) break;
}
else
{
ERR( "got unexpected event %d\n", event.type );
break;
}
}
if (tmp) DeleteObject( tmp );
}
wine_tsx11_unlock();
*(HRGN *)out_data = hrgn;
return TRUE;
}
break;
}
}
break;

View File

@ -75,14 +75,20 @@ INT X11DRV_ScrollWindowEx( HWND hwnd, INT dx, INT dy,
hDC = GetDCEx( hwnd, 0, DCX_CACHE | DCX_USESTYLE );
if (hDC)
{
HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
X11DRV_StartGraphicsExposures( hDC );
enum x11drv_escape_codes code = X11DRV_START_EXPOSURES;
HRGN hrgn = 0;
ExtEscape( hDC, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, 0, NULL );
ScrollDC( hDC, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate );
X11DRV_EndGraphicsExposures( hDC, hrgn );
code = X11DRV_END_EXPOSURES;
ExtEscape( hDC, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, sizeof(hrgn), (LPSTR)&hrgn );
ReleaseDC( hwnd, hDC );
if (bUpdate) CombineRgn( hrgnUpdate, hrgnUpdate, hrgn, RGN_OR );
else RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
DeleteObject( hrgn );
if (hrgn)
{
if (bUpdate) CombineRgn( hrgnUpdate, hrgnUpdate, hrgn, RGN_OR );
else RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
DeleteObject( hrgn );
}
}
/* Take into account the fact that some damage may have occurred during the scroll */

View File

@ -424,11 +424,10 @@ BOOL X11DRV_GetDC( HWND hwnd, HDC hdc, HRGN hrgn, DWORD flags )
WND *win = WIN_GetPtr( hwnd );
HWND top = 0;
X11DRV_WND_DATA *data = win->pDriverData;
Drawable drawable;
struct x11drv_escape_set_drawable escape;
BOOL visible;
POINT org, drawable_org;
int mode = IncludeInferiors;
escape.mode = IncludeInferiors;
/* don't clip siblings if using parent clip region */
if (flags & DCX_PARENTCLIP) flags &= ~DCX_CLIPSIBLINGS;
@ -460,48 +459,49 @@ BOOL X11DRV_GetDC( HWND hwnd, HDC hdc, HRGN hrgn, DWORD flags )
if (top)
{
HWND parent = GetAncestor( top, GA_PARENT );
org.x = org.y = 0;
escape.org.x = escape.org.y = 0;
if (flags & DCX_WINDOW)
{
org.x = win->rectWindow.left - win->rectClient.left;
org.y = win->rectWindow.top - win->rectClient.top;
escape.org.x = win->rectWindow.left - win->rectClient.left;
escape.org.y = win->rectWindow.top - win->rectClient.top;
}
MapWindowPoints( hwnd, parent, &org, 1 );
drawable_org.x = drawable_org.y = 0;
MapWindowPoints( parent, 0, &drawable_org, 1 );
MapWindowPoints( hwnd, parent, &escape.org, 1 );
escape.drawable_org.x = escape.drawable_org.y = 0;
MapWindowPoints( parent, 0, &escape.drawable_org, 1 );
/* have to use the parent so that we include siblings */
if (parent) drawable = X11DRV_get_client_window( parent );
else drawable = root_window;
if (parent) escape.drawable = X11DRV_get_client_window( parent );
else escape.drawable = root_window;
}
else
{
if (IsIconic( hwnd ))
{
drawable = data->icon_window ? data->icon_window : data->whole_window;
org.x = 0;
org.y = 0;
drawable_org = org;
escape.drawable = data->icon_window ? data->icon_window : data->whole_window;
escape.org.x = 0;
escape.org.y = 0;
escape.drawable_org = escape.org;
}
else if (flags & DCX_WINDOW)
{
drawable = data->whole_window;
org.x = win->rectWindow.left - data->whole_rect.left;
org.y = win->rectWindow.top - data->whole_rect.top;
drawable_org.x = data->whole_rect.left - win->rectClient.left;
drawable_org.y = data->whole_rect.top - win->rectClient.top;
escape.drawable = data->whole_window;
escape.org.x = win->rectWindow.left - data->whole_rect.left;
escape.org.y = win->rectWindow.top - data->whole_rect.top;
escape.drawable_org.x = data->whole_rect.left - win->rectClient.left;
escape.drawable_org.y = data->whole_rect.top - win->rectClient.top;
}
else
{
drawable = data->client_window;
org.x = 0;
org.y = 0;
drawable_org = org;
if (flags & DCX_CLIPCHILDREN) mode = ClipByChildren; /* can use X11 clipping */
escape.drawable = data->client_window;
escape.org.x = 0;
escape.org.y = 0;
escape.drawable_org = escape.org;
if (flags & DCX_CLIPCHILDREN) escape.mode = ClipByChildren; /* can use X11 clipping */
}
MapWindowPoints( hwnd, 0, &drawable_org, 1 );
MapWindowPoints( hwnd, 0, &escape.drawable_org, 1 );
}
X11DRV_SetDrawable( hdc, drawable, mode, &org, &drawable_org );
escape.code = X11DRV_SET_DRAWABLE;
ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL );
if (flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN) ||
SetHookFlags16( HDC_16(hdc), DCHF_VALIDATEVISRGN )) /* DC was dirty */
@ -511,7 +511,7 @@ BOOL X11DRV_GetDC( HWND hwnd, HDC hdc, HRGN hrgn, DWORD flags )
if (visible)
{
visRgn = get_visible_region( win, top, flags, mode );
visRgn = get_visible_region( win, top, flags, escape.mode );
if (flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN))
CombineRgn( visRgn, visRgn, hrgn,
@ -533,10 +533,15 @@ BOOL X11DRV_GetDC( HWND hwnd, HDC hdc, HRGN hrgn, DWORD flags )
*/
void X11DRV_ReleaseDC( HWND hwnd, HDC hdc )
{
POINT org;
struct x11drv_escape_set_drawable escape;
org.x = org.y = 0;
X11DRV_SetDrawable( hdc, root_window, IncludeInferiors, &org, &org );
escape.code = X11DRV_SET_DRAWABLE;
escape.drawable = root_window;
escape.mode = IncludeInferiors;
escape.org.x = escape.org.y = 0;
escape.drawable_org.x = escape.drawable_org.y = 0;
ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL );
}

View File

@ -205,10 +205,6 @@ extern Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc );
extern Pixmap X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp, HDC hdc );
extern RGNDATA *X11DRV_GetRegionData( HRGN hrgn, HDC hdc_lptodp );
extern void X11DRV_SetDrawable( HDC hdc, Drawable drawable, int mode, const POINT *org,
const POINT *drawable_org );
extern void X11DRV_StartGraphicsExposures( HDC hdc );
extern void X11DRV_EndGraphicsExposures( HDC hdc, HRGN hrgn );
extern BOOL X11DRV_SetupGCForPatBlt( X11DRV_PDEVICE *physDev, GC gc, BOOL fMapColors );
extern BOOL X11DRV_SetupGCForBrush( X11DRV_PDEVICE *physDev );
@ -332,9 +328,21 @@ extern int X11DRV_PALETTE_ToPhysical(X11DRV_PDEVICE *physDev, COLORREF color);
#define X11DRV_ESCAPE 6789
enum x11drv_escape_codes
{
X11DRV_GET_DISPLAY, /* get X11 display for a DC */
X11DRV_GET_DRAWABLE, /* get current drawable for a DC */
X11DRV_GET_FONT, /* get current X font for a DC */
X11DRV_GET_DISPLAY, /* get X11 display for a DC */
X11DRV_GET_DRAWABLE, /* get current drawable for a DC */
X11DRV_GET_FONT, /* get current X font for a DC */
X11DRV_SET_DRAWABLE, /* set current drawable for a DC */
X11DRV_START_EXPOSURES, /* start graphics exposures */
X11DRV_END_EXPOSURES, /* end graphics exposures */
};
struct x11drv_escape_set_drawable
{
enum x11drv_escape_codes code; /* escape code (X11DRV_SET_DRAWABLE) */
Drawable drawable; /* X drawable */
int mode; /* ClipByChildren or IncludeInferiors */
POINT org; /* origin of DC relative to drawable */
POINT drawable_org; /* origin of drawable relative to screen */
};
/**************************************************************************