comparison gtk/dw.c @ 1246:c228c90f95cb

Compile fix for GTK2 and attempt at getting stretching working with pixmaps... Doesn't work yet but wanted to commit it before I slept.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 19 Oct 2011 10:41:50 +0000
parents 3a2ffe3a7eae
children b31056c321a2
comparison
equal deleted inserted replaced
1245:3a2ffe3a7eae 1246:c228c90f95cb
8586 DW_MUTEX_UNLOCK; 8586 DW_MUTEX_UNLOCK;
8587 } 8587 }
8588 8588
8589 #if GTK_CHECK_VERSION(2,10,0) 8589 #if GTK_CHECK_VERSION(2,10,0)
8590 /* Cairo version of dw_pixmap_bitblt() from GTK3, use if either pixmap is a cairo surface */ 8590 /* Cairo version of dw_pixmap_bitblt() from GTK3, use if either pixmap is a cairo surface */
8591 void _cairo_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight) 8591 int _cairo_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight)
8592 { 8592 {
8593 int _locked_by_me = FALSE; 8593 int _locked_by_me = FALSE;
8594 cairo_t *cr = NULL; 8594 cairo_t *cr = NULL;
8595 int retval = DW_ERROR_GENERAL; 8595 int retval = DW_ERROR_GENERAL;
8596 8596
8697 * Returns: 8697 * Returns:
8698 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. 8698 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
8699 */ 8699 */
8700 int API dw_pixmap_stretch_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight) 8700 int API dw_pixmap_stretch_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight)
8701 { 8701 {
8702 /* Ok, these #ifdefs are going to get a bit confusing because
8703 * when using gdk-pixbuf, pixmaps are really pixbufs, so we
8704 * have to use the pixbuf functions on them, and thus convoluting
8705 * the code here a bit. -Brian
8706 */
8707 int _locked_by_me = FALSE; 8702 int _locked_by_me = FALSE;
8708 GdkGC *gc = NULL; 8703 GdkGC *gc = NULL;
8709 int retval = DW_ERROR_GENERAL; 8704 int retval = DW_ERROR_GENERAL;
8710 8705
8711 #if GTK_CHECK_VERSION(2,10,0) 8706 #if GTK_CHECK_VERSION(2,10,0)
8712 if((destp && destp->image) || (srcp && srcp->image)) 8707 if((destp && destp->image) || (srcp && srcp->image))
8713 return _cairo_pixmap_bitblt(dest, destp, xdest, ydest, width, height, src, srcp, xsrc, ysrc, srcwidth, srcheight); 8708 return _cairo_pixmap_bitblt(dest, destp, xdest, ydest, width, height, src, srcp, xsrc, ysrc, srcwidth, srcheight);
8714 #endif 8709 #endif
8715 8710
8716 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap))) 8711 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap)))
8712 return retval;
8713
8714 if((srcwidth == -1 || srcheight == -1) && srcwidth != srcheight)
8717 return retval; 8715 return retval;
8718 8716
8719 DW_MUTEX_LOCK; 8717 DW_MUTEX_LOCK;
8720 if(dest) 8718 if(dest)
8721 gc = _set_colors(dest->window); 8719 gc = _set_colors(dest->window);
8734 if ( srcp && srcp->bitmap ) 8732 if ( srcp && srcp->bitmap )
8735 { 8733 {
8736 gdk_gc_set_clip_mask( gc, srcp->bitmap ); 8734 gdk_gc_set_clip_mask( gc, srcp->bitmap );
8737 gdk_gc_set_clip_origin( gc, xdest, ydest ); 8735 gdk_gc_set_clip_origin( gc, xdest, ydest );
8738 } 8736 }
8739 gdk_draw_pixmap( dest ? dest->window : destp->pixmap, gc, src ? src->window : srcp->pixmap, xsrc, ysrc, xdest, ydest, width, height ); 8737
8738 #if GTK_MAJOR_VERSION > 1
8739 if(srcwidth != -1)
8740 {
8741 GdkPixbuf *pbdst, *pbsrc = gdk_pixbuf_get_from_drawable(NULL, src ? src->window : srcp->pixmap, NULL, xsrc, ysrc, 0, 0, srcwidth, srcheight);
8742
8743 if( srcp && srcp->bitmap )
8744 gdk_pixbuf_render_threshold_alpha(pbsrc, srcp->bitmap, xsrc, ysrc, 0, 0, srcwidth, srcheight, 255);
8745 pbdst = gdk_pixbuf_scale_simple(pbsrc, width, height, GDK_INTERP_BILINEAR);
8746 gdk_draw_pixbuf(dest ? dest->window : destp->pixmap, gc, pbdst, 0, 0, xdest, ydest, width, height, GDK_RGB_DITHER_NONE, 0, 0);
8747 gdk_pixbuf_unref(pbsrc);
8748 gdk_pixbuf_unref(pbdst);
8749 }
8750 else
8751 #endif
8752 gdk_draw_pixmap( dest ? dest->window : destp->pixmap, gc, src ? src->window : srcp->pixmap, xsrc, ysrc, xdest, ydest, width, height );
8753
8740 /* 8754 /*
8741 * Reset the clipping region 8755 * Reset the clipping region
8742 */ 8756 */
8743 if ( srcp && srcp->bitmap ) 8757 if ( srcp && srcp->bitmap )
8744 { 8758 {