update for HEAD-2003050101
[reactos.git] / subsys / win32k / eng / surface.c
index 3ec0967..dfa33be 100644 (file)
@@ -18,8 +18,9 @@
 #include <include/object.h>
 #include <include/paint.h>
 #include "handle.h"
+#include "../dib/dib.h"
 
-//#define NDEBUG
+#define NDEBUG
 #include <win32k/debug1.h>
 
 INT BitsPerFormat(ULONG Format)
@@ -60,13 +61,94 @@ ULONG BitmapFormat(WORD Bits, DWORD Compression)
   }
 }
 
-VOID InitializeHooks(SURFGDI *SurfGDI)
+static VOID Dummy_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c)
+{
+  return;
+}
+
+static VOID Dummy_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
+{
+  return;
+}
+
+static VOID Dummy_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
+{
+  return;
+}
+
+static BOOLEAN Dummy_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
+                            SURFGDI *DestGDI,  SURFGDI *SourceGDI,
+                            PRECTL  DestRect,  POINTL  *SourcePoint,
+                            XLATEOBJ *ColorTranslation)
+{
+  return FALSE;
+}
+
+VOID InitializeFuncs(SURFGDI *SurfGDI, ULONG BitmapFormat)
 {
   SurfGDI->BitBlt   = NULL;
   SurfGDI->CopyBits = NULL;
   SurfGDI->CreateDeviceBitmap = NULL;
   SurfGDI->SetPalette = NULL;
   SurfGDI->TransparentBlt = NULL;
+
+  switch(BitmapFormat)
+    {
+    case BMF_1BPP:
+      SurfGDI->DIB_PutPixel = DIB_1BPP_PutPixel;
+      SurfGDI->DIB_HLine    = DIB_1BPP_HLine;
+      SurfGDI->DIB_VLine    = DIB_1BPP_VLine;
+      SurfGDI->DIB_BitBlt   = DIB_1BPP_BitBlt;
+      break;
+
+    case BMF_4BPP:
+      SurfGDI->DIB_PutPixel = DIB_4BPP_PutPixel;
+      SurfGDI->DIB_HLine    = DIB_4BPP_HLine;
+      SurfGDI->DIB_VLine    = DIB_4BPP_VLine;
+      SurfGDI->DIB_BitBlt   = DIB_4BPP_BitBlt;
+      break;
+
+    case BMF_8BPP:
+      SurfGDI->DIB_PutPixel = DIB_8BPP_PutPixel;
+      SurfGDI->DIB_HLine    = DIB_8BPP_HLine;
+      SurfGDI->DIB_VLine    = DIB_8BPP_VLine;
+      SurfGDI->DIB_BitBlt   = DIB_8BPP_BitBlt;
+      break;
+
+    case BMF_16BPP:
+      SurfGDI->DIB_PutPixel = DIB_16BPP_PutPixel;
+      SurfGDI->DIB_HLine    = DIB_16BPP_HLine;
+      SurfGDI->DIB_VLine    = DIB_16BPP_VLine;
+      SurfGDI->DIB_BitBlt   = DIB_16BPP_BitBlt;
+      break;
+
+    case BMF_24BPP:
+      SurfGDI->DIB_PutPixel = DIB_24BPP_PutPixel;
+      SurfGDI->DIB_HLine    = DIB_24BPP_HLine;
+      SurfGDI->DIB_VLine    = DIB_24BPP_VLine;
+      SurfGDI->DIB_BitBlt   = DIB_24BPP_BitBlt;
+      break;
+
+    case BMF_32BPP:
+      SurfGDI->DIB_PutPixel = DIB_32BPP_PutPixel;
+      SurfGDI->DIB_HLine    = DIB_32BPP_HLine;
+      SurfGDI->DIB_VLine    = DIB_32BPP_VLine;
+      SurfGDI->DIB_BitBlt   = DIB_32BPP_BitBlt;
+      break;
+
+    case BMF_4RLE:
+    case BMF_8RLE:
+      /* Not supported yet, fall through to unrecognized case */
+    default:
+      DPRINT1("InitializeFuncs: unsupported DIB format %d\n",
+               BitmapFormat);
+
+      SurfGDI->DIB_PutPixel = Dummy_PutPixel;
+      SurfGDI->DIB_HLine    = Dummy_HLine;
+      SurfGDI->DIB_VLine    = Dummy_VLine;
+      SurfGDI->DIB_BitBlt   = Dummy_BitBlt;
+      break;
+    }
 }
 
 HBITMAP STDCALL
@@ -100,13 +182,11 @@ EngCreateBitmap(IN SIZEL Size,
   if( !ValidEngHandle( NewBitmap ) )
        return 0;
 
-  SurfObj = (SURFOBJ*) AccessUserObject( NewBitmap );
-  SurfGDI = (SURFGDI*) AccessInternalObject( NewBitmap );
+  SurfObj = (SURFOBJ*) AccessUserObject( (ULONG) NewBitmap );
+  SurfGDI = (SURFGDI*) AccessInternalObject( (ULONG) NewBitmap );
   ASSERT( SurfObj );
   ASSERT( SurfGDI );
 
-  InitializeHooks(SurfGDI);
-
   SurfGDI->BitsPerPixel = BitsPerFormat(Format);
   SurfObj->lDelta = Width;
   SurfObj->cjBits = SurfObj->lDelta * Size.cy;
@@ -134,6 +214,10 @@ EngCreateBitmap(IN SIZEL Size,
   SurfObj->sizlBitmap = Size;
   SurfObj->iBitmapFormat = Format;
   SurfObj->iType = STYPE_BITMAP;
+  SurfObj->fjBitmap = Flags & (BMF_TOPDOWN | BMF_NOZEROINIT);
+  SurfObj->pvScan0 = SurfObj->pvBits;
+
+  InitializeFuncs(SurfGDI, Format);
 
   // Use flags to determine bitmap type -- TOP_DOWN or whatever
 
@@ -153,13 +237,11 @@ EngCreateDeviceSurface(IN DHSURF dhsurf,
   if( !ValidEngHandle( NewSurface ) )
        return 0;
 
-  SurfObj = (SURFOBJ*) AccessUserObject( NewSurface );
-  SurfGDI = (SURFGDI*) AccessInternalObject( NewSurface );
+  SurfObj = (SURFOBJ*) AccessUserObject( (ULONG) NewSurface );
+  SurfGDI = (SURFGDI*) AccessInternalObject( (ULONG) NewSurface );
   ASSERT( SurfObj );
   ASSERT( SurfGDI );
 
-  InitializeHooks(SurfGDI);
-
   SurfGDI->BitsPerPixel = BitsPerFormat(Format);
   SurfObj->dhsurf = dhsurf;
   SurfObj->hsurf  = dhsurf; // FIXME: Is this correct??
@@ -168,6 +250,8 @@ EngCreateDeviceSurface(IN DHSURF dhsurf,
   SurfObj->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(Format));
   SurfObj->iType = STYPE_DEVICE;
 
+  InitializeFuncs(SurfGDI, Format);
+
   return NewSurface;
 }
 
@@ -243,3 +327,9 @@ EngLockSurface(IN HSURF Surface)
   // FIXME: Call GDI_LockObject (see subsys/win32k/objects/gdi.c)
   return (SURFOBJ*)AccessUserObject((ULONG)Surface);
 }
+
+VOID STDCALL
+EngUnlockSurface(IN SURFOBJ *Surface)
+{
+  // FIXME: Call GDI_UnlockObject
+}