Commit 99a25831 authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Replace remaining instance of DC_GetDCUpdate by get_dc_ptr+update_dc.

parent baa8d225
...@@ -177,32 +177,6 @@ DC *DC_GetDCPtr( HDC hdc ) ...@@ -177,32 +177,6 @@ DC *DC_GetDCPtr( HDC hdc )
return dc; return dc;
} }
/***********************************************************************
* DC_GetDCUpdate
*
* Retrieve a DC ptr while making sure the visRgn is updated.
* This function may call up to USER so the GDI lock should _not_
* be held when calling it.
*/
DC *DC_GetDCUpdate( HDC hdc )
{
DC *dc = DC_GetDCPtr( hdc );
if (!dc) return NULL;
while (InterlockedExchange( &dc->dirty, 0 ))
{
DCHOOKPROC proc = dc->hookThunk;
if (proc)
{
DWORD_PTR data = dc->dwHookData;
DC_ReleaseDCPtr( dc );
proc( hdc, DCHC_INVALIDVISRGN, data, 0 );
if (!(dc = DC_GetDCPtr( hdc ))) break;
/* otherwise restart the loop in case it became dirty again in the meantime */
}
}
return dc;
}
/*********************************************************************** /***********************************************************************
* DC_ReleaseDCPtr * DC_ReleaseDCPtr
...@@ -488,20 +462,21 @@ void WINAPI SetDCState( HDC hdc, HDC hdcs ) ...@@ -488,20 +462,21 @@ void WINAPI SetDCState( HDC hdc, HDC hdcs )
{ {
DC *dc, *dcs; DC *dc, *dcs;
if (!(dc = DC_GetDCUpdate( hdc ))) return; if (!(dc = get_dc_ptr( hdc ))) return;
if (!(dcs = DC_GetDCPtr( hdcs ))) if (!(dcs = get_dc_ptr( hdcs )))
{ {
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return; return;
} }
if (!dcs->flags & DC_SAVED) if (!dcs->flags & DC_SAVED)
{ {
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
DC_ReleaseDCPtr( dcs ); release_dc_ptr( dcs );
return; return;
} }
TRACE("%p %p\n", hdc, hdcs ); TRACE("%p %p\n", hdc, hdcs );
update_dc( dc );
dc->flags = dcs->flags & ~DC_SAVED; dc->flags = dcs->flags & ~DC_SAVED;
dc->layout = dcs->layout; dc->layout = dcs->layout;
dc->hDevice = dcs->hDevice; dc->hDevice = dcs->hDevice;
...@@ -569,8 +544,8 @@ void WINAPI SetDCState( HDC hdc, HDC hdcs ) ...@@ -569,8 +544,8 @@ void WINAPI SetDCState( HDC hdc, HDC hdcs )
SetBkColor( hdc, dcs->backgroundColor); SetBkColor( hdc, dcs->backgroundColor);
SetTextColor( hdc, dcs->textColor); SetTextColor( hdc, dcs->textColor);
GDISelectPalette( hdc, dcs->hPalette, FALSE ); GDISelectPalette( hdc, dcs->hPalette, FALSE );
DC_ReleaseDCPtr( dcs ); release_dc_ptr( dc );
DC_ReleaseDCPtr( dc ); release_dc_ptr( dcs );
} }
...@@ -653,22 +628,23 @@ BOOL WINAPI RestoreDC( HDC hdc, INT level ) ...@@ -653,22 +628,23 @@ BOOL WINAPI RestoreDC( HDC hdc, INT level )
BOOL success; BOOL success;
TRACE("%p %d\n", hdc, level ); TRACE("%p %d\n", hdc, level );
dc = DC_GetDCUpdate( hdc ); if (!(dc = get_dc_ptr( hdc ))) return FALSE;
if(!dc) return FALSE;
if(abs(level) > dc->saveLevel || level == 0) if(abs(level) > dc->saveLevel || level == 0)
{ {
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return FALSE; return FALSE;
} }
update_dc( dc );
if(dc->funcs->pRestoreDC) if(dc->funcs->pRestoreDC)
{ {
success = dc->funcs->pRestoreDC( dc->physDev, level ); success = dc->funcs->pRestoreDC( dc->physDev, level );
if(level < 0) level = dc->saveLevel + level + 1; if(level < 0) level = dc->saveLevel + level + 1;
if(success) if(success)
dc->saveLevel = level - 1; dc->saveLevel = level - 1;
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return success; return success;
} }
...@@ -677,10 +653,10 @@ BOOL WINAPI RestoreDC( HDC hdc, INT level ) ...@@ -677,10 +653,10 @@ BOOL WINAPI RestoreDC( HDC hdc, INT level )
while (dc->saveLevel >= level) while (dc->saveLevel >= level)
{ {
HDC hdcs = dc->saved_dc; HDC hdcs = dc->saved_dc;
if (!(dcs = DC_GetDCPtr( hdcs ))) if (!(dcs = get_dc_ptr( hdcs )))
{ {
DC_ReleaseDCPtr( dc ); success = FALSE;
return FALSE; break;
} }
dc->saved_dc = dcs->saved_dc; dc->saved_dc = dcs->saved_dc;
dcs->saved_dc = 0; dcs->saved_dc = 0;
...@@ -692,12 +668,10 @@ BOOL WINAPI RestoreDC( HDC hdc, INT level ) ...@@ -692,12 +668,10 @@ BOOL WINAPI RestoreDC( HDC hdc, INT level )
* returning FALSE but still destroying the saved DC state */ * returning FALSE but still destroying the saved DC state */
success=FALSE; success=FALSE;
} }
DC_ReleaseDCPtr( dcs ); release_dc_ptr( dcs );
DC_ReleaseDCPtr( dc );
DeleteDC( hdcs ); DeleteDC( hdcs );
if (!(dc = DC_GetDCPtr( hdc ))) return FALSE;
} }
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return success; return success;
} }
......
...@@ -1879,7 +1879,7 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags, ...@@ -1879,7 +1879,7 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
BOOL done_extents = FALSE; BOOL done_extents = FALSE;
INT width = 0, xwidth = 0, ywidth = 0; INT width = 0, xwidth = 0, ywidth = 0;
DWORD type; DWORD type;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
INT breakRem; INT breakRem;
if (!dc) return FALSE; if (!dc) return FALSE;
...@@ -1891,15 +1891,16 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags, ...@@ -1891,15 +1891,16 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
if (!dc->funcs->pExtTextOut && !PATH_IsPathOpen(dc->path)) if (!dc->funcs->pExtTextOut && !PATH_IsPathOpen(dc->path))
{ {
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
update_dc( dc );
type = GetObjectType(hdc); type = GetObjectType(hdc);
if(type == OBJ_METADC || type == OBJ_ENHMETADC) if(type == OBJ_METADC || type == OBJ_ENHMETADC)
{ {
ret = dc->funcs->pExtTextOut(dc->physDev, x, y, flags, lprect, str, count, lpDx); ret = dc->funcs->pExtTextOut(dc->physDev, x, y, flags, lprect, str, count, lpDx);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
...@@ -2198,7 +2199,7 @@ done: ...@@ -2198,7 +2199,7 @@ done:
if(reordered_str != str) if(reordered_str != str)
HeapFree(GetProcessHeap(), 0, reordered_str); HeapFree(GetProcessHeap(), 0, reordered_str);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
if (ret && (lf.lfUnderline || lf.lfStrikeOut)) if (ret && (lf.lfUnderline || lf.lfStrikeOut))
{ {
......
...@@ -55,8 +55,8 @@ static DC* OPENGL_GetDefaultDC(void) ...@@ -55,8 +55,8 @@ static DC* OPENGL_GetDefaultDC(void)
{ {
if(!default_hdc) if(!default_hdc)
default_hdc = CreateDCA("DISPLAY", NULL, NULL, NULL); default_hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
return DC_GetDCPtr(default_hdc); return get_dc_ptr(default_hdc);
} }
/*********************************************************************** /***********************************************************************
...@@ -169,16 +169,17 @@ BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc) ...@@ -169,16 +169,17 @@ BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
if(hglrc == NULL) if(hglrc == NULL)
dc = OPENGL_GetDefaultDC(); dc = OPENGL_GetDefaultDC();
else else
dc = DC_GetDCUpdate( hdc ); dc = get_dc_ptr( hdc );
TRACE("hdc: (%p), hglrc: (%p)\n", hdc, hglrc); TRACE("hdc: (%p), hglrc: (%p)\n", hdc, hglrc);
if (!dc) return FALSE; if (!dc) return FALSE;
update_dc( dc );
if (!dc->funcs->pwglMakeCurrent) FIXME(" :stub\n"); if (!dc->funcs->pwglMakeCurrent) FIXME(" :stub\n");
else ret = dc->funcs->pwglMakeCurrent(dc->physDev,hglrc); else ret = dc->funcs->pwglMakeCurrent(dc->physDev,hglrc);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
...@@ -294,7 +295,7 @@ PROC WINAPI wglGetProcAddress(LPCSTR func) ...@@ -294,7 +295,7 @@ PROC WINAPI wglGetProcAddress(LPCSTR func)
if (!dc->funcs->pwglGetProcAddress) FIXME(" :stub\n"); if (!dc->funcs->pwglGetProcAddress) FIXME(" :stub\n");
else ret = dc->funcs->pwglGetProcAddress(func); else ret = dc->funcs->pwglGetProcAddress(func);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
/* At the moment we implement one WGL extension which requires a HDC. When we /* At the moment we implement one WGL extension which requires a HDC. When we
* are looking up this call and when the Extension is available (that is the case * are looking up this call and when the Extension is available (that is the case
......
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