[cairo-commit] cairo/src cairo_gl_surface.c,1.9,1.10

David Reveman commit at pdx.freedesktop.org
Fri Jun 11 08:08:31 PDT 2004


Committed by: davidr

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

Modified Files:
	cairo_gl_surface.c 
Log Message:
Software multi-sample support

Index: cairo_gl_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gl_surface.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** cairo_gl_surface.c	24 May 2004 09:28:05 -0000	1.9
--- cairo_gl_surface.c	11 Jun 2004 15:08:27 -0000	1.10
***************
*** 92,98 ****
  
  #define CAIRO_GL_COMPOSITE_TRAPEZOIDS_SUPPORT(surface) \
!     ((surface->format->stencil_size >= \
!         ((surface->hints & GLITZ_HINT_CLIPPING_MASK)? 2: 1)) || \
!     CAIRO_GL_OFFSCREEN_SUPPORT (surface))
  
  #define CAIRO_GL_SURFACE_IS_OFFSCREEN(surface) \
--- 92,97 ----
  
  #define CAIRO_GL_COMPOSITE_TRAPEZOIDS_SUPPORT(surface) \
!     (surface->format->stencil_size >= \
!         ((surface->hints & GLITZ_HINT_CLIPPING_MASK)? 2: 1))
  
  #define CAIRO_GL_SURFACE_IS_OFFSCREEN(surface) \
***************
*** 103,106 ****
--- 102,108 ----
       (surface->pattern.type == CAIRO_PATTERN_SOLID))
  
+ #define CAIRO_GL_SURFACE_MULTISAMPLE(surface) \
+     (surface->hints & GLITZ_HINT_MULTISAMPLE_MASK)
+ 
  static void
  _cairo_gl_surface_destroy (void *abstract_surface)
***************
*** 335,338 ****
--- 337,343 ----
      if (!drawable)
  	option_mask |= GLITZ_FORMAT_OPTION_READONLY_MASK;
+ 
+     if (src->format->multisample.samples < 2)
+ 	option_mask |= GLITZ_FORMAT_OPTION_NO_MULTISAMPLE_MASK;
      
      glitz_format =
***************
*** 347,350 ****
--- 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)
***************
*** 511,514 ****
--- 522,553 ----
  }
  
+ static int
+ _cairo_gl_extract_rectangle (cairo_trapezoid_t *trap,
+ 			     cairo_rectangle_t *rect)
+ {
+     if (trap->left.p1.x == trap->left.p2.x &&
+ 	trap->right.p1.x == trap->right.p2.x &&
+ 	trap->left.p1.y == trap->right.p1.y &&
+ 	trap->left.p2.y == trap->right.p2.y &&
+ 	_cairo_fixed_is_integer (trap->left.p1.x) &&
+ 	_cairo_fixed_is_integer (trap->left.p1.y) &&
+ 	_cairo_fixed_is_integer (trap->left.p2.x) &&
+ 	_cairo_fixed_is_integer (trap->left.p2.y) &&
+ 	_cairo_fixed_is_integer (trap->right.p1.x) &&
+ 	_cairo_fixed_is_integer (trap->right.p1.y) &&
+ 	_cairo_fixed_is_integer (trap->right.p2.x) &&
+ 	_cairo_fixed_is_integer (trap->right.p2.y)) {
+ 	
+ 	rect->x = _cairo_fixed_integer_part (trap->left.p1.x);
+ 	rect->y = _cairo_fixed_integer_part (trap->left.p1.y);
+ 	rect->width = _cairo_fixed_integer_part (trap->right.p1.x) - rect->x;
+ 	rect->height = _cairo_fixed_integer_part (trap->left.p2.y) - rect->y;
+ 	
+ 	return 1;
+     }
+     
+     return 0;
+ }
+ 
  static cairo_int_status_t
  _cairo_gl_surface_composite_trapezoids (cairo_operator_t operator,
***************
*** 540,550 ****
      if ((generic_src->backend == dst->base.backend) &&
  	(src->pattern.type == CAIRO_PATTERN_SOLID)) {
  
! 	/* We can use fill trapezoids if only one trapezoid should be drawn or
! 	   if solid color alpha is 1.0. If composite trapezoid support
! 	   is missing we always use fill trapezoids. */
! 	if ((num_traps == 1) ||
!             (src->pattern.color.alpha == 1.0) ||
!             (!CAIRO_GL_COMPOSITE_TRAPEZOIDS_SUPPORT (dst)))
  	    return _cairo_gl_surface_fill_trapezoids (dst, operator,
  						      &src->pattern.color,
--- 579,595 ----
      if ((generic_src->backend == dst->base.backend) &&
  	(src->pattern.type == CAIRO_PATTERN_SOLID)) {
+ 	cairo_rectangle_t rect;
  
! 	/* Check to see if we can represent these traps as a rectangle. */
! 	if (num_traps == 1 && _cairo_gl_extract_rectangle (traps, &rect))
! 	    return _cairo_gl_surface_fill_rectangles (dst, operator,
! 						      &src->pattern.color,
! 						      &rect, 1);
! 	
! 	/* If we're not using software multi-sampling, then we can use
! 	   fill trapezoids if only one trapezoid should be drawn or if
! 	   solid color alpha is 1.0. */
! 	if ((!CAIRO_GL_SURFACE_MULTISAMPLE (dst)) &&
! 	    (num_traps == 1 || src->pattern.color.alpha == 1.0))
  	    return _cairo_gl_surface_fill_trapezoids (dst, operator,
  						      &src->pattern.color,
***************
*** 552,555 ****
--- 597,603 ----
      }
  
+     if (!CAIRO_GL_COMPOSITE_TRAPEZOIDS_SUPPORT (dst))
+ 	return CAIRO_INT_STATUS_UNSUPPORTED;
+ 
      if (generic_src->backend != dst->base.backend) {
  	src_clone = _cairo_gl_surface_clone_similar (generic_src, dst,





More information about the cairo-commit mailing list