+bool wxBitmap::HasAlpha() const
+{
+ const wxBitmapRefData* bmpData = M_BMPDATA;
+#ifdef __WXGTK3__
+ return bmpData && bmpData->m_bpp == 32;
+#else
+ return bmpData && (bmpData->m_alphaRequested ||
+ (bmpData->m_pixbuf && gdk_pixbuf_get_has_alpha(bmpData->m_pixbuf)));
+#endif
+}
+
+wxGDIRefData* wxBitmap::CreateGDIRefData() const
+{
+ return new wxBitmapRefData(0, 0, 0);
+}
+
+wxGDIRefData* wxBitmap::CloneGDIRefData(const wxGDIRefData* data) const
+{
+ const wxBitmapRefData* oldRef = static_cast<const wxBitmapRefData*>(data);
+ wxBitmapRefData * const newRef = new wxBitmapRefData(oldRef->m_width,
+ oldRef->m_height,
+ oldRef->m_bpp);
+#ifdef __WXGTK3__
+ if (oldRef->m_pixbufNoMask)
+ newRef->m_pixbufNoMask = gdk_pixbuf_copy(oldRef->m_pixbufNoMask);
+ if (oldRef->m_surface)
+ {
+ const int w = oldRef->m_width;
+ const int h = oldRef->m_height;
+ cairo_surface_t* surface = cairo_image_surface_create(
+ cairo_image_surface_get_format(oldRef->m_surface), w, h);
+ newRef->m_surface = surface;
+ cairo_surface_flush(oldRef->m_surface);
+ const guchar* src = cairo_image_surface_get_data(oldRef->m_surface);
+ guchar* dst = cairo_image_surface_get_data(surface);
+ const int stride = cairo_image_surface_get_stride(surface);
+ wxASSERT(stride == cairo_image_surface_get_stride(oldRef->m_surface));
+ memcpy(dst, src, stride * h);
+ cairo_surface_mark_dirty(surface);
+ }
+#else
+ if (oldRef->m_pixmap != NULL)
+ {
+ newRef->m_pixmap = gdk_pixmap_new(
+ oldRef->m_pixmap, oldRef->m_width, oldRef->m_height,
+ // use pixmap depth, m_bpp may not match
+ gdk_drawable_get_depth(oldRef->m_pixmap));
+ wxGtkObject<GdkGC> gc(gdk_gc_new(newRef->m_pixmap));
+ gdk_draw_drawable(
+ newRef->m_pixmap, gc, oldRef->m_pixmap, 0, 0, 0, 0, -1, -1);
+ }
+ if (oldRef->m_pixbuf != NULL)
+ {
+ newRef->m_pixbuf = gdk_pixbuf_copy(oldRef->m_pixbuf);
+ }
+#endif
+ if (oldRef->m_mask != NULL)
+ {
+ newRef->m_mask = new wxMask(*oldRef->m_mask);
+ }
+
+ return newRef;
+}
+
+/* static */ void wxBitmap::InitStandardHandlers()
+{
+ // TODO: Insert handler based on GdkPixbufs handler later