[beryl-commits] r2275 - trunk/beryl-plugins/src

maniac at server.beryl-project.org maniac at server.beryl-project.org
Tue Jan 2 14:40:18 CET 2007


Author: maniac
Date: 2007-01-02 13:40:17 +0000 (Tue, 02 Jan 2007)
New Revision: 2275

Modified:
   trunk/beryl-plugins/src/cube.c
Log:
beryl-plugins (cube): removed SVG stuff - we now have a SVG image loader plugin


Modified: trunk/beryl-plugins/src/cube.c
===================================================================
--- trunk/beryl-plugins/src/cube.c	2007-01-02 13:22:57 UTC (rev 2274)
+++ trunk/beryl-plugins/src/cube.c	2007-01-02 13:40:17 UTC (rev 2275)
@@ -36,11 +36,6 @@
 #include <math.h>
 #include <sys/time.h>
 
-#include <cairo/cairo.h>
-#include <cairo/cairo-xlib.h>
-#include <librsvg/rsvg.h>
-#include <librsvg/rsvg-cairo.h>
-
 #include <X11/Xatom.h>
 #include <X11/Xproto.h>
 
@@ -200,9 +195,6 @@
 
 typedef struct _CubeCapInfo
 {
-	Pixmap pixmap;
-	int pw, ph;
-
 	CompTexture texture;
 	GLfloat tc[12];
 
@@ -211,8 +203,6 @@
 	CompOptionValue *imgFiles;
 
 	Bool scale;
-
-	cairo_t *cr;
 } CubeCapInfo;
 
 typedef struct _CubeScreen
@@ -300,140 +290,6 @@
 
 #define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption))
 
-static void cubeInitSvg(CubeCapInfo * cubeCap)
-{
-	cubeCap->pixmap = None;
-	cubeCap->pw = cubeCap->ph = 0;
-
-	cubeCap->cr = NULL;
-}
-
-static void cubeFiniSvg(CubeCapInfo * cubeCap, CompScreen * s)
-{
-	if (cubeCap->cr)
-		cairo_destroy(cubeCap->cr);
-
-	if (cubeCap->pixmap)
-		XFreePixmap(s->display->display, cubeCap->pixmap);
-}
-
-/* A monster of a function decleration, all it does is accept the exact
- * same values the individual top/bottom functions received, with the
- * addition of the individual top/bottom specific variables.
- */
-static Bool
-readSvgTo_generic(CompScreen * s, CompTexture * texture,
-				  const char *svgFileName,
-				  unsigned int *returnWidth, unsigned int *returnHeight,
-				  Bool scale, Pixmap * pixmap, int *pw_gen, int *ph_gen,
-				  cairo_t ** cr_gen)
-{
-	unsigned int width, height, pw, ph;
-	char *name;
-	GError *error = NULL;
-	RsvgHandle *svgHandle;
-	RsvgDimensionData svgDimension;
-
-	CUBE_SCREEN(s);
-
-	name = strdup(svgFileName);
-
-	svgHandle = rsvg_handle_new_from_file(name, &error);
-	free(name);
-	if (!svgHandle)
-		return FALSE;
-
-	rsvg_handle_get_dimensions(svgHandle, &svgDimension);
-
-	width = svgDimension.width;
-	height = svgDimension.height;
-
-	if (scale)
-	{
-		pw = (cs->nOutput > 1) ? s->outputDev[0].width : s->width;
-		ph = (cs->nOutput > 1) ? s->outputDev[0].height : s->height;
-	}
-	else
-	{
-		pw = width;
-		ph = height;
-	}
-
-	if (!*pixmap || *pw_gen != pw || *ph_gen != ph)
-	{
-		cairo_surface_t *surface;
-		Visual *visual;
-		int depth;
-
-		if (*cr_gen)
-		{
-			cairo_destroy(*cr_gen);
-			*cr_gen = NULL;
-		}
-
-		if (*pixmap)
-			XFreePixmap(s->display->display, *pixmap);
-
-		*pw_gen = pw;
-		*ph_gen = ph;
-
-		depth = DefaultDepth(s->display->display, s->screenNum);
-		*pixmap = XCreatePixmap(s->display->display, s->root,
-								*pw_gen, *ph_gen, depth);
-
-		if (!bindPixmapToTexture(s, texture, *pixmap,
-								 *pw_gen, *ph_gen, depth))
-		{
-			fprintf(stderr,
-					"%s: Couldn't bind slide pixmap 0x%x to "
-					"texture\n", getProgramName(), (int)*pixmap);
-
-			return FALSE;
-		}
-
-		visual = DefaultVisual(s->display->display, s->screenNum);
-		surface = cairo_xlib_surface_create(s->display->display,
-											*pixmap, visual,
-											*pw_gen, *ph_gen);
-		*cr_gen = cairo_create(surface);
-		cairo_surface_destroy(surface);
-	}
-
-	cairo_save(*cr_gen);
-	cairo_set_source_rgb(*cr_gen,
-						 (double)cs->color[0] / 0xffff,
-						 (double)cs->color[1] / 0xffff,
-						 (double)cs->color[2] / 0xffff);
-	cairo_rectangle(*cr_gen, 0, 0, *pw_gen, *ph_gen);
-	cairo_fill(*cr_gen);
-
-	cairo_scale(*cr_gen, (double)*pw_gen / width, (double)*ph_gen / height);
-
-	rsvg_handle_render_cairo(svgHandle, *cr_gen);
-
-	rsvg_handle_free(svgHandle);
-	cairo_restore(*cr_gen);
-
-	*returnWidth = *pw_gen;
-	*returnHeight = *ph_gen;
-
-	return TRUE;
-}
-
-static inline Bool
-readSvgToTexture(CompScreen * s, CubeCapInfo * cubeCap,
-				 const char *svgFileName,
-				 unsigned int *returnWidth, unsigned int *returnHeight)
-{
-	if (!cubeCap)
-		return FALSE;
-
-	return readSvgTo_generic(s, &cubeCap->texture, svgFileName,
-							 returnWidth, returnHeight, cubeCap->scale,
-							 &cubeCap->pixmap, &cubeCap->pw,
-							 &cubeCap->ph, &cubeCap->cr);
-}
-
 static void
 cubeInitTextureCoords(CompScreen * s, CubeCapInfo * cubeCap,
 					  unsigned int width, unsigned int height)
@@ -518,37 +374,23 @@
 		ph = s->outputDev[0].height;
 	}
 
-	if (!cubeCap->imgNFile || cubeCap->pw != pw || cubeCap->ph != ph)
-	{
-		finiTexture(s, &cubeCap->texture);
-		initTexture(s, &cubeCap->texture);
-		cubeFiniSvg(cubeCap, s);
-		cubeInitSvg(cubeCap);
+	finiTexture(s, &cubeCap->texture);
+	initTexture(s, &cubeCap->texture);
 
-		if (!cubeCap->imgNFile)
-			return;
-	}
+	if (!cubeCap->imgNFile)
+		return;
 
 	cubeCap->imgCurFile = n % cubeCap->imgNFile;
 
-	if (readImageToTexture
+	if (!readImageToTexture
 		(s, &cubeCap->texture,
 		 cubeCap->imgFiles[cubeCap->imgCurFile].s, &width, &height))
 	{
-		cubeFiniSvg(cubeCap, s);
-		cubeInitSvg(cubeCap);
-	}
-	else if (!readSvgToTexture
-			 (s, cubeCap, cubeCap->imgFiles[cubeCap->imgCurFile].s,
-			  &width, &height))
-	{
 		fprintf(stderr, "%s: Failed to load slide: %s\n",
 				getProgramName(), cubeCap->imgFiles[cubeCap->imgCurFile].s);
 
 		finiTexture(s, &cubeCap->texture);
 		initTexture(s, &cubeCap->texture);
-		cubeFiniSvg(cubeCap, s);
-		cubeInitSvg(cubeCap);
 
 		return;
 	}
@@ -560,7 +402,6 @@
 	memset(cubeCap->tc, 0, sizeof(cubeCap->tc));
 
 	initTexture(s, &cubeCap->texture);
-	cubeInitSvg(cubeCap);
 
 	cubeCap->scale = FALSE;
 	cubeCap->imgCurFile = 0;
@@ -2956,9 +2797,6 @@
 
 static void cubeFiniDisplay(CompPlugin * p, CompDisplay * d)
 {
-
-	rsvg_term();
-
 	CUBE_DISPLAY(d);
 
 	freeScreenPrivateIndex(d, cd->screenPrivateIndex);
@@ -3103,9 +2941,6 @@
 	finiTexture(s, &cs->cubeCapBottom.texture);
 	finiTexture(s, &cs->sky);
 
-	cubeFiniSvg(&cs->cubeCapTop, s);
-	cubeFiniSvg(&cs->cubeCapBottom, s);
-
 	if (cs->vertices)
 		free(cs->vertices);
 
@@ -3114,9 +2949,6 @@
 
 static Bool cubeInit(CompPlugin * p)
 {
-
-	rsvg_init();
-
 	displayPrivateIndex = allocateDisplayPrivateIndex();
 	if (displayPrivateIndex < 0)
 		return FALSE;




More information about the commits mailing list