[cairo] perf: long dashed lines

Vladimir Vukicevic vladimir at pobox.com
Thu Jan 31 12:07:58 PST 2008


I'm running into a perf problem that's related to the 'long-dashed- 
lines' test we have in the test suite.  I added that benchmark at one  
point because dashed lines weren't going through the draw_rectangles  
path; however, now we have a problem where dashed paths that are way  
outside the destination surface bounds are still going through the  
full stroker pipeline.  If the test is modified to do:

    cairo_move_to (cr, -width * 3.0, y0);
    cairo_line_to (cr, width * 3.0, y0);

instead of (0, y0) -> (width, y0), the performance decreases...  
something like 174ms -> 852ms here.  Here's the profile:

         (Self)     (Total)
	10.7%	93.2%	libcairo.2.dylib	            _cairo_stroker_line_to_dashed	
	2.3%	65.6%	libcairo.2.dylib	             _cairo_stroker_add_sub_edge	
	19.8%	36.7%	libcairo.2.dylib	              _compute_face	
	5.9%	5.9%	libcairo.2.dylib	               _cairo_fixed_from_double	
	4.8%	4.8%	libcairo.2.dylib	                
cairo_matrix_transform_distance	
	3.7%	3.7%	libcairo.2.dylib	               _cairo_fixed_to_double	
	1.5%	1.5%	libcairo.2.dylib	               _translate_point	
	0.9%	0.9%	libcairo.2.dylib	                
_cairo_matrix_compute_determinant	
	8.2%	26.6%	libcairo.2.dylib	               
_cairo_traps_tessellate_convex_quad	
	0.0%	0.0%	libcairo.2.dylib	               
cairo_matrix_transform_distance	
	0.0%	0.0%	libcairo.2.dylib	              _compare_point_fixed_by_y	
	5.9%	5.9%	libcairo.2.dylib	             _cairo_fixed_from_double	
	5.1%	5.1%	libcairo.2.dylib	             _cairo_stroker_step_dash	
	2.4%	2.9%	libcairo.2.dylib	             _cairo_stroker_add_leading_cap	
	1.8%	1.8%	libcairo.2.dylib	              
cairo_matrix_transform_distance	
	0.3%	1.2%	libcairo.2.dylib	              
_cairo_stroker_add_trailing_cap	
	0.1%	0.1%	libcairo.2.dylib	             _cairo_stroker_add_cap	
	0.0%	0.0%	libcairo.2.dylib	             _compute_face	
	0.0%	0.0%	libcairo.2.dylib	             _cairo_fixed_to_double	
	0.0%	0.0%	libcairo.2.dylib	            _cairo_stroker_add_leading_cap	
	0.0%	0.0%	libcairo.2.dylib	            cairo_matrix_transform_distance	


Any thoughts on where we could optimize this?  The complex thing seems  
to be in making sure that the dash pattern starts at the right point  
when the path is visible again.

     - Vlad



More information about the cairo mailing list