Patch by Brecht Machiels: Add operator==() to BRegion. Thanks a lot!
Also fixed some coding style inconsistency. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29849 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -32,6 +32,7 @@ class BRegion {
|
|||||||
virtual ~BRegion();
|
virtual ~BRegion();
|
||||||
|
|
||||||
BRegion& operator=(const BRegion& from);
|
BRegion& operator=(const BRegion& from);
|
||||||
|
bool operator==(const BRegion& other) const;
|
||||||
|
|
||||||
void Set(BRect newBounds);
|
void Set(BRect newBounds);
|
||||||
void Set(clipping_rect newBounds);
|
void Set(clipping_rect newBounds);
|
||||||
|
|||||||
@@ -26,10 +26,11 @@ const static int32 kDataBlockSize = 8;
|
|||||||
and its fBounds will be invalid.
|
and its fBounds will be invalid.
|
||||||
*/
|
*/
|
||||||
BRegion::BRegion()
|
BRegion::BRegion()
|
||||||
: fCount(0)
|
:
|
||||||
, fDataSize(0)
|
fCount(0),
|
||||||
, fBounds((clipping_rect){ 0, 0, 0, 0 })
|
fDataSize(0),
|
||||||
, fData(NULL)
|
fBounds((clipping_rect){ 0, 0, 0, 0 }),
|
||||||
|
fData(NULL)
|
||||||
{
|
{
|
||||||
_SetSize(kDataBlockSize);
|
_SetSize(kDataBlockSize);
|
||||||
}
|
}
|
||||||
@@ -39,10 +40,11 @@ BRegion::BRegion()
|
|||||||
\param region The region to copy.
|
\param region The region to copy.
|
||||||
*/
|
*/
|
||||||
BRegion::BRegion(const BRegion& region)
|
BRegion::BRegion(const BRegion& region)
|
||||||
: fCount(0)
|
:
|
||||||
, fDataSize(0)
|
fCount(0),
|
||||||
, fBounds((clipping_rect){ 0, 0, 0, 0 })
|
fDataSize(0),
|
||||||
, fData(NULL)
|
fBounds((clipping_rect){ 0, 0, 0, 0 }),
|
||||||
|
fData(NULL)
|
||||||
{
|
{
|
||||||
*this = region;
|
*this = region;
|
||||||
}
|
}
|
||||||
@@ -52,10 +54,11 @@ BRegion::BRegion(const BRegion& region)
|
|||||||
\param rect The BRect to set the region to.
|
\param rect The BRect to set the region to.
|
||||||
*/
|
*/
|
||||||
BRegion::BRegion(const BRect rect)
|
BRegion::BRegion(const BRect rect)
|
||||||
: fCount(0)
|
:
|
||||||
, fDataSize(1)
|
fCount(0),
|
||||||
, fBounds((clipping_rect){ 0, 0, 0, 0 })
|
fDataSize(1),
|
||||||
, fData(&fBounds)
|
fBounds((clipping_rect){ 0, 0, 0, 0 }),
|
||||||
|
fData(&fBounds)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid())
|
if (!rect.IsValid())
|
||||||
return;
|
return;
|
||||||
@@ -112,6 +115,21 @@ BRegion::operator=(const BRegion ®ion)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! \brief Compares this region to another (by value).
|
||||||
|
\param other the BRegion to compare to.
|
||||||
|
\return \ctrue if the two regions are the same, \cfalse otherwise.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BRegion::operator==(const BRegion& other) const
|
||||||
|
{
|
||||||
|
if (&other == this)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (fCount != other.fCount)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return memcmp(fData, other.fData, fCount * sizeof(clipping_rect)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*! \brief Set the region to contain just the given BRect.
|
/*! \brief Set the region to contain just the given BRect.
|
||||||
\param newBounds A BRect.
|
\param newBounds A BRect.
|
||||||
|
|||||||
Reference in New Issue
Block a user