+/*
+ * ReactOS W32 Subsystem
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
#include <internal/safe.h>
#include <win32k/coord.h>
#include <win32k/dc.h>
+#include <include/error.h>
#define NDEBUG
#include <win32k/debug1.h>
/* FUNCTIONS *****************************************************************/
-BOOL STDCALL W32kCombineTransform(LPXFORM UnsafeXFormResult,
+BOOL STDCALL NtGdiCombineTransform(LPXFORM UnsafeXFormResult,
CONST LPXFORM Unsafexform1,
CONST LPXFORM Unsafexform2)
{
return TRUE;
}
-VOID STATIC
+VOID STATIC FASTCALL
CoordDPtoLP(PDC Dc, LPPOINT Point)
{
FLOAT x, y;
* \return TRUE if success.
*/
BOOL STDCALL
-W32kDPtoLP(HDC hDC,
+NtGdiDPtoLP(HDC hDC,
LPPOINT UnsafePoints,
int Count)
{
- PDC Dc;
- ULONG i;
+ PDC dc;
+ INT i;
LPPOINT Points = (LPPOINT) ExAllocatePool( PagedPool, Count*sizeof(POINT));
+ BOOL ret = FALSE; // default to failure
ASSERT(Points);
+ if ( !Points )
+ return ret;
+
MmCopyFromCaller( Points, UnsafePoints, Count*sizeof(POINT) );
- Dc = DC_HandleToPtr (hDC);
- if (Dc == NULL || !Dc->w.vport2WorldValid)
+ dc = DC_LockDc (hDC);
+ if ( dc )
+ {
+ ret = TRUE;
+ if ( dc->w.vport2WorldValid )
{
- return(FALSE);
+ for (i = 0; i < Count; i++)
+ {
+ CoordDPtoLP ( dc, &Points[i] );
+ }
}
- for (i = 0; i < Count; i++)
- {
- CoordDPtoLP(Dc, &Points[i]);
- }
- DC_ReleasePtr( hDC );
+ DC_UnlockDc( hDC );
+
+ MmCopyToCaller( UnsafePoints, Points, Count*sizeof(POINT) );
+
+ }
+
+ ExFreePool ( Points );
- MmCopyToCaller( UnsafePoints, Points, Count*sizeof(POINT) );
return(TRUE);
}
int
+FASTCALL
+IntGetGraphicsMode ( PDC dc )
+{
+ ASSERT ( dc );
+ return dc->w.GraphicsMode;
+}
+
+int
STDCALL
-W32kGetGraphicsMode(HDC hDC)
+NtGdiGetGraphicsMode ( HDC hDC )
{
- PDC dc;
- int GraphicsMode;
+ PDC dc = DC_LockDc ( hDC );
+ int GraphicsMode = 0; // default to failure
- dc = DC_HandleToPtr (hDC);
- if (!dc)
+ if ( dc )
{
- return 0;
+ GraphicsMode = dc->w.GraphicsMode;
+ DC_UnlockDc ( hDC );
}
- GraphicsMode = dc->w.GraphicsMode;
- DC_ReleasePtr( hDC );
- return GraphicsMode;
+ return GraphicsMode;
}
BOOL
STDCALL
-W32kGetWorldTransform(HDC hDC,
+NtGdiGetWorldTransform(HDC hDC,
LPXFORM XForm)
{
PDC dc;
- dc = DC_HandleToPtr (hDC);
- if (!dc)
- {
- return FALSE;
- }
if (!XForm)
- {
- return FALSE;
- }
+ return FALSE;
+
+ dc = DC_LockDc (hDC);
+ if (!dc)
+ return FALSE;
+
*XForm = dc->w.xformWorld2Wnd;
- DC_ReleasePtr( hDC );
+
+ DC_UnlockDc ( hDC );
+
return TRUE;
}
-VOID STATIC
-CoordLPtoDP(PDC Dc, LPPOINT Point)
+VOID
+FASTCALL
+CoordLPtoDP ( PDC Dc, LPPOINT Point )
{
FLOAT x, y;
+
+ ASSERT ( Dc );
+ ASSERT ( Point );
+
x = (FLOAT)Point->x;
y = (FLOAT)Point->y;
Point->x = x * Dc->w.xformWorld2Vport.eM11 +
y * Dc->w.xformWorld2Vport.eM22 + Dc->w.xformWorld2Vport.eDy;
}
+VOID
+FASTCALL
+IntLPtoDP ( PDC dc, LPPOINT Points, INT Count )
+{
+ INT i;
+
+ ASSERT ( Points );
+
+ for ( i = 0; i < Count; i++ )
+ CoordLPtoDP ( dc, &Points[i] );
+}
+
/*!
* Converts points from logical coordinates into device coordinates. Conversion depends on the mapping mode,
* world transfrom, viewport origin settings for the given device context.
* \return TRUE if success.
*/
BOOL STDCALL
-W32kLPtoDP(HDC hDC, LPPOINT UnsafePoints, INT Count)
+NtGdiLPtoDP ( HDC hDC, LPPOINT UnsafePoints, INT Count )
{
- PDC Dc;
- ULONG i;
- LPPOINT Points = (LPPOINT) ExAllocatePool( PagedPool, Count*sizeof(POINT));
+ PDC dc;
+ LPPOINT Points = (LPPOINT)ExAllocatePool ( PagedPool, Count*sizeof(POINT) );
+ BOOL ret = FALSE; // default to failure
ASSERT(Points);
- MmCopyFromCaller( Points, UnsafePoints, Count*sizeof(POINT) );
+ if ( !Points )
+ return FALSE;
- Dc = DC_HandleToPtr (hDC);
- if (Dc == NULL)
- {
- return(FALSE);
- }
+ dc = DC_LockDc ( hDC );
- for (i = 0; i < Count; i++)
- {
- CoordLPtoDP(Dc, &Points[i]);
- }
- DC_ReleasePtr( hDC );
- MmCopyToCaller( UnsafePoints, Points, Count*sizeof(POINT) );
- return(TRUE);
+ if ( dc )
+ {
+ ret = TRUE;
+
+ MmCopyFromCaller( Points, UnsafePoints, Count*sizeof(POINT) );
+
+ IntLPtoDP ( dc, Points, Count );
+
+ MmCopyToCaller ( UnsafePoints, Points, Count*sizeof(POINT) );
+
+ DC_UnlockDc ( hDC );
+ }
+
+ ExFreePool ( Points );
+
+ return ret;
}
BOOL
STDCALL
-W32kModifyWorldTransform(HDC hDC,
- CONST LPXFORM UnsafeXForm,
- DWORD Mode)
+NtGdiModifyWorldTransform(HDC hDC,
+ CONST LPXFORM UnsafeXForm,
+ DWORD Mode)
{
PDC dc;
LPXFORM XForm = (LPXFORM) ExAllocatePool( PagedPool, sizeof( XFORM ) );
+ BOOL ret = FALSE; // default to failure
ASSERT( XForm );
-
- MmCopyFromCaller( XForm, UnsafeXForm, sizeof( XFORM ) );
-
- dc = DC_HandleToPtr (hDC);
- if (!dc)
- {
-// SetLastError( ERROR_INVALID_HANDLE );
- return FALSE;
- }
if (!XForm)
- {
return FALSE;
- }
- /* Check that graphics mode is GM_ADVANCED */
- if (dc->w.GraphicsMode!=GM_ADVANCED)
- {
- return FALSE;
- }
- switch (Mode)
+ MmCopyFromCaller( XForm, UnsafeXForm, sizeof( XFORM ) );
+
+ dc = DC_LockDc (hDC);
+ if ( dc )
{
- case MWT_IDENTITY:
- dc->w.xformWorld2Wnd.eM11 = 1.0f;
- dc->w.xformWorld2Wnd.eM12 = 0.0f;
- dc->w.xformWorld2Wnd.eM21 = 0.0f;
- dc->w.xformWorld2Wnd.eM22 = 1.0f;
- dc->w.xformWorld2Wnd.eDx = 0.0f;
- dc->w.xformWorld2Wnd.eDy = 0.0f;
- break;
-
- case MWT_LEFTMULTIPLY:
- W32kCombineTransform(&dc->w.xformWorld2Wnd, XForm, &dc->w.xformWorld2Wnd );
- break;
-
- case MWT_RIGHTMULTIPLY:
- W32kCombineTransform(&dc->w.xformWorld2Wnd, &dc->w.xformWorld2Wnd, XForm);
- break;
-
- default:
- DC_ReleasePtr( hDC );
- return FALSE;
+ /* Check that graphics mode is GM_ADVANCED */
+ if ( dc->w.GraphicsMode == GM_ADVANCED )
+ {
+ ret = TRUE; // switch to a default of success
+ switch (Mode)
+ {
+ case MWT_IDENTITY:
+ dc->w.xformWorld2Wnd.eM11 = 1.0f;
+ dc->w.xformWorld2Wnd.eM12 = 0.0f;
+ dc->w.xformWorld2Wnd.eM21 = 0.0f;
+ dc->w.xformWorld2Wnd.eM22 = 1.0f;
+ dc->w.xformWorld2Wnd.eDx = 0.0f;
+ dc->w.xformWorld2Wnd.eDy = 0.0f;
+ break;
+
+ case MWT_LEFTMULTIPLY:
+ NtGdiCombineTransform(&dc->w.xformWorld2Wnd, XForm, &dc->w.xformWorld2Wnd );
+ break;
+
+ case MWT_RIGHTMULTIPLY:
+ NtGdiCombineTransform(&dc->w.xformWorld2Wnd, &dc->w.xformWorld2Wnd, XForm);
+ break;
+
+ default:
+ ret = FALSE;
+ break;
+ }
+ if ( ret )
+ DC_UpdateXforms ( dc );
+ }
+ DC_UnlockDc ( hDC );
}
- DC_UpdateXforms (dc);
- DC_ReleasePtr( hDC );
- return TRUE;
+ ExFreePool ( XForm );
+ return ret;
}
BOOL
STDCALL
-W32kOffsetViewportOrgEx(HDC hDC,
- int XOffset,
- int YOffset,
- LPPOINT Point)
+NtGdiOffsetViewportOrgEx(HDC hDC,
+ int XOffset,
+ int YOffset,
+ LPPOINT UnsafePoint)
{
- UNIMPLEMENTED;
+ PDC dc;
+ POINT Point;
+ NTSTATUS Status;
+ BOOL ret = FALSE; // default to failure
+
+ dc = DC_LockDc ( hDC );
+ if ( dc )
+ {
+ ret = TRUE;
+ if (NULL != UnsafePoint)
+ {
+ Point.x = dc->vportOrgX;
+ Point.y = dc->vportOrgY;
+ Status = MmCopyToCaller(UnsafePoint, &Point, sizeof(POINT));
+ if ( !NT_SUCCESS(Status) )
+ {
+ SetLastNtError(Status);
+ ret = FALSE;
+ }
+ }
+
+ if ( ret )
+ {
+ dc->vportOrgX += XOffset;
+ dc->vportOrgY += YOffset;
+ DC_UpdateXforms(dc);
+
+ dc->w.DCOrgX += XOffset;
+ dc->w.DCOrgY += YOffset;
+ }
+
+ DC_UnlockDc ( hDC );
+ }
+ return TRUE;
}
BOOL
STDCALL
-W32kOffsetWindowOrgEx(HDC hDC,
- int XOffset,
- int YOffset,
- LPPOINT Point)
+NtGdiOffsetWindowOrgEx(HDC hDC,
+ int XOffset,
+ int YOffset,
+ LPPOINT Point)
{
- UNIMPLEMENTED;
+ PDC dc;
+
+ dc = DC_LockDc(hDC);
+ if (!dc)
+ {
+ return FALSE;
+ }
+
+ if (Point)
+ {
+ Point->x = dc->wndOrgX;
+ Point->y = dc->wndOrgY;
+ }
+
+ dc->wndOrgX += XOffset;
+ dc->wndOrgY += YOffset;
+
+ DC_UnlockDc(hDC);
+
+ return TRUE;
}
BOOL
STDCALL
-W32kScaleViewportExtEx(HDC hDC,
+NtGdiScaleViewportExtEx(HDC hDC,
int Xnum,
int Xdenom,
int Ynum,
BOOL
STDCALL
-W32kScaleWindowExtEx(HDC hDC,
+NtGdiScaleWindowExtEx(HDC hDC,
int Xnum,
int Xdenom,
int Ynum,
int
STDCALL
-W32kSetGraphicsMode(HDC hDC,
- int Mode)
+NtGdiSetGraphicsMode(HDC hDC,
+ int Mode)
{
INT ret;
- DC *dc;
+ PDC dc;
- dc = DC_HandleToPtr (hDC);
+ dc = DC_LockDc (hDC);
if (!dc)
{
return 0;
*/
if ((Mode != GM_COMPATIBLE) && (Mode != GM_ADVANCED))
- {
- DC_ReleasePtr( hDC );
- return 0;
- }
+ {
+ DC_UnlockDc( hDC );
+ return 0;
+ }
+
ret = dc->w.GraphicsMode;
dc->w.GraphicsMode = Mode;
- DC_ReleasePtr( hDC );
+ DC_UnlockDc( hDC );
return ret;
}
int
STDCALL
-W32kSetMapMode(HDC hDC,
- int MapMode)
+NtGdiSetMapMode(HDC hDC,
+ int MapMode)
{
- UNIMPLEMENTED;
+ int PrevMapMode;
+ PDC dc;
+
+ dc = DC_LockDc(hDC);
+ if (!dc)
+ return 0;
+
+ PrevMapMode = dc->w.MapMode;
+ dc->w.MapMode = MapMode;
+
+ DC_UnlockDc ( hDC );
+
+ return PrevMapMode;
}
BOOL
STDCALL
-W32kSetViewportExtEx(HDC hDC,
- int XExtent,
- int YExtent,
- LPSIZE Size)
+NtGdiSetViewportExtEx(HDC hDC,
+ int XExtent,
+ int YExtent,
+ LPSIZE Size)
{
- UNIMPLEMENTED;
+ PDC dc;
+
+ dc = DC_LockDc(hDC);
+ if ( !dc )
+ return FALSE;
+
+ switch (dc->w.MapMode)
+ {
+ case MM_HIENGLISH:
+ case MM_HIMETRIC:
+ case MM_LOENGLISH:
+ case MM_LOMETRIC:
+ case MM_TEXT:
+ case MM_TWIPS:
+ DC_UnlockDc(hDC);
+ return FALSE;
+
+ case MM_ISOTROPIC:
+ // Here we should (probably) check that SetWindowExtEx *really* has
+ // been called
+ break;
+ }
+
+ if (Size)
+ {
+ Size->cx = dc->vportExtX;
+ Size->cy = dc->vportExtY;
+ }
+
+ dc->vportExtX = XExtent;
+ dc->vportExtY = YExtent;
+
+ DC_UnlockDc(hDC);
+
+ return TRUE;
}
BOOL
STDCALL
-W32kSetViewportOrgEx(HDC hDC,
- int X,
- int Y,
- LPPOINT Point)
+NtGdiSetViewportOrgEx(HDC hDC,
+ int X,
+ int Y,
+ LPPOINT Point)
{
- UNIMPLEMENTED;
+ PDC dc;
+
+ dc = DC_LockDc(hDC);
+ if (!dc)
+ {
+ return FALSE;
+ }
+
+ if (Point)
+ {
+ Point->x = dc->vportOrgX;
+ Point->y = dc->vportOrgY;
+ }
+
+ dc->vportOrgX = X;
+ dc->vportOrgY = Y;
+
+ DC_UnlockDc(hDC);
+
+ return TRUE;
}
BOOL
STDCALL
-W32kSetWindowExtEx(HDC hDC,
- int XExtent,
- int YExtent,
- LPSIZE Size)
+NtGdiSetWindowExtEx(HDC hDC,
+ int XExtent,
+ int YExtent,
+ LPSIZE Size)
{
- UNIMPLEMENTED;
+ PDC dc;
+
+ dc = DC_LockDc(hDC);
+ if (!dc)
+ {
+ return FALSE;
+ }
+
+ switch (dc->w.MapMode)
+ {
+ case MM_HIENGLISH:
+ case MM_HIMETRIC:
+ case MM_LOENGLISH:
+ case MM_LOMETRIC:
+ case MM_TEXT:
+ case MM_TWIPS:
+ DC_UnlockDc(hDC);
+ return FALSE;
+ }
+
+ if (Size)
+ {
+ Size->cx = dc->wndExtX;
+ Size->cy = dc->wndExtY;
+ }
+
+ dc->wndExtX = XExtent;
+ dc->wndExtY = YExtent;
+
+ DC_UnlockDc(hDC);
+
+ return TRUE;
}
BOOL
STDCALL
-W32kSetWindowOrgEx(HDC hDC,
- int X,
- int Y,
- LPPOINT Point)
+NtGdiSetWindowOrgEx(HDC hDC,
+ int X,
+ int Y,
+ LPPOINT Point)
{
- UNIMPLEMENTED;
+ PDC dc;
+
+ dc = DC_LockDc(hDC);
+ if (!dc)
+ {
+ return FALSE;
+ }
+
+ if (Point)
+ {
+ Point->x = dc->wndOrgX;
+ Point->y = dc->wndOrgY;
+ }
+
+ dc->wndOrgX = X;
+ dc->wndOrgY = Y;
+
+ DC_UnlockDc(hDC);
+
+ return TRUE;
}
BOOL
STDCALL
-W32kSetWorldTransform(HDC hDC,
- CONST LPXFORM XForm)
+NtGdiSetWorldTransform(HDC hDC,
+ CONST LPXFORM XForm)
{
PDC dc;
- dc = DC_HandleToPtr (hDC);
- if (!dc)
- {
- return FALSE;
- }
if (!XForm)
+ return FALSE;
+
+ dc = DC_LockDc (hDC);
+ if ( !dc )
{
- DC_ReleasePtr( hDC );
return FALSE;
}
/* Check that graphics mode is GM_ADVANCED */
- if (dc->w.GraphicsMode != GM_ADVANCED)
+ if ( dc->w.GraphicsMode != GM_ADVANCED )
{
- DC_ReleasePtr( hDC );
+ DC_UnlockDc( hDC );
return FALSE;
}
dc->w.xformWorld2Wnd = *XForm;
DC_UpdateXforms (dc);
- DC_ReleasePtr( hDC );
+ DC_UnlockDc( hDC );
return TRUE;
}
-
+/* EOF */