[ros-diffs] [greatlrd] 15577: Implement NtGdiAnimatePalette (partly ripped from Wine)

greatlrd at svn.reactos.com greatlrd at svn.reactos.com
Sat May 28 14:43:28 CEST 2005


Implement NtGdiAnimatePalette (partly ripped from Wine)
by hpussin
Modified: trunk/reactos/lib/gdi32/gdi32.def
Modified: trunk/reactos/lib/gdi32/misc/stubs.c
Modified: trunk/reactos/subsys/win32k/objects/color.c
  _____  

Modified: trunk/reactos/lib/gdi32/gdi32.def
--- trunk/reactos/lib/gdi32/gdi32.def	2005-05-28 12:15:11 UTC (rev
15576)
+++ trunk/reactos/lib/gdi32/gdi32.def	2005-05-28 12:43:26 UTC (rev
15577)
@@ -17,7 +17,7 @@

 AddFontResourceW at 4
 AddFontResourceTracking at 8
 AngleArc at 24
-AnimatePalette at 16
+AnimatePalette at 16=NtGdiAnimatePalette at 16
 AnyLinkedFonts at 0
 Arc at 36=NtGdiArc at 36
 ArcTo at 36=NtGdiArcTo at 36
  _____  

Modified: trunk/reactos/lib/gdi32/misc/stubs.c
--- trunk/reactos/lib/gdi32/misc/stubs.c	2005-05-28 12:15:11 UTC
(rev 15576)
+++ trunk/reactos/lib/gdi32/misc/stubs.c	2005-05-28 12:43:26 UTC
(rev 15577)
@@ -13,25 +13,10 @@

 
 #define UNIMPLEMENTED DbgPrint("GDI32: %s is unimplemented, please try
again later.\n", __FUNCTION__);
 
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
-AnimatePalette(
-	HPALETTE		a0,
-	UINT			a1,
-	UINT			a2,
-	CONST PALETTEENTRY	*a3
-	)
-{
-	UNIMPLEMENTED;
-	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-	return FALSE;
-}
 
 
 
+
 /*
  * @unimplemented
  */
  _____  

Modified: trunk/reactos/subsys/win32k/objects/color.c
--- trunk/reactos/subsys/win32k/objects/color.c	2005-05-28 12:15:11 UTC
(rev 15576)
+++ trunk/reactos/subsys/win32k/objects/color.c	2005-05-28 12:43:26 UTC
(rev 15577)
@@ -70,12 +70,57 @@

    return (const PALETTEENTRY*)&COLOR_sysPalTemplate;
 }
 
-BOOL STDCALL NtGdiAnimatePalette(HPALETTE hPalette, UINT uStartIndex,
-   UINT uEntries, CONST PPALETTEENTRY ppe)
+BOOL STDCALL NtGdiAnimatePalette(HPALETTE hPal, UINT StartIndex,
+   UINT NumEntries, CONST PPALETTEENTRY PaletteColors)
 {
-   UNIMPLEMENTED;
-   SetLastWin32Error(ERROR_CALL_NOT_IMPLEMENTED);
-   return FALSE;
+    if( hPal != NtGdiGetStockObject(DEFAULT_PALETTE) )
+    {
+        PPALGDI palPtr;
+        UINT pal_entries;
+        HDC hDC;
+        PDC dc;	
+		HWND hHwd;
+        const PALETTEENTRY *pptr = PaletteColors;
+ 
+        palPtr = (PPALGDI)PALETTE_LockPalette(hPal);
+        if (!palPtr) return FALSE;
+ 
+        pal_entries = palPtr->NumColors;
+        if (StartIndex >= pal_entries)
+        {
+          PALETTE_UnlockPalette(hPal);
+          return FALSE;
+        }
+        if (StartIndex+NumEntries > pal_entries) NumEntries =
pal_entries - StartIndex;
+ 
+        for (NumEntries += StartIndex; StartIndex < NumEntries;
StartIndex++, pptr++) {
+          /* According to MSDN, only animate PC_RESERVED colours */
+          if (palPtr->IndexedColors[StartIndex].peFlags & PC_RESERVED)
{
+            memcpy( &palPtr->IndexedColors[StartIndex], pptr,
+                    sizeof(PALETTEENTRY) );
+            PALETTE_ValidateFlags(&palPtr->IndexedColors[StartIndex],
1);
+          }
+        }
+ 
+        PALETTE_UnlockPalette(hPal);
+ 
+        /* Immediately apply the new palette if current window uses it
*/		
+		hHwd = NtUserGetDesktopWindow();
+        hDC =  (HDC)NtUserGetWindowDC(hHwd);
+        dc = DC_LockDc(hDC);
+        if (NULL != dc)
+        {
+          if (dc->w.hPalette == hPal)
+          {
+            DC_UnlockDc(hDC);
+            NtGdiRealizePalette(hDC);
+          }
+          else
+            DC_UnlockDc(hDC);
+        }		
+		NtUserReleaseDC(hHwd,hDC);   
+    }
+    return TRUE;
 }
 
 HPALETTE STDCALL NtGdiCreateHalftonePalette(HDC  hDC)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.reactos.org/pipermail/ros-diffs/attachments/20050528/9ee76bec/attachment.html


More information about the Ros-diffs mailing list