return TRUE;
}
-/***********************************************************************
- * REGION_CropRgn
- *
- *
+/*!
+ * \param
* hSrc: Region to crop and offset.
* lpRect: Clipping rectangle. Can be NULL (no clipping).
* lpPt: Points to offset the cropped region. Can be NULL (no offset).
* Allowed to be the same region as hSrc in which case everything
* will be done in place, with no memory reallocations.
*
- * Returns: hDst if success, 0 otherwise.
+ * \return hDst if success, 0 otherwise.
*/
HRGN REGION_CropRgn(HRGN hDst, HRGN hSrc, const PRECT lpRect, PPOINT lpPt)
{
- PROSRGNDATA objSrc = RGNDATA_LockRgn(hSrc);
- HRGN hNewDst;
+ PROSRGNDATA objSrc, rgnDst;
+ HRGN hNewDst, hRet = NULL;
+ GDIMULTILOCK Lock[2] = {{hDst, 0, GO_REGION_MAGIC}, {hSrc, 0, GO_REGION_MAGIC}};
- if(objSrc)
- {
- PROSRGNDATA rgnDst;
-
- if(hDst)
- {
- if(!(rgnDst = RGNDATA_LockRgn(hDst)))
- {
- hDst = 0;
- goto done;
- }
- }
- else{
+ if( !hDst ){
if( !( hNewDst = RGNDATA_AllocRgn(1) ) ){
- RGNDATA_UnlockRgn( hSrc );
return 0;
}
+ Lock[0].hObj = hNewDst;
+ }
- if(!(rgnDst = RGNDATA_LockRgn(hNewDst)))
- {
- RGNDATA_FreeRgn( hNewDst );
- RGNDATA_UnlockRgn( hSrc );
- return 0;
- }
- }
+ GDIOBJ_LockMultipleObj( &Lock, 2 );
+ rgnDst = Lock[0].pObj;
+ objSrc = Lock[1].pObj;
+ if( objSrc && rgnDst )
+ {
if(rgnDst)
{
POINT pt = { 0, 0 };
if(REGION_CropAndOffsetRegion(lpPt, lpRect, objSrc, rgnDst) == FALSE)
{ // ve failed cleanup and return
- RGNDATA_UnlockRgn( hSrc );
-
- if(hDst) // unlock new region if allocated
- RGNDATA_UnlockRgn( hDst );
- else
- RGNDATA_UnlockRgn( hNewDst );
-
- return 0;
+ hRet = NULL;
}
else{ // ve are fine. unlock the correct pointer and return correct handle
- RGNDATA_UnlockRgn( hSrc );
-
- if(hDst == 0){
- RGNDATA_UnlockRgn( hNewDst );
- return hNewDst;
- }
- else {
- RGNDATA_UnlockRgn( hDst );
- return hDst;
- }
+ hRet = Lock[0].hObj;
}
}
-done:
- RGNDATA_UnlockRgn( hSrc );
}
- return 0;
+ GDIOBJ_UnlockMultipleObj( &Lock, 2 );
+ return hRet;
}
-/***********************************************************************
- * REGION_Coalesce
- *
+/*!
* Attempt to merge the rects in the current band with those in the
* previous one. Used only by REGION_RegionOp.
*
* Results:
* The new index for the previous band.
*
- * Side Effects:
+ * \note Side Effects:
* If coalescing takes place:
* - rectangles in the previous band will have their bottom fields
* altered.
return (curStart);
}
-/***********************************************************************
- * REGION_RegionOp
- *
+/*!
* Apply an operation to two regions. Called by REGION_Union,
* REGION_Inverse, REGION_Subtract, REGION_Intersect...
*
* Side Effects:
* The new region is overwritten.
*
- * Notes:
- * The idea behind this function is to view the two regions as sets.
+ *\note The idea behind this function is to view the two regions as sets.
* Together they cover a rectangle of area that this function divides
* into horizontal bands where points are covered only by one region
* or by both. For the first case, the nonOverlapFunc is called with
***********************************************************************/
-/***********************************************************************
- * REGION_IntersectO
- *
+/*!
* Handle an overlapping band for REGION_Intersect.
*
* Results:
* None.
*
- * Side Effects:
+ * \note Side Effects:
* Rectangles may be added to the region.
*
*/
* Region Union
***********************************************************************/
-/***********************************************************************
- * REGION_UnionNonO
- *
+/*!
* Handle a non-overlapping band for the union operation. Just
* Adds the rectangles into the region. Doesn't have to check for
* subsumption or anything.
* Results:
* None.
*
- * Side Effects:
+ * \note Side Effects:
* pReg->numRects is incremented and the final rectangles overwritten
* with the rectangles we're passed.
*
return;
}
-/***********************************************************************
- * REGION_UnionO
- *
+/*!
* Handle an overlapping band for the union operation. Picks the
* left-most rectangle each time and merges it into the region.
*
* Results:
* None.
*
- * Side Effects:
+ * \note Side Effects:
* Rectangles are overwritten in pReg->rects and pReg->numRects will
* be changed.
*
* Region Subtraction
***********************************************************************/
-/***********************************************************************
- * REGION_SubtractNonO1
- *
+/*!
* Deal with non-overlapping band for subtraction. Any parts from
* region 2 we discard. Anything from region 1 we add to the region.
*
* Results:
* None.
*
- * Side Effects:
+ * \note Side Effects:
* pReg may be affected.
*
*/
}
-/***********************************************************************
- * REGION_SubtractO
- *
+/*!
* Overlapping band subtraction. x1 is the left-most point not yet
* checked.
*
* Results:
* None.
*
- * Side Effects:
+ * \note Side Effects:
* pReg may have rectangles added to it.
*
*/
return;
}
-/***********************************************************************
- * REGION_SubtractRegion
- *
+/*!
* Subtract regS from regM and leave the result in regD.
* S stands for subtrahend, M for minuend and D for difference.
*
* Results:
* TRUE.
*
- * Side Effects:
+ * \note Side Effects:
* regD is overwritten.
*
*/
}
-/***********************************************************************
- * REGION_UnionRectWithRegion
- * Adds a rectangle to a WINEREGION
+/*!
+ * Adds a rectangle to a REGION
*/
static void REGION_UnionRectWithRegion(const RECT *rect, ROSRGNDATA *rgn)
{
INT CombineMode)
{
INT result = ERROR;
- PROSRGNDATA destRgn = RGNDATA_LockRgn(hDest);
+ GDIMULTILOCK Lock[3] = {{hDest, 0, GO_REGION_MAGIC}, {hSrc1, 0, GO_REGION_MAGIC}, {hSrc2, 0, GO_REGION_MAGIC}};
+ PROSRGNDATA destRgn, src1Rgn, src2Rgn;
- if( destRgn ){
- PROSRGNDATA src1Rgn = RGNDATA_LockRgn(hSrc1);
+ GDIOBJ_LockMultipleObj( &Lock, 3 );
+ destRgn = (PROSRGNDATA) Lock[0].pObj;
+ src1Rgn = (PROSRGNDATA) Lock[1].pObj;
+ src2Rgn = (PROSRGNDATA) Lock[2].pObj;
+
+ if( destRgn ){
if( src1Rgn ){
if (CombineMode == RGN_COPY)
{
}
else
{
- PROSRGNDATA src2Rgn = RGNDATA_LockRgn(hSrc2);
if( src2Rgn ){
switch (CombineMode)
{
break;
}
result = destRgn->rdh.iType;
- RGNDATA_UnlockRgn( hSrc2 );
}
- RGNDATA_UnlockRgn( hSrc1 );
}
- RGNDATA_UnlockRgn( hDest );
- }
- else{
- DPRINT("W32kCombineRgn: hDest unavailable\n");
- return ERROR;
}
}
+ else{
+ DPRINT("W32kCombineRgn: hDest unavailable\n");
+ result = ERROR;
+ }
+ GDIOBJ_UnlockMultipleObj( &Lock, 3 );
return result;
}
return hDest;
}
-/***********************************************************************
- * GetRegionData (GDI32.@)
- *
+/*!
* MSDN: GetRegionData, Return Values:
*
* "If the function succeeds and dwCount specifies an adequate number of bytes,