[cairo-commit] gtkcairo/gtkcairo gtkcairo.c, 1.9, 1.10 gtkcairo.h, 1.6, 1.7

OEyvind Kolaas commit at pdx.freedesktop.org
Thu May 13 14:38:25 PDT 2004


Committed by: pippin

Update of /cvs/cairo/gtkcairo/gtkcairo
In directory pdx:/tmp/cvs-serv24653/gtkcairo

Modified Files:
	gtkcairo.c gtkcairo.h 
Log Message:
added gtk_cairo_set_gdk_color convenience function, and checking of GTKCAIRO_GL enviroment variable


Index: gtkcairo.c
===================================================================
RCS file: /cvs/cairo/gtkcairo/gtkcairo/gtkcairo.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** a/gtkcairo.c	20 Apr 2004 12:48:05 -0000	1.9
--- b/gtkcairo.c	13 May 2004 21:38:22 -0000	1.10
***************
*** 36,39 ****
--- 36,43 ----
  #include <cairo.h>
  
+ #ifdef CAIRO_HAS_GL_SURFACE
+ #include <glitz-glx.h>
+ #endif
+ 
  #include "gtkcairo.h"
  
***************
*** 121,131 ****
  gtk_cairo_init (GtkCairo *gtkcairo)
  {
! #ifdef CAIRO_HAS_GLX_SURFACE
!     gtkcairo->glx = 0;
      gtkcairo->surface = NULL;
  #endif
- #ifndef CAIRO_HAS_GLX_SURFACE
-     gtkcairo->glx = 0;
- #endif
  	gtkcairo->cairo = cairo_create ();
  }
--- 125,136 ----
  gtk_cairo_init (GtkCairo *gtkcairo)
  {
! #ifdef CAIRO_HAS_GL_SURFACE
! 	char *GTKCAIRO_GL=getenv ("GTKCAIRO_GL");
! 	if (GTKCAIRO_GL && atoi (GTKCAIRO_GL))
! 		gtkcairo->gl = 1;
! 	else
! 		gtkcairo->gl = 0;
      gtkcairo->surface = NULL;
  #endif
  	gtkcairo->cairo = cairo_create ();
  }
***************
*** 183,196 ****
  	attributes.visual = gtk_widget_get_visual (widget);
  
! #ifdef CAIRO_HAS_GLX_SURFACE
!     if (gtkcairo->glx ) {
!        XSetWindowAttributes xswa;
         XVisualInfo *vinfo;
  
!        vinfo = cairo_glx_find_best_visual_info (
!                gdk_x11_get_default_xdisplay (),
!                gdk_x11_get_default_screen (), 0);
  
!        if (vinfo) {
              gtk_widget_set_double_buffered (widget, FALSE);
              attributes.visual = gdkx_visual_get (vinfo->visualid);
--- 188,209 ----
  	attributes.visual = gtk_widget_get_visual (widget);
  
! #ifdef CAIRO_HAS_GL_SURFACE
!     if (gtkcairo->gl ) {
! 	   Display *dpy = gdk_x11_get_default_xdisplay ();
! 	   int screen = gdk_x11_get_default_screen ();
         XVisualInfo *vinfo;
+ 	   glitz_format_t *onscreen_format;
  
! 	   onscreen_format = glitz_glx_find_standard_format (dpy, screen,
! 			   GLITZ_FORMAT_OPTION_ONSCREEN_MASK, GLITZ_STANDARD_ARGB32);
! 	   if (!onscreen_format)
! 	      onscreen_format = glitz_glx_find_standard_format (dpy, screen,
! 	           GLITZ_FORMAT_OPTION_ONSCREEN_MASK, GLITZ_STANDARD_RGB24);
  
! 	   /*   XSetWindowAttributes xswa;*/
! 
!        vinfo = glitz_glx_get_visual_info_from_format (dpy, screen, onscreen_format);
! 
! 	   if (onscreen_format) {
              gtk_widget_set_double_buffered (widget, FALSE);
              attributes.visual = gdkx_visual_get (vinfo->visualid);
***************
*** 203,218 ****
  
              gtkcairo->surface =
!               cairo_glx_surface_create_for_window (gdk_x11_get_default_xdisplay (),
!                                DefaultScreen (gdk_x11_get_default_xdisplay ()),
!                                0, gdk_x11_drawable_get_xid (widget->window));
  
!             cairo_set_target_surface (gtkcairo->cairo, gtkcairo->surface); 
         } else {
!             fprintf (stderr, "could not find a usable GLX visual\n");
!             gtkcairo->glx = 0;
         }
      }
  
! 	if (!gtkcairo->glx){
  #endif
  	    attributes.colormap = gtk_widget_get_colormap (widget);
--- 216,231 ----
  
              gtkcairo->surface =
!               glitz_glx_surface_create_for_window (dpy, screen,
! 					  onscreen_format,
! 					  gdk_x11_drawable_get_xid (widget->window));
  
!             cairo_set_target_gl (gtkcairo->cairo, gtkcairo->surface);
         } else {
!             g_error ("could not find a usable GL visual\n");
!             gtkcairo->gl = 0;
         }
      }
  
! 	if (!gtkcairo->gl){
  #endif
  	    attributes.colormap = gtk_widget_get_colormap (widget);
***************
*** 221,228 ****
  	    widget->window = gdk_window_new (widget->parent->window,
  			    &attributes, attributes_mask);
! #ifdef CAIRO_HAS_GLX_SURFACE
      }
  #endif
!  
  	gtk_style_attach (widget->style, widget->window);
  	gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
--- 234,241 ----
  	    widget->window = gdk_window_new (widget->parent->window,
  			    &attributes, attributes_mask);
! #ifdef CAIRO_HAS_GL_SURFACE
      }
  #endif
! 
  	gtk_style_attach (widget->style, widget->window);
  	gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
***************
*** 247,253 ****
  					    allocation->x, allocation->y,
  					    allocation->width, allocation->height);
! #ifdef CAIRO_HAS_GLX_SURFACE
!             if (gtkcairo->glx && gtkcairo->surface) {
!                 cairo_gl_surface_realize (gtkcairo->surface);
              }
  #endif
--- 260,266 ----
  					    allocation->x, allocation->y,
  					    allocation->width, allocation->height);
! #ifdef CAIRO_HAS_GL_SURFACE
!             if (gtkcairo->gl && gtkcairo->surface) {
! 				glitz_surface_update_size (gtkcairo->surface);
              }
  #endif
***************
*** 267,272 ****
  	gtkcairo = GTK_CAIRO (widget);
  
! #ifdef CAIRO_HAS_GLX_SURFACE
!     if (gtkcairo->glx) {
          cairo_rectangle (gtkcairo->cairo,
  						 0, 0,
--- 280,285 ----
  	gtkcairo = GTK_CAIRO (widget);
  
! #ifdef CAIRO_HAS_GL_SURFACE
!     if (gtkcairo->gl) {
          cairo_rectangle (gtkcairo->cairo,
  						 0, 0,
***************
*** 276,280 ****
  
  	    g_signal_emit_by_name (gtkcairo, "redraw", gtkcairo->cairo);
!         cairo_copy_page (gtkcairo->cairo);
      } else {
  #endif
--- 289,298 ----
  
  	    g_signal_emit_by_name (gtkcairo, "redraw", gtkcairo->cairo);
!         //cairo_copy_page (gtkcairo->cairo);
! 		//
! 		glitz_surface_flush (gtkcairo->surface, 0,0,
! 				widget->allocation.width,
! 				widget->allocation.height);
! 		XSync (gdk_x11_get_default_xdisplay (), 0);
      } else {
  #endif
***************
*** 300,304 ****
  		    cairo_restore (gtkcairo->cairo);
  	    }
! #ifdef CAIRO_HAS_GLX_SURFACE
      }
  #endif
--- 318,322 ----
  		    cairo_restore (gtkcairo->cairo);
  	    }
! #ifdef CAIRO_HAS_GL_SURFACE
      }
  #endif
***************
*** 313,315 ****
--- 331,347 ----
  }
  
+ 
+ void
+ gtk_cairo_set_gdk_color (cairo_t *cr,
+                          GdkColor *color)
+ {
+     double red, green, blue;
+ 
+     red   = color->red   / 65535.0;
+     green = color->green / 65535.0;
+     blue  = color->blue  / 65535.0;
+ 
+     cairo_set_rgb_color (cr, red, green, blue);
+ }
+ 
  /* vim: set ts=4 sw=4 noet : */

Index: gtkcairo.h
===================================================================
RCS file: /cvs/cairo/gtkcairo/gtkcairo/gtkcairo.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** a/gtkcairo.h	21 Feb 2004 14:29:37 -0000	1.6
--- b/gtkcairo.h	13 May 2004 21:38:22 -0000	1.7
***************
*** 49,52 ****
--- 49,53 ----
  typedef struct _GtkCairoClass   GtkCairoClass;
  
+ 
  struct _GtkCairo
  {
***************
*** 56,62 ****
  	cairo_t *cairo;
  
!     int glx;
! #ifdef CAIRO_HAS_GLX_SURFACE
!     cairo_surface_t *surface;
  #endif
  
--- 57,63 ----
  	cairo_t *cairo;
  
! #ifdef CAIRO_HAS_GL_SURFACE
!     int gl;
!     glitz_surface_t *surface;
  #endif
  
***************
*** 78,81 ****
--- 79,88 ----
  gtk_cairo_get_cairo             (GtkCairo *gtkcairo);
  
+ /* convenience function to set the current cairo color
+  * from a GdkColor
+  */
+ void
+ gtk_cairo_set_gdk_color (cairo_t *cr,
+                          GdkColor *color);
  
  #ifdef __cplusplus





More information about the cairo-commit mailing list