update for HEAD-2003091401
[reactos.git] / subsys / win32k / objects / brush.c
index f64f874..909ff3c 100644 (file)
@@ -1,3 +1,21 @@
+/*
+ *  ReactOS W32 Subsystem
+ *  Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
 /* $Id$
  */
 
 //#include <win32k/debug.h>
 #include <include/object.h>
 #include <include/inteng.h>
+#include <include/error.h>
 
 #define NDEBUG
 #include <win32k/debug1.h>
 
-HBRUSH STDCALL W32kCreateBrushIndirect(CONST LOGBRUSH  *lb)
+HBRUSH STDCALL NtGdiCreateBrushIndirect(CONST LOGBRUSH  *lb)
 {
   PBRUSHOBJ  brushPtr;
   HBRUSH  hBrush;
@@ -26,7 +45,8 @@ HBRUSH STDCALL W32kCreateBrushIndirect(CONST LOGBRUSH  *lb)
   }
 
   brushPtr = BRUSHOBJ_LockBrush (hBrush);
-  ASSERT( brushPtr ); //I want to know if this ever occurs
+/* FIXME: Occurs! FiN */
+/*  ASSERT( brushPtr ); *///I want to know if this ever occurs
 
   if( brushPtr ){
        brushPtr->iSolidColor = lb->lbColor;
@@ -40,7 +60,7 @@ HBRUSH STDCALL W32kCreateBrushIndirect(CONST LOGBRUSH  *lb)
   return NULL;
 }
 
-HBRUSH STDCALL W32kCreateDIBPatternBrush(HGLOBAL  hDIBPacked,
+HBRUSH STDCALL NtGdiCreateDIBPatternBrush(HGLOBAL  hDIBPacked,
                                   UINT  ColorSpec)
 {
   UNIMPLEMENTED;
@@ -76,11 +96,11 @@ HBRUSH STDCALL W32kCreateDIBPatternBrush(HGLOBAL  hDIBPacked,
   memcpy(newInfo, info, size);
   GlobalUnlock16((HGLOBAL16)logbrush.lbHatch);
   GlobalUnlock(hbitmap);
-  return W32kCreateBrushIndirect(&logbrush);
+  return NtGdiCreateBrushIndirect(&logbrush);
 #endif
 }
 
-HBRUSH STDCALL W32kCreateDIBPatternBrushPt(CONST VOID  *PackedDIB,
+HBRUSH STDCALL NtGdiCreateDIBPatternBrushPt(CONST VOID  *PackedDIB,
                                     UINT  Usage)
 {
   INT  size;
@@ -115,20 +135,20 @@ HBRUSH STDCALL W32kCreateDIBPatternBrushPt(CONST VOID  *PackedDIB,
   }
   size += DIB_BitmapInfoSize (info, Usage);
 
-  logbrush.lbHatch = (LONG) GDIOBJ_AllocObj(size, GO_MAGIC_DONTCARE);
+  logbrush.lbHatch = (LONG) GDIOBJ_AllocObj(size, GDI_OBJECT_TYPE_DONTCARE, NULL);
   if (logbrush.lbHatch == 0)
   {
     return 0;
   }
-  newInfo = (PBITMAPINFO) GDIOBJ_LockObj ((HGDIOBJ) logbrush.lbHatch, GO_MAGIC_DONTCARE);
+  newInfo = (PBITMAPINFO) GDIOBJ_LockObj ((HGDIOBJ) logbrush.lbHatch, GDI_OBJECT_TYPE_DONTCARE);
   ASSERT(newInfo);
   memcpy(newInfo, info, size);
-  GDIOBJ_UnlockObj( (HGDIOBJ) logbrush.lbHatch, GO_MAGIC_DONTCARE );
+  GDIOBJ_UnlockObj((HGDIOBJ) logbrush.lbHatch, GDI_OBJECT_TYPE_DONTCARE);
 
-  return  W32kCreateBrushIndirect (&logbrush);
+  return  NtGdiCreateBrushIndirect (&logbrush);
 }
 
-HBRUSH STDCALL W32kCreateHatchBrush(INT  Style,
+HBRUSH STDCALL NtGdiCreateHatchBrush(INT  Style,
                              COLORREF  Color)
 {
   LOGBRUSH  logbrush;
@@ -143,10 +163,10 @@ HBRUSH STDCALL W32kCreateHatchBrush(INT  Style,
   logbrush.lbColor = Color;
   logbrush.lbHatch = Style;
 
-  return  W32kCreateBrushIndirect (&logbrush);
+  return  NtGdiCreateBrushIndirect (&logbrush);
 }
 
-HBRUSH STDCALL W32kCreatePatternBrush(HBITMAP  hBitmap)
+HBRUSH STDCALL NtGdiCreatePatternBrush(HBITMAP  hBitmap)
 {
   LOGBRUSH  logbrush = { BS_PATTERN, 0, 0 };
 
@@ -158,11 +178,11 @@ HBRUSH STDCALL W32kCreatePatternBrush(HBITMAP  hBitmap)
   }
   else
   {
-    return W32kCreateBrushIndirect( &logbrush );
+    return NtGdiCreateBrushIndirect( &logbrush );
   }
 }
 
-HBRUSH STDCALL W32kCreateSolidBrush(COLORREF  Color)
+HBRUSH STDCALL NtGdiCreateSolidBrush(COLORREF  Color)
 {
   LOGBRUSH logbrush;
 
@@ -170,35 +190,28 @@ HBRUSH STDCALL W32kCreateSolidBrush(COLORREF  Color)
   logbrush.lbColor = Color;
   logbrush.lbHatch = 0;
 
-  return W32kCreateBrushIndirect(&logbrush);
+  return NtGdiCreateBrushIndirect(&logbrush);
 }
 
-BOOL STDCALL W32kFixBrushOrgEx(VOID)
+BOOL STDCALL NtGdiFixBrushOrgEx(VOID)
 {
   return FALSE;
 }
 
-BOOL STDCALL W32kPatBlt(HDC  hDC,
+BOOL STDCALL IntPatBlt(DC *dc,
                        INT  XLeft,
                        INT  YLeft,
                        INT  Width,
                        INT  Height,
-                       DWORD  ROP)
+                       DWORD  ROP,
+                       PBRUSHOBJ BrushObj)
 {
   RECT DestRect;
-  PBRUSHOBJ BrushObj;
   PSURFOBJ SurfObj;
-  DC *dc = DC_HandleToPtr(hDC);
   BOOL ret;
 
-  if (dc == NULL)
-    {
-      return(FALSE);
-    }
-
   SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface);
 
-  BrushObj = (BRUSHOBJ*) GDIOBJ_LockObj(dc->w.hBrush, GO_BRUSH_MAGIC);
   assert(BrushObj);
   if (BrushObj->logbrush.lbStyle != BS_NULL)
     {
@@ -209,8 +222,8 @@ BOOL STDCALL W32kPatBlt(HDC  hDC,
        }
       else
        {
-         DestRect.left = XLeft + Width + dc->w.DCOrgX;
-         DestRect.right = XLeft + dc->w.DCOrgX;
+         DestRect.left = XLeft + Width + 1 + dc->w.DCOrgX;
+         DestRect.right = XLeft + dc->w.DCOrgX + 1;
        }
       if (Height > 0)
        {
@@ -219,30 +232,81 @@ BOOL STDCALL W32kPatBlt(HDC  hDC,
        }
       else
        {
-         DestRect.top = YLeft + Height + dc->w.DCOrgY;
-         DestRect.bottom = YLeft + dc->w.DCOrgY;
+         DestRect.top = YLeft + Height + dc->w.DCOrgY + 1;
+         DestRect.bottom = YLeft + dc->w.DCOrgY + 1;
        }
       ret = IntEngBitBlt(SurfObj,
                         NULL,
                         NULL,
-                        NULL,
+                        dc->CombinedClip,
                         NULL,
                         &DestRect,
                         NULL,
                         NULL,
                         BrushObj,
                         NULL,
-                        PATCOPY);
+                        ROP);
+    }
+  return(ret);
+}
+
+BOOL STDCALL NtGdiPolyPatBlt(HDC hDC,
+                       DWORD dwRop,
+                       PPATRECT pRects,
+                       int cRects,
+                       ULONG Reserved)
+{
+       int i;
+       PATRECT r;
+       PBRUSHOBJ BrushObj;
+       DC *dc = DC_LockDc(hDC);
+       if (dc == NULL)
+       {
+               SetLastWin32Error(ERROR_INVALID_HANDLE);
+               return(FALSE);
+       }
+       for (i = 0;i<cRects;i++)
+       {
+               r = *pRects;
+               BrushObj = BRUSHOBJ_LockBrush(r.hBrush);
+               IntPatBlt(dc,r.r.left,r.r.top,r.r.right,r.r.bottom,dwRop,BrushObj);
+               BRUSHOBJ_UnlockBrush(r.hBrush);
+               pRects++;
+       }
+       DC_UnlockDc( hDC );
+       return TRUE;
+}
+
+BOOL STDCALL NtGdiPatBlt(HDC  hDC,
+                       INT  XLeft,
+                       INT  YLeft,
+                       INT  Width,
+                       INT  Height,
+                       DWORD  ROP)
+{
+  PBRUSHOBJ BrushObj;
+  DC *dc = DC_LockDc(hDC);
+  BOOL ret;
+
+  if (dc == NULL)
+    {
+      SetLastWin32Error(ERROR_INVALID_HANDLE);
+      return(FALSE);
     }
-  GDIOBJ_UnlockObj( dc->w.hBrush, GO_BRUSH_MAGIC );
-  DC_ReleasePtr( hDC );
+
+  BrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
+  ret = IntPatBlt(dc,XLeft,YLeft,Width,Height,ROP,BrushObj);
+
+  BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+  DC_UnlockDc( hDC );
   return(ret);
 }
 
-BOOL STDCALL W32kSetBrushOrgEx(HDC  hDC,
+BOOL STDCALL NtGdiSetBrushOrgEx(HDC  hDC,
                         INT  XOrg,
                         INT  YOrg,
                         LPPOINT  Point)
 {
   UNIMPLEMENTED;
 }
+/* EOF */