[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[E-devel] xrender engine patch



    Attached is a small test patch for some xrender engine changes.
Index: e17/libs/evas/src/modules/engines/xrender_x11/evas_engine_gradient.c
===================================================================
RCS file: /var/cvs/e/e17/libs/evas/src/modules/engines/xrender_x11/evas_engine_gradient.c,v
retrieving revision 1.2
diff -u -r1.2 evas_engine_gradient.c
--- e17/libs/evas/src/modules/engines/xrender_x11/evas_engine_gradient.c	2 May 2006 07:28:49 -0000	1.2
+++ e17/libs/evas/src/modules/engines/xrender_x11/evas_engine_gradient.c	11 May 2006 03:55:41 -0000
@@ -164,8 +164,10 @@
 _xre_gradient_draw(Xrender_Surface *rs, RGBA_Draw_Context *dc, XR_Gradient *gr, int x, int y, int w, int h, double angle, int spread)
 {
    RGBA_Image *im;
+   int   mul_use;
    
    if ((w <= 0) || (h <= 0)) return;
+   if (!rs || !dc || !gr) return;
    
    if ((angle != gr->angle) || (spread != gr->spread) || (gr->changed))
      {
@@ -201,7 +203,10 @@
 	     evas_common_image_free(im);
 	  }
      }
+   mul_use = dc->mul.use;
+   dc->mul.use = 0;
    if (gr->surface)
      _xr_render_surface_composite(gr->surface, rs, dc, 0, 0, gr->surface->w, gr->surface->h, x, y, w, h, 1);
+   dc->mul.use = mul_use;
    gr->changed = 0;
 }
Index: e17/libs/evas/src/modules/engines/xrender_x11/evas_engine_xrender.c
===================================================================
RCS file: /var/cvs/e/e17/libs/evas/src/modules/engines/xrender_x11/evas_engine_xrender.c,v
retrieving revision 1.7
diff -u -r1.7 evas_engine_xrender.c
--- e17/libs/evas/src/modules/engines/xrender_x11/evas_engine_xrender.c	11 May 2006 00:24:48 -0000	1.7
+++ e17/libs/evas/src/modules/engines/xrender_x11/evas_engine_xrender.c	11 May 2006 03:55:43 -0000
@@ -11,6 +11,7 @@
    Xrender_Surface *rs;
    XRenderPictureAttributes att;
    
+   if ((!xinf) || (!fmt) || (w < 1) || (h < 1)) return NULL;
    rs = calloc(1, sizeof(Xrender_Surface));
    if (!rs) return NULL;
    rs->xinf = xinf;
@@ -21,11 +22,23 @@
    rs->depth = fmt->depth;
    rs->allocated = 1;
    rs->draw = XCreatePixmap(xinf->disp, xinf->root, w, h, fmt->depth);
+   if (rs->draw == None)
+     {
+	free(rs);
+	return NULL;
+     }
    rs->xinf->references++;
    att.dither = 0;
    att.component_alpha = 0;
    att.repeat = 0;
    rs->pic = XRenderCreatePicture(xinf->disp, rs->draw, fmt, CPRepeat | CPDither | CPComponentAlpha, &att);
+   if (rs->pic == None)
+     {
+	XFreePixmap(rs->xinf->disp, rs->draw);
+	rs->xinf->references--;
+        free(rs);
+	return NULL;
+     }
    return rs;
 }
 
@@ -36,9 +49,11 @@
    XRenderPictFormat *fmt;
    XRenderPictureAttributes att;
    
+   if ((!xinf) || (draw == None) || (w < 1) || (h < 1)) return NULL;
    fmt = XRenderFindVisualFormat(xinf->disp, xinf->vis);
    if (!fmt) return NULL;
    rs = calloc(1, sizeof(Xrender_Surface));
+   if (!rs) return NULL;
    rs->xinf = xinf;
    rs->w = w;
    rs->h = h;
@@ -53,6 +68,12 @@
    att.component_alpha = 0;
    att.repeat = 0;
    rs->pic = XRenderCreatePicture(xinf->disp, rs->draw, fmt, CPRepeat | CPDither | CPComponentAlpha, &att);
+   if (rs->pic == None)
+     {
+	rs->xinf->references--;
+        free(rs);
+	return NULL;
+     }
    return rs;
 }
 
@@ -62,7 +83,9 @@
    Xrender_Surface *rs;
    XRenderPictureAttributes att;
    
+   if ((!xinf) || (!fmt) || (draw == None) || (w < 1) || (h < 1)) return NULL;
    rs = calloc(1, sizeof(Xrender_Surface));
+   if (!rs) return NULL;
    rs->xinf = xinf;
    rs->w = w;
    rs->h = h;
@@ -77,16 +100,28 @@
    att.component_alpha = 0;
    att.repeat = 0;
    rs->pic = XRenderCreatePicture(xinf->disp, rs->draw, fmt, CPRepeat | CPDither | CPComponentAlpha, &att);
+   if (rs->pic == None)
+     {
+	rs->xinf->references--;
+        free(rs);
+	return NULL;
+     }
    return rs;
 }
 
 void
 _xr_render_surface_free(Xrender_Surface *rs)
 {
-   if (rs->allocated) XFreePixmap(rs->xinf->disp, rs->draw);
-   XRenderFreePicture(rs->xinf->disp, rs->pic);
-   _xr_image_info_free(rs->xinf);
-   rs->xinf = NULL;
+   if (!rs) return;
+   if (rs->xinf)
+     {
+	if ((rs->allocated) && (rs->draw != None))
+	   XFreePixmap(rs->xinf->disp, rs->draw);
+	if (rs->pic != None)
+	   XRenderFreePicture(rs->xinf->disp, rs->pic);
+	_xr_image_info_free(rs->xinf);
+	rs->xinf = NULL;
+     }
    free(rs);
 }
 
@@ -105,7 +140,7 @@
    XRenderColor col;
    int aa;
    
-   aa = a +1;
+   aa = a + 1;
    r = (r * aa) >> 8;
    g = (g * aa) >> 8;
    b = (b * aa) >> 8;
@@ -173,20 +208,18 @@
 	     sple = sp + w;
 	     while (sp < sple)
 	       {
-		  switch (a = A_VAL(sp))
+		  switch (a = (*sp & 0xff000000))
 		  {
 		    case 0:
 			*p = 0;
 		    break;
-		    case 255:
+		    case 0xff000000:
 			*p = *sp;
 		    break;
 		    default:
-			aa = a + 1;
-			r = ((R_VAL(sp)) * aa) >> 8;
-			g = ((G_VAL(sp)) * aa) >> 8;
-			b = ((B_VAL(sp)) * aa) >> 8;
-			*p = (a << 24) | (r << 16) | (g << 8) | b;
+			aa = (a >> 24) + 1;
+			*p = a + (((((*sp) >> 8) & 0xff) * aa) & 0xff00) + 
+			     (((((*sp) & 0x00ff00ff) * aa) >> 8) & 0x00ff00ff);
 		    break;
 		  }
 		  p++;
@@ -240,7 +273,7 @@
 	     sple = sp + w;
 	     while (sp < sple)
 	       {
-		  *p = 0xff000000 | ((R_VAL(sp)) << 16) | ((G_VAL(sp)) << 8) | (B_VAL(sp));
+		  *p = 0xff000000 | *sp;
 		  p++;
 		  sp++;
 	       }
@@ -361,21 +394,25 @@
 		  xf.matrix[2][1] = 0;
 		  xf.matrix[2][2] = 1 << 16;
 		  if ((srs->alpha) || (a != 0xff))
-		    trs = _xr_render_surface_new(srs->xinf, sw + 1, sh + 1,
+		  //  trs = _xr_render_surface_new(srs->xinf, sw + 1, sh + 1,
+		    trs = _xr_render_surface_new(srs->xinf, sw, sh,
 						 srs->xinf->fmt32, 1);
 		  else
-		    trs = _xr_render_surface_new(srs->xinf, sw + 1, sh + 1,
+		  //  trs = _xr_render_surface_new(srs->xinf, sw + 1, sh + 1,
+		    trs = _xr_render_surface_new(srs->xinf, sw, sh,
 						 srs->fmt, srs->alpha);
 		  XRenderSetPictureTransform(srs->xinf->disp, srs->pic, &xf);
 		  XRenderComposite(srs->xinf->disp, PictOpSrc, srs->pic, mask,
 				   trs->pic, sx, sy, 0, 0, 0, 0, sw, sh);
 		  /* fill right and bottom pixel so interpolation works right */
+		  /*
 		  XRenderComposite(srs->xinf->disp, PictOpSrc, srs->pic, mask,
 				   trs->pic, sx + sw, sy, 0, 0, sw, 0, 1, sh);
 		  XRenderComposite(srs->xinf->disp, PictOpSrc, srs->pic, mask,
 				   trs->pic, sx, sy + sh, 0, 0, 0, sh, sw + 1, 1);
 		  XRenderComposite(srs->xinf->disp, PictOpSrc, srs->pic, mask,
 				   trs->pic, sx + sw, sy, 0, 0, sw, 0, 1, sh);
+		  */
 		  mask = 0;
 	       }
 	  }
@@ -450,17 +487,17 @@
    XRenderPictureAttributes att;
 
    if ((w <= 0) || (h <= 0) || (!srs) || (!drs)) return;
-   xf.matrix[0][0] = 1;
+   xf.matrix[0][0] = 1 << 16;
    xf.matrix[0][1] = 0;
    xf.matrix[0][2] = 0;
    
    xf.matrix[1][0] = 0;
-   xf.matrix[1][1] = 1;
+   xf.matrix[1][1] = 1 << 16;
    xf.matrix[1][2] = 0;
    
    xf.matrix[2][0] = 0;
    xf.matrix[2][1] = 0;
-   xf.matrix[2][2] = 1;
+   xf.matrix[2][2] = 1 << 16;
    
    XRenderSetPictureTransform(srs->xinf->disp, srs->pic, &xf);
    att.clip_mask = None;
@@ -479,13 +516,13 @@
    XRenderPictureAttributes att;
    int r, g, b, a, aa, op;
 
-   if ((w <= 0) || (h <= 0)) return;
+   if ((w <= 0) || (h <= 0) || (!rs) || (!dc)) return;
    a = (dc->col.col >> 24) & 0xff;
    if (a == 0) return;
    r = (dc->col.col >> 16) & 0xff;
    g = (dc->col.col >> 8 ) & 0xff;
    b = (dc->col.col      ) & 0xff;
-   aa = a +1;
+   aa = a + 1;
    r = (r * aa) >> 8;
    g = (g * aa) >> 8;
    b = (b * aa) >> 8;
@@ -508,6 +545,7 @@
    XRenderPictureAttributes att;
    int op;
    
+   if ((!rs) || (!dc)) return;
    op = PictOpSrc;
    att.clip_mask = None;
    XRenderChangePicture(rs->xinf->disp, rs->pic, CPClipMask, &att);
@@ -565,6 +603,7 @@
    XRenderPictureAttributes att;
    int op;
    
+   if ((!rs) || (!dc)) return;
    op = PictOpSrc;
    num = 0;
    for (pt = points; pt; pt = (RGBA_Polygon_Point *)(((Evas_Object_List *)pt)->next)) num++;