[CMAKE]
[reactos.git] / subsystems / win32 / win32k / objects / arc.c
index 5839303..eefccce 100644 (file)
@@ -1,4 +1,6 @@
 #include <win32k.h>
+#define _USE_MATH_DEFINES
+#include <math.h>
 
 #define NDEBUG
 #include <debug.h>
@@ -31,7 +33,7 @@ BOOL FASTCALL IntDrawArc( PDC dc, INT XLeft, INT YLeft, INT Width, INT Height, d
 static
 BOOL
 FASTCALL
-IntArc( DC *dc, 
+IntArc( DC *dc,
         int  Left,
         int  Top,
         int  Right,
@@ -44,7 +46,7 @@ IntArc( DC *dc,
 {
     PDC_ATTR pdcattr;
     RECTL RectBounds, RectSEpts;
-    PBRUSH pbrushPen;
+    PBRUSH pbrPen;
     SURFACE *psurf;
     BOOL ret = TRUE;
     LONG PenWidth, PenOrigWidth;
@@ -69,18 +71,18 @@ IntArc( DC *dc,
 
     pdcattr = dc->pdcattr;
 
-    pbrushPen = PEN_LockPen(pdcattr->hpen);
-    if (!pbrushPen)
+    pbrPen = PEN_ShareLockPen(pdcattr->hpen);
+    if (!pbrPen)
     {
         DPRINT1("Arc Fail 1\n");
-        SetLastWin32Error(ERROR_INTERNAL_ERROR);
+        EngSetLastError(ERROR_INTERNAL_ERROR);
         return FALSE;
     }
 
-    PenOrigWidth = PenWidth = pbrushPen->ptPenWidth.x;
-    if (pbrushPen->ulPenStyle == PS_NULL) PenWidth = 0;
+    PenOrigWidth = PenWidth = pbrPen->ptPenWidth.x;
+    if (pbrPen->ulPenStyle == PS_NULL) PenWidth = 0;
 
-    if (pbrushPen->ulPenStyle == PS_INSIDEFRAME)
+    if (pbrPen->ulPenStyle == PS_INSIDEFRAME)
     {
        if (2*PenWidth > (Right - Left)) PenWidth = (Right -Left + 1)/2;
        if (2*PenWidth > (Bottom - Top)) PenWidth = (Bottom -Top + 1)/2;
@@ -91,7 +93,7 @@ IntArc( DC *dc,
     }
 
     if (!PenWidth) PenWidth = 1;
-    pbrushPen->ptPenWidth.x = PenWidth;  
+    pbrPen->ptPenWidth.x = PenWidth;
 
     RectBounds.left   = Left;
     RectBounds.right  = Right;
@@ -105,7 +107,7 @@ IntArc( DC *dc,
 
     IntLPtoDP(dc, (LPPOINT)&RectBounds, 2);
     IntLPtoDP(dc, (LPPOINT)&RectSEpts, 2);
-    
+
     RectBounds.left   += dc->ptlDCOrig.x;
     RectBounds.right  += dc->ptlDCOrig.x;
     RectBounds.top    += dc->ptlDCOrig.y;
@@ -154,14 +156,14 @@ IntArc( DC *dc,
               AngleStart,
               AngleEnd,
               arctype,
-              pbrushPen);
+              pbrPen);
 
     psurf = dc->dclevel.pSurface;
     if (NULL == psurf)
     {
         DPRINT1("Arc Fail 2\n");
-        PEN_UnlockPen(pbrushPen);
-        SetLastWin32Error(ERROR_INTERNAL_ERROR);
+        PEN_ShareUnlockPen(pbrPen);
+        EngSetLastError(ERROR_INTERNAL_ERROR);
         return FALSE;
     }
 
@@ -172,9 +174,9 @@ IntArc( DC *dc,
     }
     if (arctype == GdiTypeChord)
         PUTLINE(EfCx + CenterX, EfCy + CenterY, SfCx + CenterX, SfCy + CenterY, dc->eboLine);
-           
-    pbrushPen->ptPenWidth.x = PenOrigWidth;
-    PEN_UnlockPen(pbrushPen);
+
+    pbrPen->ptPenWidth.x = PenOrigWidth;
+    PEN_ShareUnlockPen(pbrPen);
     DPRINT("IntArc Exit.\n");
     return ret;
 }
@@ -219,12 +221,6 @@ IntGdiArcInternal(
 
   pdcattr = dc->pdcattr;
 
-  if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
-    DC_vUpdateFillBrush(dc);
-
-  if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY))
-    DC_vUpdateLineBrush(dc);
-
   if (arctype == GdiTypeArcTo)
   {
     if (dc->dclevel.flPath & DCPATH_CLOCKWISE)
@@ -318,7 +314,7 @@ NtGdiAngleArc(
   pDC = DC_LockDc (hDC);
   if(!pDC)
   {
-    SetLastWin32Error(ERROR_INVALID_HANDLE);
+    EngSetLastError(ERROR_INVALID_HANDLE);
     return FALSE;
   }
   if (pDC->dctype == DC_TYPE_INFO)
@@ -329,7 +325,14 @@ NtGdiAngleArc(
   }
   worker.l  = dwStartAngle;
   worker1.l = dwSweepAngle;
+  DC_vPrepareDCsForBlit(pDC, pDC->rosdc.CombinedClip->rclBounds,
+                           NULL, pDC->rosdc.CombinedClip->rclBounds);
+  if (pDC->pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
+    DC_vUpdateFillBrush(pDC);
+  if (pDC->pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY))
+    DC_vUpdateLineBrush(pDC);
   Ret = IntGdiAngleArc( pDC, x, y, dwRadius, worker.f, worker1.f);
+  DC_vFinishBlit(pDC, NULL);
   DC_UnlockDc( pDC );
   return Ret;
 }
@@ -354,7 +357,7 @@ NtGdiArcInternal(
   dc = DC_LockDc (hDC);
   if(!dc)
   {
-    SetLastWin32Error(ERROR_INVALID_HANDLE);
+    EngSetLastError(ERROR_INVALID_HANDLE);
     return FALSE;
   }
   if (dc->dctype == DC_TYPE_INFO)
@@ -364,6 +367,15 @@ NtGdiArcInternal(
     return TRUE;
   }
 
+  DC_vPrepareDCsForBlit(dc, dc->rosdc.CombinedClip->rclBounds,
+                            NULL, dc->rosdc.CombinedClip->rclBounds);
+
+  if (dc->pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
+    DC_vUpdateFillBrush(dc);
+
+  if (dc->pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY))
+    DC_vUpdateLineBrush(dc);
+
   Ret = IntGdiArcInternal(
                   arctype,
                   dc,
@@ -376,6 +388,7 @@ NtGdiArcInternal(
                   XEndArc,
                   YEndArc);
 
+  DC_vFinishBlit(dc, NULL);
   DC_UnlockDc( dc );
   return Ret;
 }