summaryrefslogtreecommitdiff
path: root/tikzit/src/gtk/NodeStyleSelector.m
diff options
context:
space:
mode:
Diffstat (limited to 'tikzit/src/gtk/NodeStyleSelector.m')
-rw-r--r--tikzit/src/gtk/NodeStyleSelector.m41
1 files changed, 3 insertions, 38 deletions
diff --git a/tikzit/src/gtk/NodeStyleSelector.m b/tikzit/src/gtk/NodeStyleSelector.m
index 4fd3a5e..d44f446 100644
--- a/tikzit/src/gtk/NodeStyleSelector.m
+++ b/tikzit/src/gtk/NodeStyleSelector.m
@@ -23,6 +23,8 @@
#import "ShapeNames.h"
#import "StyleManager.h"
+#import "gtkhelpers.h"
+
#import <gdk-pixbuf/gdk-pixbuf.h>
// {{{ Internal interfaces
@@ -52,7 +54,6 @@ enum {
@interface NodeStyleSelector (Private)
- (cairo_surface_t*) createNodeIconSurface;
- (GdkPixbuf*) pixbufOfNodeInStyle:(NodeStyle*)style;
-- (GdkPixbuf*) pixbufFromSurface:(cairo_surface_t*)surface;
- (GdkPixbuf*) pixbufOfNodeInStyle:(NodeStyle*)style usingSurface:(cairo_surface_t*)surface;
- (void) addStyle:(NodeStyle*)style;
- (void) observeStyle:(NodeStyle*)style;
@@ -285,42 +286,6 @@ enum {
return pixbuf;
}
-// Bring on GTK+3 and gdk_pixbuf_get_from_surface()
-- (GdkPixbuf*) pixbufFromSurface:(cairo_surface_t*)surface {
- cairo_surface_flush (surface);
-
- int width = cairo_image_surface_get_width (surface);
- int height = cairo_image_surface_get_height (surface);
- int stride = cairo_image_surface_get_stride (surface);
- unsigned char *data = cairo_image_surface_get_data (surface);
-
- GdkPixbuf *pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- TRUE,
- 8,
- width,
- height);
- unsigned char *pbdata = gdk_pixbuf_get_pixels (pixbuf);
- int pbstride = gdk_pixbuf_get_rowstride (pixbuf);
-
- for (int y = 0; y < height; ++y) {
- uint32_t *line = (uint32_t*)(data + y*stride);
- unsigned char *pbline = pbdata + (y*pbstride);
- for (int x = 0; x < width; ++x) {
- uint32_t pixel = *(line + x);
- unsigned char *pbpixel = pbline + (x*4);
- // NB: We should un-pre-mult the alpha here.
- // However, in our world, alpha is always
- // on or off, so it doesn't really matter
- pbpixel[3] = ((pixel & 0xff000000) >> 24);
- pbpixel[0] = ((pixel & 0x00ff0000) >> 16);
- pbpixel[1] = ((pixel & 0x0000ff00) >> 8);
- pbpixel[2] = (pixel & 0x000000ff);
- }
- }
-
- return pixbuf;
-}
-
- (GdkPixbuf*) pixbufOfNodeInStyle:(NodeStyle*)style usingSurface:(cairo_surface_t*)surface {
Shape *shape = [Shape shapeForName:[style shapeName]];
@@ -342,7 +307,7 @@ enum {
andFillWithColor:[[style fillColorRGB] rColor]];
[context release];
- return [self pixbufFromSurface:surface];
+ return pixbuf_get_from_surface (surface);
}
- (void) addStyle:(NodeStyle*)style usingSurface:(cairo_surface_t*)surface {