forget commit Implement of GdiGetLocalBrush, GdiGetLocalDC, GdiGetLocalFont
[reactos.git] / reactos / dll / win32 / gdi32 / misc / misc.c
index bef5120..0f2612f 100644 (file)
@@ -32,6 +32,64 @@ PGDI_TABLE_ENTRY GdiHandleTable = NULL;
 HANDLE CurrentProcessId = NULL;
 DWORD GDI_BatchLimit = 1;
 
+
+BOOL
+STDCALL
+GdiAlphaBlend(
+            HDC hDCDst,
+            int DstX,
+            int DstY,
+            int DstCx,
+            int DstCy,
+            HDC hDCSrc,
+            int SrcX,
+            int SrcY,
+            int SrcCx,
+            int SrcCy,
+            BLENDFUNCTION BlendFunction
+            )
+{
+   if ( hDCSrc == NULL ) return FALSE;
+
+   if (GDI_HANDLE_GET_TYPE(hDCSrc) == GDI_OBJECT_TYPE_METADC) return FALSE;
+      
+   return NtGdiAlphaBlend(
+                      hDCDst,
+                        DstX,
+                        DstY,
+                       DstCx,
+                       DstCy,
+                      hDCSrc,
+                        SrcX,
+                        SrcY,
+                       SrcCx,
+                       SrcCy,
+               BlendFunction,
+                           0 );
+}
+
+/*
+ * @implemented
+ */
+HGDIOBJ 
+STDCALL
+GdiFixUpHandle(HGDIOBJ hGdiObj)
+{
+    PGDI_TABLE_ENTRY Entry;
+
+    if (((ULONG_PTR)(hGdiObj)) & GDI_HANDLE_UPPER_MASK )
+    {
+        return hGdiObj;
+    }
+
+    /* FIXME is this right ?? */
+
+    Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj);
+
+   /* Rebuild handle for Object */
+    return hGdiObj = (HGDIOBJ)(((LONG_PTR)(hGdiObj)) | (Entry->Type << GDI_ENTRY_UPPER_SHIFT));
+}
+
 /*
  * @implemented
  */
@@ -45,7 +103,8 @@ GdiQueryTable(VOID)
 BOOL GdiIsHandleValid(HGDIOBJ hGdiObj)
 {
   PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj);
-  if(Entry->KernelData != NULL && (Entry->Type & GDI_HANDLE_TYPE_MASK) == (LONG)GDI_HANDLE_GET_TYPE(hGdiObj))
+  if((Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 && 
+     (Entry->Type << GDI_ENTRY_UPPER_SHIFT) == GDI_HANDLE_GET_UPPER(hGdiObj))
   {
     HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
     if(pid == NULL || pid == CurrentProcessId)
@@ -59,7 +118,8 @@ BOOL GdiIsHandleValid(HGDIOBJ hGdiObj)
 BOOL GdiGetHandleUserData(HGDIOBJ hGdiObj, PVOID *UserData)
 {
   PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj);
-  if(Entry->KernelData != NULL && (Entry->Type & GDI_HANDLE_TYPE_MASK) == (LONG)GDI_HANDLE_GET_TYPE(hGdiObj))
+  if((Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 && 
+     (Entry->Type << GDI_ENTRY_UPPER_SHIFT) == GDI_HANDLE_GET_UPPER(hGdiObj))
   {
     HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
     if(pid == NULL || pid == CurrentProcessId)
@@ -68,6 +128,7 @@ BOOL GdiGetHandleUserData(HGDIOBJ hGdiObj, PVOID *UserData)
       return TRUE;
     }
   }
+  SetLastError(ERROR_INVALID_PARAMETER);
   return FALSE;
 }
 
@@ -86,8 +147,14 @@ DWORD
 STDCALL
 GdiSetBatchLimit(DWORD Limit)
 {
-  DWORD OldLimit = GDI_BatchLimit;
-    if ((!Limit) || (Limit > GDI_BATCH_LIMIT)) return Limit;
+    DWORD OldLimit = GDI_BatchLimit;
+
+    if ( (!Limit) ||
+         (Limit >= GDI_BATCH_LIMIT))
+    {
+        return Limit;
+    }
+
     GdiFlush();
     GDI_BatchLimit = Limit;
     return OldLimit;
@@ -103,3 +170,35 @@ GdiGetBatchLimit()
 {
     return GDI_BatchLimit;
 }
+
+/*
+ * @unimplemented
+ */
+BOOL
+STDCALL
+GdiReleaseDC(HDC hdc)
+{
+    return 0;
+}
+
+INT
+STDCALL
+ExtEscape(HDC hDC,
+          int nEscape,
+          int cbInput,
+          LPCSTR lpszInData,
+          int cbOutput,
+          LPSTR lpszOutData)
+{
+    return NtGdiExtEscape(hDC, NULL, 0, nEscape, cbInput, (LPSTR)lpszInData, cbOutput, lpszOutData);
+}
+
+/*
+ * @implemented
+ */
+VOID
+STDCALL
+GdiSetLastError(DWORD dwErrCode)
+{
+    NtCurrentTeb ()->LastErrorValue = (ULONG) dwErrCode;
+}