[Win32SS|GDI] Implement seldom used API and update types for local DC's.
authorJames Tabor <james.tabor@reactos.org>
Sat, 25 Sep 2021 16:57:26 +0000 (11:57 -0500)
committerJames Tabor <james.tabor@reactos.org>
Sat, 25 Sep 2021 16:57:26 +0000 (11:57 -0500)
Two working in house application require these API. Known as FolCOL and Reach.

win32ss/gdi/eng/stubs.c
win32ss/gdi/gdi32/objects/bitmap.c
win32ss/gdi/gdi32/objects/brush.c
win32ss/gdi/gdi32/objects/icm.c
win32ss/gdi/ntgdi/brush.cpp
win32ss/gdi/ntgdi/gdiobj.c
win32ss/gdi/ntgdi/gdiobj.h
win32ss/include/ntgdihdl.h

index 8a91c86..5cc878e 100644 (file)
@@ -784,7 +784,7 @@ NtGdiCheckBitmapBits(
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 HBITMAP
 APIENTRY
@@ -792,7 +792,13 @@ NtGdiClearBitmapAttributes(
     IN HBITMAP hbm,
     IN DWORD dwFlags)
 {
-    UNIMPLEMENTED;
+    if ( dwFlags & SC_BB_STOCKOBJ )
+    {
+        if (GDIOBJ_ConvertFromStockObj((HGDIOBJ*)&hbm))
+        {
+            return hbm;
+        }
+    }
     return NULL;
 }
 
@@ -1406,7 +1412,7 @@ NtGdiMonoBitmap(
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 HBITMAP
 APIENTRY
@@ -1414,7 +1420,13 @@ NtGdiSetBitmapAttributes(
     IN HBITMAP hbm,
     IN DWORD dwFlags)
 {
-    UNIMPLEMENTED;
+    if ( dwFlags & SC_BB_STOCKOBJ )
+    {
+        if (GDIOBJ_ConvertToStockObj((HGDIOBJ*)&hbm))
+        {
+            return hbm;
+        }
+    }
     return NULL;
 }
 
index 91e8a0b..f290b54 100644 (file)
@@ -812,52 +812,23 @@ StretchDIBits(
 
     DPRINT("StretchDIBits %p : %p : %u\n", lpBits, lpBitsInfo, iUsage);
 #if 0
-// Handle something other than a normal dc object.
-    if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
-    {
-        if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
-        return MFDRV_StretchBlt( hdc,
-                XDest,
-                YDest,
-                nDestWidth,
-                nDestHeight,
-                XSrc,
-                YSrc,
-                nSrcWidth,
-                nSrcHeight,
-                lpBits,
-                lpBitsInfo,
-                iUsage,
-                dwRop);
-        else
-        {
-            PLDC pLDC = GdiGetLDC(hdc);
-            if ( !pLDC )
-            {
-                SetLastError(ERROR_INVALID_HANDLE);
-                return 0;
-            }
-            if (pLDC->iType == LDC_EMFLDC)
-            {
-                return EMFDRV_StretchBlt(hdc,
-                        XDest,
-                        YDest,
-                        nDestWidth,
-                        nDestHeight,
-                        XSrc,
-                        YSrc,
-                        nSrcWidth,
-                        nSrcHeight,
-                        lpBits,
-                        lpBitsInfo,
-                        iUsage,
-                        dwRop);
-            }
-            return 0;
-        }
-    }
+    HANDLE_METADC( int,
+                   StretchDIBits,
+                   0,
+                   hdc,
+                   XDest,
+                   YDest,
+                   nDestWidth,
+                   nDestHeight,
+                   XSrc,
+                   YSrc,
+                   nSrcWidth,
+                   nSrcHeight,
+                   lpBits,
+                   lpBitsInfo,
+                   iUsage,
+                   dwRop );
 #endif
-
     if ( GdiConvertAndCheckDC(hdc) == NULL ) return 0;
 
     pConvertedInfo = ConvertBitmapInfo(lpBitsInfo, iUsage, &ConvertedInfoSize,
@@ -921,61 +892,45 @@ StretchDIBits(
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 DWORD
 WINAPI
 GetBitmapAttributes(HBITMAP hbm)
 {
-    UNIMPLEMENTED;
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+    if ( GDI_HANDLE_IS_STOCKOBJ(hbm) )
+    {
+        return SC_BB_STOCKOBJ;
+    }
     return 0;
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 HBITMAP
 WINAPI
 SetBitmapAttributes(HBITMAP hbm, DWORD dwFlags)
 {
-    UNIMPLEMENTED;
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return 0;
+    if ( dwFlags & ~SC_BB_STOCKOBJ )
+    {
+        return NULL;
+    }
+    return NtGdiSetBitmapAttributes( hbm, dwFlags );
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 HBITMAP
 WINAPI
 ClearBitmapAttributes(HBITMAP hbm, DWORD dwFlags)
 {
-    UNIMPLEMENTED;
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return 0;
+    if ( dwFlags & ~SC_BB_STOCKOBJ )
+    {
+        return NULL;
+    }
+    return NtGdiClearBitmapAttributes( hbm, dwFlags );;
 }
 
-/*
- * @unimplemented
- *
- */
-HBITMAP
-WINAPI
-GdiConvertBitmapV5(
-    HBITMAP in_format_BitMap,
-    HBITMAP src_BitMap,
-    INT bpp,
-    INT unuse)
-{
-    /* FIXME guessing the prototypes */
-
-    /*
-     * it have create a new bitmap with desired in format,
-     * then convert it src_bitmap to new format
-     * and return it as HBITMAP
-     */
-
-    return FALSE;
-}
 
index 6f73d62..9be9dc9 100644 (file)
@@ -340,39 +340,45 @@ SetBrushOrgEx(HDC hdc,
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 DWORD
 WINAPI
 GetBrushAttributes(HBRUSH hbr)
 {
-    UNIMPLEMENTED;
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+    if ( GDI_HANDLE_IS_STOCKOBJ(hbr) )
+    {
+        return SC_BB_STOCKOBJ;
+    }
     return 0;
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 HBRUSH
 WINAPI
 SetBrushAttributes(HBRUSH hbm, DWORD dwFlags)
 {
-    UNIMPLEMENTED;
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return 0;
+    if ( dwFlags & ~SC_BB_STOCKOBJ )
+    {
+        return NULL;
+    }
+    return NtGdiSetBrushAttributes(hbm, dwFlags);
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 HBRUSH
 WINAPI
 ClearBrushAttributes(HBRUSH hbm, DWORD dwFlags)
 {
-    UNIMPLEMENTED;
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return 0;
+    if ( dwFlags & ~SC_BB_STOCKOBJ )
+    {
+        return NULL;
+    }
+    return NtGdiClearBrushAttributes(hbm, dwFlags);
 }
 
 /*
index 520463a..97dc342 100644 (file)
@@ -106,12 +106,12 @@ SetColorSpace(
 {
     HCOLORSPACE rhCS = GetColorSpace(hDC);
 
-    if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC)
+    if (GDI_HANDLE_GET_TYPE(hDC) == GDILoObjType_LO_DC_TYPE)
     {
         if (NtGdiSetColorSpace(hDC, hCS)) return rhCS;
     }
 #if 0
-    if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC)
+    if (GDI_HANDLE_GET_TYPE(hDC) != GDILoObjType_LO_METADC16_TYPE)
     {
         PLDC pLDC = GdiGetLDC(hDC);
         if ( !pLDC )
@@ -119,7 +119,7 @@ SetColorSpace(
             SetLastError(ERROR_INVALID_HANDLE);
             return NULL;
         }
-        if (pLDC->iType == LDC_EMFLDC)
+        if (pLDC->iType == LDC_EMFLDC && !EMFDC_SetColorSpace( pLDC, hCS ))
         {
             return NULL;
         }
@@ -327,3 +327,26 @@ SetICMMode(
     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
     return 0;
 }
+
+/*
+ * @unimplemented
+ *
+ */
+HBITMAP
+WINAPI
+GdiConvertBitmapV5(
+    HBITMAP in_format_BitMap,
+    HBITMAP src_BitMap,
+    INT bpp,
+    INT unuse)
+{
+    /* FIXME guessing the prototypes */
+
+    /*
+     * it have create a new bitmap with desired in format,
+     * then convert it src_bitmap to new format
+     * and return it as HBITMAP
+     */
+
+    return FALSE;
+}
index 41d1318..2c18e25 100644 (file)
@@ -543,7 +543,13 @@ NtGdiSetBrushAttributes(
     _In_ HBRUSH hbr,
     _In_ DWORD dwFlags)
 {
-    FIXME("NtGdiSetBrushAttributes is unimplemented\n");
+    if ( dwFlags & SC_BB_STOCKOBJ )
+    {
+        if (GDIOBJ_ConvertToStockObj((HGDIOBJ*)&hbr))
+        {
+            return hbr;
+        }
+    }
     return NULL;
 }
 
@@ -554,7 +560,13 @@ NtGdiClearBrushAttributes(
     _In_ HBRUSH hbr,
     _In_ DWORD dwFlags)
 {
-    FIXME("NtGdiClearBrushAttributes is unimplemented\n");
+    if ( dwFlags & SC_BB_STOCKOBJ )
+    {
+        if (GDIOBJ_ConvertFromStockObj((HGDIOBJ*)&hbr))
+        {
+            return hbr;
+        }
+    }
     return NULL;
 }
 
index e92c070..7bd97e3 100644 (file)
@@ -1484,6 +1484,40 @@ GDIOBJ_ConvertToStockObj(HGDIOBJ *phObj)
     return TRUE;
 }
 
+BOOL
+NTAPI
+GDIOBJ_ConvertFromStockObj(HGDIOBJ *phObj)
+{
+    PENTRY pentry;
+    POBJ pobj;
+
+    /* Reference the handle entry */
+    pentry = ENTRY_ReferenceEntryByHandle(*phObj, 0);
+    if (!pentry)
+    {
+        DPRINT1("GDIOBJ: Requested handle 0x%p is not valid.\n", *phObj);
+        return FALSE;
+    }
+
+    /* Update the entry */
+    pentry->FullUnique &= ~GDI_ENTRY_STOCK_MASK;
+    pentry->ObjectOwner.ulObj = 0;
+
+    /* Get the pointer to the BASEOBJECT */
+    pobj = pentry->einfo.pobj;
+
+    /* Calculate the new handle */
+    pobj->hHmgr = (HGDIOBJ)((ULONG_PTR)pobj->hHmgr & ~GDI_HANDLE_STOCK_MASK);
+
+    /* Return the new handle */
+    *phObj = pobj->hHmgr;
+
+    /* Dereference the handle */
+    GDIOBJ_vDereferenceObject(pobj);
+
+    return TRUE;
+}
+
 POBJ NTAPI
 GDIOBJ_AllocObjWithHandle(ULONG ObjectType, ULONG cjSize)
 {
index f7b6559..bd7c416 100644 (file)
@@ -195,6 +195,7 @@ GDIOBJ_pvGetObjectAttr(
     POBJ pobj);
 
 BOOL    NTAPI GDIOBJ_ConvertToStockObj(HGDIOBJ *hObj);
+BOOL    NTAPI GDIOBJ_ConvertFromStockObj(HGDIOBJ *phObj);
 POBJ    NTAPI GDIOBJ_AllocObjWithHandle(ULONG ObjectType, ULONG cjSize);
 PGDIOBJ NTAPI GDIOBJ_ShareLockObj(HGDIOBJ hObj, DWORD ObjectType);
 PVOID   NTAPI GDI_MapHandleTable(PEPROCESS Process);
index 1c0c230..36dc54c 100644 (file)
 #define LDC_INIT_PAGE     0x00000080
 #define LDC_STARTPAGE     0x00000100
 #define LDC_NEXTBAND      0x00000200
+#define LDC_FONTHASH      0x00001000
 #define LDC_CLOCKWISE     0x00002000
+#define LDC_NEWFONT       0x00008000
 #define LDC_KILL_DOCUMENT 0x00010000
 #define LDC_META_PRINT    0x00020000
 #define LDC_DIRECT        0x00040000
 #define LDC_RESET_BANDING 0x00080000
+#define LDC_DOWNLOADFONTS 0x00100000
 #define LDC_RESETDC       0x00200000
 #define LDC_UFIMAP        0x00400000
 #define LDC_INFODC        0x01000000 /* If CreateIC was passed. */
 #define LDC_DEVCAPS       0x02000000
+#define LDC_XPS_PASS      0x08000000 // Guessing, not sure.
 #define LDC_ATENDPAGE     0x10000000
+#define LDC_COLORPAGE     0x20000000
+
+#define UFIHASHTABLESIZE  64
 
 /* DC_ATTR Xform Flags */
 #define METAFILE_TO_WORLD_IDENTITY          0x00000001
 #define ATTR_RGN_VALID                      0x00000010
 #define ATTR_RGN_DIRTY                      0x00000020
 
+/* Set/Clear Bitmap/Brush Stock Attribute */
+#define SC_BB_STOCKOBJ 1
 
 /* TYPES *********************************************************************/