Bug 92044

Summary: Matrix operations offset draw on widget creation.
Product: cairo Reporter: Chris S. Cowles <c_cowles>
Component: generalAssignee: Chris Wilson <chris>
Status: RESOLVED NOTABUG QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: major    
Priority: medium    
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Source files illustrating cairo matrix offset bug.

Description Chris S. Cowles 2015-09-18 22:56:34 UTC
Created attachment 118353 [details]
Source files illustrating cairo matrix offset bug.

When using cairo (version 1.14.3) in creating a widget, matrix use causes image to be offset within the cairo_t.  This can be illustrated by drawing with/without an identity matrix. (Matrix is needed for image rotation on widget.) An example is attached. Define "USE_MATRIX" in the header file to turn on the error. Environment used: Debian 4.8.4-1, Linux version 3.16.0-4-amd64, gcc version 4.9.2
Comment 1 Uli Schlachter 2015-09-20 11:25:55 UTC
This works as documented. Try using things like cairo_rotate() instead of overwriting the matrix. At least try something like this:

cairo_matrix_t matrix, identity_matrix;
cairo_get_matrix(cr, &matrix);
cairo_matrix_init_identity(&identity_matrix); // This makes no sense, but feel free to replace with a rotation
cairo_matrix_multiply(&matrix, &matrix, &identity_matrix);
cairo_set_matrix(cr, &matrix);

(Technical detail: Gtk is giving you a cairo context onto a large surface and uses the matrix so that it appears to you as if the surface's (0, 0) were at the top-left corner of your widget. If you ignore the matrix, stuff breaks.)

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.