* COPYRIGHT: GNU GPL, See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Bit blit functions
- * FILE: subsys/win32k/objects/bitblt.c
+ * FILE: win32ss/gdi/ntgdi/bitblt.c
* PROGRAMER: Unknown
*/
#include <win32k.h>
DBG_DEFAULT_CHANNEL(GdiBlt);
-#define ROP_USES_SOURCE(Rop) (((((Rop) & 0xCC0000) >> 2) != ((Rop) & 0x330000)) || ((((Rop) & 0xCC000000) >> 2) != ((Rop) & 0x33000000)))
-#define ROP_USES_MASK(Rop) (((Rop) & 0xFF000000) != (((Rop) & 0xff0000) << 8))
-
-#define FIXUP_ROP(Rop) if(((Rop) & 0xFF000000) == 0) Rop = MAKEROP4((Rop), (Rop))
-#define ROP_TO_ROP4(Rop) ((Rop) >> 16)
-
BOOL APIENTRY
NtGdiAlphaBlend(
HDC hDCDest,
return FALSE;
}
+ if ((hDCDest == NULL) || (hDCSrc == NULL))
+ {
+ EngSetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
TRACE("Locking DCs\n");
ahDC[0] = hDCDest;
ahDC[1] = hDCSrc ;
DestRect.right += DCDest->ptlDCOrig.x;
DestRect.bottom += DCDest->ptlDCOrig.y;
+ if (DCDest->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+ {
+ IntUpdateBoundsRect(DCDest, &DestRect);
+ }
+
SourceRect.left = XOriginSrc;
SourceRect.top = YOriginSrc;
SourceRect.right = XOriginSrc + WidthSrc;
/* Prepare DCs for blit */
TRACE("Preparing DCs for blit\n");
- DC_vPrepareDCsForBlit(DCDest, DestRect, DCSrc, SourceRect);
+ DC_vPrepareDCsForBlit(DCDest, &DestRect, DCSrc, &SourceRect);
/* Determine surfaces to be used in the bitblt */
BitmapDest = DCDest->dclevel.pSurface;
TRACE("Performing the alpha blend\n");
bResult = IntEngAlphaBlend(&BitmapDest->SurfObj,
&BitmapSrc->SurfObj,
- DCDest->rosdc.CombinedClip,
+ (CLIPOBJ *)&DCDest->co,
&exlo.xlo,
&DestRect,
&SourceRect,
HDC hDCSrc,
INT XSrc,
INT YSrc,
- DWORD ROP,
+ DWORD dwRop,
IN DWORD crBackColor,
IN FLONG fl)
{
+
+ if (dwRop & CAPTUREBLT)
+ {
+ return NtGdiStretchBlt(hDCDest,
+ XDest,
+ YDest,
+ Width,
+ Height,
+ hDCSrc,
+ XSrc,
+ YSrc,
+ Width,
+ Height,
+ dwRop,
+ crBackColor);
+ }
+
+ dwRop = dwRop & ~(NOMIRRORBITMAP|CAPTUREBLT);
+
/* Forward to NtGdiMaskBlt */
- // TODO: What's fl for?
+ // TODO: What's fl for? LOL not to send this to MaskBit!
return NtGdiMaskBlt(hDCDest,
XDest,
YDest,
NULL,
0,
0,
- ROP,
+ MAKEROP4(dwRop, dwRop),
crBackColor);
}
BOOL Ret = FALSE;
EXLATEOBJ exlo;
+ if ((hdcDst == NULL) || (hdcSrc == NULL))
+ {
+ EngSetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
TRACE("Locking DCs\n");
ahDC[0] = hdcDst;
ahDC[1] = hdcSrc ;
rcSrc.right += DCSrc->ptlDCOrig.x;
rcSrc.bottom += DCSrc->ptlDCOrig.y;
+ if (DCDest->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+ {
+ IntUpdateBoundsRect(DCDest, &rcDest);
+ }
+
/* Prepare for blit */
- DC_vPrepareDCsForBlit(DCDest, rcDest, DCSrc, rcSrc);
+ DC_vPrepareDCsForBlit(DCDest, &rcDest, DCSrc, &rcSrc);
BitmapDest = DCDest->dclevel.pSurface;
if (!BitmapDest)
EXLATEOBJ_vInitXlateFromDCs(&exlo, DCSrc, DCDest);
Ret = IntEngTransparentBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj,
- DCDest->rosdc.CombinedClip, &exlo.xlo, &rcDest, &rcSrc,
+ (CLIPOBJ *)&DCDest->co, &exlo.xlo, &rcDest, &rcSrc,
TransparentColor, 0);
EXLATEOBJ_vCleanup(&exlo);
HBITMAP hbmMask,
INT xMask,
INT yMask,
- DWORD dwRop,
+ DWORD dwRop4,
IN DWORD crBackColor)
{
PDC DCDest;
BOOL Status = FALSE;
EXLATEOBJ exlo;
XLATEOBJ *XlateObj = NULL;
- BOOL UsesSource = ROP_USES_SOURCE(dwRop);
- BOOL UsesMask;
-
- FIXUP_ROP(dwRop);
+ BOOL UsesSource;
+ ROP4 rop4;
- UsesMask = ROP_USES_MASK(dwRop);
+ rop4 = WIN32_ROP4_TO_ENG_ROP4(dwRop4);
- //DPRINT1("dwRop : 0x%08x\n", dwRop);
+ UsesSource = ROP4_USES_SOURCE(rop4);
if (!hdcDest || (UsesSource && !hdcSrc))
{
EngSetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
- /* Take care of mask bitmap */
- if(hbmMask)
+ /* Check if we need a mask and have a mask bitmap */
+ if (ROP4_USES_MASK(rop4) && (hbmMask != NULL))
{
+ /* Reference the mask bitmap */
psurfMask = SURFACE_ShareLockSurface(hbmMask);
- if(!psurfMask)
+ if (psurfMask == NULL)
{
EngSetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
- }
- if(UsesMask)
- {
- if(!psurfMask)
- {
- EngSetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
- if(gajBitsPerFormat[psurfMask->SurfObj.iBitmapFormat] != 1)
+ /* Make sure the mask bitmap is 1 BPP */
+ if (gajBitsPerFormat[psurfMask->SurfObj.iBitmapFormat] != 1)
{
EngSetLastError(ERROR_INVALID_PARAMETER);
SURFACE_ShareUnlockSurface(psurfMask);
return FALSE;
}
}
- else if(psurfMask)
+ else
{
- WARN("Getting Mask bitmap without needing it?\n");
- SURFACE_ShareUnlockSurface(psurfMask);
+ /* We use NULL, if we need a mask, the Eng function will take care of
+ that and use the brushobject to get a mask */
psurfMask = NULL;
}
+
MaskPoint.x = xMask;
MaskPoint.y = yMask;
ahDC[1] = UsesSource ? hdcSrc : NULL;
if (!GDIOBJ_bLockMultipleObjects(2, (HGDIOBJ*)ahDC, apObj, GDIObjType_DC_TYPE))
{
- WARN("Invalid dc handle (dest=0x%p, src=0x%p) passed to NtGdiAlphaBlend\n", hdcDest, hdcSrc);
+ WARN("Invalid dc handle (dest=0x%p, src=0x%p) passed to NtGdiMaskBlt\n", hdcDest, hdcSrc);
EngSetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (NULL == DCDest)
{
if(DCSrc) DC_UnlockDc(DCSrc);
- WARN("Invalid destination dc handle (0x%p) passed to NtGdiBitBlt\n", hdcDest);
+ WARN("Invalid destination dc handle (0x%p) passed to NtGdiMaskBlt\n", hdcDest);
return FALSE;
}
DestRect.right += DCDest->ptlDCOrig.x;
DestRect.bottom += DCDest->ptlDCOrig.y;
+ if (DCDest->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+ {
+ IntUpdateBoundsRect(DCDest, &DestRect);
+ }
+
SourcePoint.x = nXSrc;
SourcePoint.y = nYSrc;
}
/* Prepare blit */
- DC_vPrepareDCsForBlit(DCDest, DestRect, DCSrc, SourceRect);
+ DC_vPrepareDCsForBlit(DCDest, &DestRect, DCSrc, &SourceRect);
if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
DC_vUpdateFillBrush(DCDest);
XlateObj = &exlo.xlo;
}
-
/* Perform the bitblt operation */
Status = IntEngBitBlt(&BitmapDest->SurfObj,
BitmapSrc ? &BitmapSrc->SurfObj : NULL,
psurfMask ? &psurfMask->SurfObj : NULL,
- DCDest->rosdc.CombinedClip,
+ (CLIPOBJ *)&DCDest->co,
XlateObj,
&DestRect,
&SourcePoint,
&MaskPoint,
&DCDest->eboFill.BrushObject,
&DCDest->dclevel.pbrFill->ptOrigin,
- ROP_TO_ROP4(dwRop));
+ rop4);
if (UsesSource)
EXLATEOBJ_vCleanup(&exlo);
return FALSE;
}
-BOOL APIENTRY
+BOOL
+NTAPI
GreStretchBltMask(
HDC hDCDest,
INT XOriginDest,
INT YOriginSrc,
INT WidthSrc,
INT HeightSrc,
- DWORD ROP,
+ DWORD dwRop4,
IN DWORD dwBackColor,
HDC hDCMask,
INT XOriginMask,
POINTL BrushOrigin;
BOOL UsesSource;
BOOL UsesMask;
+ ROP4 rop4;
- FIXUP_ROP(ROP);
- UsesSource = ROP_USES_SOURCE(ROP);
- UsesMask = ROP_USES_MASK(ROP);
+ rop4 = WIN32_ROP4_TO_ENG_ROP4(dwRop4);
+
+ UsesSource = ROP4_USES_SOURCE(rop4);
+ UsesMask = ROP4_USES_MASK(rop4);
if (0 == WidthDest || 0 == HeightDest || 0 == WidthSrc || 0 == HeightSrc)
{
DestRect.right += DCDest->ptlDCOrig.x;
DestRect.bottom += DCDest->ptlDCOrig.y;
+ if (DCDest->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+ {
+ IntUpdateBoundsRect(DCDest, &DestRect);
+ }
+
SourceRect.left = XOriginSrc;
SourceRect.top = YOriginSrc;
SourceRect.right = XOriginSrc+WidthSrc;
BrushOrigin.y = 0;
/* Only prepare Source and Dest, hdcMask represents a DIB */
- DC_vPrepareDCsForBlit(DCDest, DestRect, DCSrc, SourceRect);
+ DC_vPrepareDCsForBlit(DCDest, &DestRect, DCSrc, &SourceRect);
if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
DC_vUpdateFillBrush(DCDest);
Status = IntEngStretchBlt(&BitmapDest->SurfObj,
BitmapSrc ? &BitmapSrc->SurfObj : NULL,
BitmapMask ? &BitmapMask->SurfObj : NULL,
- DCDest->rosdc.CombinedClip,
+ (CLIPOBJ *)&DCDest->co,
XlateObj,
&DCDest->dclevel.ca,
&DestRect,
BitmapMask ? &MaskPoint : NULL,
&DCDest->eboFill.BrushObject,
&BrushOrigin,
- ROP_TO_ROP4(ROP));
+ rop4);
if (UsesSource)
{
EXLATEOBJ_vCleanup(&exlo);
INT YOriginSrc,
INT WidthSrc,
INT HeightSrc,
- DWORD ROP,
+ DWORD dwRop3,
IN DWORD dwBackColor)
{
+ dwRop3 = dwRop3 & ~(NOMIRRORBITMAP|CAPTUREBLT);
+
return GreStretchBltMask(
hDCDest,
XOriginDest,
YOriginSrc,
WidthSrc,
HeightSrc,
- ROP,
+ MAKEROP4(dwRop3 & 0xFF0000, dwRop3),
dwBackColor,
NULL,
0,
INT YLeft,
INT Width,
INT Height,
- DWORD dwRop,
+ DWORD dwRop3,
PEBRUSHOBJ pebo)
{
RECTL DestRect;
pbrush = pebo->pbrush;
ASSERT(pbrush);
- FIXUP_ROP(dwRop);
-
if (pbrush->flAttrs & BR_IS_NULL)
{
return TRUE;
DestRect.top += pdc->ptlDCOrig.y;
DestRect.right += pdc->ptlDCOrig.x;
DestRect.bottom += pdc->ptlDCOrig.y;
+
+ if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+ {
+ IntUpdateBoundsRect(pdc, &DestRect);
+ }
+
#ifdef _USE_DIBLIB_
BrushOrigin.x = pbrush->ptOrigin.x + pdc->ptlDCOrig.x + XLeft;
BrushOrigin.y = pbrush->ptOrigin.y + pdc->ptlDCOrig.y + YLeft;
BrushOrigin.y = pbrush->ptOrigin.y + pdc->ptlDCOrig.y;
#endif
- DC_vPrepareDCsForBlit(pdc, DestRect, NULL, DestRect);
+ DC_vPrepareDCsForBlit(pdc, &DestRect, NULL, NULL);
psurf = pdc->dclevel.pSurface;
- ret = IntEngBitBlt(
- &psurf->SurfObj,
- NULL,
- NULL,
- pdc->rosdc.CombinedClip,
- NULL,
- &DestRect,
- NULL,
- NULL,
- &pebo->BrushObject,
- &BrushOrigin,
- ROP_TO_ROP4(dwRop));
+ ret = IntEngBitBlt(&psurf->SurfObj,
+ NULL,
+ NULL,
+ (CLIPOBJ *)&pdc->co,
+ NULL,
+ &DestRect,
+ NULL,
+ NULL,
+ &pebo->BrushObject,
+ &BrushOrigin,
+ WIN32_ROP3_TO_ENG_ROP4(dwRop3));
DC_vFinishBlit(pdc, NULL);
BOOL bResult;
PDC pdc;
- /* Mask away everything except foreground rop index */
- dwRop = dwRop & 0x00FF0000;
- dwRop |= dwRop << 8;
+ /* Convert the ROP3 to a ROP4 */
+ dwRop = MAKEROP4(dwRop & 0xFF0000, dwRop);
/* Check if the rop uses a source */
- if (ROP_USES_SOURCE(dwRop))
+ if (WIN32_ROP4_USES_SOURCE(dwRop))
{
/* This is not possible */
- return 0;
+ return FALSE;
}
/* Lock the DC */
return TRUE;
}
- /* Update the fill brush, if neccessary */
+ /* Update the fill brush, if necessary */
if (pdc->pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
DC_vUpdateFillBrush(pdc);
return Ret;
}
+static
+BOOL
+FASTCALL
+REGION_LPTODP(
+ _In_ PDC pdc,
+ _Inout_ PREGION prgnDest,
+ _In_ PREGION prgnSrc)
+{
+ if (IntGdiCombineRgn(prgnDest, prgnSrc, NULL, RGN_COPY) == ERROR)
+ return FALSE;
+
+ return REGION_bXformRgn(prgnDest, DC_pmxWorldToDevice(pdc));
+}
+
+BOOL
+APIENTRY
+IntGdiBitBltRgn(
+ _In_ PDC pdc,
+ _In_ PREGION prgn,
+ _In_opt_ BRUSHOBJ *pbo,
+ _In_opt_ POINTL *pptlBrush,
+ _In_ ROP4 rop4)
+{
+ PREGION prgnClip;
+ XCLIPOBJ xcoClip;
+ BOOL bResult;
+ NT_ASSERT((pdc != NULL) && (prgn != NULL));
+
+ /* Check if we have a surface */
+ if (pdc->dclevel.pSurface == NULL)
+ {
+ return TRUE;
+ }
+
+ /* Create an empty clip region */
+ prgnClip = IntSysCreateRectpRgn(0, 0, 0, 0);
+ if (prgnClip == NULL)
+ {
+ return FALSE;
+ }
+
+ /* Transform given region into device coordinates */
+ if (!REGION_LPTODP(pdc, prgnClip, prgn))
+ {
+ REGION_Delete(prgnClip);
+ return FALSE;
+ }
+
+ /* Intersect with the system or RAO region (these are (atm) without DC-origin) */
+ if (pdc->prgnRao)
+ IntGdiCombineRgn(prgnClip, prgnClip, pdc->prgnRao, RGN_AND);
+ else
+ IntGdiCombineRgn(prgnClip, prgnClip, pdc->prgnVis, RGN_AND);
+
+ /* Now account for the DC-origin */
+ if (!REGION_bOffsetRgn(prgnClip, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y))
+ {
+ REGION_Delete(prgnClip);
+ return FALSE;
+ }
+
+ if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+ {
+ RECTL rcrgn;
+ REGION_GetRgnBox(prgnClip, &rcrgn);
+ IntUpdateBoundsRect(pdc, &rcrgn);
+ }
+
+ /* Prepare the DC */
+ DC_vPrepareDCsForBlit(pdc, &prgnClip->rdh.rcBound, NULL, NULL);
+
+ /* Initialize a clip object */
+ IntEngInitClipObj(&xcoClip);
+ IntEngUpdateClipRegion(&xcoClip,
+ prgnClip->rdh.nCount,
+ prgnClip->Buffer,
+ &prgnClip->rdh.rcBound);
+
+ /* Call the Eng or Drv function */
+ bResult = IntEngBitBlt(&pdc->dclevel.pSurface->SurfObj,
+ NULL,
+ NULL,
+ (CLIPOBJ *)&xcoClip,
+ NULL,
+ &prgnClip->rdh.rcBound,
+ NULL,
+ NULL,
+ pbo,
+ pptlBrush,
+ rop4);
+
+ /* Cleanup */
+ DC_vFinishBlit(pdc, NULL);
+ REGION_Delete(prgnClip);
+ IntEngFreeClipResources(&xcoClip);
+
+ /* Return the result */
+ return bResult;
+}
+
+BOOL
+IntGdiFillRgn(
+ _In_ PDC pdc,
+ _In_ PREGION prgn,
+ _In_opt_ PBRUSH pbrFill)
+{
+ PREGION prgnClip;
+ XCLIPOBJ xcoClip;
+ EBRUSHOBJ eboFill;
+ BRUSHOBJ *pbo;
+ BOOL bRet;
+ DWORD rop2Fg;
+ MIX mix;
+ NT_ASSERT((pdc != NULL) && (prgn != NULL));
+
+ if (pdc->dclevel.pSurface == NULL)
+ {
+ return TRUE;
+ }
+
+ prgnClip = IntSysCreateRectpRgn(0, 0, 0, 0);
+ if (prgnClip == NULL)
+ {
+ return FALSE;
+ }
+
+ /* Transform region into device coordinates */
+ if (!REGION_LPTODP(pdc, prgnClip, prgn))
+ {
+ REGION_Delete(prgnClip);
+ return FALSE;
+ }
+
+ /* Intersect with the system or RAO region (these are (atm) without DC-origin) */
+ if (pdc->prgnRao)
+ IntGdiCombineRgn(prgnClip, prgnClip, pdc->prgnRao, RGN_AND);
+ else
+ IntGdiCombineRgn(prgnClip, prgnClip, pdc->prgnVis, RGN_AND);
+
+ /* Now account for the DC-origin */
+ if (!REGION_bOffsetRgn(prgnClip, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y))
+ {
+ REGION_Delete(prgnClip);
+ return FALSE;
+ }
+
+ if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+ {
+ RECTL rcrgn;
+ REGION_GetRgnBox(prgnClip, &rcrgn);
+ IntUpdateBoundsRect(pdc, &rcrgn);
+ }
+
+ IntEngInitClipObj(&xcoClip);
+ IntEngUpdateClipRegion(&xcoClip,
+ prgnClip->rdh.nCount,
+ prgnClip->Buffer,
+ &prgnClip->rdh.rcBound );
+
+ /* Get the FG rop and create a MIX based on the BK mode */
+ rop2Fg = FIXUP_ROP2(pdc->pdcattr->jROP2);
+ mix = rop2Fg | (pdc->pdcattr->jBkMode == OPAQUE ? rop2Fg : R2_NOP) << 8;
+
+ /* Prepare DC for blit */
+ DC_vPrepareDCsForBlit(pdc, &prgnClip->rdh.rcBound, NULL, NULL);
+
+ /* Check if we have a fill brush */
+ if (pbrFill != NULL)
+ {
+ /* Initialize the brush object */
+ /// \todo Check parameters
+ EBRUSHOBJ_vInit(&eboFill, pbrFill, pdc->dclevel.pSurface, 0x00FFFFFF, 0, NULL);
+ pbo = &eboFill.BrushObject;
+ }
+ else
+ {
+ /* Update the fill brush if needed */
+ if (pdc->pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
+ DC_vUpdateFillBrush(pdc);
+
+ /* Use the DC brush object */
+ pbo = &pdc->eboFill.BrushObject;
+ }
+
+ /* Call the internal function */
+ bRet = IntEngPaint(&pdc->dclevel.pSurface->SurfObj,
+ (CLIPOBJ *)&xcoClip,
+ pbo,
+ &pdc->pdcattr->ptlBrushOrigin,
+ mix);
+
+ DC_vFinishBlit(pdc, NULL);
+ REGION_Delete(prgnClip);
+ IntEngFreeClipResources(&xcoClip);
+
+ // Fill the region
+ return bRet;
+}
+
+BOOL
+FASTCALL
+IntGdiPaintRgn(
+ _In_ PDC pdc,
+ _In_ PREGION prgn)
+{
+ return IntGdiFillRgn(pdc, prgn, NULL);
+}
+
+BOOL
+APIENTRY
+NtGdiFillRgn(
+ _In_ HDC hdc,
+ _In_ HRGN hrgn,
+ _In_ HBRUSH hbrush)
+{
+ PDC pdc;
+ PREGION prgn;
+ PBRUSH pbrFill;
+ BOOL bResult;
+
+ /* Lock the DC */
+ pdc = DC_LockDc(hdc);
+ if (pdc == NULL)
+ {
+ ERR("Failed to lock hdc %p\n", hdc);
+ return FALSE;
+ }
+
+ /* Check if the DC has no surface (empty mem or info DC) */
+ if (pdc->dclevel.pSurface == NULL)
+ {
+ DC_UnlockDc(pdc);
+ return TRUE;
+ }
+
+ /* Lock the region */
+ prgn = REGION_LockRgn(hrgn);
+ if (prgn == NULL)
+ {
+ ERR("Failed to lock hrgn %p\n", hrgn);
+ DC_UnlockDc(pdc);
+ return FALSE;
+ }
+
+ /* Lock the brush */
+ pbrFill = BRUSH_ShareLockBrush(hbrush);
+ if (pbrFill == NULL)
+ {
+ ERR("Failed to lock hbrush %p\n", hbrush);
+ REGION_UnlockRgn(prgn);
+ DC_UnlockDc(pdc);
+ return FALSE;
+ }
+
+ /* Call the internal function */
+ bResult = IntGdiFillRgn(pdc, prgn, pbrFill);
+
+ /* Cleanup locks */
+ BRUSH_ShareUnlockBrush(pbrFill);
+ REGION_UnlockRgn(prgn);
+ DC_UnlockDc(pdc);
+
+ return bResult;
+}
+
+BOOL
+APIENTRY
+NtGdiFrameRgn(
+ _In_ HDC hdc,
+ _In_ HRGN hrgn,
+ _In_ HBRUSH hbrush,
+ _In_ INT xWidth,
+ _In_ INT yHeight)
+{
+ HRGN hrgnFrame;
+ BOOL bResult;
+
+ hrgnFrame = GreCreateFrameRgn(hrgn, xWidth, yHeight);
+ if (hrgnFrame == NULL)
+ {
+ return FALSE;
+ }
+
+ bResult = NtGdiFillRgn(hdc, hrgnFrame, hbrush);
+
+ GreDeleteObject(hrgnFrame);
+ return bResult;
+}
+
+BOOL
+APIENTRY
+NtGdiInvertRgn(
+ _In_ HDC hdc,
+ _In_ HRGN hrgn)
+{
+ BOOL bResult;
+ PDC pdc;
+ PREGION prgn;
+
+ /* Lock the DC */
+ pdc = DC_LockDc(hdc);
+ if (pdc == NULL)
+ {
+ EngSetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ /* Check if the DC has no surface (empty mem or info DC) */
+ if (pdc->dclevel.pSurface == NULL)
+ {
+ /* Nothing to do, Windows returns TRUE! */
+ DC_UnlockDc(pdc);
+ return TRUE;
+ }
+
+ /* Lock the region */
+ prgn = REGION_LockRgn(hrgn);
+ if (prgn == NULL)
+ {
+ DC_UnlockDc(pdc);
+ return FALSE;
+ }
+
+ /* Call the internal function */
+ bResult = IntGdiBitBltRgn(pdc,
+ prgn,
+ NULL, // pbo
+ NULL, // pptlBrush,
+ ROP4_DSTINVERT);
+
+ /* Unlock the region and DC and return the result */
+ REGION_UnlockRgn(prgn);
+ DC_UnlockDc(pdc);
+ return bResult;
+}
COLORREF
APIENTRY
return -1;
}
+ if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
+ {
+ RECTL rcDst;
+
+ RECTL_vSetRect(&rcDst, x, y, x+1, y+1);
+
+ IntLPtoDP(pdc, (LPPOINT)&rcDst, 2);
+
+ rcDst.left += pdc->ptlDCOrig.x;
+ rcDst.top += pdc->ptlDCOrig.y;
+ rcDst.right += pdc->ptlDCOrig.x;
+ rcDst.bottom += pdc->ptlDCOrig.y;
+
+ IntUpdateBoundsRect(pdc, &rcDst);
+ }
+
/* Translate the color to the target format */
iSolidColor = TranslateCOLORREF(pdc, crColor);
EBRUSHOBJ_iSetSolidColor(pebo, iOldColor);
pdc->pdcattr->ulDirty_ = ulDirty;
+ /// FIXME: we shouldn't dereference pSurface while the PDEV is not locked!
/* Initialize an XLATEOBJ from the target surface to RGB */
EXLATEOBJ_vInitialize(&exlo,
pdc->dclevel.pSurface->ppal,
PDC pdc;
ULONG ulRGBColor = CLR_INVALID;
POINTL ptlSrc;
+ RECT rcDest;
PSURFACE psurfSrc, psurfDest;
/* Lock the DC */
}
/* Check if the DC has no surface (empty mem or info DC) */
- psurfSrc = pdc->dclevel.pSurface;
- if (psurfSrc == NULL)
+ if (pdc->dclevel.pSurface == NULL)
{
/* Fail! */
goto leave;
ptlSrc.x += pdc->ptlDCOrig.x;
ptlSrc.y += pdc->ptlDCOrig.y;
+ rcDest.left = x;
+ rcDest.top = y;
+ rcDest.right = x + 1;
+ rcDest.bottom = y + 1;
+
+ /* Prepare DC for blit */
+ DC_vPrepareDCsForBlit(pdc, &rcDest, NULL, NULL);
+
/* Check if the pixel is outside the surface */
+ psurfSrc = pdc->dclevel.pSurface;
if ((ptlSrc.x >= psurfSrc->SurfObj.sizlBitmap.cx) ||
- (ptlSrc.y >= psurfSrc->SurfObj.sizlBitmap.cy))
+ (ptlSrc.y >= psurfSrc->SurfObj.sizlBitmap.cy) ||
+ (ptlSrc.x < 0) ||
+ (ptlSrc.y < 0))
{
/* Fail! */
goto leave;
BMF_32BPP,
0,
0,
+ 0,
&ulRGBColor);
if (psurfDest)
{
}
leave:
+
/* Unlock the DC */
+ DC_vFinishBlit(pdc, NULL);
DC_UnlockDc(pdc);
/* Return the new RGB color or -1 on failure */