Mercurial > dwindows
comparison gtk3/dw.c @ 815:c1e93dd575a5
Initial implementation of a slightly disjointed dual cairo_surface gdkpixbuf image model.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 26 Mar 2011 04:53:41 +0000 |
parents | f5972669d7e9 |
children | 916002e29d4c |
comparison
equal
deleted
inserted
replaced
814:f5972669d7e9 | 815:c1e93dd575a5 |
---|---|
6590 cairo_t *cr = NULL; | 6590 cairo_t *cr = NULL; |
6591 | 6591 |
6592 DW_MUTEX_LOCK; | 6592 DW_MUTEX_LOCK; |
6593 if(handle) | 6593 if(handle) |
6594 cr = gdk_cairo_create(gtk_widget_get_window(handle)); | 6594 cr = gdk_cairo_create(gtk_widget_get_window(handle)); |
6595 #if 0 /* TODO */ | |
6596 else if(pixmap) | 6595 else if(pixmap) |
6597 gc = _set_colors(pixmap->pixbuf); | 6596 cr = cairo_create(pixmap->image); |
6598 #endif | |
6599 if(cr) | 6597 if(cr) |
6600 { | 6598 { |
6601 int index = _find_thread_index(dw_thread_id()); | 6599 int index = _find_thread_index(dw_thread_id()); |
6602 | 6600 |
6603 cairo_set_source_rgb(cr, _foreground[index].red, _foreground[index].green, _foreground[index].blue); | 6601 cairo_set_source_rgb(cr, _foreground[index].red, _foreground[index].green, _foreground[index].blue); |
6624 cairo_t *cr = NULL; | 6622 cairo_t *cr = NULL; |
6625 | 6623 |
6626 DW_MUTEX_LOCK; | 6624 DW_MUTEX_LOCK; |
6627 if(handle) | 6625 if(handle) |
6628 cr = gdk_cairo_create(gtk_widget_get_window(handle)); | 6626 cr = gdk_cairo_create(gtk_widget_get_window(handle)); |
6629 #if 0 /* TODO */ | |
6630 else if(pixmap) | 6627 else if(pixmap) |
6631 gc = _set_colors(pixmap->pixbuf); | 6628 cr = cairo_create(pixmap->image); |
6632 #endif | |
6633 if(cr) | 6629 if(cr) |
6634 { | 6630 { |
6635 int index = _find_thread_index(dw_thread_id()); | 6631 int index = _find_thread_index(dw_thread_id()); |
6636 | 6632 |
6637 cairo_set_source_rgb(cr, _foreground[index].red, _foreground[index].green, _foreground[index].blue); | 6633 cairo_set_source_rgb(cr, _foreground[index].red, _foreground[index].green, _foreground[index].blue); |
6660 int z; | 6656 int z; |
6661 | 6657 |
6662 DW_MUTEX_LOCK; | 6658 DW_MUTEX_LOCK; |
6663 if(handle) | 6659 if(handle) |
6664 cr = gdk_cairo_create(gtk_widget_get_window(handle)); | 6660 cr = gdk_cairo_create(gtk_widget_get_window(handle)); |
6665 #if 0 /* TODO */ | |
6666 else if(pixmap) | 6661 else if(pixmap) |
6667 gc = _set_colors(pixmap->pixbuf); | 6662 cr = cairo_create(pixmap->image); |
6668 #endif | |
6669 if(cr) | 6663 if(cr) |
6670 { | 6664 { |
6671 int index = _find_thread_index(dw_thread_id()); | 6665 int index = _find_thread_index(dw_thread_id()); |
6672 | 6666 |
6673 cairo_set_source_rgb(cr, _foreground[index].red, _foreground[index].green, _foreground[index].blue); | 6667 cairo_set_source_rgb(cr, _foreground[index].red, _foreground[index].green, _foreground[index].blue); |
6701 cairo_t *cr = NULL; | 6695 cairo_t *cr = NULL; |
6702 | 6696 |
6703 DW_MUTEX_LOCK; | 6697 DW_MUTEX_LOCK; |
6704 if(handle) | 6698 if(handle) |
6705 cr = gdk_cairo_create(gtk_widget_get_window(handle)); | 6699 cr = gdk_cairo_create(gtk_widget_get_window(handle)); |
6706 #if 0 /* TODO */ | |
6707 else if(pixmap) | 6700 else if(pixmap) |
6708 gc = _set_colors(pixmap->pixbuf); | 6701 cr = cairo_create(pixmap->image); |
6709 #endif | |
6710 if(cr) | 6702 if(cr) |
6711 { | 6703 { |
6712 int index = _find_thread_index(dw_thread_id()); | 6704 int index = _find_thread_index(dw_thread_id()); |
6713 | 6705 |
6714 cairo_set_source_rgb(cr, _foreground[index].red, _foreground[index].green, _foreground[index].blue); | 6706 cairo_set_source_rgb(cr, _foreground[index].red, _foreground[index].green, _foreground[index].blue); |
6747 if(handle) | 6739 if(handle) |
6748 { | 6740 { |
6749 cr = gdk_cairo_create(gtk_widget_get_window(handle)); | 6741 cr = gdk_cairo_create(gtk_widget_get_window(handle)); |
6750 fontname = (char *)g_object_get_data(G_OBJECT(handle), "_dw_fontname"); | 6742 fontname = (char *)g_object_get_data(G_OBJECT(handle), "_dw_fontname"); |
6751 } | 6743 } |
6752 #if 0 /* TODO */ | |
6753 else if(pixmap) | 6744 else if(pixmap) |
6754 { | 6745 { |
6755 fontname = (char *)g_object_get_data(G_OBJECT(pixmap->handle), "_dw_fontname"); | 6746 fontname = (char *)g_object_get_data(G_OBJECT(pixmap->handle), "_dw_fontname"); |
6756 gc = _set_colors(pixmap->pixbuf); | 6747 cr = cairo_create(pixmap->image); |
6757 } | 6748 } |
6758 #endif | |
6759 if(cr) | 6749 if(cr) |
6760 { | 6750 { |
6761 font = pango_font_description_from_string(fontname); | 6751 font = pango_font_description_from_string(fontname); |
6762 if(font) | 6752 if(font) |
6763 { | 6753 { |
6882 DW_MUTEX_LOCK; | 6872 DW_MUTEX_LOCK; |
6883 pixmap->handle = handle; | 6873 pixmap->handle = handle; |
6884 /* Depth needs to be divided by 3... but for the RGB colorspace... | 6874 /* Depth needs to be divided by 3... but for the RGB colorspace... |
6885 * only 8 bits per sample is allowed, so to avoid issues just pass 8 for now. | 6875 * only 8 bits per sample is allowed, so to avoid issues just pass 8 for now. |
6886 */ | 6876 */ |
6887 if ( handle ) | 6877 pixmap->pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, FALSE, 8, width, height ); |
6888 pixmap->pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, FALSE, 8, width, height ); | 6878 pixmap->image = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); |
6889 else | |
6890 pixmap->pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, FALSE, 8, width, height ); | |
6891 DW_MUTEX_UNLOCK; | 6879 DW_MUTEX_UNLOCK; |
6892 return pixmap; | 6880 return pixmap; |
6893 } | 6881 } |
6894 | 6882 |
6895 /* | 6883 /* |
6936 } | 6924 } |
6937 } | 6925 } |
6938 | 6926 |
6939 DW_MUTEX_LOCK; | 6927 DW_MUTEX_LOCK; |
6940 pixmap->pixbuf = gdk_pixbuf_new_from_file(file, NULL); | 6928 pixmap->pixbuf = gdk_pixbuf_new_from_file(file, NULL); |
6929 pixmap->image = cairo_image_surface_create_from_png(file); | |
6941 pixmap->width = gdk_pixbuf_get_width(pixmap->pixbuf); | 6930 pixmap->width = gdk_pixbuf_get_width(pixmap->pixbuf); |
6942 pixmap->height = gdk_pixbuf_get_height(pixmap->pixbuf); | 6931 pixmap->height = gdk_pixbuf_get_height(pixmap->pixbuf); |
6943 pixmap->handle = handle; | 6932 pixmap->handle = handle; |
6944 DW_MUTEX_UNLOCK; | 6933 DW_MUTEX_UNLOCK; |
6945 return pixmap; | 6934 return pixmap; |
6981 { | 6970 { |
6982 DW_MUTEX_UNLOCK; | 6971 DW_MUTEX_UNLOCK; |
6983 return 0; | 6972 return 0; |
6984 } | 6973 } |
6985 pixmap->pixbuf = gdk_pixbuf_new_from_file(file, NULL); | 6974 pixmap->pixbuf = gdk_pixbuf_new_from_file(file, NULL); |
6975 pixmap->image = cairo_image_surface_create_from_png(file); | |
6986 pixmap->width = gdk_pixbuf_get_width(pixmap->pixbuf); | 6976 pixmap->width = gdk_pixbuf_get_width(pixmap->pixbuf); |
6987 pixmap->height = gdk_pixbuf_get_height(pixmap->pixbuf); | 6977 pixmap->height = gdk_pixbuf_get_height(pixmap->pixbuf); |
6988 /* remove our temporary file */ | 6978 /* remove our temporary file */ |
6989 unlink (file ); | 6979 unlink (file ); |
6990 pixmap->handle = handle; | 6980 pixmap->handle = handle; |