cleanup of raw access to bitmaps:
1. remove UseAlpha() on platforms that don't need it and call it automatically from ~wxPixelData instead of requiring explicit call; deprecate wxPixelData::UseAlpha() 2. don't call UngetRawData() if GetRawData() failed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47295 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -122,7 +122,6 @@ public:
|
|||||||
// raw bitmap access support functions
|
// raw bitmap access support functions
|
||||||
void *GetRawData(wxPixelDataBase& data, int bpp);
|
void *GetRawData(wxPixelDataBase& data, int bpp);
|
||||||
void UngetRawData(wxPixelDataBase& data);
|
void UngetRawData(wxPixelDataBase& data);
|
||||||
void UseAlpha();
|
|
||||||
|
|
||||||
wxPalette* GetPalette() const;
|
wxPalette* GetPalette() const;
|
||||||
void SetPalette(const wxPalette& palette);
|
void SetPalette(const wxPalette& palette);
|
||||||
|
@@ -117,7 +117,6 @@ public:
|
|||||||
void UngetRawData(wxPixelDataBase& data);
|
void UngetRawData(wxPixelDataBase& data);
|
||||||
|
|
||||||
bool HasAlpha() const;
|
bool HasAlpha() const;
|
||||||
void UseAlpha();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CreateFromImage(const wxImage& image, int depth);
|
bool CreateFromImage(const wxImage& image, int depth);
|
||||||
|
@@ -130,7 +130,6 @@ public:
|
|||||||
void UngetRawData(wxPixelDataBase& data);
|
void UngetRawData(wxPixelDataBase& data);
|
||||||
|
|
||||||
bool HasAlpha() const;
|
bool HasAlpha() const;
|
||||||
void UseAlpha();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CreateFromImage(const wxImage& image, int depth);
|
bool CreateFromImage(const wxImage& image, int depth);
|
||||||
|
@@ -135,7 +135,6 @@ public:
|
|||||||
// these functions are internal and shouldn't be used, they risk to
|
// these functions are internal and shouldn't be used, they risk to
|
||||||
// disappear in the future
|
// disappear in the future
|
||||||
bool HasAlpha() const;
|
bool HasAlpha() const;
|
||||||
void UseAlpha();
|
|
||||||
|
|
||||||
// implementation only from now on
|
// implementation only from now on
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
@@ -9,8 +9,8 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_RAWBMP_H_BASE_
|
#ifndef _WX_RAWBMP_H_
|
||||||
#define _WX_RAWBMP_H_BASE_
|
#define _WX_RAWBMP_H_
|
||||||
|
|
||||||
#include "wx/image.h"
|
#include "wx/image.h"
|
||||||
|
|
||||||
@@ -631,11 +631,22 @@ struct wxPixelDataOut<wxBitmap>
|
|||||||
// dtor unlocks the bitmap
|
// dtor unlocks the bitmap
|
||||||
~wxPixelDataIn()
|
~wxPixelDataIn()
|
||||||
{
|
{
|
||||||
|
if ( m_pixels.IsOk() )
|
||||||
|
{
|
||||||
|
#if defined(__WXMSW__) || defined(__WXMAC__)
|
||||||
|
// this is a hack to mark wxBitmap as using alpha channel
|
||||||
|
if ( Format::HasAlpha )
|
||||||
|
m_bmp.UseAlpha();
|
||||||
|
#endif
|
||||||
m_bmp.UngetRawData(*this);
|
m_bmp.UngetRawData(*this);
|
||||||
}
|
}
|
||||||
|
// else: don't call UngetRawData() if GetRawData() failed
|
||||||
|
}
|
||||||
|
|
||||||
// call this to indicate that we should use the alpha channel
|
#if WXWIN_COMPATIBILITY_2_8
|
||||||
void UseAlpha() { m_bmp.UseAlpha(); }
|
// not needed anymore, calls to it should be simply removed
|
||||||
|
wxDEPRECATED( inline void UseAlpha() {} );
|
||||||
|
#endif
|
||||||
|
|
||||||
// private: -- see comment in the beginning of the file
|
// private: -- see comment in the beginning of the file
|
||||||
|
|
||||||
@@ -656,6 +667,7 @@ struct wxPixelDataOut<wxBitmap>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //wxUSE_GUI
|
#endif //wxUSE_GUI
|
||||||
|
|
||||||
template <class Image, class PixelFormat = wxPixelFormatFor<Image> >
|
template <class Image, class PixelFormat = wxPixelFormatFor<Image> >
|
||||||
@@ -709,5 +721,4 @@ struct wxPixelIterator : public wxPixelData<Image, PixelFormat>::Iterator
|
|||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WX_RAWBMP_H_BASE_
|
#endif // _WX_RAWBMP_H_
|
||||||
|
|
||||||
|
@@ -397,7 +397,6 @@ public:
|
|||||||
wxLogError(_T("Failed to gain raw access to bitmap data"));
|
wxLogError(_T("Failed to gain raw access to bitmap data"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data.UseAlpha();
|
|
||||||
wxAlphaPixelData::Iterator p(data);
|
wxAlphaPixelData::Iterator p(data);
|
||||||
for ( int y = 0; y < SIZE; ++y )
|
for ( int y = 0; y < SIZE; ++y )
|
||||||
{
|
{
|
||||||
@@ -421,7 +420,6 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.UseAlpha();
|
|
||||||
wxAlphaPixelData::Iterator p(data);
|
wxAlphaPixelData::Iterator p(data);
|
||||||
|
|
||||||
for ( int y = 0; y < REAL_SIZE; ++y )
|
for ( int y = 0; y < REAL_SIZE; ++y )
|
||||||
|
@@ -483,10 +483,6 @@ void wxBitmap::UngetRawData(wxPixelDataBase& data)
|
|||||||
{ // TODO
|
{ // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::UseAlpha()
|
|
||||||
{ // TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
// wxMask
|
// wxMask
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
|
@@ -917,19 +917,6 @@ bool wxBitmap::HasAlpha() const
|
|||||||
gdk_pixbuf_get_has_alpha(M_BMPDATA->m_pixbuf);
|
gdk_pixbuf_get_has_alpha(M_BMPDATA->m_pixbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::UseAlpha()
|
|
||||||
{
|
|
||||||
GdkPixbuf* pixbuf = GetPixbuf();
|
|
||||||
// add alpha if necessary
|
|
||||||
if (!gdk_pixbuf_get_has_alpha(pixbuf))
|
|
||||||
{
|
|
||||||
M_BMPDATA->m_pixbuf = NULL;
|
|
||||||
AllocExclusive();
|
|
||||||
M_BMPDATA->m_pixbuf = gdk_pixbuf_add_alpha(pixbuf, false, 0, 0, 0);
|
|
||||||
g_object_unref(pixbuf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wxObjectRefData* wxBitmap::CreateRefData() const
|
wxObjectRefData* wxBitmap::CreateRefData() const
|
||||||
{
|
{
|
||||||
return new wxBitmapRefData;
|
return new wxBitmapRefData;
|
||||||
|
@@ -1377,10 +1377,6 @@ bool wxBitmap::HasAlpha() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::UseAlpha()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxBitmapHandler
|
// wxBitmapHandler
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -331,10 +331,6 @@ wxDC *wxBitmap::GetSelectedInto() const
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void wxBitmap::UseAlpha()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxBitmap::HasAlpha() const
|
bool wxBitmap::HasAlpha() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user