Author: fireball
Date: Tue Aug 11 15:26:06 2009
New Revision: 42614
URL:
http://svn.reactos.org/svn/reactos?rev=42614&view=rev
Log:
- Don't try to lock DC twice in BitBlt if it's a same DC.
- Implement GetPixel operation (lacks color conversion!).
- Implement SetPixel using the idea from trunk's win32k: create a solid brush and
PatBlt it to the needed place. Return value needs to be checked though, what gdi32 expects
from it.
Modified:
branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c
branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c
branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c
branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h
branches/arwinss/reactos/subsystems/win32/win32k/include/palobj.h
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] Tue Aug 11
15:26:06 2009
@@ -36,13 +36,16 @@
/* Get a pointer to the DCs */
pSrc = DC_Lock(physDevSrc);
- pDst = DC_Lock(physDevDst);
+ if (physDevSrc != physDevDst)
+ pDst = DC_Lock(physDevDst);
+ else
+ pDst = pSrc;
/* Call the internal helper */
bRes = GreBitBlt(pDst, xDst, yDst, width, height, pSrc, xSrc, ySrc, rop);
/* Release DC objects */
- DC_Unlock(pDst);
+ if (physDevSrc != physDevDst) DC_Unlock(pDst);
DC_Unlock(pSrc);
/* Return status */
@@ -227,8 +230,33 @@
COLORREF APIENTRY RosGdiGetPixel( HDC physDev, INT x, INT y )
{
- UNIMPLEMENTED;
- return 0;
+ PDC pDC;
+ COLORREF crPixel;
+
+ /* Get a pointer to the DC */
+ pDC = DC_Lock(physDev);
+
+ crPixel = GreGetPixel(pDC, x, y);
+
+ /* Release DC */
+ DC_Unlock(pDC);
+
+ return crPixel;
+}
+
+COLORREF APIENTRY RosGdiSetPixel( HDC physDev, INT x, INT y, COLORREF color )
+{
+ PDC pDC;
+
+ /* Get a pointer to the DC */
+ pDC = DC_Lock(physDev);
+
+ GreSetPixel(pDC, x, y, color);
+
+ /* Release DC */
+ DC_Unlock(pDC);
+
+ return color;
}
BOOL APIENTRY RosGdiPatBlt( HDC physDev, INT left, INT top, INT width, INT height, DWORD
rop )
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] Tue Aug 11
15:26:06 2009
@@ -484,12 +484,6 @@
return FALSE;
}
-COLORREF APIENTRY RosGdiSetPixel( HDC physDev, INT x, INT y, COLORREF color )
-{
- UNIMPLEMENTED;
- return 0;
-}
-
BOOL APIENTRY RosGdiSetPixelFormat(HDC physDev,
int iPixelFormat,
const PIXELFORMATDESCRIPTOR *ppfd)
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c [iso-8859-1] Tue Aug 11
15:26:06 2009
@@ -238,3 +238,65 @@
/* Return amount copied */
return ulBytes;
}
+
+COLORREF
+NTAPI
+GreGetPixel(
+ PDC pDC,
+ UINT x,
+ UINT y)
+{
+ COLORREF crPixel = (COLORREF)CLR_INVALID;
+ PSURFACE psurf;
+ SURFOBJ *pso;
+
+ /* Offset coordinate by DC origin */
+ x += pDC->rcVport.left + pDC->rcDcRect.left;
+ y += pDC->rcVport.top + pDC->rcDcRect.top;
+
+ /* If points is outside combined clipping region - return error */
+ if (!RECTL_bPointInRect(&pDC->CombinedClip->rclBounds, x, y))
+ return CLR_INVALID;
+
+ /* Get DC's surface */
+ psurf = pDC->pBitmap;
+
+ if (!psurf) return CLR_INVALID;
+
+ pso = &psurf->SurfObj;
+
+ /* Actually get the pixel */
+ if (pso->pvScan0)
+ {
+ ASSERT(pso->lDelta);
+
+ // FIXME: Translate the color?
+ crPixel = DibFunctionsForBitmapFormat[pso->iBitmapFormat].DIB_GetPixel(pso, x,
y);
+ }
+
+ /* Return found pixel color */
+ return crPixel;
+}
+
+VOID
+NTAPI
+GreSetPixel(
+ PDC pDC,
+ UINT x,
+ UINT y,
+ COLORREF crColor)
+{
+ PBRUSHGDI pOldBrush = pDC->pFillBrush;
+
+ /* Create a solid brush with this color */
+ pDC->pFillBrush = GreCreateSolidBrush(crColor);
+
+ /* Put pixel */
+ GrePatBlt(pDC, x, y, 1, 1, PATCOPY, pDC->pFillBrush);
+
+ /* Free the created brush */
+ GreFreeBrush(pDC->pFillBrush);
+
+ /* Restore the old brush */
+ pDC->pFillBrush = pOldBrush;
+}
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h [iso-8859-1] Tue Aug 11
15:26:06 2009
@@ -172,6 +172,23 @@
y >= prcl->top && y <= prcl->bottom);
}
+/* surfobj.c */
+COLORREF
+NTAPI
+GreGetPixel(
+ PDC pDC,
+ UINT x,
+ UINT y);
+
+VOID
+NTAPI
+GreSetPixel(
+ PDC pDC,
+ UINT x,
+ UINT y,
+ COLORREF crColor);
+
+
/* Private Eng functions */
BOOL APIENTRY
EngpStretchBlt(SURFOBJ *psoDest,
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/palobj.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/palobj.h [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/palobj.h [iso-8859-1] Tue Aug
11 15:26:06 2009
@@ -44,5 +44,7 @@
#define PALETTE_LockPalette(hPalette) ((PPALETTE)GDIOBJ_LockObj((HGDIOBJ)hPalette,
GDI_OBJECT_TYPE_PALETTE))
#define PALETTE_UnlockPalette(pPalette) GDIOBJ_UnlockObjByPtr((PBASEOBJECT)pPalette)
+#define PALETTE_ShareLock(hpal) ((PPALETTE)GDIOBJ_ShareLockObj((HGDIOBJ)hpal,
GDI_OBJECT_TYPE_PALETTE))
+#define PALETTE_ShareUnlock(ppal) GDIOBJ_ShareUnlockObjByPtr(&ppal->BaseObject)
#endif