[cairo-commit] gtkcairo/gtkcairo gdkcairo.c, NONE, 1.1 gdkcairo.h,
NONE, 1.1 Makefile.am, 1.1, 1.2 gtkcairo.c, 1.11,
1.12 gtkcairo.h, 1.7, 1.8
OEyvind Kolaas
commit at pdx.freedesktop.org
Thu May 20 11:41:18 PDT 2004
Committed by: pippin
Update of /cvs/cairo/gtkcairo/gtkcairo
In directory pdx:/tmp/cvs-serv14100/gtkcairo
Modified Files:
Makefile.am gtkcairo.c gtkcairo.h
Added Files:
gdkcairo.c gdkcairo.h
Log Message:
seperated out the gdkwindow / cairo stuff, to easier support the different backends
--- NEW FILE: gdkcairo.c ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: gdkcairo.h ---
(This appears to be a binary file; contents omitted.)
Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/gtkcairo/gtkcairo/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** a/Makefile.am 18 Nov 2003 15:17:07 -0000 1.1
--- b/Makefile.am 20 May 2004 18:41:16 -0000 1.2
***************
*** 4,8 ****
libgtkcairo_la_SOURCES = \
gtkcairo.c \
! gtkcairo.h
libgtkcairo_la_LDFLAGS = -version-info @VERSION_INFO@
--- 4,10 ----
libgtkcairo_la_SOURCES = \
gtkcairo.c \
! gtkcairo.h \
! gdkcairo.h \
! gdkcairo.c
libgtkcairo_la_LDFLAGS = -version-info @VERSION_INFO@
Index: gtkcairo.c
===================================================================
RCS file: /cvs/cairo/gtkcairo/gtkcairo/gtkcairo.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** a/gtkcairo.c 20 May 2004 00:19:12 -0000 1.11
--- b/gtkcairo.c 20 May 2004 18:41:16 -0000 1.12
***************
*** 1,10 ****
! /* gtkcairo - GTK+ widget for displaying a cairo surface.
! *
! * Hacked up by Evan Martin <martine at danga.com>.
! * Further adjusted and modified by Ãyvind KolÃ¥s <oeyvindk at hig.no>
! *
! * Originally from grrobot:
*
! * Copyright © 2003 Carl Worth
*
* Permission to use, copy, modify, distribute, and sell this software
--- 1,7 ----
! /* gtkcairo - cairo drawing widget for gtk+
*
! * Copyright © 2003, 2004 Carl Worth <carl at theworths.org>
! * Evan Martin <martine at danga.com>
! * Ãyvind KolÃ¥s oeyvindk at hig.no>
*
* Permission to use, copy, modify, distribute, and sell this software
***************
*** 26,31 ****
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl Worth <carl at theworths.org>
*/
--- 23,26 ----
***************
*** 41,44 ****
--- 36,40 ----
#include "gtkcairo.h"
+ #include "gdkcairo.h"
enum {
***************
*** 125,137 ****
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 ();
}
--- 121,125 ----
gtk_cairo_init (GtkCairo *gtkcairo)
{
! gtkcairo->gdkcairo = gdkcairo_new (GTK_WIDGET (gtkcairo));
}
***************
*** 157,164 ****
gtkcairo = GTK_CAIRO (object);
! if (gtkcairo->cairo) {
! cairo_destroy (gtkcairo->cairo);
! gtkcairo->cairo = NULL;
! }
if (GTK_OBJECT_CLASS (parent_class)->destroy)
--- 145,149 ----
gtkcairo = GTK_CAIRO (object);
! gdkcairo_destroy (gtkcairo->gdkcairo);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
***************
*** 170,175 ****
{
GtkCairo *gtkcairo;
- GdkWindowAttr attributes;
- gint attributes_mask;
g_return_if_fail (widget != NULL);
--- 155,158 ----
***************
*** 179,244 ****
gtkcairo = GTK_CAIRO (widget);
! attributes.x = widget->allocation.x;
! attributes.y = widget->allocation.y;
! attributes.width = widget->allocation.width;
! attributes.height = widget->allocation.height;
! attributes.wclass = GDK_INPUT_OUTPUT;
! attributes.window_type = GDK_WINDOW_CHILD;
! attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
! 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);
! attributes.colormap = gdk_colormap_new (attributes.visual, TRUE);
!
! attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
!
! widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
! &attributes, attributes_mask);
!
! 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);
!
! attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
! 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);
! gdk_window_set_user_data (widget->window, widget);
}
--- 162,166 ----
gtkcairo = GTK_CAIRO (widget);
! gdkcairo_realize (gtkcairo->gdkcairo);
}
***************
*** 256,269 ****
widget->allocation = *allocation;
! if (GTK_WIDGET_REALIZED (widget)) {
! gdk_window_move_resize (widget->window,
! 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
! }
}
--- 178,184 ----
widget->allocation = *allocation;
! gdkcairo_size_allocate (gtkcairo->gdkcairo,
! allocation->x, allocation->y,
! allocation->width, allocation->height);
}
***************
*** 280,322 ****
gtkcairo = GTK_CAIRO (widget);
! #ifdef CAIRO_HAS_GL_SURFACE
! if (gtkcairo->gl) {
! cairo_rectangle (gtkcairo->cairo,
! 0, 0,
! widget->allocation.width, widget->allocation.height);
! cairo_set_rgb_color (gtkcairo->cairo, 0.7, 0.7, 0.7);
! cairo_fill (gtkcairo->cairo);
!
! g_signal_emit_by_name (gtkcairo, "redraw", gtkcairo->cairo);
! //cairo_copy_page (gtkcairo->cairo);
! //
! glitz_surface_swap_buffers (gtkcairo->surface);
! XSync (gdk_x11_get_default_xdisplay (), 0);
! } else {
! #endif
! GdkDrawable *gdkdrawable;
! gint x_off, y_off;
!
! gdk_window_get_internal_paint_info (widget->window,
! &gdkdrawable, &x_off, &y_off);
!
! cairo_set_target_drawable (gtkcairo->cairo,
! gdk_x11_drawable_get_xdisplay (gdkdrawable),
! gdk_x11_drawable_get_xid (gdkdrawable));
!
! /* counter offset of expose */
! if (x_off || y_off) {
! cairo_save (gtkcairo->cairo);
! cairo_translate (gtkcairo->cairo, -x_off, -y_off);
! }
!
! g_signal_emit_by_name (gtkcairo, "redraw", gtkcairo->cairo);
!
! if (x_off || y_off) {
! cairo_restore (gtkcairo->cairo);
! }
! #ifdef CAIRO_HAS_GL_SURFACE
! }
! #endif
return FALSE;
}
--- 195,199 ----
gtkcairo = GTK_CAIRO (widget);
! gdkcairo_expose (gtkcairo->gdkcairo, event);
return FALSE;
}
***************
*** 326,330 ****
g_return_val_if_fail (gtkcairo != NULL, NULL);
g_return_val_if_fail (GTK_IS_CAIRO (gtkcairo), NULL);
! return gtkcairo->cairo;
}
--- 203,207 ----
g_return_val_if_fail (gtkcairo != NULL, NULL);
g_return_val_if_fail (GTK_IS_CAIRO (gtkcairo), NULL);
! return ((gdkcairo_t*) gtkcairo->gdkcairo)->cr;
}
Index: gtkcairo.h
===================================================================
RCS file: /cvs/cairo/gtkcairo/gtkcairo/gtkcairo.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** a/gtkcairo.h 13 May 2004 21:38:22 -0000 1.7
--- b/gtkcairo.h 20 May 2004 18:41:16 -0000 1.8
***************
*** 1,10 ****
! /* gtkcairo - GTK+ widget for displaying a cairo surface.
! *
! * Hacked up by Evan Martin <martine at danga.com>.
! * Further adjusted and modified by Ãyvind KolÃ¥s <oeyvindk at hig.no>
! *
! * Originally from Ricochet Robots:
*
! * Copyright © 2003 Carl Worth
*
* Permission to use, copy, modify, distribute, and sell this software
--- 1,7 ----
! /* gtkcairo - cairo drawing widget for gtk+
*
! * Copyright © 2003, 2004 Carl Worth <carl at theworths.org>
! * Evan Martin <martine at danga.com>
! * Ãyvind KolÃ¥s oeyvindk at hig.no>
*
* Permission to use, copy, modify, distribute, and sell this software
***************
*** 26,31 ****
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl Worth <carl at theworths.org>
*/
--- 23,26 ----
***************
*** 34,38 ****
#include <gtk/gtkwidget.h>
-
#include <cairo.h>
--- 29,32 ----
***************
*** 49,67 ****
typedef struct _GtkCairoClass GtkCairoClass;
struct _GtkCairo
{
GtkWidget widget;
!
! /* all fields are private */
! cairo_t *cairo;
!
! #ifdef CAIRO_HAS_GL_SURFACE
! int gl;
! glitz_surface_t *surface;
! #endif
!
};
struct _GtkCairoClass
{
--- 43,56 ----
typedef struct _GtkCairoClass GtkCairoClass;
+ #define gdkcairo_t void
struct _GtkCairo
{
GtkWidget widget;
! gdkcairo_t *gdkcairo;
};
+ #undef gdkcairo_t
+
struct _GtkCairoClass
{
***************
*** 79,82 ****
--- 68,72 ----
gtk_cairo_get_cairo (GtkCairo *gtkcairo);
+
/* convenience function to set the current cairo color
* from a GdkColor
More information about the cairo-commit
mailing list