[cairo-commit] cairo/src cairo_gl_surface.c, 1.10, 1.11 cairo_gstate.c, 1.53, 1.54

David Reveman commit at pdx.freedesktop.org
Mon Jun 21 15:13:54 PDT 2004


Committed by: davidr

Update of /cvs/cairo/cairo/src
In directory pdx:/tmp/cvs-serv25409/src

Modified Files:
	cairo_gl_surface.c cairo_gstate.c 
Log Message:
Glitz updates and a minor clipping fix

Index: cairo_gl_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gl_surface.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** cairo_gl_surface.c	11 Jun 2004 15:08:27 -0000	1.10
--- cairo_gl_surface.c	21 Jun 2004 22:13:52 -0000	1.11
***************
*** 133,136 ****
--- 133,137 ----
      int rowstride;
      cairo_format_masks_t format;
+     glitz_pixel_format_t pf;
  
      if (surface->hints & GLITZ_HINT_PROGRAMMATIC_MASK)
***************
*** 141,161 ****
      height = glitz_surface_get_height (surface->surface);
  
!     rowstride = (width * (surface->format->bpp / 8) + 3) & -4;
! 
!     pixels = (char *) malloc (sizeof (char) * height * rowstride);
  
!     glitz_surface_read_pixels (surface->surface, 0, 0, width, height, pixels);
  
!     format.bpp = surface->format->bpp;
!     format.red_mask = surface->format->red_mask;
!     format.green_mask = surface->format->green_mask;
!     format.blue_mask = surface->format->blue_mask;
!     format.alpha_mask = surface->format->alpha_mask;
  
      image = (cairo_image_surface_t *)
          _cairo_image_surface_create_with_masks (pixels,
  						&format,
  						width, height, rowstride);
! 
      _cairo_image_surface_assume_ownership_of_data (image);
  
--- 142,188 ----
      height = glitz_surface_get_height (surface->surface);
  
!     if (surface->format->red_size > 0) {
! 	format.bpp = 32;
! 	
! 	if (surface->format->alpha_size > 0)
! 	    format.alpha_mask = 0xff000000;
! 	else
! 	    format.alpha_mask = 0x0;
! 	
! 	format.red_mask = 0xff0000;
! 	format.green_mask = 0xff00;
! 	format.blue_mask = 0xff;
!     } else {
! 	format.bpp = 8;
! 	format.blue_mask = format.green_mask = format.red_mask = 0x0;
! 	format.alpha_mask = 0xff;
!     }
  
!     rowstride = (((width * format.bpp) / 8) + 3) & -4;
  
!     pf.masks.bpp = format.bpp;
!     pf.masks.alpha_mask = format.alpha_mask;
!     pf.masks.red_mask = format.red_mask;
!     pf.masks.green_mask = format.green_mask;
!     pf.masks.blue_mask = format.blue_mask;
!     pf.xoffset = 0;
!     pf.bytes_per_line = rowstride;
!     pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
  
+     pixels = (char *) malloc (height * rowstride);
+     if (!pixels)
+ 	return NULL;
+     
+     glitz_get_pixels (surface->surface,
+ 		      0, 0,
+ 		      width, height,
+ 		      &pf,
+ 		      pixels);
+     
      image = (cairo_image_surface_t *)
          _cairo_image_surface_create_with_masks (pixels,
  						&format,
  						width, height, rowstride);
!     
      _cairo_image_surface_assume_ownership_of_data (image);
  
***************
*** 171,178 ****
  {
      cairo_gl_surface_t *surface = abstract_surface;
  
!     glitz_surface_draw_pixels (surface->surface, 0, 0,
! 			       image->width, image->height, image->data);
  
      return CAIRO_STATUS_SUCCESS;
  }
--- 198,230 ----
  {
      cairo_gl_surface_t *surface = abstract_surface;
+     glitz_pixel_format_t pf;
  
!     if (image->depth > 8) {
! 	pf.masks.bpp = 32;
! 	
! 	if (surface->format->alpha_size)
! 	    pf.masks.alpha_mask = 0xff000000;
! 	else
! 	    pf.masks.alpha_mask = 0x0;
! 	
! 	pf.masks.red_mask = 0xff0000;
! 	pf.masks.green_mask = 0xff00;
! 	pf.masks.blue_mask = 0xff;
!     } else {
! 	pf.masks.bpp = 8;
! 	pf.masks.alpha_mask = 0xff;
! 	pf.masks.red_mask = pf.masks.green_mask = pf.masks.blue_mask = 0x0;
!     }
  
+     pf.xoffset = 0;
+     pf.bytes_per_line = (((image->width * pf.masks.bpp) / 8) + 3) & -4;
+     pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
+ 
+     glitz_put_pixels (surface->surface,
+ 		      0, 0,
+ 		      image->width, image->height,
+ 		      &pf,
+ 		      image->data);
+     
      return CAIRO_STATUS_SUCCESS;
  }
***************
*** 209,215 ****
      static glitz_convolution_t gaussian = {
          {
!             {0, 1 << 16, 0},
!             {1 << 16, 4 << 16, 1 << 16},
!             {0, 1 << 16, 0}
          }
      };
--- 261,267 ----
      static glitz_convolution_t gaussian = {
          {
!             { 0, 1 << 16, 0 },
!             { 1 << 16, 4 << 16, 1 << 16 },
!             { 0, 1 << 16, 0 }
          }
      };
***************
*** 333,339 ****
      glitz_format_t *glitz_format;
      unsigned long option_mask;
      
      option_mask = GLITZ_FORMAT_OPTION_OFFSCREEN_MASK;
!     if (!drawable)
  	option_mask |= GLITZ_FORMAT_OPTION_READONLY_MASK;
  
--- 385,395 ----
      glitz_format_t *glitz_format;
      unsigned long option_mask;
+     glitz_format_name_t format_name = _glitz_format (format);
      
      option_mask = GLITZ_FORMAT_OPTION_OFFSCREEN_MASK;
! 
!     if (drawable)
! 	option_mask |= GLITZ_FORMAT_OPTION_READDRAW_MASK;
!     else
  	option_mask |= GLITZ_FORMAT_OPTION_READONLY_MASK;
  
***************
*** 343,347 ****
      glitz_format =
  	glitz_surface_find_similar_standard_format (src->surface, option_mask,
! 						    _glitz_format (format));
      if (glitz_format == NULL)
  	return NULL;
--- 399,411 ----
      glitz_format =
  	glitz_surface_find_similar_standard_format (src->surface, option_mask,
! 						    format_name);
!     if (glitz_format == NULL) {
! 	option_mask &= ~GLITZ_FORMAT_OPTION_READDRAW_MASK;
! 	glitz_format =
! 	    glitz_surface_find_similar_standard_format (src->surface,
! 							option_mask,
! 							format_name);
!     }
!     
      if (glitz_format == NULL)
  	return NULL;
***************
*** 352,361 ****
  	return NULL;
  
-     src->hints = glitz_surface_get_hints (src->surface);
-     if ((!CAIRO_GL_SURFACE_MULTISAMPLE (src)) &&
- 	(src->format->multisample.samples < 2)) {
- 	glitz_surface_set_polyedge (surface, GLITZ_POLYEDGE_SHARP);
-     }
- 
      crsurface = _cairo_gl_surface_create (surface, 1);
      if (crsurface == NULL)
--- 416,419 ----
***************
*** 639,653 ****
  
  static void
- _cario_gl_uint_to_power_of_two (unsigned int *value)
- {
-     unsigned int x = 1;
- 
-     while (x < *value)
- 	x <<= 1;
- 
-     *value = x;
- }
- 
- static void
  _cairo_gl_create_color_range (cairo_pattern_t *pattern,
  			      unsigned char *data,
--- 697,700 ----
***************
*** 685,692 ****
  	source = glitz_surface_create_solid (&color);
      } break;
!     case CAIRO_PATTERN_LINEAR:
!     case CAIRO_PATTERN_RADIAL: {
! 	unsigned int color_range_size;
  	glitz_color_range_t *color_range;
  
  	if (!CAIRO_GL_FRAGMENT_PROGRAM_SUPPORT (surface))
--- 732,746 ----
  	source = glitz_surface_create_solid (&color);
      } break;
!     case CAIRO_PATTERN_RADIAL:
! 	/* glitz doesn't support inner circle yet. */
! 	if (pattern->u.radial.center0.x != pattern->u.radial.center1.x ||
! 	    pattern->u.radial.center0.y != pattern->u.radial.center1.y)
! 	    return CAIRO_INT_STATUS_UNSUPPORTED;
! 	/* fall-through */
!     case CAIRO_PATTERN_LINEAR: {
! 	int color_range_size;
  	glitz_color_range_t *color_range;
+ 	int width = ((box->p2.x + 65535) >> 16) - (box->p1.x >> 16);
+ 	int height = ((box->p2.y + 65535) >> 16) - (box->p1.y >> 16);
  
  	if (!CAIRO_GL_FRAGMENT_PROGRAM_SUPPORT (surface))
***************
*** 699,722 ****
              (!CAIRO_GL_TEXTURE_MIRRORED_REPEAT_SUPPORT (surface)))
  	    return CAIRO_INT_STATUS_UNSUPPORTED;
  
! 	if (pattern->type == CAIRO_PATTERN_LINEAR) {
! 	    double dx, dy;
! 
! 	    dx = pattern->u.linear.point1.x - pattern->u.linear.point0.x;
! 	    dy = pattern->u.linear.point1.y - pattern->u.linear.point0.y;
! 
! 	    color_range_size = sqrt (dx * dx + dy * dy);
! 	} else {
! 	    /* glitz doesn't support inner circle yet. */
! 	    if (pattern->u.radial.center0.x != pattern->u.radial.center1.x ||
! 		pattern->u.radial.center0.y != pattern->u.radial.center1.y)
! 		return CAIRO_INT_STATUS_UNSUPPORTED;
! 
! 	    color_range_size = pattern->u.radial.radius1;
! 	}
! 
! 	if ((!CAIRO_GL_TEXTURE_NPOT_SUPPORT (surface)))
! 	    _cario_gl_uint_to_power_of_two (&color_range_size);
! 
  	color_range = glitz_color_range_create (color_range_size);
  	if (!color_range)
--- 753,767 ----
              (!CAIRO_GL_TEXTURE_MIRRORED_REPEAT_SUPPORT (surface)))
  	    return CAIRO_INT_STATUS_UNSUPPORTED;
+ 	
+ 	/* TODO: how do we figure out the color range resolution? transforming
+ 	   the gradient vector with the inverse of the pattern matrix should
+ 	   give us a good hint. */
+ 	color_range_size = 512;
  
! 	/* destination surface size less than color range size, an image
! 	   gradient is probably more efficient. */
! 	if ((width * height) <= color_range_size)
! 	    return CAIRO_INT_STATUS_UNSUPPORTED;
! 	
  	color_range = glitz_color_range_create (color_range_size);
  	if (!color_range)
***************
*** 726,730 ****
  				      glitz_color_range_get_data (color_range),
  				      color_range_size);
! 
  	switch (pattern->extend) {
  	case CAIRO_EXTEND_REPEAT:
--- 771,777 ----
  				      glitz_color_range_get_data (color_range),
  				      color_range_size);
! 	
! 	glitz_color_range_put_back_data (color_range);
! 	
  	switch (pattern->extend) {
  	case CAIRO_EXTEND_REPEAT:

Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** cairo_gstate.c	11 Jun 2004 13:20:17 -0000	1.53
--- cairo_gstate.c	21 Jun 2004 22:13:52 -0000	1.54
***************
*** 1363,1366 ****
--- 1363,1367 ----
      cairo_pattern_t pattern;
      cairo_box_t extents;
+     int x_src, y_src;
  
      if (traps->num_traps == 0)
***************
*** 1405,1408 ****
--- 1406,1417 ----
  	}
  
+ 	if (traps->traps[0].left.p1.y < traps->traps[0].left.p2.y) {
+ 	    x_src = _cairo_fixed_to_double (traps->traps[0].left.p1.x);
+ 	    y_src = _cairo_fixed_to_double (traps->traps[0].left.p1.y);
+ 	} else {
+ 	    x_src = _cairo_fixed_to_double (traps->traps[0].left.p2.x);
+ 	    y_src = _cairo_fixed_to_double (traps->traps[0].left.p2.y);
+ 	}
+ 
  	_cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);
  	_cairo_pattern_set_alpha (&pattern, 1.0);
***************
*** 1415,1419 ****
  	status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_ADD,
  						      pattern.source, intermediate,
! 						      0, 0,
  						      traps->traps,
  						      traps->num_traps);
--- 1424,1429 ----
  	status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_ADD,
  						      pattern.source, intermediate,
! 						      x_src,
! 						      y_src,
  						      traps->traps,
  						      traps->num_traps);
***************
*** 1466,1477 ****
  	
      } else {
- 	int xoff, yoff;
- 
  	if (traps->traps[0].left.p1.y < traps->traps[0].left.p2.y) {
! 	    xoff = _cairo_fixed_to_double (traps->traps[0].left.p1.x);
! 	    yoff = _cairo_fixed_to_double (traps->traps[0].left.p1.y);
  	} else {
! 	    xoff = _cairo_fixed_to_double (traps->traps[0].left.p2.x);
! 	    yoff = _cairo_fixed_to_double (traps->traps[0].left.p2.y);
  	}
  
--- 1476,1485 ----
  	
      } else {
  	if (traps->traps[0].left.p1.y < traps->traps[0].left.p2.y) {
! 	    x_src = _cairo_fixed_to_double (traps->traps[0].left.p1.x);
! 	    y_src = _cairo_fixed_to_double (traps->traps[0].left.p1.y);
  	} else {
! 	    x_src = _cairo_fixed_to_double (traps->traps[0].left.p2.x);
! 	    y_src = _cairo_fixed_to_double (traps->traps[0].left.p2.y);
  	}
  
***************
*** 1485,1490 ****
  	status = _cairo_surface_composite_trapezoids (gstate->operator,
  						      pattern.source, dst,
! 						      xoff - pattern.source_offset.x,
! 						      yoff - pattern.source_offset.y,
  						      traps->traps,
  						      traps->num_traps);
--- 1493,1498 ----
  	status = _cairo_surface_composite_trapezoids (gstate->operator,
  						      pattern.source, dst,
! 						      x_src - pattern.source_offset.x,
! 						      y_src - pattern.source_offset.y,
  						      traps->traps,
  						      traps->num_traps);





More information about the cairo-commit mailing list