+ /* apply mask if any */
+ WXPixmap mask = NULL;
+ if (use_bitmap.GetMask())
+ mask = use_bitmap.GetMask()->GetBitmap();
+
+ if (useMask && mask)
+ {
+ Pixmap pixmap = (Pixmap) use_bitmap.GetPixmap() ;
+ Pixmap maskPixmap = (Pixmap) use_bitmap.GetMask()->GetBitmap() ;
+ Pixmap bufPixmap = GrNewPixmap(w, h, 0);
+ GC gc = GrNewGC();
+ GrSetGCUseBackground(gc, FALSE);
+ GrSetGCMode(gc, GR_MODE_COPY);
+
+ // This code assumes that background and foreground
+ // colours are used in ROPs, like in MSW.
+ // Not sure if this is true.
+
+ // Copy destination to buffer.
+ // In DoBlit, we need this step because Blit has
+ // a ROP argument. Here, we don't need it.
+ // In DoBlit, we may be able to eliminate this step
+ // if we check if the rop = copy
+#if 0
+ GrCopyArea(bufPixmap, gc, 0, 0, w, h, (Window) m_window,
+ 0, 0, GR_MODE_COPY);
+#endif
+
+ // Copy src to buffer using selected raster op (none selected
+ // in DrawBitmap, so just use Gxcopy)
+ GrCopyArea(bufPixmap, gc, 0, 0, w, h, pixmap,
+ 0, 0, GR_MODE_COPY);
+
+ // Set masked area in buffer to BLACK (pixel value 0)
+ GrSetGCBackground(gc, WHITE);
+ GrSetGCForeground(gc, BLACK);
+ GrCopyArea(bufPixmap, gc, 0, 0, w, h, maskPixmap,
+ 0, 0, GR_MODE_AND);
+
+ // set unmasked area in dest to BLACK
+ GrSetGCBackground(gc, BLACK);
+ GrSetGCForeground(gc, WHITE);
+ GrCopyArea((Window) m_window, gc, xx, yy, w, h, maskPixmap,
+ 0, 0, GR_MODE_AND);
+
+ // OR buffer to dest
+ GrCopyArea((Window) m_window, gc, xx, yy, w, h, bufPixmap,
+ 0, 0, GR_MODE_OR);
+
+ GrDestroyGC(gc);
+ GrDestroyWindow(bufPixmap);
+ }
+ else
+ XCopyArea( (Display*) m_display, (Pixmap) use_bitmap.GetPixmap(), (Window) m_window,
+ (GC) m_penGC, 0, 0, w, h, xx, yy );
+
+ /* remove mask again if any */
+ if (useMask && mask)
+ {
+ if (!m_currentClippingRegion.IsNull())
+ XSetRegion( (Display*) m_display, (GC) m_penGC, (Region) m_currentClippingRegion.GetX11Region() );
+ }