* Made copy constructor and assign public and implemented them.

* Added BBitmap(const BBitmap&, uint32 flags) constructor as found in Dano/Zeta.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19270 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-11-13 18:56:44 +00:00
parent 7022e7903a
commit fdd0f4ce10
2 changed files with 45 additions and 23 deletions
+4 -3
View File
@@ -38,6 +38,8 @@ class BBitmap : public BArchivable {
screen_id screenID = B_MAIN_SCREEN_ID); screen_id screenID = B_MAIN_SCREEN_ID);
BBitmap(BRect bounds, color_space colorSpace, bool acceptsViews = false, BBitmap(BRect bounds, color_space colorSpace, bool acceptsViews = false,
bool needsContiguous = false); bool needsContiguous = false);
BBitmap(const BBitmap& source, uint32 flags);
BBitmap(const BBitmap& source);
BBitmap(const BBitmap *source, bool acceptsViews = false, BBitmap(const BBitmap *source, bool acceptsViews = false,
bool needsContiguous = false); bool needsContiguous = false);
virtual ~BBitmap(); virtual ~BBitmap();
@@ -87,6 +89,8 @@ class BBitmap : public BArchivable {
void Unlock(); void Unlock();
bool IsLocked() const; bool IsLocked() const;
BBitmap& operator=(const BBitmap& source);
//----- Private or reserved -----------------------------------------// //----- Private or reserved -----------------------------------------//
virtual status_t Perform(perform_code d, void *arg); virtual status_t Perform(perform_code d, void *arg);
@@ -100,9 +104,6 @@ class BBitmap : public BArchivable {
virtual void _ReservedBitmap2(); virtual void _ReservedBitmap2();
virtual void _ReservedBitmap3(); virtual void _ReservedBitmap3();
BBitmap(const BBitmap &);
BBitmap &operator=(const BBitmap &);
int32 _ServerToken() const; int32 _ServerToken() const;
void _InitObject(BRect bounds, color_space colorSpace, uint32 flags, void _InitObject(BRect bounds, color_space colorSpace, uint32 flags,
int32 bytesPerRow, screen_id screenID); int32 bytesPerRow, screen_id screenID);
+41 -20
View File
@@ -212,7 +212,27 @@ BBitmap::BBitmap(const BBitmap *source, bool acceptsViews,
} }
} }
// destructor
BBitmap::BBitmap(const BBitmap& source, uint32 flags)
{
if (!source.IsValid())
return;
_InitObject(source.Bounds(), source.ColorSpace(), flags,
source.BytesPerRow(), B_MAIN_SCREEN_ID);
if (InitCheck() == B_OK)
memcpy(Bits(), source.Bits(), min_c(BitsLength(), source.BitsLength()));
}
BBitmap::BBitmap(const BBitmap& source)
{
fBasePointer = NULL;
*this = source;
}
/*! \brief Frees all resources associated with this object. /*! \brief Frees all resources associated with this object.
*/ */
BBitmap::~BBitmap() BBitmap::~BBitmap()
@@ -373,7 +393,7 @@ BBitmap::InitCheck() const
bool bool
BBitmap::IsValid() const BBitmap::IsValid() const
{ {
return (InitCheck() == B_OK); return InitCheck() == B_OK;
} }
@@ -840,9 +860,25 @@ BBitmap::IsLocked() const
return fWindow != NULL ? fWindow->IsLocked() : false; return fWindow != NULL ? fWindow->IsLocked() : false;
} }
// Perform
/*! \brief ??? BBitmap &
*/ BBitmap::operator=(const BBitmap& source)
{
_CleanUp();
fInitError = B_NO_INIT;
if (!source.IsValid())
return *this;
_InitObject(source.Bounds(), source.ColorSpace(), source.Flags(),
source.BytesPerRow(), B_MAIN_SCREEN_ID);
if (InitCheck() == B_OK)
memcpy(Bits(), source.Bits(), min_c(BitsLength(), source.BitsLength()));
return *this;
}
status_t status_t
BBitmap::Perform(perform_code d, void *arg) BBitmap::Perform(perform_code d, void *arg)
{ {
@@ -854,21 +890,6 @@ void BBitmap::_ReservedBitmap1() {}
void BBitmap::_ReservedBitmap2() {} void BBitmap::_ReservedBitmap2() {}
void BBitmap::_ReservedBitmap3() {} void BBitmap::_ReservedBitmap3() {}
// copy constructor
/*! \brief Privatized copy constructor to prevent usage.
*/
BBitmap::BBitmap(const BBitmap &)
{
}
// =
/*! \brief Privatized assignment operator to prevent usage.
*/
BBitmap &
BBitmap::operator=(const BBitmap &)
{
return *this;
}
#if 0 #if 0
// get_shared_pointer // get_shared_pointer