ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

engmisc.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:         See COPYING in the top level directory
00003  * PROJECT:           ReactOS Win32k subsystem
00004  * PURPOSE:           ENG misc Functions
00005  * FILE:              subsystems/win32/win32k/eng/engmisc.c
00006  * PROGRAMER:         ReactOS Team
00007  */
00008 
00009 #include <win32k.h>
00010 
00011 #define NDEBUG
00012 #include <debug.h>
00013 
00014 BOOL APIENTRY
00015 IntEngEnter(PINTENG_ENTER_LEAVE EnterLeave,
00016             SURFOBJ *psoDest,
00017             RECTL *DestRect,
00018             BOOL ReadOnly,
00019             POINTL *Translate,
00020             SURFOBJ **ppsoOutput)
00021 {
00022   LONG Exchange;
00023   SIZEL BitmapSize;
00024   POINTL SrcPoint;
00025   LONG Width;
00026   RECTL ClippedDestRect;
00027 
00028   /* Normalize */
00029   if (DestRect->right < DestRect->left)
00030     {
00031     Exchange = DestRect->left;
00032     DestRect->left = DestRect->right;
00033     DestRect->right = Exchange;
00034     }
00035   if (DestRect->bottom < DestRect->top)
00036     {
00037     Exchange = DestRect->top;
00038     DestRect->top = DestRect->bottom;
00039     DestRect->bottom = Exchange;
00040     }
00041 
00042   if (NULL != psoDest && STYPE_BITMAP != psoDest->iType &&
00043       (NULL == psoDest->pvScan0 || 0 == psoDest->lDelta))
00044     {
00045     /* Driver needs to support DrvCopyBits, else we can't do anything */
00046     SURFACE *psurfDest = CONTAINING_RECORD(psoDest, SURFACE, SurfObj);
00047     if (!(psurfDest->flags & HOOK_COPYBITS))
00048     {
00049       return FALSE;
00050     }
00051 
00052     /* Allocate a temporary bitmap */
00053     BitmapSize.cx = DestRect->right - DestRect->left;
00054     BitmapSize.cy = DestRect->bottom - DestRect->top;
00055     Width = WIDTH_BYTES_ALIGN32(BitmapSize.cx, BitsPerFormat(psoDest->iBitmapFormat));
00056     EnterLeave->OutputBitmap = EngCreateBitmap(BitmapSize, Width,
00057                                                psoDest->iBitmapFormat,
00058                                                BMF_TOPDOWN | BMF_NOZEROINIT, NULL);
00059 
00060     if (!EnterLeave->OutputBitmap)
00061       {
00062       DPRINT1("EngCreateBitmap() failed\n");
00063       return FALSE;
00064       }
00065 
00066     *ppsoOutput = EngLockSurface((HSURF)EnterLeave->OutputBitmap);
00067     if (*ppsoOutput == NULL)
00068     {
00069       EngDeleteSurface((HSURF)EnterLeave->OutputBitmap);
00070       return FALSE;
00071     }
00072 
00073     EnterLeave->DestRect.left = 0;
00074     EnterLeave->DestRect.top = 0;
00075     EnterLeave->DestRect.right = BitmapSize.cx;
00076     EnterLeave->DestRect.bottom = BitmapSize.cy;
00077     SrcPoint.x = DestRect->left;
00078     SrcPoint.y = DestRect->top;
00079     ClippedDestRect = EnterLeave->DestRect;
00080     if (SrcPoint.x < 0)
00081       {
00082         ClippedDestRect.left -= SrcPoint.x;
00083         SrcPoint.x = 0;
00084       }
00085     if (psoDest->sizlBitmap.cx < SrcPoint.x + ClippedDestRect.right - ClippedDestRect.left)
00086       {
00087         ClippedDestRect.right = ClippedDestRect.left + psoDest->sizlBitmap.cx - SrcPoint.x;
00088       }
00089     if (SrcPoint.y < 0)
00090       {
00091         ClippedDestRect.top -= SrcPoint.y;
00092         SrcPoint.y = 0;
00093       }
00094     if (psoDest->sizlBitmap.cy < SrcPoint.y + ClippedDestRect.bottom - ClippedDestRect.top)
00095       {
00096         ClippedDestRect.bottom = ClippedDestRect.top + psoDest->sizlBitmap.cy - SrcPoint.y;
00097       }
00098     EnterLeave->TrivialClipObj = EngCreateClip();
00099     if (EnterLeave->TrivialClipObj == NULL)
00100     {
00101       EngUnlockSurface(*ppsoOutput);
00102       EngDeleteSurface((HSURF)EnterLeave->OutputBitmap);
00103       return FALSE;
00104     }
00105     EnterLeave->TrivialClipObj->iDComplexity = DC_TRIVIAL;
00106     if (ClippedDestRect.left < (*ppsoOutput)->sizlBitmap.cx &&
00107         0 <= ClippedDestRect.right &&
00108         SrcPoint.x < psoDest->sizlBitmap.cx &&
00109         ClippedDestRect.top <= (*ppsoOutput)->sizlBitmap.cy &&
00110         0 <= ClippedDestRect.bottom &&
00111         SrcPoint.y < psoDest->sizlBitmap.cy &&
00112         ! GDIDEVFUNCS(psoDest).CopyBits(
00113                                         *ppsoOutput, psoDest,
00114                                         EnterLeave->TrivialClipObj, NULL,
00115                                         &ClippedDestRect, &SrcPoint))
00116       {
00117           EngDeleteClip(EnterLeave->TrivialClipObj);
00118           EngUnlockSurface(*ppsoOutput);
00119           EngDeleteSurface((HSURF)EnterLeave->OutputBitmap);
00120           return FALSE;
00121       }
00122     EnterLeave->DestRect.left = DestRect->left;
00123     EnterLeave->DestRect.top = DestRect->top;
00124     EnterLeave->DestRect.right = DestRect->right;
00125     EnterLeave->DestRect.bottom = DestRect->bottom;
00126     Translate->x = - DestRect->left;
00127     Translate->y = - DestRect->top;
00128     }
00129   else
00130     {
00131     Translate->x = 0;
00132     Translate->y = 0;
00133     *ppsoOutput = psoDest;
00134     }
00135 
00136   if (NULL != *ppsoOutput)
00137   {
00138     SURFACE* psurfOutput = CONTAINING_RECORD(*ppsoOutput, SURFACE, SurfObj);
00139     if (0 != (psurfOutput->flags & HOOK_SYNCHRONIZE))
00140     {
00141       if (NULL != GDIDEVFUNCS(*ppsoOutput).SynchronizeSurface)
00142         {
00143           GDIDEVFUNCS(*ppsoOutput).SynchronizeSurface(*ppsoOutput, DestRect, 0);
00144         }
00145       else if (STYPE_BITMAP == (*ppsoOutput)->iType
00146                && NULL != GDIDEVFUNCS(*ppsoOutput).Synchronize)
00147         {
00148           GDIDEVFUNCS(*ppsoOutput).Synchronize((*ppsoOutput)->dhpdev, DestRect);
00149         }
00150     }
00151   }
00152   else return FALSE;
00153 
00154   EnterLeave->DestObj = psoDest;
00155   EnterLeave->OutputObj = *ppsoOutput;
00156   EnterLeave->ReadOnly = ReadOnly;
00157 
00158   return TRUE;
00159 }
00160 
00161 BOOL APIENTRY
00162 IntEngLeave(PINTENG_ENTER_LEAVE EnterLeave)
00163 {
00164   POINTL SrcPoint;
00165   BOOL Result = TRUE;
00166 
00167   if (EnterLeave->OutputObj != EnterLeave->DestObj && NULL != EnterLeave->OutputObj)
00168     {
00169     if (! EnterLeave->ReadOnly)
00170       {
00171       SrcPoint.x = 0;
00172       SrcPoint.y = 0;
00173       if (EnterLeave->DestRect.left < 0)
00174         {
00175           SrcPoint.x = - EnterLeave->DestRect.left;
00176           EnterLeave->DestRect.left = 0;
00177         }
00178       if (EnterLeave->DestObj->sizlBitmap.cx < EnterLeave->DestRect.right)
00179         {
00180           EnterLeave->DestRect.right = EnterLeave->DestObj->sizlBitmap.cx;
00181         }
00182       if (EnterLeave->DestRect.top < 0)
00183         {
00184           SrcPoint.y = - EnterLeave->DestRect.top;
00185           EnterLeave->DestRect.top = 0;
00186         }
00187       if (EnterLeave->DestObj->sizlBitmap.cy < EnterLeave->DestRect.bottom)
00188         {
00189           EnterLeave->DestRect.bottom = EnterLeave->DestObj->sizlBitmap.cy;
00190         }
00191       if (SrcPoint.x < EnterLeave->OutputObj->sizlBitmap.cx &&
00192           EnterLeave->DestRect.left <= EnterLeave->DestRect.right &&
00193           EnterLeave->DestRect.left < EnterLeave->DestObj->sizlBitmap.cx &&
00194           SrcPoint.y < EnterLeave->OutputObj->sizlBitmap.cy &&
00195           EnterLeave->DestRect.top <= EnterLeave->DestRect.bottom &&
00196           EnterLeave->DestRect.top < EnterLeave->DestObj->sizlBitmap.cy)
00197         {
00198           Result = GDIDEVFUNCS(EnterLeave->DestObj).CopyBits(
00199                                                  EnterLeave->DestObj,
00200                                                  EnterLeave->OutputObj,
00201                                                  EnterLeave->TrivialClipObj, NULL,
00202                                                  &EnterLeave->DestRect, &SrcPoint);
00203         }
00204       else
00205         {
00206           Result = TRUE;
00207         }
00208       }
00209     EngUnlockSurface(EnterLeave->OutputObj);
00210     EngDeleteSurface((HSURF)EnterLeave->OutputBitmap);
00211     EngDeleteClip(EnterLeave->TrivialClipObj);
00212     }
00213   else
00214     {
00215     Result = TRUE;
00216     }
00217 
00218   return Result;
00219 }
00220 
00221 HANDLE APIENTRY
00222 EngGetProcessHandle(VOID)
00223 {
00224   /* http://www.osr.com/ddk/graphics/gdifncs_3tif.htm
00225      In Windows 2000 and later, the EngGetProcessHandle function always returns NULL.
00226      FIXME: What does NT4 return? */
00227   return NULL;
00228 }
00229 
00230 VOID
00231 APIENTRY
00232 EngGetCurrentCodePage(OUT PUSHORT OemCodePage,
00233                       OUT PUSHORT AnsiCodePage)
00234 {
00235     /* Forward to kernel */
00236     RtlGetDefaultCodePage(AnsiCodePage, OemCodePage);
00237 }
00238 
00239 BOOL
00240 APIENTRY
00241 EngQuerySystemAttribute(
00242    IN ENG_SYSTEM_ATTRIBUTE CapNum,
00243    OUT PDWORD pCapability)
00244 {
00245     SYSTEM_BASIC_INFORMATION sbi;
00246     SYSTEM_PROCESSOR_INFORMATION spi;
00247 
00248     switch (CapNum)
00249     {
00250         case EngNumberOfProcessors:
00251             NtQuerySystemInformation(SystemBasicInformation,
00252                                      &sbi,
00253                                      sizeof(SYSTEM_BASIC_INFORMATION),
00254                                      NULL);
00255             *pCapability = sbi.NumberOfProcessors;
00256             return TRUE;
00257 
00258         case EngProcessorFeature:
00259             NtQuerySystemInformation(SystemProcessorInformation,
00260                                      &spi,
00261                                      sizeof(SYSTEM_PROCESSOR_INFORMATION),
00262                                      NULL);
00263             *pCapability = spi.ProcessorFeatureBits;
00264             return TRUE;
00265 
00266         default:
00267             break;
00268     }
00269 
00270     return FALSE;
00271 }
00272 
00273 ULONGLONG
00274 APIENTRY
00275 EngGetTickCount(VOID)
00276 {
00277     ULONG Multiplier;
00278     LARGE_INTEGER TickCount;
00279 
00280     /* Get the multiplier and current tick count */
00281     KeQueryTickCount(&TickCount);
00282     Multiplier = SharedUserData->TickCountMultiplier;
00283 
00284     /* Convert to milliseconds and return */
00285     return (Int64ShrlMod32(UInt32x32To64(Multiplier, TickCount.LowPart), 24) +
00286             (Multiplier * (TickCount.HighPart << 8)));
00287 }
00288 
00289 /* EOF */

Generated on Sun May 27 2012 04:38:20 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.