Bug 13411 - pattern and dashes incompatible!
Summary: pattern and dashes incompatible!
Status: RESOLVED DUPLICATE of bug 9189
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.4.10
Hardware: All All
: high normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-27 11:43 UTC by Charles Doutriaux
Modified: 2008-09-28 13:52 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
cairo configure log (67.51 KB, application/octet-stream)
2007-11-27 14:42 UTC, Charles Doutriaux
Details
good (working) ps file (1.69 KB, application/postscript)
2007-11-27 14:46 UTC, Charles Doutriaux
Details
bad (weird lines) ps file (182.33 KB, application/postscript)
2007-11-27 14:52 UTC, Charles Doutriaux
Details

Description Charles Doutriaux 2007-11-27 11:43:59 UTC
when using dashes and patterns the putput "freaks" out for lines!
This is postscript only, cairo works great with png for example
I'm pasting a small C example, turn on/off any of do32, dodashes or dopattern
ude <cairo.h>
#include <cairo-ps.h>
 int main() {
cairo_surface_t *surface=NULL;
cairo_t *cr=NULL;
cairo_pattern_t *pattern=NULL;
cairo_surface_t *image=NULL;
cairo_t *cr2=NULL;
 double dashes[4] ;
int ndashes;
double offset=0.;
 dashes[0]=8.;
 dashes[1]=4.;
 dashes[2]=4.;
 dashes[3]=4.;
 ndashes = 4;
 int dodash = 1;
 int dopattern = 1;
 int do32=1;

 surface = cairo_ps_surface_create("crap.ps",611,792);
cairo_ps_surface_dsc_begin_setup (surface);
cairo_ps_surface_dsc_begin_page_setup (surface);
cr = cairo_create (surface);
cairo_set_line_cap (cr,CAIRO_LINE_CAP_ROUND);
cairo_set_source_rgb (cr, 0.000000,1.000000,0.000000);
 if (dopattern) {
   if (do32) image = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,4,4);
   else image = cairo_image_surface_create(CAIRO_FORMAT_RGB24,4,4);
   cr2 = cairo_create (image);
   cairo_set_source(cr2,cairo_get_source(cr));
   cairo_move_to(cr2,0,0);
   cairo_line_to(cr2,0,3);
   cairo_line_to(cr2,3,3);
   cairo_fill(cr2);
   pattern = cairo_pattern_create_for_surface (image);
   cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
   cairo_set_source(cr,pattern);
 }
cairo_move_to(cr,136.372589,619.799988);
cairo_line_to(cr,136.372589,172.199997);
cairo_line_to(cr,491.490326,172.199997);
cairo_line_to(cr,491.490326,619.799988);
cairo_line_to(cr,136.372589,619.799988);
cairo_fill(cr);
cairo_set_source_rgb (cr, 0.000000,0.000000,0.000000);
if (dodash) { cairo_set_dash(cr,dashes,ndashes,0.);}
cairo_move_to(cr,136.372589,470.600006);
cairo_line_to(cr,491.490326,172.199997);
cairo_line_to(cr,550.676575,396.000000);
cairo_line_to(cr,77.186295,396.000000);
cairo_stroke(cr);
 cairo_show_page(cr);
cairo_surface_flush(surface);
cairo_surface_finish(surface);
cairo_surface_destroy (surface);
cairo_destroy (cr);
}
Comment 1 Adrian Johnson 2007-11-27 14:03:09 UTC
I am unable to reproduce the problem. What PostScript viewer are you using?

Can you attach the PostScript output and screenshots of the problem.


Comment 2 Charles Doutriaux 2007-11-27 14:42:14 UTC
Created attachment 12748 [details]
cairo configure log
Comment 3 Charles Doutriaux 2007-11-27 14:44:55 UTC
reproducible under mac/lunix, cairo 1.4.10 or 1.4.12 (not 1.5.2, but i have other things that break under 1.5.2)

I'm attaching the "good" (no pattenr) and bad (dash,argb32,pattern) version as ps

I'm also pasting here my gs version:
gs --version
8.57
and my config.log file is attached
Comment 4 Charles Doutriaux 2007-11-27 14:46:22 UTC
Created attachment 12749 [details]
good (working) ps file

"good" (except the black background in pattern), but the line is correct
Comment 5 Charles Doutriaux 2007-11-27 14:52:27 UTC
Created attachment 12751 [details]
bad (weird lines) ps file

now simply by creating the image pattern as ARGB32 i get this!
or it works if i turn off the dashes...
NOTE I had to reduce the size of the square otherwise the ps couldn't be attached, but the bug (lines) is still here
Comment 6 Adrian Johnson 2007-11-28 01:24:50 UTC
When using the PostScript backend to draw something that is not supported by PostScript, cairo will use fallback images. Before 1.5.2 many drawing operations that could be supported by PostScript were not implemented in the PostScript backend which resulted in unnecessary fallback images. An additional problem was that full page fallback images were used.

In the example you attached you are painting an ARGB32 image. The PostScript backend assumes this contains transparency. As PostScript does not support transparency the backend uses a full page image fallback. You can see in bad.ps that it contains one big image.

This has been fixed in 1.5.2 where ARGB32 images are analyzed to check if they really do contain transparency and all fallback images only cover the unsupported region instead of the entire page.

The problem of the incorrectly drawn dashed line is in the fallback image. I don't know what the problem is but as it is not a problem with the PostScript backend I am moving this bug to general.

You mentioned that you have found regressions in 1.5.2. Please open bug reports for these problems as we would like to fix them before the 1.6 release.
Comment 7 Chris Wilson 2008-09-28 13:52:19 UTC
Since Adrian has resolved one half of the problem, this bug reduces to incorrect stroking of dashed lines in fallback images, namely bug 9189.

*** This bug has been marked as a duplicate of bug 9189 ***


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.