Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Attributes | Private Member Functions
nsRegionOS2 Class Reference

#include <nsRegionOS2.h>

Inheritance diagram for nsRegionOS2:
Inheritance graph
[legend]
Collaboration diagram for nsRegionOS2:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsRegionOS2 ()
NS_DECL_ISUPPORTS NS_IMETHOD GetNativeRegion (void *&aRegion) const
 Get the native region that this nsIRegion represents.
HRGN GetHRGN (PRUint32 ulHeight, HPS hps)
nsresult InitWithHRGN (HRGN copy, PRUint32 ulHeight, HPS hps)
virtual nsresult Init (void)
virtual void SetTo (const nsIRegion &aRegion)
 copy operator equivalent that takes another region
virtual void SetTo (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
 copy operator equivalent that takes a rect
virtual void Intersect (const nsIRegion &aRegion)
 destructively intersect another region with this one
virtual void Intersect (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
 destructively intersect a rect with this region
virtual void Union (const nsIRegion &aRegion)
 destructively union another region with this one
virtual void Union (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
 destructively union a rect with this region
virtual void Subtract (const nsIRegion &aRegion)
 destructively subtract another region with this one
virtual void Subtract (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
 destructively subtract a rect from this region
virtual PRBool IsEmpty (void)
 is this region empty? i.e.
virtual PRBool IsEqual (const nsIRegion &aRegion)
 == operator equivalent i.e.
virtual void GetBoundingBox (PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight)
 returns the bounding box of the region i.e.
virtual void Offset (PRInt32 aXOffset, PRInt32 aYOffset)
 offsets the region in x and y
virtual PRBool ContainsRect (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
 does the region intersect the rectangle?
NS_IMETHOD GetRects (nsRegionRectSet **aRects)
 get the set of rects which make up this region.
NS_IMETHOD FreeRects (nsRegionRectSet *aRects)
 Free a rect set returned by GetRects.
NS_IMETHOD GetRegionComplexity (nsRegionComplexity &aComplexity) const
 Get the complexity of the region as defined by the nsRegionComplexity enum.
NS_IMETHOD GetNumRects (PRUint32 *aRects) const
 get the number of rects which make up this region.

Protected Attributes

nsRegion mRegion

Private Member Functions

PRUint32 NumOfRects (HPS aPS, HRGN aRegion) const

Detailed Description

Definition at line 44 of file nsRegionOS2.h.


Constructor & Destructor Documentation

Definition at line 43 of file nsRegionOS2.cpp.

{  
}

Member Function Documentation

PRBool nsRegionImpl::ContainsRect ( PRInt32  aX,
PRInt32  aY,
PRInt32  aWidth,
PRInt32  aHeight 
) [virtual, inherited]

does the region intersect the rectangle?

Parameters:
rectto check for containment
Returns:
true if the region intersects the rect

Implements nsIRegion.

Definition at line 116 of file nsRegionImpl.cpp.

{
  nsRegion TmpRegion;
  TmpRegion.And (mRegion, nsRect (aX, aY, aWidth, aHeight));
  return (!TmpRegion.IsEmpty ());
}

Here is the call graph for this function:

nsresult nsRegionImpl::FreeRects ( nsRegionRectSet aRects) [virtual, inherited]

Free a rect set returned by GetRects.

Parameters:
aRectsrects to free
Returns:
error status

Implements nsIRegion.

Definition at line 167 of file nsRegionImpl.cpp.

{
  if (!aRects)
    return NS_ERROR_NULL_POINTER;

  delete [] NS_REINTERPRET_CAST (PRUint8*, aRects);
  return NS_OK;
}
void nsRegionImpl::GetBoundingBox ( PRInt32 aX,
PRInt32 aY,
PRInt32 aWidth,
PRInt32 aHeight 
) [virtual, inherited]

returns the bounding box of the region i.e.

the smallest rectangle that completely contains the region.

Parameters:
aXout parameter for xoffset of bounding rect for region
aYout parameter for yoffset of bounding rect for region
aWidthout parameter for width of bounding rect for region
aHeightout parameter for height of bounding rect for region
Returns:
void

Implements nsIRegion.

Definition at line 102 of file nsRegionImpl.cpp.

{
  const nsRect& BoundRect = mRegion.GetBounds();
  *aX = BoundRect.x;
  *aY = BoundRect.y;
  *aWidth  = BoundRect.width;
  *aHeight = BoundRect.height;
}

Here is the call graph for this function:

HRGN nsRegionOS2::GetHRGN ( PRUint32  ulHeight,
HPS  hps 
)

Definition at line 67 of file nsRegionOS2.cpp.

{
  PRUint32 NumRects = mRegion.GetNumRects ();

  if (NumRects > 0)
  {
    PRECTL pRects = new RECTL [NumRects];

    nsRegionRectIterator ri (mRegion);
    const nsRect* pSrc;
    PRECTL pDest = pRects;

    while ((pSrc = ri.Next()))
    {
      pDest->xLeft    = pSrc->x;
      pDest->xRight   = pSrc->XMost ();
      pDest->yTop     = DestHeight - pSrc->y;
      pDest->yBottom  = pDest->yTop - pSrc->height;
      pDest++;
    }

    HRGN rgn = GFX (::GpiCreateRegion (DestPS, NumRects, pRects), RGN_ERROR);
    delete [] pRects;

    return rgn;
  } else
  {
    return GFX (::GpiCreateRegion (DestPS, 0, NULL), RGN_ERROR);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsRegionOS2::GetNativeRegion ( void *&  aRegion) const [virtual]

Get the native region that this nsIRegion represents.

Parameters:
aRegionout parameter for native region handle
Returns:
error status

Reimplemented from nsRegionImpl.

Definition at line 48 of file nsRegionOS2.cpp.

{
  aRegion = (void*)RGN_ERROR;
  return NS_OK;
}
nsresult nsRegionImpl::GetNumRects ( PRUint32 aRects) const [virtual, inherited]

get the number of rects which make up this region.

Parameters:
aRectsout parameter containing the number of rects comprising the region
Returns:
error status

Implements nsIRegion.

Definition at line 194 of file nsRegionImpl.cpp.

{
  *aRects = mRegion.GetNumRects ();
  return NS_OK;
}
nsresult nsRegionImpl::GetRects ( nsRegionRectSet **  aRects) [virtual, inherited]

get the set of rects which make up this region.

the aRects parameter must be freed by calling FreeRects before the region is deleted. aRects may be passed in again when requesting the rect list as a recycling method.

Parameters:
aRectsout parameter containing set of rects comprising the region
Returns:
error status

Implements nsIRegion.

Definition at line 123 of file nsRegionImpl.cpp.

{
  if (!aRects)
    return NS_ERROR_NULL_POINTER;

  nsRegionRectSet* pRegionSet = *aRects;
  PRUint32 NumRects = mRegion.GetNumRects ();

  if (!pRegionSet)                          // Not yet allocated
  {
    PRUint8* pBuf = new PRUint8 [sizeof (nsRegionRectSet) + NumRects * sizeof (nsRegionRect)];
    pRegionSet = NS_REINTERPRET_CAST (nsRegionRectSet*, pBuf);
    pRegionSet->mRectsLen = NumRects + 1;
  } else                                    // Already allocated in previous call
  {
    if (NumRects > pRegionSet->mRectsLen)   // passed array is not big enough - reallocate it.
    {
      delete [] NS_REINTERPRET_CAST (PRUint8*, pRegionSet);
      PRUint8* pBuf = new PRUint8 [sizeof (nsRegionRectSet) + NumRects * sizeof (nsRegionRect)];
      pRegionSet = NS_REINTERPRET_CAST (nsRegionRectSet*, pBuf);
      pRegionSet->mRectsLen = NumRects + 1;
    }
  }
  pRegionSet->mNumRects = NumRects;
  *aRects = pRegionSet;


  nsRegionRectIterator ri (mRegion);
  nsRegionRect* pDest = &pRegionSet->mRects [0];
  const nsRect* pSrc;

  while ((pSrc = ri.Next ()) != nsnull)
  {
    pDest->x = pSrc->x;
    pDest->y = pSrc->y;
    pDest->width  = pSrc->width;
    pDest->height = pSrc->height;

    ++pDest;
  }

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsRegionImpl::GetRegionComplexity ( nsRegionComplexity aComplexity) const [virtual, inherited]

Get the complexity of the region as defined by the nsRegionComplexity enum.

Parameters:
aComplexityout parameter for region complexity
Returns:
error status

Implements nsIRegion.

Definition at line 182 of file nsRegionImpl.cpp.

{
  switch (mRegion.GetNumRects ())
  {
    case 0:   aComplexity = eRegionComplexity_empty;    break;
    case 1:   aComplexity = eRegionComplexity_rect;     break;
    default:  aComplexity = eRegionComplexity_complex;  break;
  }

  return NS_OK;
}
nsresult nsRegionImpl::Init ( void  ) [virtual, inherited]

Implements nsIRegion.

Definition at line 41 of file nsRegionImpl.cpp.

{
  mRegion.SetEmpty ();
  return NS_OK;
}

Here is the caller graph for this function:

nsresult nsRegionOS2::InitWithHRGN ( HRGN  copy,
PRUint32  ulHeight,
HPS  hps 
)

Definition at line 99 of file nsRegionOS2.cpp.

{
  PRUint32 NumRects = NumOfRects (SrcPS, SrcRegion);
  mRegion.SetEmpty ();

  if (NumRects > 0)
  {
    RGNRECT RgnControl = { 1, NumRects, 0, RECTDIR_LFRT_TOPBOT };
    PRECTL  pRects = new RECTL [NumRects];

    GFX (::GpiQueryRegionRects (SrcPS, SrcRegion, NULL, &RgnControl, pRects), FALSE);

    for (PRUint32 cnt = 0 ; cnt < NumRects ; cnt++)
      mRegion.Or (mRegion, nsRect ( pRects [cnt].xLeft, SrcHeight - pRects [cnt].yTop, 
                  pRects [cnt].xRight - pRects [cnt].xLeft, pRects [cnt].yTop - pRects [cnt].yBottom));

    delete [] pRects;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsRegionImpl::Intersect ( const nsIRegion aRegion) [virtual, inherited]

destructively intersect another region with this one

Parameters:
regionto intersect
Returns:
void

Implements nsIRegion.

Definition at line 58 of file nsRegionImpl.cpp.

{
  const nsRegionImpl* pRegion = NS_STATIC_CAST (const nsRegionImpl*, &aRegion);
  mRegion.And (mRegion, pRegion->mRegion);
}
void nsRegionImpl::Intersect ( PRInt32  aX,
PRInt32  aY,
PRInt32  aWidth,
PRInt32  aHeight 
) [virtual, inherited]

destructively intersect a rect with this region

Parameters:
aXxoffset of rect to intersect with region
aYyoffset of rect to intersect with region
aWidthwidth of rect to intersect with region
aHeightheight of rect to intersect with region
Returns:
void

Implements nsIRegion.

Definition at line 64 of file nsRegionImpl.cpp.

{
  mRegion.And (mRegion, nsRect (aX, aY, aWidth, aHeight));
}

Here is the call graph for this function:

PRBool nsRegionImpl::IsEmpty ( void  ) [virtual, inherited]

is this region empty? i.e.

does it contain any pixels

Parameters:
none
Returns:
returns whether the region is empty

Implements nsIRegion.

Definition at line 91 of file nsRegionImpl.cpp.

{
  return mRegion.IsEmpty ();
}
PRBool nsRegionImpl::IsEqual ( const nsIRegion aRegion) [virtual, inherited]

== operator equivalent i.e.

do the regions contain exactly the same pixels

Parameters:
regionto compare
Returns:
whether the regions are identical

Implements nsIRegion.

Definition at line 96 of file nsRegionImpl.cpp.

{
  const nsRegionImpl* pRegion = NS_STATIC_CAST (const nsRegionImpl*, &aRegion);
  return mRegion.IsEqual (pRegion->mRegion);
}
PRUint32 nsRegionOS2::NumOfRects ( HPS  aPS,
HRGN  aRegion 
) const [private]

Definition at line 54 of file nsRegionOS2.cpp.

{
  RGNRECT rgnRect;
  rgnRect.ircStart = 1;
  rgnRect.crc = 0xFFFFFFFF;
  rgnRect.crcReturned = 0;
  rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT;

  GFX (::GpiQueryRegionRects (aPS, aRegion, NULL, &rgnRect, NULL), FALSE);
 
  return rgnRect.crcReturned;
}

Here is the caller graph for this function:

void nsRegionImpl::Offset ( PRInt32  aXOffset,
PRInt32  aYOffset 
) [virtual, inherited]

offsets the region in x and y

Parameters:
xoffsetpixel offset in x
yoffsetpixel offset in y
Returns:
void

Implements nsIRegion.

Definition at line 111 of file nsRegionImpl.cpp.

{
  mRegion.MoveBy (aXOffset, aYOffset);
}
void nsRegionImpl::SetTo ( const nsIRegion aRegion) [virtual, inherited]

copy operator equivalent that takes another region

Parameters:
regionto copy
Returns:
void

Implements nsIRegion.

Definition at line 47 of file nsRegionImpl.cpp.

{
  const nsRegionImpl* pRegion = NS_STATIC_CAST (const nsRegionImpl*, &aRegion);
  mRegion = pRegion->mRegion;
}
void nsRegionImpl::SetTo ( PRInt32  aX,
PRInt32  aY,
PRInt32  aWidth,
PRInt32  aHeight 
) [virtual, inherited]

copy operator equivalent that takes a rect

Parameters:
aXxoffset of rect to set region to
aYyoffset of rect to set region to
aWidthwidth of rect to set region to
aHeightheight of rect to set region to
Returns:
void

Implements nsIRegion.

Definition at line 53 of file nsRegionImpl.cpp.

{
  mRegion = nsRect (aX, aY, aWidth, aHeight);
}

Here is the call graph for this function:

void nsRegionImpl::Subtract ( const nsIRegion aRegion) [virtual, inherited]

destructively subtract another region with this one

Parameters:
regionto subtract
Returns:
void

Implements nsIRegion.

Definition at line 80 of file nsRegionImpl.cpp.

{
  const nsRegionImpl* pRegion = NS_STATIC_CAST (const nsRegionImpl*, &aRegion);
  mRegion.Sub (mRegion, pRegion->mRegion);
}
void nsRegionImpl::Subtract ( PRInt32  aX,
PRInt32  aY,
PRInt32  aWidth,
PRInt32  aHeight 
) [virtual, inherited]

destructively subtract a rect from this region

Parameters:
aXxoffset of rect to subtract with region
aYyoffset of rect to subtract with region
aWidthwidth of rect to subtract with region
aHeightheight of rect to subtract with region
Returns:
void

Implements nsIRegion.

Definition at line 86 of file nsRegionImpl.cpp.

{
  mRegion.Sub (mRegion, nsRect (aX, aY, aWidth, aHeight));
}

Here is the call graph for this function:

void nsRegionImpl::Union ( const nsIRegion aRegion) [virtual, inherited]

destructively union another region with this one

Parameters:
regionto union
Returns:
void

Implements nsIRegion.

Definition at line 69 of file nsRegionImpl.cpp.

{
  const nsRegionImpl* pRegion = NS_STATIC_CAST (const nsRegionImpl*, &aRegion);
  mRegion.Or (mRegion, pRegion->mRegion);
}
void nsRegionImpl::Union ( PRInt32  aX,
PRInt32  aY,
PRInt32  aWidth,
PRInt32  aHeight 
) [virtual, inherited]

destructively union a rect with this region

Parameters:
aXxoffset of rect to union with region
aYyoffset of rect to union with region
aWidthwidth of rect to union with region
aHeightheight of rect to union with region
Returns:
void

Implements nsIRegion.

Definition at line 75 of file nsRegionImpl.cpp.

{
  mRegion.Or (mRegion, nsRect (aX, aY, aWidth, aHeight));
}

Here is the call graph for this function:


Member Data Documentation

nsRegion nsRegionImpl::mRegion [protected, inherited]

Definition at line 48 of file nsRegionImpl.h.


The documentation for this class was generated from the following files: