Bug 21111 - Pattern surfaces don't work with xlib surfaces
Summary: Pattern surfaces don't work with xlib surfaces
Status: VERIFIED INVALID
Alias: None
Product: cairo
Classification: Unclassified
Component: xlib backend (show other bugs)
Version: 1.8.0
Hardware: Other All
: medium normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-10 08:10 UTC by Mukund Sivaraman
Modified: 2009-04-10 09:41 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
GTK+ test (1.61 KB, text/plain)
2009-04-10 08:35 UTC, Chris Wilson
Details

Description Mukund Sivaraman 2009-04-10 08:10:31 UTC
The following code creates 'pcontext' which is made to hold a tiling pattern, and then uses it to fill 'context' whose surface is a GtkDrawingArea. But 'pcontext' appears nowhere on 'context'.

        cairo_t *context;
        cairo_surface_t *surface;
        cairo_t *pcontext;

        context = gdk_cairo_create (GDK_DRAWABLE (window));

        surface = cairo_surface_create_similar
                (cairo_get_group_target (context),
                 CAIRO_CONTENT_COLOR_ALPHA, 4, 4);
        pcontext = cairo_create (surface);
        cairo_surface_destroy (surface);

        cairo_new_path (pcontext);
        cairo_set_source_rgba (pcontext, 1.0, 0.0, 0.0, 0.8);
        cairo_rectangle (pcontext, 1, 1, 2, 2);
        cairo_fill (pcontext);

        cairo_set_source_surface (context, cairo_get_target (pcontext),
                                  0, 0);
        cairo_pattern_set_extend (cairo_get_source (context),
                                  CAIRO_EXTEND_REPEAT);
        cairo_destroy (pcontext);

        cairo_move_to (context, 100.5, 100.5);
        cairo_line_to (context, 100.5, 600.5);
        cairo_line_to (context, 600.5, 600.5);
        cairo_line_to (context, 600.5, 550.5);
        cairo_line_to (context, 150.5, 550.5);
        cairo_line_to (context, 150.5, 100.5);
        cairo_line_to (context, 100.5, 100.5);
        cairo_fill (context);

        cairo_destroy (context);


On replacing cairo_surface_create_similar() with cairo_image_surface_create(), this problem disappears. But using the xlib surface is preferable due to acceleration.

FYI, I'm running this on a stock fully updated Fedora 10 x86_64 distro:

cairo-1.8.0-1.fc10.x86_64
gtk2-2.14.7-7.fc10.x86_64

(--) PCI:*(0 at 1:0:0) ATI Technologies Inc Radeon Mobility X1400 rev 0,
Mem @ 0xd8000000/134217728, 0xee100000/65536, I/O @ 0x00002000/256,

(II) Loading /usr/lib64/xorg/modules/drivers//radeon_drv.so
(II) Module radeon: vendor="X.Org Foundation"
        compiled for 1.5.3, module version = 6.10.0
        Module class: X.Org Video Driver
        ABI class: X.Org Video Driver, version 4.1
Comment 1 Chris Wilson 2009-04-10 08:35:54 UTC
Created attachment 24696 [details]
GTK+ test

Hmm, seems to work here. Please check the attached test case for any discrepancies.
Comment 2 Mukund Sivaraman 2009-04-10 09:14:05 UTC
This is so weird.. the attached test case works, but the same code in my app isn't displaying the pattern.

Please don't close this bug yet. Let me find out what is different and get back to you.
Comment 3 Mukund Sivaraman 2009-04-10 09:41:29 UTC
It seems that I had changed the (4, 4) resolution arguments to cairo_surface_create_similar() with (width, height) when I didn't have CAIRO_EXTEND_REPEAT set and was trying to debug why the pattern was not showing.

When this changed to 4, 4, it seems to work well.

Chris: Thank you for the testcase, and I'm sorry for wasting your time. I'll close this bug now as INVALID.
Comment 4 Mukund Sivaraman 2009-04-10 09:41:52 UTC
Verified as INVALID.


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.