From 2bf8f4c0d57be03ee27a0f84d041ebcb99202497 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 1 Nov 2006 03:23:35 +0000 Subject: [PATCH] Implement deep copy of wxBitmapRefData git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42890 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mac/carbon/bitmap.h | 9 +++++- include/wx/mac/carbon/private.h | 4 +-- src/mac/carbon/bitmap.cpp | 52 +++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/include/wx/mac/carbon/bitmap.h b/include/wx/mac/carbon/bitmap.h index 865ee73a90..418586576b 100644 --- a/include/wx/mac/carbon/bitmap.h +++ b/include/wx/mac/carbon/bitmap.h @@ -34,11 +34,13 @@ class WXDLLEXPORT wxPixelDataBase; class WXDLLEXPORT wxMask: public wxObject { DECLARE_DYNAMIC_CLASS(wxMask) - DECLARE_NO_COPY_CLASS(wxMask) public: wxMask(); + // Copy constructor + wxMask(const wxMask& mask); + // Construct a mask from a bitmap and a colour indicating // the transparent area wxMask(const wxBitmap& bitmap, const wxColour& colour); @@ -181,6 +183,11 @@ public: // makes sure that no cached images will be constructed until terminated void *BeginRawAccess() ; void EndRawAccess() ; + +protected: + // ref counting code + virtual wxObjectRefData *CreateRefData() const; + virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; }; #endif // _WX_BITMAP_H_ diff --git a/include/wx/mac/carbon/private.h b/include/wx/mac/carbon/private.h index 50cdec1bec..1990703794 100644 --- a/include/wx/mac/carbon/private.h +++ b/include/wx/mac/carbon/private.h @@ -1168,13 +1168,13 @@ void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size); class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData { - DECLARE_NO_COPY_CLASS(wxBitmapRefData) - friend class WXDLLEXPORT wxIcon; friend class WXDLLEXPORT wxCursor; public: wxBitmapRefData(int width , int height , int depth); wxBitmapRefData(); + wxBitmapRefData(const wxBitmapRefData &tocopy); + virtual ~wxBitmapRefData(); void Free(); diff --git a/src/mac/carbon/bitmap.cpp b/src/mac/carbon/bitmap.cpp index 4c0a49334f..1b4dca41c7 100644 --- a/src/mac/carbon/bitmap.cpp +++ b/src/mac/carbon/bitmap.cpp @@ -153,6 +153,28 @@ void wxBitmapRefData::Init() m_hasAlpha = false; } +wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData &tocopy) +{ + Init(); + Create(tocopy.m_width, tocopy.m_height, tocopy.m_depth); + + if (tocopy.m_bitmapMask) + m_bitmapMask = new wxMask(*tocopy.m_bitmapMask); + + unsigned char* dest = (unsigned char*)GetRawAccess(); + unsigned char* source = (unsigned char*)tocopy.GetRawAccess(); + size_t numbytes = tocopy.m_width * tocopy.m_height * 4; + + for (size_t i=0; i