Commit dc73184c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Directly use ntgdi interface to select objects.

parent 7c957ec9
......@@ -785,42 +785,42 @@ BOOL WINAPI MaskBlt(HDC hdcDest, INT nXDest, INT nYDest,
return BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, FRGND_ROP3(dwRop));
hbrMask = CreatePatternBrush(hbmMask);
hbrDst = SelectObject(hdcDest, GetStockObject(NULL_BRUSH));
hbrDst = NtGdiSelectBrush(hdcDest, GetStockObject(NULL_BRUSH));
/* make bitmap */
hDC1 = CreateCompatibleDC(hdcDest);
hBitmap1 = CreateCompatibleBitmap(hdcDest, nWidth, nHeight);
hOldBitmap1 = SelectObject(hDC1, hBitmap1);
hOldBitmap1 = NtGdiSelectBitmap(hDC1, hBitmap1);
/* draw using bkgnd rop */
BitBlt(hDC1, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, SRCCOPY);
hbrTmp = SelectObject(hDC1, hbrDst);
hbrTmp = NtGdiSelectBrush(hDC1, hbrDst);
BitBlt(hDC1, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, BKGND_ROP3(dwRop));
SelectObject(hDC1, hbrTmp);
NtGdiSelectBrush(hDC1, hbrTmp);
/* make bitmap */
hDC2 = CreateCompatibleDC(hdcDest);
hBitmap2 = CreateCompatibleBitmap(hdcDest, nWidth, nHeight);
hOldBitmap2 = SelectObject(hDC2, hBitmap2);
hOldBitmap2 = NtGdiSelectBitmap(hDC2, hBitmap2);
/* draw using foregnd rop */
BitBlt(hDC2, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, SRCCOPY);
hbrTmp = SelectObject(hDC2, hbrDst);
hbrTmp = NtGdiSelectBrush(hDC2, hbrDst);
BitBlt(hDC2, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, FRGND_ROP3(dwRop));
/* combine both using the mask as a pattern brush */
SelectObject(hDC2, hbrMask);
NtGdiSelectBrush(hDC2, hbrMask);
SetBrushOrgEx(hDC2, -xMask, -yMask, NULL);
BitBlt(hDC2, 0, 0, nWidth, nHeight, hDC1, 0, 0, 0xac0744 ); /* (D & P) | (S & ~P) */
SelectObject(hDC2, hbrTmp);
NtGdiSelectBrush(hDC2, hbrTmp);
/* blit to dst */
BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hDC2, 0, 0, SRCCOPY);
/* restore all objects */
SelectObject(hdcDest, hbrDst);
SelectObject(hDC1, hOldBitmap1);
SelectObject(hDC2, hOldBitmap2);
NtGdiSelectBrush(hdcDest, hbrDst);
NtGdiSelectBitmap(hDC1, hOldBitmap1);
NtGdiSelectBitmap(hDC2, hOldBitmap2);
/* delete all temp objects */
DeleteObject(hBitmap1);
......@@ -880,7 +880,7 @@ BOOL WINAPI GdiTransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDest,
bmpWork = CreateDIBSection( 0, &info, DIB_RGB_COLORS, NULL, NULL, 0 );
}
else bmpWork = CreateCompatibleBitmap(hdcDest, widthDest, heightDest);
oldWork = SelectObject(hdcWork, bmpWork);
oldWork = NtGdiSelectBitmap(hdcWork, bmpWork);
if(!StretchBlt(hdcWork, 0, 0, widthDest, heightDest, hdcSrc, xSrc, ySrc, widthSrc, heightSrc, SRCCOPY)) {
TRACE("Failed to stretch\n");
goto error;
......@@ -890,7 +890,7 @@ BOOL WINAPI GdiTransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDest,
/* Create mask */
hdcMask = CreateCompatibleDC(hdcDest);
bmpMask = CreateCompatibleBitmap(hdcMask, widthDest, heightDest);
oldMask = SelectObject(hdcMask, bmpMask);
oldMask = NtGdiSelectBitmap(hdcMask, bmpMask);
if(!BitBlt(hdcMask, 0, 0, widthDest, heightDest, hdcWork, 0, 0, SRCCOPY)) {
TRACE("Failed to create mask\n");
goto error;
......@@ -922,12 +922,12 @@ error:
SetBkColor(hdcDest, oldBackground);
SetTextColor(hdcDest, oldForeground);
if(hdcWork) {
SelectObject(hdcWork, oldWork);
NtGdiSelectBitmap(hdcWork, oldWork);
DeleteDC(hdcWork);
}
if(bmpWork) DeleteObject(bmpWork);
if(hdcMask) {
SelectObject(hdcMask, oldMask);
NtGdiSelectBitmap(hdcMask, oldMask);
DeleteDC(hdcMask);
}
if(bmpMask) DeleteObject(bmpMask);
......
......@@ -269,9 +269,9 @@ void DC_InitDC( DC* dc )
physdev->funcs->pRealizeDefaultPalette( physdev );
SetTextColor( dc->hSelf, dc->textColor );
SetBkColor( dc->hSelf, dc->backgroundColor );
SelectObject( dc->hSelf, dc->hPen );
SelectObject( dc->hSelf, dc->hBrush );
SelectObject( dc->hSelf, dc->hFont );
NtGdiSelectPen( dc->hSelf, dc->hPen );
NtGdiSelectBrush( dc->hSelf, dc->hBrush );
NtGdiSelectFont( dc->hSelf, dc->hFont );
update_dc_clipping( dc );
SetVirtualResolution( dc->hSelf, 0, 0, 0, 0 );
physdev = GET_DC_PHYSDEV( dc, pSetBoundsRect );
......@@ -365,8 +365,8 @@ void DC_UpdateXforms( DC *dc )
if (linear_xform_cmp( &oldworld2vport, &dc->xformWorld2Vport ) &&
GetObjectType( dc->hSelf ) != OBJ_METADC)
{
SelectObject(dc->hSelf, dc->hFont);
SelectObject(dc->hSelf, dc->hPen);
NtGdiSelectFont(dc->hSelf, dc->hFont);
NtGdiSelectPen(dc->hSelf, dc->hPen);
}
}
......@@ -515,10 +515,10 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level )
DC_UpdateXforms( dc );
update_dc_clipping( dc );
SelectObject( dev->hdc, dcs->hBitmap );
SelectObject( dev->hdc, dcs->hBrush );
SelectObject( dev->hdc, dcs->hFont );
SelectObject( dev->hdc, dcs->hPen );
NtGdiSelectBitmap( dev->hdc, dcs->hBitmap );
NtGdiSelectBrush( dev->hdc, dcs->hBrush );
NtGdiSelectFont( dev->hdc, dcs->hFont );
NtGdiSelectPen( dev->hdc, dcs->hPen );
SetBkColor( dev->hdc, dcs->backgroundColor);
SetTextColor( dev->hdc, dcs->textColor);
GDISelectPalette( dev->hdc, dcs->hPalette, FALSE );
......@@ -551,9 +551,9 @@ static BOOL reset_dc_state( HDC hdc )
set_initial_dc_state( dc );
SetBkColor( hdc, RGB( 255, 255, 255 ));
SetTextColor( hdc, RGB( 0, 0, 0 ));
SelectObject( hdc, GetStockObject( WHITE_BRUSH ));
SelectObject( hdc, GetStockObject( SYSTEM_FONT ));
SelectObject( hdc, GetStockObject( BLACK_PEN ));
NtGdiSelectBrush( hdc, GetStockObject( WHITE_BRUSH ));
NtGdiSelectFont( hdc, GetStockObject( SYSTEM_FONT ));
NtGdiSelectPen( hdc, GetStockObject( BLACK_PEN ));
SetVirtualResolution( hdc, 0, 0, 0, 0 );
GDISelectPalette( hdc, GetStockObject( DEFAULT_PALETTE ), FALSE );
SetBoundsRect( hdc, NULL, DCB_DISABLE );
......@@ -1067,7 +1067,7 @@ INT WINAPI SetGraphicsMode( HDC hdc, INT mode )
dc->GraphicsMode = mode;
}
/* font metrics depend on the graphics mode */
if (ret != mode) SelectObject(dc->hSelf, dc->hFont);
if (ret != mode) NtGdiSelectFont(dc->hSelf, dc->hFont);
release_dc_ptr( dc );
return ret;
}
......
......@@ -940,8 +940,8 @@ UINT WINAPI SetDIBColorTable( HDC hdc, UINT startpos, UINT entries, const RGBQUA
{
SetTextColor( hdc, dc->textColor );
SetBkColor( hdc, dc->backgroundColor );
SelectObject( hdc, dc->hPen );
SelectObject( hdc, dc->hBrush );
NtGdiSelectPen( hdc, dc->hPen );
NtGdiSelectBrush( hdc, dc->hBrush );
}
}
release_dc_ptr( dc );
......@@ -1686,7 +1686,7 @@ NTSTATUS WINAPI D3DKMTCreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc )
desc->hDc = dc;
desc->hBitmap = bitmap;
SelectObject( dc, bitmap );
NtGdiSelectBitmap( dc, bitmap );
return STATUS_SUCCESS;
error:
......
......@@ -5722,10 +5722,10 @@ BOOL CDECL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT
if (brush)
{
orig = SelectObject( dev->hdc, brush );
orig = NtGdiSelectBrush( dev->hdc, brush );
dp_to_lp( dc, (POINT *)&rc, 2 );
PatBlt( dev->hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY );
SelectObject( dev->hdc, orig );
NtGdiSelectBrush( dev->hdc, orig );
DeleteObject( brush );
}
}
......@@ -5811,7 +5811,7 @@ BOOL CDECL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT
}
pen = CreatePen( PS_SOLID, 1, dc->textColor );
orig = SelectObject( dev->hdc, pen );
orig = NtGdiSelectPen( dev->hdc, pen );
for (i = 0; i < count; i++)
{
......@@ -5840,7 +5840,7 @@ BOOL CDECL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT
}
}
SelectObject( dev->hdc, orig );
NtGdiSelectPen( dev->hdc, orig );
DeleteObject( pen );
return TRUE;
}
......@@ -6264,10 +6264,10 @@ done:
UINT size = GetOutlineTextMetricsW(hdc, 0, NULL);
OUTLINETEXTMETRICW* otm = NULL;
POINT pts[5];
HPEN hpen = SelectObject(hdc, GetStockObject(NULL_PEN));
HPEN hpen = NtGdiSelectPen(hdc, GetStockObject(NULL_PEN));
HBRUSH hbrush = CreateSolidBrush(dc->textColor);
hbrush = SelectObject(hdc, hbrush);
hbrush = NtGdiSelectBrush(hdc, hbrush);
if(!size)
{
......@@ -6322,8 +6322,8 @@ done:
Polygon(hdc, pts, 5);
}
SelectObject(hdc, hpen);
hbrush = SelectObject(hdc, hbrush);
NtGdiSelectPen(hdc, hpen);
hbrush = NtGdiSelectBrush(hdc, hbrush);
DeleteObject(hbrush);
}
......
......@@ -74,10 +74,10 @@ BOOL CDECL nulldrv_FillRgn( PHYSDEV dev, HRGN rgn, HBRUSH brush )
BOOL ret = FALSE;
HBRUSH prev;
if ((prev = SelectObject( dev->hdc, brush )))
if ((prev = NtGdiSelectBrush( dev->hdc, brush )))
{
ret = PaintRgn( dev->hdc, rgn );
SelectObject( dev->hdc, prev );
NtGdiSelectBrush( dev->hdc, prev );
}
return ret;
}
......@@ -97,10 +97,10 @@ BOOL CDECL nulldrv_FrameRgn( PHYSDEV dev, HRGN rgn, HBRUSH brush, INT width, INT
BOOL CDECL nulldrv_InvertRgn( PHYSDEV dev, HRGN rgn )
{
HBRUSH prev_brush = SelectObject( dev->hdc, GetStockObject(BLACK_BRUSH) );
HBRUSH prev_brush = NtGdiSelectBrush( dev->hdc, GetStockObject(BLACK_BRUSH) );
INT prev_rop = SetROP2( dev->hdc, R2_NOT );
BOOL ret = PaintRgn( dev->hdc, rgn );
SelectObject( dev->hdc, prev_brush );
NtGdiSelectBrush( dev->hdc, prev_brush );
SetROP2( dev->hdc, prev_rop );
return ret;
}
......
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