summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/cube.c
diff options
context:
space:
mode:
authormaniac <maniac@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-01-02 13:40:17 +0000
committermaniac <maniac@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-01-02 13:40:17 +0000
commitd4ff789f155ed8c5933c0e89276556fa28a8ff85 (patch)
tree7ff2a07bc3be4a40e4b709b61456912db8f844c1 /beryl-plugins/src/cube.c
parent5b5d6227864c5d291384aa5fe2956238cd7e3efb (diff)
downloadmarex-dev-d4ff789f155ed8c5933c0e89276556fa28a8ff85.tar.gz
marex-dev-d4ff789f155ed8c5933c0e89276556fa28a8ff85.tar.bz2
beryl-plugins (cube): removed SVG stuff - we now have a SVG image loader plugin
git-svn-id: file:///beryl/trunk@2275 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/cube.c')
-rw-r--r--beryl-plugins/src/cube.c178
1 files changed, 5 insertions, 173 deletions
diff --git a/beryl-plugins/src/cube.c b/beryl-plugins/src/cube.c
index fa4d307..2f8a54f 100644
--- a/beryl-plugins/src/cube.c
+++ b/beryl-plugins/src/cube.c
@@ -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 _CubeDisplay
typedef struct _CubeCapInfo
{
- Pixmap pixmap;
- int pw, ph;
-
CompTexture texture;
GLfloat tc[12];
@@ -211,8 +203,6 @@ typedef struct _CubeCapInfo
CompOptionValue *imgFiles;
Bool scale;
-
- cairo_t *cr;
} CubeCapInfo;
typedef struct _CubeScreen
@@ -300,140 +290,6 @@ typedef struct _CubeScreen
#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 @@ static void cubeLoadImg(CompScreen * s, CubeCapInfo * cubeCap, int n)
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 @@ static void cubeInitCubeCap(CompScreen * s, CubeCapInfo * cubeCap)
memset(cubeCap->tc, 0, sizeof(cubeCap->tc));
initTexture(s, &cubeCap->texture);
- cubeInitSvg(cubeCap);
cubeCap->scale = FALSE;
cubeCap->imgCurFile = 0;
@@ -2956,9 +2797,6 @@ static Bool cubeInitDisplay(CompPlugin * p, CompDisplay * d)
static void cubeFiniDisplay(CompPlugin * p, CompDisplay * d)
{
-
- rsvg_term();
-
CUBE_DISPLAY(d);
freeScreenPrivateIndex(d, cd->screenPrivateIndex);
@@ -3103,9 +2941,6 @@ static void cubeFiniScreen(CompPlugin * p, CompScreen * s)
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 void cubeFiniScreen(CompPlugin * p, CompScreen * s)
static Bool cubeInit(CompPlugin * p)
{
-
- rsvg_init();
-
displayPrivateIndex = allocateDisplayPrivateIndex();
if (displayPrivateIndex < 0)
return FALSE;