From: Paul Cornett Date: Mon, 19 Jun 2006 18:30:13 +0000 (+0000) Subject: remove redundant GdkBitmap representation from wxBitmap X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b85229d15bb4a02a2f3058718a1cf5ed99433020 remove redundant GdkBitmap representation from wxBitmap git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39796 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/gtk/bitmap.h b/include/wx/gtk/bitmap.h index 29649632b9..9298f96af9 100644 --- a/include/wx/gtk/bitmap.h +++ b/include/wx/gtk/bitmap.h @@ -113,11 +113,9 @@ public: void SetWidth( int width ); void SetDepth( int depth ); void SetPixmap( GdkPixmap *pixmap ); - void SetBitmap( GdkBitmap *bitmap ); void SetPixbuf(GdkPixbuf *pixbuf); GdkPixmap *GetPixmap() const; - GdkBitmap *GetBitmap() const; bool HasPixmap() const; bool HasPixbuf() const; GdkPixbuf *GetPixbuf() const; diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index 5bfb2f4e4b..e420d57b51 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -203,7 +203,7 @@ bool wxMask::Create( const wxBitmap& bitmap ) if (!bitmap.Ok()) return false; - wxCHECK_MSG( bitmap.GetBitmap(), false, wxT("Cannot create mask from colour bitmap") ); + wxCHECK_MSG( bitmap.GetDepth() == 1, false, wxT("Cannot create mask from colour bitmap") ); m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 ); @@ -211,7 +211,7 @@ bool wxMask::Create( const wxBitmap& bitmap ) GdkGC *gc = gdk_gc_new( m_bitmap ); - gdk_wx_draw_bitmap( m_bitmap, gc, bitmap.GetBitmap(), 0, 0, 0, 0, bitmap.GetWidth(), bitmap.GetHeight() ); + gdk_wx_draw_bitmap( m_bitmap, gc, bitmap.GetPixmap(), 0, 0, 0, 0, bitmap.GetWidth(), bitmap.GetHeight() ); g_object_unref (gc); @@ -234,7 +234,6 @@ public: ~wxBitmapRefData(); GdkPixmap *m_pixmap; - GdkBitmap *m_bitmap; GdkPixbuf *m_pixbuf; wxMask *m_mask; int m_width; @@ -246,7 +245,6 @@ public: wxBitmapRefData::wxBitmapRefData() { m_pixmap = (GdkPixmap *) NULL; - m_bitmap = (GdkBitmap *) NULL; m_pixbuf = (GdkPixbuf *) NULL; m_mask = (wxMask *) NULL; m_width = 0; @@ -259,8 +257,6 @@ wxBitmapRefData::~wxBitmapRefData() { if (m_pixmap) g_object_unref (m_pixmap); - if (m_bitmap) - g_object_unref (m_bitmap); if (m_pixbuf) g_object_unref (m_pixbuf); delete m_mask; @@ -271,7 +267,7 @@ wxBitmapRefData::~wxBitmapRefData() //----------------------------------------------------------------------------- -#define M_BMPDATA ((wxBitmapRefData *)m_refData) +#define M_BMPDATA wx_static_cast(wxBitmapRefData*, m_refData) IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject) @@ -305,21 +301,15 @@ bool wxBitmap::Create( int width, int height, int depth ) M_BMPDATA->m_mask = (wxMask *) NULL; M_BMPDATA->m_width = width; M_BMPDATA->m_height = height; - if (depth == 1) - { - M_BMPDATA->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ); - M_BMPDATA->m_bpp = 1; - } - else if (depth == 32) + M_BMPDATA->m_bpp = depth; + if (depth == 32) { M_BMPDATA->m_pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, true, 8, width, height); - M_BMPDATA->m_bpp = 32; } else { M_BMPDATA->m_pixmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, depth ); - M_BMPDATA->m_bpp = visual->depth; } return Ok(); @@ -387,8 +377,6 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, GdkImage *img = (GdkImage*) NULL; if (GetPixmap()) img = gdk_image_get( GetPixmap(), 0, 0, GetWidth(), GetHeight() ); - else if (GetBitmap()) - img = gdk_image_get( GetBitmap(), 0, 0, GetWidth(), GetHeight() ); else wxFAIL_MSG( wxT("Ill-formed bitmap") ); @@ -399,7 +387,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, GdkGC *gc = NULL; GdkPixmap *dstpix = NULL; - if (GetPixmap()) + if (GetDepth() != 1) { GdkVisual *visual = gdk_drawable_get_visual( GetPixmap() ); if (visual == NULL) @@ -414,7 +402,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, char *dst = NULL; long dstbyteperline = 0; - if (GetBitmap()) + if (GetDepth() == 1) { bpp = 1; dstbyteperline = width/8*M_BMPDATA->m_bpp; @@ -592,7 +580,7 @@ bool wxBitmap::CreateFromImageAsBitmap(const wxImage& img) SetHeight( height ); SetWidth( width ); - SetBitmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ) ); + SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ) ); SetDepth( 1 ); @@ -657,9 +645,9 @@ bool wxBitmap::CreateFromImageAsBitmap(const wxImage& img) // Blit picture - GdkGC *data_gc = gdk_gc_new( GetBitmap() ); + GdkGC *data_gc = gdk_gc_new( GetPixmap() ); - gdk_draw_image( GetBitmap(), data_gc, data_image, 0, 0, 0, 0, width, height ); + gdk_draw_image( GetPixmap(), data_gc, data_image, 0, 0, 0, 0, width, height ); g_object_unref (data_image); g_object_unref (data_gc); @@ -866,12 +854,6 @@ wxImage wxBitmap::ConvertToImage() const 0, 0, GetWidth(), GetHeight() ); } - else if (GetBitmap()) - { - gdk_image = gdk_image_get( GetBitmap(), - 0, 0, - GetWidth(), GetHeight() ); - } else { wxFAIL_MSG( wxT("Ill-formed bitmap") ); @@ -898,7 +880,7 @@ wxImage wxBitmap::ConvertToImage() const int blue_shift_left = 0; bool use_shift = false; - if (GetPixmap()) + if (GetDepth() != 1) { GdkVisual *visual = gdk_drawable_get_visual( GetPixmap() ); if (visual == NULL) @@ -916,7 +898,7 @@ wxImage wxBitmap::ConvertToImage() const use_shift = (visual->type == GDK_VISUAL_TRUE_COLOR) || (visual->type == GDK_VISUAL_DIRECT_COLOR); } - if (GetBitmap()) + else { bpp = 1; } @@ -1002,7 +984,7 @@ wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth m_refData = new wxBitmapRefData(); M_BMPDATA->m_mask = (wxMask *) NULL; - M_BMPDATA->m_bitmap = gdk_bitmap_create_from_data + M_BMPDATA->m_pixmap = gdk_bitmap_create_from_data ( wxGetRootWindow()->window, (gchar *) bits, @@ -1013,7 +995,7 @@ wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth M_BMPDATA->m_height = height; M_BMPDATA->m_bpp = 1; - wxASSERT_MSG( M_BMPDATA->m_bitmap, wxT("couldn't create bitmap") ); + wxASSERT_MSG( M_BMPDATA->m_pixmap, wxT("couldn't create bitmap") ); } } @@ -1036,7 +1018,7 @@ bool wxBitmap::Ok() const return (m_refData != NULL) && ( M_BMPDATA->m_pixbuf || - M_BMPDATA->m_bitmap || M_BMPDATA->m_pixmap + M_BMPDATA->m_pixmap ); } @@ -1105,7 +1087,7 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const } else { - if (ret.GetPixmap()) + if (ret.GetDepth() != 1) { GdkGC *gc = gdk_gc_new( ret.GetPixmap() ); gdk_draw_drawable( ret.GetPixmap(), gc, GetPixmap(), rect.x, rect.y, 0, 0, rect.width, rect.height ); @@ -1113,13 +1095,13 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const } else { - GdkGC *gc = gdk_gc_new( ret.GetBitmap() ); + GdkGC *gc = gdk_gc_new( ret.GetPixmap() ); GdkColor col; col.pixel = 0xFFFFFF; gdk_gc_set_foreground( gc, &col ); col.pixel = 0; gdk_gc_set_background( gc, &col ); - gdk_wx_draw_bitmap( ret.GetBitmap(), gc, GetBitmap(), rect.x, rect.y, 0, 0, rect.width, rect.height ); + gdk_wx_draw_bitmap( ret.GetPixmap(), gc, GetPixmap(), rect.x, rect.y, 0, 0, rect.width, rect.height ); g_object_unref (gc); } } @@ -1250,15 +1232,6 @@ void wxBitmap::SetPixmap( GdkPixmap *pixmap ) PurgeOtherRepresentations(Pixmap); } -void wxBitmap::SetBitmap( GdkPixmap *bitmap ) -{ - if (!m_refData) - m_refData = new wxBitmapRefData(); - - M_BMPDATA->m_bitmap = bitmap; - PurgeOtherRepresentations(Pixmap); -} - GdkPixmap *wxBitmap::GetPixmap() const { wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, wxT("invalid bitmap") ); @@ -1284,13 +1257,6 @@ bool wxBitmap::HasPixmap() const return M_BMPDATA->m_pixmap != NULL; } -GdkBitmap *wxBitmap::GetBitmap() const -{ - wxCHECK_MSG( Ok(), (GdkBitmap *) NULL, wxT("invalid bitmap") ); - - return M_BMPDATA->m_bitmap; -} - GdkPixbuf *wxBitmap::GetPixbuf() const { wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") ); diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 53f8ebfad9..06b60cd000 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -1069,7 +1069,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") ); - bool is_mono = (bitmap.GetBitmap() != NULL); + bool is_mono = bitmap.GetDepth() == 1; // scale/translate size and position int xx = XLOG2DEV(x); @@ -1162,7 +1162,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, GdkGC *gc = gdk_gc_new( bitmap2 ); gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() ); gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() ); - gdk_wx_draw_bitmap( bitmap2, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 ); + gdk_wx_draw_bitmap( bitmap2, gc, use_bitmap.GetPixmap(), 0, 0, 0, 0, -1, -1 ); gdk_draw_drawable( m_window, m_textGC, bitmap2, 0, 0, xx, yy, -1, -1 ); @@ -1416,7 +1416,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, GdkGC *gc = gdk_gc_new( bitmap ); gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() ); gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() ); - gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 ); + gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetPixmap(), 0, 0, 0, 0, -1, -1 ); gdk_draw_drawable( m_window, m_textGC, bitmap, xsrc, ysrc, cx, cy, cw, ch ); @@ -2009,7 +2009,7 @@ void wxWindowDC::SetBrush( const wxBrush &brush ) if ((m_brush.GetStyle() == wxSTIPPLE) && (m_brush.GetStipple()->Ok())) { - if (m_brush.GetStipple()->GetPixmap()) + if (m_brush.GetStipple()->GetDepth() != 1) { gdk_gc_set_fill( m_brushGC, GDK_TILED ); gdk_gc_set_tile( m_brushGC, m_brush.GetStipple()->GetPixmap() ); @@ -2017,7 +2017,7 @@ void wxWindowDC::SetBrush( const wxBrush &brush ) else { gdk_gc_set_fill( m_brushGC, GDK_STIPPLED ); - gdk_gc_set_stipple( m_brushGC, m_brush.GetStipple()->GetBitmap() ); + gdk_gc_set_stipple( m_brushGC, m_brush.GetStipple()->GetPixmap() ); } } @@ -2060,7 +2060,7 @@ void wxWindowDC::SetBackground( const wxBrush &brush ) if ((m_backgroundBrush.GetStyle() == wxSTIPPLE) && (m_backgroundBrush.GetStipple()->Ok())) { - if (m_backgroundBrush.GetStipple()->GetPixmap()) + if (m_backgroundBrush.GetStipple()->GetDepth() != 1) { gdk_gc_set_fill( m_bgGC, GDK_TILED ); gdk_gc_set_tile( m_bgGC, m_backgroundBrush.GetStipple()->GetPixmap() ); @@ -2068,7 +2068,7 @@ void wxWindowDC::SetBackground( const wxBrush &brush ) else { gdk_gc_set_fill( m_bgGC, GDK_STIPPLED ); - gdk_gc_set_stipple( m_bgGC, m_backgroundBrush.GetStipple()->GetBitmap() ); + gdk_gc_set_stipple( m_bgGC, m_backgroundBrush.GetStipple()->GetPixmap() ); } } diff --git a/src/gtk/dcmemory.cpp b/src/gtk/dcmemory.cpp index c758430a63..b57a4b8aa8 100644 --- a/src/gtk/dcmemory.cpp +++ b/src/gtk/dcmemory.cpp @@ -59,14 +59,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) m_selected = bitmap; if (m_selected.Ok()) { - if (m_selected.GetPixmap()) - { - m_window = m_selected.GetPixmap(); - } - else - { - m_window = m_selected.GetBitmap(); - } + m_window = m_selected.GetPixmap(); m_selected.PurgeOtherRepresentations(wxBitmap::Pixmap); @@ -85,7 +78,7 @@ void wxMemoryDC::SetPen( const wxPen& penOrig ) { wxPen pen( penOrig ); if ( m_selected.Ok() && - m_selected.GetBitmap() && + m_selected.GetDepth() == 1 && (pen != *wxTRANSPARENT_PEN) ) { pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); @@ -98,7 +91,7 @@ void wxMemoryDC::SetBrush( const wxBrush& brushOrig ) { wxBrush brush( brushOrig ); if ( m_selected.Ok() && - m_selected.GetBitmap() && + m_selected.GetDepth() == 1 && (brush != *wxTRANSPARENT_BRUSH) ) { brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE); @@ -112,7 +105,7 @@ void wxMemoryDC::SetBackground( const wxBrush& brushOrig ) wxBrush brush(brushOrig); if ( m_selected.Ok() && - m_selected.GetBitmap() && + m_selected.GetDepth() == 1 && (brush != *wxTRANSPARENT_BRUSH) ) { brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); @@ -123,7 +116,7 @@ void wxMemoryDC::SetBackground( const wxBrush& brushOrig ) void wxMemoryDC::SetTextForeground( const wxColour& col ) { - if ( m_selected.Ok() && m_selected.GetBitmap() ) + if ( m_selected.Ok() && m_selected.GetDepth() == 1 ) { wxWindowDC::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE); } @@ -135,7 +128,7 @@ void wxMemoryDC::SetTextForeground( const wxColour& col ) void wxMemoryDC::SetTextBackground( const wxColour &col ) { - if (m_selected.Ok() && m_selected.GetBitmap()) + if (m_selected.Ok() && m_selected.GetDepth() == 1) { wxWindowDC::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE ); } diff --git a/src/gtk/tbargtk.cpp b/src/gtk/tbargtk.cpp index 62aa329954..458e5f1299 100644 --- a/src/gtk/tbargtk.cpp +++ b/src/gtk/tbargtk.cpp @@ -365,7 +365,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) wxCHECK_MSG( bitmap.Ok(), false, wxT("invalid bitmap for wxToolBar icon") ); - wxCHECK_MSG( bitmap.GetBitmap() == NULL, false, + wxCHECK_MSG( bitmap.GetDepth() != 1, false, wxT("wxToolBar doesn't support GdkBitmap") ); wxCHECK_MSG( bitmap.GetPixmap() != NULL, false,