Hi,

this mail contains a core patch that enables wrapping of texture functions and 
a plugin that uses this functions to realize the so called "copy mode". The 
pure "copy" code is quite simple and mostly clean. The most "hacky" part is 
the code that fixes the maximum texture size limitations of some graphic 
cards. But maybe we can use this as a basis to create a proper interface to 
this problem. The pure copy part of the plugin can also be used to provide a 
system that replaces the texture from pixmap extension for some buggy graphic 
card drivers.

DO NOT USE THIS FOR PRODUCTIVE WORK !!!!!

Dennis
diff --git a/include/compiz.h b/include/compiz.h
index 5e52c8c..dd4f2df 100644
--- a/include/compiz.h
+++ b/include/compiz.h
@@ -26,7 +26,7 @@
 #ifndef _COMPIZ_H
 #define _COMPIZ_H
 
-#define ABIVERSION 20070506
+#define ABIVERSION 20070510
 
 #include <stdio.h>
 #include <sys/time.h>
@@ -1250,11 +1250,12 @@ typedef Bool (*DrawWindowProc) (CompWind
 				Region		     region,
 				unsigned int	     mask);
 
-typedef void (*AddWindowGeometryProc) (CompWindow *window,
-				       CompMatrix *matrix,
-				       int	  nMatrix,
-				       Region	  region,
-				       Region	  clip);
+typedef void (*AddWindowGeometryProc) (CompWindow  *window,
+				       CompMatrix  *matrix,
+				       int	   nMatrix,
+				       CompTexture *texture,
+				       Region	   region,
+				       Region	   clip);
 
 typedef void (*DrawWindowTextureProc) (CompWindow	    *w,
 				       CompTexture	    *texture,
@@ -1325,11 +1326,12 @@ moreWindowIndices (CompWindow *w,
 		   int        newSize);
 
 void
-addWindowGeometry (CompWindow *w,
-		   CompMatrix *matrix,
-		   int	      nMatrix,
-		   Region     region,
-		   Region     clip);
+addWindowGeometry (CompWindow  *w,
+		   CompMatrix  *matrix,
+		   int	       nMatrix,
+		   CompTexture *texture,
+		   Region      region,
+		   Region      clip);
 
 void
 drawWindowTexture (CompWindow		*w,
@@ -1373,31 +1375,32 @@ typedef enum {
 } CompTextureFilter;
 
 struct _CompTexture {
-    GLuint     name;
-    GLenum     target;
-    GLfloat    dx, dy;
-    GLXPixmap  pixmap;
-    GLenum     filter;
-    GLenum     wrap;
-    CompMatrix matrix;
-    Bool       oldMipmaps;
-    Bool       mipmap;
-    int        refCount;
+    GLuint      name;
+    GLenum      target;
+    GLfloat     dx, dy;
+    GLXPixmap   pixmap;
+    GLenum      filter;
+    GLenum      wrap;
+    CompMatrix  matrix;
+    Bool        oldMipmaps;
+    Bool        mipmap;
+    int         refCount;
+	CompPrivate *private;
 };
 
 void
-initTexture (CompScreen  *screen,
+compInitTexture (CompScreen  *screen,
 	     CompTexture *texture);
 
 void
-finiTexture (CompScreen  *screen,
+compFiniTexture (CompScreen  *screen,
 	     CompTexture *texture);
 
 CompTexture *
-createTexture (CompScreen *screen);
+compCreateTexture (CompScreen *screen);
 
 void
-destroyTexture (CompScreen  *screen,
+compDestroyTexture (CompScreen  *screen,
 		CompTexture *texture);
 
 Bool
@@ -1429,7 +1432,7 @@ iconToTexture (CompScreen *screen,
 	       CompIcon   *icon);
 
 Bool
-bindPixmapToTexture (CompScreen  *screen,
+compBindPixmapToTexture (CompScreen  *screen,
 		     CompTexture *texture,
 		     Pixmap	 pixmap,
 		     int	 width,
@@ -1437,11 +1440,11 @@ bindPixmapToTexture (CompScreen  *screen
 		     int	 depth);
 
 void
-releasePixmapFromTexture (CompScreen  *screen,
+compReleasePixmapFromTexture (CompScreen  *screen,
 			  CompTexture *texture);
 
 void
-enableTexture (CompScreen        *screen,
+compEnableTexture (CompScreen        *screen,
 	       CompTexture	 *texture,
 	       CompTextureFilter filter);
 
@@ -1456,7 +1459,36 @@ enableTextureClampToEdge (CompScreen
 			  CompTextureFilter filter);
 
 void
-disableTexture (CompScreen  *screen,
+compDisableTexture (CompScreen  *screen,
+		CompTexture *texture);
+
+
+typedef void (*InitTextureProc) (CompScreen  *screen,
+	     CompTexture *texture);
+
+typedef void (*FiniTextureProc) (CompScreen  *screen,
+	     CompTexture *texture);
+
+typedef CompTexture * (*CreateTextureProc) (CompScreen *screen);
+
+typedef void (*DestroyTextureProc) (CompScreen  *screen,
+		CompTexture *texture);
+
+typedef Bool (*BindPixmapToTextureProc) (CompScreen  *screen,
+		     CompTexture *texture,
+		     Pixmap	 pixmap,
+		     int	 width,
+		     int	 height,
+		     int	 depth);
+
+typedef void (*ReleasePixmapFromTextureProc) (CompScreen  *screen,
+			  CompTexture *texture);
+
+typedef void (*EnableTextureProc) (CompScreen        *screen,
+	       CompTexture	 *texture,
+	       CompTextureFilter filter);
+
+typedef void (*DisableTextureProc) (CompScreen  *screen,
 		CompTexture *texture);
 
 
@@ -1966,6 +1998,16 @@ struct _CompScreen {
 
     OutputChangeNotifyProc outputChangeNotify;
 
+
+    InitTextureProc              initTexture;
+    FiniTextureProc              finiTexture;
+    CreateTextureProc            createTexture;
+    DestroyTextureProc           destroyTexture;
+    BindPixmapToTextureProc      bindPixmapToTexture;
+    ReleasePixmapFromTextureProc releasePixmapFromTexture;
+    EnableTextureProc            enableTexture;
+    DisableTextureProc           disableTexture;
+
     CompPrivate *privates;
 };
 
diff --git a/plugins/annotate.c b/plugins/annotate.c
index e8fac5e..831c968 100644
--- a/plugins/annotate.c
+++ b/plugins/annotate.c
@@ -119,7 +119,7 @@ annoCairoContext (CompScreen *s)
 
 	as->pixmap = XCreatePixmap (s->display->display, s->root, w, h, 32);
 
-	if (!bindPixmapToTexture (s, &as->texture, as->pixmap, w, h, 32))
+	if (!(*s->bindPixmapToTexture) (s, &as->texture, as->pixmap, w, h, 32))
 	{
 	    fprintf (stderr, "%s: Couldn't bind annotate pixmap 0x%x to "
 		     "texture\n", programName, (int) as->pixmap);
@@ -609,7 +609,7 @@ annoPaintScreen (CompScreen		 *s,
 	glDisableClientState (GL_TEXTURE_COORD_ARRAY);
 	glEnable (GL_BLEND);
 
-	enableTexture (s, &as->texture, COMP_TEXTURE_FILTER_FAST);
+	(*s->enableTexture) (s, &as->texture, COMP_TEXTURE_FILTER_FAST);
 
 	pBox = region->rects;
 	nBox = region->numRects;
@@ -636,7 +636,7 @@ annoPaintScreen (CompScreen		 *s,
 
 	glEnd ();
 
-	disableTexture (s, &as->texture);
+	(*s->disableTexture) (s, &as->texture);
 
 	glDisable (GL_BLEND);
 	glEnableClientState (GL_TEXTURE_COORD_ARRAY);
@@ -816,7 +816,7 @@ annoInitScreen (CompPlugin *p,
     as->cairo     = NULL;
     as->content   = FALSE;
 
-    initTexture (s, &as->texture);
+    (*s->initTexture) (s, &as->texture);
 
     WRAP (as, s, paintScreen, annoPaintScreen);
 
@@ -837,7 +837,7 @@ annoFiniScreen (CompPlugin *p,
     if (as->surface)
 	cairo_surface_destroy (as->surface);
 
-    finiTexture (s, &as->texture);
+    (*s->finiTexture) (s, &as->texture);
 
     if (as->pixmap)
 	XFreePixmap (s->display->display, as->pixmap);
diff --git a/plugins/blur.c b/plugins/blur.c
index cd4b154..e0d3baa 100644
--- a/plugins/blur.c
+++ b/plugins/blur.c
@@ -1558,7 +1558,7 @@ blurProjectRegion (CompWindow	       *w,
     BLUR_SCREEN(s);
 
     w->vCount = w->indexCount = 0;
-    (*w->screen->addWindowGeometry) (w, NULL, 0, bs->tmpRegion2,
+    (*w->screen->addWindowGeometry) (w, NULL, 0, NULL, bs->tmpRegion2,
 				     &infiniteRegion);
 
     if (!w->vCount)
@@ -1966,7 +1966,8 @@ blurDrawWindow (CompWindow	     *w,
 	    if (clipped)
 	    {
 		w->vCount = w->indexCount = 0;
-		(*w->screen->addWindowGeometry) (w, NULL, 0, bs->tmpRegion, reg);
+		(*w->screen->addWindowGeometry) (w, NULL, 0, NULL,
+		                                 bs->tmpRegion, reg);
 		if (w->vCount)
 		{
 		    BoxRec clearBox = bs->stencilBox;
diff --git a/plugins/cube.c b/plugins/cube.c
index 833d33e..b7ce507 100644
--- a/plugins/cube.c
+++ b/plugins/cube.c
@@ -314,8 +314,8 @@ cubeLoadImg (CompScreen *s,
 
     if (!imgNFile || cs->pw != pw || cs->ph != ph)
     {
-	finiTexture (s, &cs->texture);
-	initTexture (s, &cs->texture);
+	(*s->finiTexture) (s, &cs->texture);
+	(*s->initTexture) (s, &cs->texture);
 	cubeFiniSvg (s);
 	cubeInitSvg (s);
 
@@ -339,8 +339,8 @@ cubeLoadImg (CompScreen *s,
 	fprintf (stderr, "%s: Failed to load slide: %s\n",
 		 programName, imgFiles[cs->imgCurFile].s);
 
-	finiTexture (s, &cs->texture);
-	initTexture (s, &cs->texture);
+	(*s->finiTexture) (s, &cs->texture);
+	(*s->initTexture) (s, &cs->texture);
 	cubeFiniSvg (s);
 	cubeInitSvg (s);
 
@@ -553,8 +553,8 @@ cubeUpdateSkyDomeTexture (CompScreen *sc
 {
     CUBE_SCREEN (screen);
 
-    finiTexture (screen, &cs->sky);
-    initTexture (screen, &cs->sky);
+    (*screen->finiTexture) (screen, &cs->sky);
+    (*screen->initTexture) (screen, &cs->sky);
 
     if (!cs->opt[CUBE_SCREEN_OPTION_SKYDOME].value.b)
 	return;
@@ -733,7 +733,7 @@ cubeUpdateSkyDomeList (CompScreen *s,
 
     glNewList (cs->skyListId, GL_COMPILE);
 
-    enableTexture (s, &cs->sky, COMP_TEXTURE_FILTER_GOOD);
+    (*s->enableTexture) (s, &cs->sky, COMP_TEXTURE_FILTER_GOOD);
 
     glBegin (GL_QUADS);
 
@@ -796,7 +796,7 @@ cubeUpdateSkyDomeList (CompScreen *s,
 
     glEnd ();
 
-    disableTexture (s, &cs->sky);
+    (*s->disableTexture) (s, &cs->sky);
 
     glEndList ();
 
@@ -816,7 +816,7 @@ cubeUnloadBackgrounds (CompScreen *s)
 	int i;
 
 	for (i = 0; i < cs->nBg; i++)
-	    finiTexture (s, &cs->bg[i]);
+	    (*s->finiTexture) (s, &cs->bg[i]);
 
 	free (cs->bg);
 
@@ -843,7 +843,7 @@ cubeLoadBackground (CompScreen *s,
 	    return;
 
 	for (i = 0; i < value->list.nValue; i++)
-	    initTexture (s, &cs->bg[i]);
+	    (*s->initTexture) (s, &cs->bg[i]);
 
 	cs->nBg = value->list.nValue;
     }
@@ -1301,10 +1301,10 @@ cubePaintTransformedScreen (CompScreen
 
 	if (cs->invert == 1 && hsize == 4 && cs->texture.name)
 	{
-	    enableTexture (s, &cs->texture, COMP_TEXTURE_FILTER_GOOD);
+	    (*s->enableTexture) (s, &cs->texture, COMP_TEXTURE_FILTER_GOOD);
 	    glTexCoordPointer (2, GL_FLOAT, 0, cs->tc);
 	    glDrawArrays (GL_TRIANGLE_FAN, 0, cs->nvertices >> 1);
-	    disableTexture (s, &cs->texture);
+	    (*s->disableTexture) (s, &cs->texture);
 	    glDisableClientState (GL_TEXTURE_COORD_ARRAY);
 	}
 	else
@@ -1505,9 +1505,9 @@ cubePaintBackground (CompScreen   *s,
 
 	if (bg->name)
 	{
-	    enableTexture (s, bg, COMP_TEXTURE_FILTER_GOOD);
+	    (*s->enableTexture) (s, bg, COMP_TEXTURE_FILTER_GOOD);
 	    glDrawArrays (GL_QUADS, 0, nBox * 4);
-	    disableTexture (s, bg);
+	    (*s->disableTexture) (s, bg);
 	}
 	else
 	{
@@ -1859,8 +1859,8 @@ cubeInitScreen (CompPlugin *p,
 
     cs->paintTopBottom = FALSE;
 
-    initTexture (s, &cs->texture);
-    initTexture (s, &cs->sky);
+    (*s->initTexture) (s, &cs->texture);
+    (*s->initTexture) (s, &cs->sky);
 
     cubeInitSvg (s);
 
@@ -1923,8 +1923,8 @@ cubeFiniScreen (CompPlugin *p,
     UNWRAP (cs, s, setScreenOption);
     UNWRAP (cs, s, outputChangeNotify);
 
-    finiTexture (s, &cs->texture);
-    finiTexture (s, &cs->sky);
+    (*s->finiTexture) (s, &cs->texture);
+    (*s->finiTexture) (s, &cs->sky);
 
     cubeFiniSvg (s);
 
diff --git a/plugins/decoration.c b/plugins/decoration.c
index 76816cb..07f4e3e 100644
--- a/plugins/decoration.c
+++ b/plugins/decoration.c
@@ -196,6 +196,7 @@ decorDrawWindow (CompWindow	      *w,
 	    {
 		(*w->screen->addWindowGeometry) (w,
 						 &wd->quad[i].matrix, 1,
+						 &wd->decor->texture->texture,
 						 &box,
 						 region);
 	    }
@@ -234,20 +235,20 @@ decorGetTexture (CompScreen *screen,
     if (!texture)
 	return NULL;
 
-    initTexture (screen, &texture->texture);
+    (*screen->initTexture) (screen, &texture->texture);
 
     if (!XGetGeometry (screen->display->display, pixmap, &root,
 		       &i, &i, &width, &height, &ui, &depth))
     {
-	finiTexture (screen, &texture->texture);
+	(*screen->finiTexture) (screen, &texture->texture);
 	free (texture);
 	return NULL;
     }
 
-    if (!bindPixmapToTexture (screen, &texture->texture, pixmap,
+    if (!(*screen->bindPixmapToTexture) (screen, &texture->texture, pixmap,
 			      width, height, depth))
     {
-	finiTexture (screen, &texture->texture);
+	(*screen->finiTexture) (screen, &texture->texture);
 	free (texture);
 	return NULL;
     }
@@ -295,7 +296,7 @@ decorReleaseTexture (CompScreen   *scree
 	}
     }
 
-    finiTexture (screen, &texture->texture);
+    (*screen->finiTexture) (screen, &texture->texture);
     free (texture);
 }
 
diff --git a/plugins/scale.c b/plugins/scale.c
index 0361743..edf9a20 100644
--- a/plugins/scale.c
+++ b/plugins/scale.c
@@ -480,6 +480,7 @@ scalePaintWindow (CompWindow		  *w,
 		    iconReg.extents.y1 < iconReg.extents.y2)
 		    (*w->screen->addWindowGeometry) (w,
 						     &icon->texture.matrix, 1,
+						     &icon->texture,
 						     &iconReg, &iconReg);
 
 		if (w->vCount)
diff --git a/plugins/switcher.c b/plugins/switcher.c
index 38ee8bb..3656d2b 100644
--- a/plugins/switcher.c
+++ b/plugins/switcher.c
@@ -1590,7 +1590,8 @@ switchPaintThumb (CompWindow		  *w,
 	sAttrib.yTranslate = wy - w->attrib.y;
 
 	w->vCount = w->indexCount = 0;
-	addWindowGeometry (w, &matrix, 1, &iconReg, &infiniteRegion);
+	addWindowGeometry (w, &matrix, 1, &icon->texture, &iconReg,
+			   &infiniteRegion);
 	if (w->vCount)
 	{
 	    FragmentAttrib fragment;
diff --git a/plugins/video.c b/plugins/video.c
index 323632b..8cf9bdd 100644
--- a/plugins/video.c
+++ b/plugins/video.c
@@ -523,6 +523,7 @@ videoDrawWindow (CompWindow	      *w,
 	    {
 		(*w->screen->addWindowGeometry) (w,
 						 &vw->context->matrix, 1,
+						 texture,
 						 &vw->context->box,
 						 region);
 	    }
@@ -570,20 +571,20 @@ videoGetTexture (CompScreen *screen,
     if (!texture)
 	return NULL;
 
-    initTexture (screen, &texture->texture);
+    (*screen->initTexture) (screen, &texture->texture);
 
     if (!XGetGeometry (screen->display->display, pixmap, &root,
 		       &i, &i, &width, &height, &ui, &depth))
     {
-	finiTexture (screen, &texture->texture);
+	(*screen->finiTexture) (screen, &texture->texture);
 	free (texture);
 	return NULL;
     }
 
-    if (!bindPixmapToTexture (screen, &texture->texture, pixmap,
+    if (!(*screen->bindPixmapToTexture) (screen, &texture->texture, pixmap,
 			      width, height, depth))
     {
-	finiTexture (screen, &texture->texture);
+	(*screen->finiTexture) (screen, &texture->texture);
 	free (texture);
 	return NULL;
     }
@@ -630,7 +631,7 @@ videoReleaseTexture (CompScreen   *scree
 	}
     }
 
-    finiTexture (screen, &texture->texture);
+    (*screen->finiTexture) (screen, &texture->texture);
     free (texture);
 }
 
diff --git a/plugins/wobbly.c b/plugins/wobbly.c
index 6267c2e..7e7975c 100644
--- a/plugins/wobbly.c
+++ b/plugins/wobbly.c
@@ -1832,11 +1832,12 @@ wobblyDrawWindowGeometry (CompWindow *w)
 }
 
 static void
-wobblyAddWindowGeometry (CompWindow *w,
-			 CompMatrix *matrix,
-			 int	    nMatrix,
-			 Region     region,
-			 Region     clip)
+wobblyAddWindowGeometry (CompWindow  *w,
+			 CompMatrix  *matrix,
+			 int	     nMatrix,
+			 CompTexture *texture,
+			 Region      region,
+			 Region      clip)
 {
     WOBBLY_WINDOW (w);
     WOBBLY_SCREEN (w->screen);
@@ -1988,7 +1989,8 @@ wobblyAddWindowGeometry (CompWindow *w,
     else
     {
 	UNWRAP (ws, w->screen, addWindowGeometry);
-	(*w->screen->addWindowGeometry) (w, matrix, nMatrix, region, clip);
+	(*w->screen->addWindowGeometry) (w, matrix, nMatrix, texture,
+	                                 region, clip);
 	WRAP (ws, w->screen, addWindowGeometry, wobblyAddWindowGeometry);
     }
 }
diff --git a/src/cursor.c b/src/cursor.c
index a1975b2..f1ec651 100644
--- a/src/cursor.c
+++ b/src/cursor.c
@@ -143,7 +143,7 @@ updateCursor (CompCursor    *c,
 	    cursorImage->width  = image->width;
 	    cursorImage->height = image->height;
 
-	    initTexture (c->screen, &cursorImage->texture);
+	    (*c->screen->initTexture) (c->screen, &cursorImage->texture);
 
 	    if (!imageBufferToTexture (c->screen,
 				       &cursorImage->texture,
diff --git a/src/event.c b/src/event.c
index 52cae89..650261c 100644
--- a/src/event.c
+++ b/src/event.c
@@ -1345,7 +1345,7 @@ handleEvent (CompDisplay *d,
 		if (w)
 		{
 		    if (d->opt[COMP_DISPLAY_OPTION_RAISE_ON_CLICK].value.b)
-			updateWindowAttributes (w, 
+			updateWindowAttributes (w,
 					CompStackingUpdateModeAboveFullscreen);
 
 		    if (!(w->type & CompWindowTypeDockMask))
@@ -1506,8 +1506,8 @@ handleEvent (CompDisplay *d,
 	    s = findScreenAtDisplay (d, event->xproperty.window);
 	    if (s)
 	    {
-		finiTexture (s, &s->backgroundTexture);
-		initTexture (s, &s->backgroundTexture);
+		(*s->finiTexture) (s, &s->backgroundTexture);
+		(*s->initTexture) (s, &s->backgroundTexture);
 
 		if (s->backgroundLoaded)
 		{
@@ -2025,7 +2025,7 @@ handleEvent (CompDisplay *d,
 				    compAddTimeout (delay, autoRaiseTimeout, d);
 			    }
 			    else
-				updateWindowAttributes (w, 
+				updateWindowAttributes (w,
 					CompStackingUpdateModeNormal);
 			}
 		    }
diff --git a/src/paint.c b/src/paint.c
index 39bcacc..05bfeb4 100644
--- a/src/paint.c
+++ b/src/paint.c
@@ -117,7 +117,7 @@ paintCursor (CompCursor		 *c,
     glDisableClientState (GL_TEXTURE_COORD_ARRAY);
     glEnable (GL_BLEND);
 
-    enableTexture (c->screen, &c->image->texture, COMP_TEXTURE_FILTER_FAST);
+    (*c->screen->enableTexture) (c->screen, &c->image->texture, COMP_TEXTURE_FILTER_FAST);
 
     glBegin (GL_QUADS);
 
@@ -136,7 +136,7 @@ paintCursor (CompCursor		 *c,
 
     glEnd ();
 
-    disableTexture (c->screen, &c->image->texture);
+    (*c->screen->disableTexture) (c->screen, &c->image->texture);
 
     glDisable (GL_BLEND);
     glEnableClientState (GL_TEXTURE_COORD_ARRAY);
@@ -518,11 +518,12 @@ drawWindowGeometry (CompWindow *w)
 }
 
 void
-addWindowGeometry (CompWindow *w,
-		   CompMatrix *matrix,
-		   int	      nMatrix,
-		   Region     region,
-		   Region     clip)
+addWindowGeometry (CompWindow  *w,
+		   CompMatrix  *matrix,
+		   int	       nMatrix,
+		   CompTexture *texture,
+		   Region      region,
+		   Region      clip)
 {
     BoxRec full;
 
@@ -691,7 +692,7 @@ enableFragmentProgramAndDrawGeometry (Co
     if (!enableFragmentAttrib (s, &fa, &blending))
 	return FALSE;
 
-    enableTexture (s, texture, filter);
+    (*s->enableTexture) (s, texture, filter);
 
     if (mask & PAINT_WINDOW_BLEND_MASK)
     {
@@ -736,7 +737,7 @@ enableFragmentProgramAndDrawGeometry (Co
 	(*w->drawWindowGeometry) (w);
     }
 
-    disableTexture (w->screen, texture);
+    (*s->disableTexture) (w->screen, texture);
 
     disableFragmentAttrib (s, &fa);
 
@@ -759,7 +760,7 @@ enableFragmentOperationsAndDrawGeometry
 	if (mask & PAINT_WINDOW_BLEND_MASK)
 	    glEnable (GL_BLEND);
 
-	enableTexture (s, texture, filter);
+	(*s->enableTexture) (s, texture, filter);
 
 	glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
 
@@ -779,7 +780,7 @@ enableFragmentOperationsAndDrawGeometry
 
 	s->activeTexture (GL_TEXTURE1_ARB);
 
-	enableTexture (s, texture, filter);
+	(*s->enableTexture) (s, texture, filter);
 
 	glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
 
@@ -804,7 +805,7 @@ enableFragmentOperationsAndDrawGeometry
 
 	    s->activeTexture (GL_TEXTURE2_ARB);
 
-	    enableTexture (s, texture, filter);
+	    (*s->enableTexture) (s, texture, filter);
 
 	    glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
 
@@ -828,7 +829,7 @@ enableFragmentOperationsAndDrawGeometry
 	    {
 		s->activeTexture (GL_TEXTURE3_ARB);
 
-		enableTexture (s, texture, filter);
+		(*s->enableTexture) (s, texture, filter);
 
 		constant[3] = attrib->opacity / 65535.0f;
 		constant[0] = constant[1] = constant[2] = constant[3] *
@@ -852,7 +853,7 @@ enableFragmentOperationsAndDrawGeometry
 
 		(*w->drawWindowGeometry) (w);
 
-		disableTexture (s, texture);
+		(*s->disableTexture) (s, texture);
 
 		glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
 
@@ -863,7 +864,7 @@ enableFragmentOperationsAndDrawGeometry
 		(*w->drawWindowGeometry) (w);
 	    }
 
-	    disableTexture (s, texture);
+	    (*s->disableTexture) (s, texture);
 
 	    glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
 
@@ -890,13 +891,13 @@ enableFragmentOperationsAndDrawGeometry
 	    (*w->drawWindowGeometry) (w);
 	}
 
-	disableTexture (s, texture);
+	(s->disableTexture) (s, texture);
 
 	glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
 
 	s->activeTexture (GL_TEXTURE0_ARB);
 
-	disableTexture (s, texture);
+	(s->disableTexture) (s, texture);
 
 	glColor4usv (defaultColor);
 	screenTexEnvMode (s, GL_REPLACE);
@@ -906,7 +907,7 @@ enableFragmentOperationsAndDrawGeometry
     }
     else
     {
-	enableTexture (s, texture, filter);
+	(*s->enableTexture) (s, texture, filter);
 
 	if (mask & PAINT_WINDOW_BLEND_MASK)
 	{
@@ -948,7 +949,7 @@ enableFragmentOperationsAndDrawGeometry
 	    (*w->drawWindowGeometry) (w);
 	}
 
-	disableTexture (w->screen, texture);
+	(*s->disableTexture) (w->screen, texture);
     }
 }
 
@@ -1003,7 +1004,8 @@ drawWindow (CompWindow		 *w,
 	mask |= PAINT_WINDOW_BLEND_MASK;
 
     w->vCount = w->indexCount = 0;
-    (*w->screen->addWindowGeometry) (w, &w->matrix, 1, w->region, region);
+    (*w->screen->addWindowGeometry) (w, &w->matrix, 1, w->texture,
+                                     w->region, region);
     if (w->vCount)
 	(*w->screen->drawWindowTexture) (w, w->texture, fragment, mask);
 
@@ -1080,8 +1082,8 @@ paintBackground (CompScreen   *s,
     {
 	if (bg->name)
 	{
-	    finiTexture (s, bg);
-	    initTexture (s, bg);
+	    (*s->finiTexture) (s, bg);
+	    (*s->initTexture) (s, bg);
 	}
 
 	s->backgroundLoaded = FALSE;
@@ -1143,13 +1145,13 @@ paintBackground (CompScreen   *s,
 	if (bg->name)
 	{
 	    if (mask & PAINT_BACKGROUND_ON_TRANSFORMED_SCREEN_MASK)
-		enableTexture (s, bg, COMP_TEXTURE_FILTER_GOOD);
+		(*s->enableTexture) (s, bg, COMP_TEXTURE_FILTER_GOOD);
 	    else
-		enableTexture (s, bg, COMP_TEXTURE_FILTER_FAST);
+		(*s->enableTexture) (s, bg, COMP_TEXTURE_FILTER_FAST);
 
 	    glDrawArrays (GL_QUADS, 0, nBox * 4);
 
-	    disableTexture (s, bg);
+	    (*s->disableTexture) (s, bg);
 	}
 	else
 	{
diff --git a/src/screen.c b/src/screen.c
index d73ceb4..010321d 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -926,10 +926,10 @@ updateScreenBackground (CompScreen  *scr
 	if (pixmap == texture->pixmap)
 	    return;
 
-	finiTexture (screen, texture);
-	initTexture (screen, texture);
+	(*screen->finiTexture) (screen, texture);
+	(*screen->initTexture) (screen, texture);
 
-	if (!bindPixmapToTexture (screen, texture, pixmap,
+	if (!(*screen->bindPixmapToTexture) (screen, texture, pixmap,
 				  width, height, depth))
 	{
 	    fprintf (stderr, "%s: Couldn't bind background pixmap 0x%x to "
@@ -938,8 +938,8 @@ updateScreenBackground (CompScreen  *scr
     }
     else
     {
-	finiTexture (screen, texture);
-	initTexture (screen, texture);
+	(*screen->finiTexture) (screen, texture);
+	(*screen->initTexture) (screen, texture);
     }
 
     if (!texture->name && backgroundImage)
@@ -1541,6 +1541,15 @@ addScreen (CompDisplay *display,
 
     s->outputChangeNotify = outputChangeNotify;
 
+    s->initTexture              = compInitTexture;
+    s->finiTexture              = compFiniTexture;
+    s->createTexture            = compCreateTexture;
+    s->destroyTexture           = compDestroyTexture;
+    s->bindPixmapToTexture      = compBindPixmapToTexture;
+    s->releasePixmapFromTexture = compReleasePixmapFromTexture;
+    s->enableTexture            = compEnableTexture;
+    s->disableTexture           = compDisableTexture;
+
     s->getProcAddress = 0;
 
     if (!XGetWindowAttributes (dpy, s->root, &s->attrib))
@@ -1955,7 +1964,7 @@ addScreen (CompDisplay *display,
 	return FALSE;
     }
 
-    initTexture (s, &s->backgroundTexture);
+    (*s->initTexture) (s, &s->backgroundTexture);
     s->backgroundLoaded = FALSE;
 
     s->defaultIcon = NULL;
@@ -2570,7 +2579,7 @@ removePassiveKeyGrab (CompScreen     *s,
 	    if (s->keyGrab[i].count)
 		return;
 
-	    memmove (s->keyGrab + i, s->keyGrab + i + 1, 
+	    memmove (s->keyGrab + i, s->keyGrab + i + 1,
 		     (s->nKeyGrab - (i + 1)) * sizeof (CompKeyGrab));
 
 	    s->nKeyGrab--;
@@ -3205,7 +3214,7 @@ moveWindowToViewportPosition (CompWindow
 	if (vWidth > w->screen->width)
 	{
 	    m = w->attrib.x + tx;
-	
+
 	    if (m - w->output.left < w->screen->width - vWidth)
 		wx = tx + vWidth;
 	    else if (m + w->width + w->output.right > vWidth)
@@ -3709,7 +3718,7 @@ updateDefaultIcon (CompScreen *screen)
 
     if (screen->defaultIcon)
     {
-	finiTexture (screen, &screen->defaultIcon->texture);
+	(*screen->finiTexture) (screen, &screen->defaultIcon->texture);
 	free (screen->defaultIcon);
 	screen->defaultIcon = NULL;
     }
@@ -3724,7 +3733,7 @@ updateDefaultIcon (CompScreen *screen)
 	return FALSE;
     }
 
-    initTexture (screen, &icon->texture);
+    (*screen->initTexture) (screen, &icon->texture);
 
     icon->width  = width;
     icon->height = height;
diff --git a/src/texture.c b/src/texture.c
index 384ae3d..fb61096 100644
--- a/src/texture.c
+++ b/src/texture.c
@@ -33,6 +33,7 @@
 
 #include <compiz.h>
 
+
 static CompMatrix _identity_matrix = {
     1.0f, 0.0f,
     0.0f, 1.0f,
@@ -40,7 +41,7 @@ static CompMatrix _identity_matrix = {
 };
 
 void
-initTexture (CompScreen  *screen,
+compInitTexture (CompScreen  *screen,
 	     CompTexture *texture)
 {
     texture->refCount	= 1;
@@ -52,22 +53,23 @@ initTexture (CompScreen  *screen,
     texture->matrix     = _identity_matrix;
     texture->oldMipmaps = TRUE;
     texture->mipmap	= FALSE;
+    texture->private    = NULL;
 }
 
 void
-finiTexture (CompScreen  *screen,
+compFiniTexture (CompScreen  *screen,
 	     CompTexture *texture)
 {
     if (texture->name)
     {
 	makeScreenCurrent (screen);
-	releasePixmapFromTexture (screen, texture);
+	(*screen->releasePixmapFromTexture) (screen, texture);
 	glDeleteTextures (1, &texture->name);
     }
 }
 
 CompTexture *
-createTexture (CompScreen *screen)
+compCreateTexture (CompScreen *screen)
 {
     CompTexture *texture;
 
@@ -75,20 +77,20 @@ createTexture (CompScreen *screen)
     if (!texture)
 	return NULL;
 
-    initTexture (screen, texture);
+    (*screen->initTexture) (screen, texture);
 
     return texture;
 }
 
 void
-destroyTexture (CompScreen  *screen,
+compDestroyTexture (CompScreen  *screen,
 		CompTexture *texture)
 {
     texture->refCount--;
     if (texture->refCount)
 	return;
 
-    finiTexture (screen, texture);
+    (*screen->finiTexture) (screen, texture);
 
     free (texture);
 }
@@ -115,7 +117,7 @@ imageToTexture (CompScreen   *screen,
 		width * 4);
 
     makeScreenCurrent (screen);
-    releasePixmapFromTexture (screen, texture);
+    (*screen->releasePixmapFromTexture) (screen, texture);
 
     if (screen->textureNonPowerOfTwo ||
 	(POWER_OF_TWO (width) && POWER_OF_TWO (height)))
@@ -138,7 +140,7 @@ imageToTexture (CompScreen   *screen,
 
     glBindTexture (texture->target, texture->name);
 
-    glTexImage2D (texture->target, 0, GL_RGBA, width, height, 0, 
+    glTexImage2D (texture->target, 0, GL_RGBA, width, height, 0,
 		  format, type, data);
 
     texture->filter = GL_NEAREST;
@@ -226,7 +228,7 @@ iconToTexture (CompScreen *screen,
 }
 
 Bool
-bindPixmapToTexture (CompScreen  *screen,
+compBindPixmapToTexture (CompScreen  *screen,
 		     CompTexture *texture,
 		     Pixmap	 pixmap,
 		     int	 width,
@@ -356,7 +358,7 @@ bindPixmapToTexture (CompScreen  *screen
 }
 
 void
-releasePixmapFromTexture (CompScreen  *screen,
+compReleasePixmapFromTexture (CompScreen  *screen,
 			  CompTexture *texture)
 {
     if (texture->pixmap)
@@ -382,7 +384,7 @@ releasePixmapFromTexture (CompScreen  *s
 }
 
 void
-enableTexture (CompScreen	 *screen,
+compEnableTexture (CompScreen	 *screen,
 	       CompTexture	 *texture,
 	       CompTextureFilter filter)
 {
@@ -465,7 +467,7 @@ enableTexture (CompScreen	 *screen,
 }
 
 void
-disableTexture (CompScreen  *screen,
+compDisableTexture (CompScreen  *screen,
 		CompTexture *texture)
 {
     makeScreenCurrent (screen);
diff --git a/src/window.c b/src/window.c
index b1922f3..ada2036 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1243,7 +1243,7 @@ bindWindow (CompWindow *w)
 	if (attr.map_state != IsViewable)
 	{
 	    XUngrabServer (w->screen->display->display);
-	    finiTexture (w->screen, w->texture);
+	    (*w->screen->finiTexture) (w->screen, w->texture);
 	    w->damaged = FALSE;
 	    w->bindFailed = TRUE;
 	    return FALSE;
@@ -1255,7 +1255,7 @@ bindWindow (CompWindow *w)
 	XUngrabServer (w->screen->display->display);
     }
 
-    if (!bindPixmapToTexture (w->screen, w->texture, w->pixmap,
+    if (!(*w->screen->bindPixmapToTexture) (w->screen, w->texture, w->pixmap,
 			      w->width, w->height,
 			      w->attrib.depth))
     {
@@ -1275,10 +1275,10 @@ releaseWindow (CompWindow *w)
     {
 	CompTexture *texture;
 
-	texture = createTexture (w->screen);
+	texture = (*w->screen->createTexture) (w->screen);
 	if (texture)
 	{
-	    destroyTexture (w->screen, w->texture);
+	    (*w->screen->destroyTexture) (w->screen, w->texture);
 
 	    w->texture = texture;
 	}
@@ -1300,7 +1300,7 @@ freeWindow (CompWindow *w)
     if (w->syncWaitHandle)
 	compRemoveTimeout (w->syncWaitHandle);
 
-    destroyTexture (w->screen, w->texture);
+    (*w->screen->destroyTexture) (w->screen, w->texture);
 
     if (w->frame)
 	XDestroyWindow (w->screen->display->display, w->frame);
@@ -1829,7 +1829,7 @@ addWindow (CompScreen *screen,
     w->resName   = NULL;
     w->resClass  = NULL;
 
-    w->texture = createTexture (screen);
+    w->texture = (*screen->createTexture) (screen);
     if (!w->texture)
     {
 	free (w);
@@ -1909,7 +1909,7 @@ addWindow (CompScreen *screen,
 	w->privates = malloc (screen->windowPrivateLen * sizeof (CompPrivate));
 	if (!w->privates)
 	{
-	    destroyTexture (screen, w->texture);
+	    (*w->screen->destroyTexture) (screen, w->texture);
 	    free (w);
 	    return;
 	}
@@ -4593,7 +4593,7 @@ getWindowIcon (CompWindow *w,
 		    icon->width  = iw;
 		    icon->height = ih;
 
-		    initTexture (w->screen, &icon->texture);
+		    (*w->screen->initTexture) (w->screen, &icon->texture);
 
 		    p = (CARD32 *) (icon + 1);
 
@@ -4662,7 +4662,7 @@ freeWindowIcons (CompWindow *w)
 
     for (i = 0; i < w->nIcon; i++)
     {
-	finiTexture (w->screen, &w->icon[i]->texture);
+	(*w->screen->finiTexture) (w->screen, &w->icon[i]->texture);
 	free (w->icon[i]);
     }
 

Attachment: copymode_plugin.tar.gz
Description: application/tgz

_______________________________________________
compiz mailing list
compiz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/compiz

Reply via email to