2003-05-18 17:16:18 +00:00
|
|
|
/*
|
2011-09-20 19:41:33 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
2011-12-14 04:07:06 +00:00
|
|
|
* PROJECT: ReactOS Win32k subsystem
|
2011-09-20 19:41:33 +00:00
|
|
|
* PURPOSE: ENG misc Functions
|
2015-11-10 17:41:55 +00:00
|
|
|
* FILE: win32ss/gdi/eng/engmisc.c
|
2011-09-20 19:41:33 +00:00
|
|
|
* PROGRAMER: ReactOS Team
|
2003-05-18 17:16:18 +00:00
|
|
|
*/
|
2005-06-29 07:09:25 +00:00
|
|
|
|
2010-04-26 13:58:46 +00:00
|
|
|
#include <win32k.h>
|
2003-02-25 23:08:54 +00:00
|
|
|
|
2005-06-29 07:09:25 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
BOOL APIENTRY
|
2003-02-25 23:08:54 +00:00
|
|
|
IntEngEnter(PINTENG_ENTER_LEAVE EnterLeave,
|
2009-01-08 16:33:40 +00:00
|
|
|
SURFOBJ *psoDest,
|
2003-02-25 23:08:54 +00:00
|
|
|
RECTL *DestRect,
|
|
|
|
BOOL ReadOnly,
|
|
|
|
POINTL *Translate,
|
2009-01-08 16:33:40 +00:00
|
|
|
SURFOBJ **ppsoOutput)
|
2003-02-25 23:08:54 +00:00
|
|
|
{
|
|
|
|
LONG Exchange;
|
|
|
|
SIZEL BitmapSize;
|
|
|
|
POINTL SrcPoint;
|
|
|
|
LONG Width;
|
2004-02-10 23:40:55 +00:00
|
|
|
RECTL ClippedDestRect;
|
2003-02-25 23:08:54 +00:00
|
|
|
|
|
|
|
/* Normalize */
|
|
|
|
if (DestRect->right < DestRect->left)
|
|
|
|
{
|
|
|
|
Exchange = DestRect->left;
|
|
|
|
DestRect->left = DestRect->right;
|
|
|
|
DestRect->right = Exchange;
|
|
|
|
}
|
|
|
|
if (DestRect->bottom < DestRect->top)
|
|
|
|
{
|
|
|
|
Exchange = DestRect->top;
|
|
|
|
DestRect->top = DestRect->bottom;
|
|
|
|
DestRect->bottom = Exchange;
|
|
|
|
}
|
|
|
|
|
2009-01-08 16:33:40 +00:00
|
|
|
if (NULL != psoDest && STYPE_BITMAP != psoDest->iType &&
|
|
|
|
(NULL == psoDest->pvScan0 || 0 == psoDest->lDelta))
|
2003-02-25 23:08:54 +00:00
|
|
|
{
|
|
|
|
/* Driver needs to support DrvCopyBits, else we can't do anything */
|
2009-01-08 16:33:40 +00:00
|
|
|
SURFACE *psurfDest = CONTAINING_RECORD(psoDest, SURFACE, SurfObj);
|
2010-06-05 21:19:41 +00:00
|
|
|
if (!(psurfDest->flags & HOOK_COPYBITS))
|
2008-02-19 22:21:39 +00:00
|
|
|
{
|
2003-02-25 23:08:54 +00:00
|
|
|
return FALSE;
|
2008-02-19 22:21:39 +00:00
|
|
|
}
|
2003-02-25 23:08:54 +00:00
|
|
|
|
|
|
|
/* Allocate a temporary bitmap */
|
|
|
|
BitmapSize.cx = DestRect->right - DestRect->left;
|
|
|
|
BitmapSize.cy = DestRect->bottom - DestRect->top;
|
2010-09-01 16:52:23 +00:00
|
|
|
Width = WIDTH_BYTES_ALIGN32(BitmapSize.cx, BitsPerFormat(psoDest->iBitmapFormat));
|
2003-02-25 23:08:54 +00:00
|
|
|
EnterLeave->OutputBitmap = EngCreateBitmap(BitmapSize, Width,
|
2009-01-08 16:33:40 +00:00
|
|
|
psoDest->iBitmapFormat,
|
2004-06-24 19:43:49 +00:00
|
|
|
BMF_TOPDOWN | BMF_NOZEROINIT, NULL);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2006-04-14 16:31:06 +00:00
|
|
|
if (!EnterLeave->OutputBitmap)
|
|
|
|
{
|
|
|
|
DPRINT1("EngCreateBitmap() failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2009-01-08 16:33:40 +00:00
|
|
|
*ppsoOutput = EngLockSurface((HSURF)EnterLeave->OutputBitmap);
|
2009-08-16 20:11:31 +00:00
|
|
|
if (*ppsoOutput == NULL)
|
|
|
|
{
|
|
|
|
EngDeleteSurface((HSURF)EnterLeave->OutputBitmap);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-02-25 23:08:54 +00:00
|
|
|
|
|
|
|
EnterLeave->DestRect.left = 0;
|
|
|
|
EnterLeave->DestRect.top = 0;
|
|
|
|
EnterLeave->DestRect.right = BitmapSize.cx;
|
|
|
|
EnterLeave->DestRect.bottom = BitmapSize.cy;
|
|
|
|
SrcPoint.x = DestRect->left;
|
|
|
|
SrcPoint.y = DestRect->top;
|
2004-02-10 23:40:55 +00:00
|
|
|
ClippedDestRect = EnterLeave->DestRect;
|
|
|
|
if (SrcPoint.x < 0)
|
|
|
|
{
|
|
|
|
ClippedDestRect.left -= SrcPoint.x;
|
|
|
|
SrcPoint.x = 0;
|
|
|
|
}
|
2009-01-08 16:33:40 +00:00
|
|
|
if (psoDest->sizlBitmap.cx < SrcPoint.x + ClippedDestRect.right - ClippedDestRect.left)
|
2004-02-10 23:40:55 +00:00
|
|
|
{
|
2009-01-08 16:33:40 +00:00
|
|
|
ClippedDestRect.right = ClippedDestRect.left + psoDest->sizlBitmap.cx - SrcPoint.x;
|
2004-02-10 23:40:55 +00:00
|
|
|
}
|
|
|
|
if (SrcPoint.y < 0)
|
|
|
|
{
|
|
|
|
ClippedDestRect.top -= SrcPoint.y;
|
|
|
|
SrcPoint.y = 0;
|
|
|
|
}
|
2009-01-08 16:33:40 +00:00
|
|
|
if (psoDest->sizlBitmap.cy < SrcPoint.y + ClippedDestRect.bottom - ClippedDestRect.top)
|
2004-02-10 23:40:55 +00:00
|
|
|
{
|
2009-01-08 16:33:40 +00:00
|
|
|
ClippedDestRect.bottom = ClippedDestRect.top + psoDest->sizlBitmap.cy - SrcPoint.y;
|
2004-02-10 23:40:55 +00:00
|
|
|
}
|
2003-02-25 23:08:54 +00:00
|
|
|
EnterLeave->TrivialClipObj = EngCreateClip();
|
2009-08-16 19:56:40 +00:00
|
|
|
if (EnterLeave->TrivialClipObj == NULL)
|
|
|
|
{
|
2009-08-16 20:11:31 +00:00
|
|
|
EngUnlockSurface(*ppsoOutput);
|
|
|
|
EngDeleteSurface((HSURF)EnterLeave->OutputBitmap);
|
|
|
|
return FALSE;
|
2009-08-16 19:56:40 +00:00
|
|
|
}
|
2003-02-25 23:08:54 +00:00
|
|
|
EnterLeave->TrivialClipObj->iDComplexity = DC_TRIVIAL;
|
2009-01-08 16:33:40 +00:00
|
|
|
if (ClippedDestRect.left < (*ppsoOutput)->sizlBitmap.cx &&
|
2004-02-10 23:40:55 +00:00
|
|
|
0 <= ClippedDestRect.right &&
|
2009-01-08 16:33:40 +00:00
|
|
|
SrcPoint.x < psoDest->sizlBitmap.cx &&
|
|
|
|
ClippedDestRect.top <= (*ppsoOutput)->sizlBitmap.cy &&
|
2004-02-10 23:40:55 +00:00
|
|
|
0 <= ClippedDestRect.bottom &&
|
2009-01-08 16:33:40 +00:00
|
|
|
SrcPoint.y < psoDest->sizlBitmap.cy &&
|
|
|
|
! GDIDEVFUNCS(psoDest).CopyBits(
|
|
|
|
*ppsoOutput, psoDest,
|
2003-02-25 23:08:54 +00:00
|
|
|
EnterLeave->TrivialClipObj, NULL,
|
2004-02-10 23:40:55 +00:00
|
|
|
&ClippedDestRect, &SrcPoint))
|
2003-02-25 23:08:54 +00:00
|
|
|
{
|
2009-08-16 19:56:40 +00:00
|
|
|
EngDeleteClip(EnterLeave->TrivialClipObj);
|
|
|
|
EngUnlockSurface(*ppsoOutput);
|
|
|
|
EngDeleteSurface((HSURF)EnterLeave->OutputBitmap);
|
|
|
|
return FALSE;
|
2003-02-25 23:08:54 +00:00
|
|
|
}
|
|
|
|
EnterLeave->DestRect.left = DestRect->left;
|
|
|
|
EnterLeave->DestRect.top = DestRect->top;
|
|
|
|
EnterLeave->DestRect.right = DestRect->right;
|
|
|
|
EnterLeave->DestRect.bottom = DestRect->bottom;
|
|
|
|
Translate->x = - DestRect->left;
|
|
|
|
Translate->y = - DestRect->top;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Translate->x = 0;
|
|
|
|
Translate->y = 0;
|
2009-01-08 16:33:40 +00:00
|
|
|
*ppsoOutput = psoDest;
|
2003-02-25 23:08:54 +00:00
|
|
|
}
|
|
|
|
|
2009-01-08 16:33:40 +00:00
|
|
|
if (NULL != *ppsoOutput)
|
2008-02-19 22:21:39 +00:00
|
|
|
{
|
2009-01-08 16:33:40 +00:00
|
|
|
SURFACE* psurfOutput = CONTAINING_RECORD(*ppsoOutput, SURFACE, SurfObj);
|
2010-06-05 21:19:41 +00:00
|
|
|
if (0 != (psurfOutput->flags & HOOK_SYNCHRONIZE))
|
2005-02-06 18:24:31 +00:00
|
|
|
{
|
2009-01-08 16:33:40 +00:00
|
|
|
if (NULL != GDIDEVFUNCS(*ppsoOutput).SynchronizeSurface)
|
2005-02-06 18:24:31 +00:00
|
|
|
{
|
2009-01-08 16:33:40 +00:00
|
|
|
GDIDEVFUNCS(*ppsoOutput).SynchronizeSurface(*ppsoOutput, DestRect, 0);
|
2005-02-06 18:24:31 +00:00
|
|
|
}
|
2009-01-08 16:33:40 +00:00
|
|
|
else if (STYPE_BITMAP == (*ppsoOutput)->iType
|
|
|
|
&& NULL != GDIDEVFUNCS(*ppsoOutput).Synchronize)
|
2005-02-06 18:24:31 +00:00
|
|
|
{
|
2009-01-08 16:33:40 +00:00
|
|
|
GDIDEVFUNCS(*ppsoOutput).Synchronize((*ppsoOutput)->dhpdev, DestRect);
|
2005-02-06 18:24:31 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-19 22:21:39 +00:00
|
|
|
}
|
2009-03-04 16:34:33 +00:00
|
|
|
else return FALSE;
|
2005-02-06 18:24:31 +00:00
|
|
|
|
2009-01-08 16:33:40 +00:00
|
|
|
EnterLeave->DestObj = psoDest;
|
|
|
|
EnterLeave->OutputObj = *ppsoOutput;
|
2003-02-25 23:08:54 +00:00
|
|
|
EnterLeave->ReadOnly = ReadOnly;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
BOOL APIENTRY
|
2003-02-25 23:08:54 +00:00
|
|
|
IntEngLeave(PINTENG_ENTER_LEAVE EnterLeave)
|
|
|
|
{
|
|
|
|
POINTL SrcPoint;
|
2004-07-03 17:40:27 +00:00
|
|
|
BOOL Result = TRUE;
|
2003-02-25 23:08:54 +00:00
|
|
|
|
|
|
|
if (EnterLeave->OutputObj != EnterLeave->DestObj && NULL != EnterLeave->OutputObj)
|
|
|
|
{
|
|
|
|
if (! EnterLeave->ReadOnly)
|
|
|
|
{
|
|
|
|
SrcPoint.x = 0;
|
|
|
|
SrcPoint.y = 0;
|
2004-02-10 23:40:55 +00:00
|
|
|
if (EnterLeave->DestRect.left < 0)
|
|
|
|
{
|
|
|
|
SrcPoint.x = - EnterLeave->DestRect.left;
|
|
|
|
EnterLeave->DestRect.left = 0;
|
|
|
|
}
|
|
|
|
if (EnterLeave->DestObj->sizlBitmap.cx < EnterLeave->DestRect.right)
|
|
|
|
{
|
|
|
|
EnterLeave->DestRect.right = EnterLeave->DestObj->sizlBitmap.cx;
|
|
|
|
}
|
|
|
|
if (EnterLeave->DestRect.top < 0)
|
|
|
|
{
|
|
|
|
SrcPoint.y = - EnterLeave->DestRect.top;
|
|
|
|
EnterLeave->DestRect.top = 0;
|
|
|
|
}
|
|
|
|
if (EnterLeave->DestObj->sizlBitmap.cy < EnterLeave->DestRect.bottom)
|
|
|
|
{
|
|
|
|
EnterLeave->DestRect.bottom = EnterLeave->DestObj->sizlBitmap.cy;
|
|
|
|
}
|
|
|
|
if (SrcPoint.x < EnterLeave->OutputObj->sizlBitmap.cx &&
|
|
|
|
EnterLeave->DestRect.left <= EnterLeave->DestRect.right &&
|
|
|
|
EnterLeave->DestRect.left < EnterLeave->DestObj->sizlBitmap.cx &&
|
|
|
|
SrcPoint.y < EnterLeave->OutputObj->sizlBitmap.cy &&
|
|
|
|
EnterLeave->DestRect.top <= EnterLeave->DestRect.bottom &&
|
|
|
|
EnterLeave->DestRect.top < EnterLeave->DestObj->sizlBitmap.cy)
|
|
|
|
{
|
2004-07-03 13:55:37 +00:00
|
|
|
Result = GDIDEVFUNCS(EnterLeave->DestObj).CopyBits(
|
|
|
|
EnterLeave->DestObj,
|
2004-02-10 23:40:55 +00:00
|
|
|
EnterLeave->OutputObj,
|
|
|
|
EnterLeave->TrivialClipObj, NULL,
|
|
|
|
&EnterLeave->DestRect, &SrcPoint);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Result = TRUE;
|
|
|
|
}
|
2003-02-25 23:08:54 +00:00
|
|
|
}
|
2004-07-03 13:55:37 +00:00
|
|
|
EngUnlockSurface(EnterLeave->OutputObj);
|
2004-04-09 20:03:21 +00:00
|
|
|
EngDeleteSurface((HSURF)EnterLeave->OutputBitmap);
|
2003-02-25 23:08:54 +00:00
|
|
|
EngDeleteClip(EnterLeave->TrivialClipObj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Result = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Result;
|
2003-05-18 17:16:18 +00:00
|
|
|
}
|
2004-02-11 19:26:51 +00:00
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
HANDLE APIENTRY
|
2004-02-11 19:26:51 +00:00
|
|
|
EngGetProcessHandle(VOID)
|
|
|
|
{
|
|
|
|
/* http://www.osr.com/ddk/graphics/gdifncs_3tif.htm
|
|
|
|
In Windows 2000 and later, the EngGetProcessHandle function always returns NULL.
|
2011-12-14 04:07:06 +00:00
|
|
|
FIXME: What does NT4 return? */
|
2004-02-11 19:26:51 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-05-20 13:21:21 +00:00
|
|
|
VOID
|
|
|
|
APIENTRY
|
2013-01-01 09:40:48 +00:00
|
|
|
EngGetCurrentCodePage(
|
|
|
|
_Out_ PUSHORT OemCodePage,
|
|
|
|
_Out_ PUSHORT AnsiCodePage)
|
2008-05-20 13:21:21 +00:00
|
|
|
{
|
|
|
|
/* Forward to kernel */
|
2009-07-31 18:21:24 +00:00
|
|
|
RtlGetDefaultCodePage(AnsiCodePage, OemCodePage);
|
2008-05-20 13:21:21 +00:00
|
|
|
}
|
|
|
|
|
2009-08-10 20:19:33 +00:00
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
EngQuerySystemAttribute(
|
2013-01-01 09:40:48 +00:00
|
|
|
_In_ ENG_SYSTEM_ATTRIBUTE CapNum,
|
|
|
|
_Out_ PDWORD pCapability)
|
2009-08-10 20:19:33 +00:00
|
|
|
{
|
|
|
|
SYSTEM_BASIC_INFORMATION sbi;
|
|
|
|
SYSTEM_PROCESSOR_INFORMATION spi;
|
2014-05-01 08:55:04 +00:00
|
|
|
NTSTATUS status;
|
2009-08-10 20:19:33 +00:00
|
|
|
|
|
|
|
switch (CapNum)
|
|
|
|
{
|
|
|
|
case EngNumberOfProcessors:
|
2014-05-01 08:55:04 +00:00
|
|
|
status = NtQuerySystemInformation(SystemBasicInformation,
|
|
|
|
&sbi,
|
|
|
|
sizeof(SYSTEM_BASIC_INFORMATION),
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(status))
|
|
|
|
{
|
2014-05-01 08:57:11 +00:00
|
|
|
DPRINT1("Failed to query basic information: 0x%lx\n", status);
|
2014-05-01 08:55:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-08-10 20:19:33 +00:00
|
|
|
*pCapability = sbi.NumberOfProcessors;
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case EngProcessorFeature:
|
2014-05-01 08:55:04 +00:00
|
|
|
status = NtQuerySystemInformation(SystemProcessorInformation,
|
|
|
|
&spi,
|
|
|
|
sizeof(SYSTEM_PROCESSOR_INFORMATION),
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(status))
|
|
|
|
{
|
2014-05-01 08:57:11 +00:00
|
|
|
DPRINT1("Failed to query processor information: 0x%lx\n", status);
|
2014-05-01 08:55:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-08-10 20:19:33 +00:00
|
|
|
*pCapability = spi.ProcessorFeatureBits;
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONGLONG
|
|
|
|
APIENTRY
|
|
|
|
EngGetTickCount(VOID)
|
|
|
|
{
|
|
|
|
ULONG Multiplier;
|
|
|
|
LARGE_INTEGER TickCount;
|
|
|
|
|
|
|
|
/* Get the multiplier and current tick count */
|
|
|
|
KeQueryTickCount(&TickCount);
|
|
|
|
Multiplier = SharedUserData->TickCountMultiplier;
|
|
|
|
|
|
|
|
/* Convert to milliseconds and return */
|
|
|
|
return (Int64ShrlMod32(UInt32x32To64(Multiplier, TickCount.LowPart), 24) +
|
|
|
|
(Multiplier * (TickCount.HighPart << 8)));
|
|
|
|
}
|
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
/* EOF */
|