Closed Bug 323566 Opened 15 years ago Closed 15 years ago

16bpp Visuals don't work with cairo-gtk2

Categories

(Core :: Graphics, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: Biesinger, Unassigned)

References

Details

(Keywords: crash)

Attachments

(1 file, 2 obsolete files)

I thought I'd file this, since I actually have a partial patch...

My graphics card is a voodoo 3; I use 16bpp mode because that's the only one with 3d accel.

First, some analysis: The build crashes on startup because a render format is null where it shouldn't be; It turns out that it fails for a certain visual:
WORKS
  visual:
    visual id:    0x23
    class:    TrueColor
    depth:    16 planes
    available colormap entries:    64 per subfield
    red, green, blue masks:    0xf800, 0x7e0, 0x1f
    significant bits in color specification:    6 bits

FAILS
  visual:
    visual id:    0x33
    class:    DirectColor
    depth:    16 planes
    available colormap entries:    64 per subfield
    red, green, blue masks:    0xf800, 0x7e0, 0x1f
    significant bits in color specification:    6 bits

This visual is used here:
#3  0x00c288a3 in gfxPlatformGtk::CreateOffscreenSurface (this=0xa176d60, width=184, height=116,
    imageFormat=gfxASurface::ImageFormatARGB32, fastPixelAccess=0)
    at ../../../../../mozilla/gfx/thebes/src/gfxPlatformGtk.cpp:111
111                                                 GDK_VISUAL_XVISUAL(gdk_visual_get_best()));

107                 GdkPixmap *pixmap = ::gdk_pixmap_new(nsnull, width, height, bpp);
108
109                 newSurface = new gfxXlibSurface(GDK_WINDOW_XDISPLAY(GDK_DRAWABLE(pixmap)),
110                                                 GDK_WINDOW_XWINDOW(GDK_DRAWABLE(pixmap)),
111                                                 GDK_VISUAL_XVISUAL(gdk_visual_get_best()));

I have a patch to make this use the right render format directly. However, if that patch is applied, I get an X error:
The program 'Gecko' received an X Window System error.
This probably reflects a bug in the program.
The error was 'RenderBadPicture (invalid Picture parameter)'.
  (Details: serial 546 error_code 182 request_code 155 minor_code 26)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
oh heh, that line I pasted was already the result of a bit of local hacking. but the original code crashed too (the pixmap had no colormap iirc)
Attached patch partial patch, v2 (obsolete) — Splinter Review
this gets a bit further, but then I get a lot of:
(Gecko:7032): Gdk-WARNING **: Attempt to draw a drawable with depth 16 to a drawable with depth 32

and
(Gecko:7032): Gdk-WARNING **: The gdk_draw_*_image require the drawable argument to
have a specified colormap. All windows have a colormap,
however, pixmaps only have colormap by default if they
were created with a non-NULL window argument. Otherwise
a colormap must be set on them with gdk_drawable_set_colormap

and in the end, gecko crashes again with:
The program 'Gecko' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadMatch (invalid parameter attributes)'.
  (Details: serial 1538 error_code 8 request_code 66 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
Attachment #208612 - Attachment is obsolete: true
I also get various warnings about themes, like:
GTK theme failed for widget type 200, error was 8, state was [active=0,focused=0,inHover=1,disabled=0]
WARNING: GTK theme failed; disabling unsafe widget, file ../../../../../mozilla/widget/src/gtk2/nsNativeThemeGTK.cpp, line 599

And the X error is also caused by a theme, via moz_gtk_scrollbar_button_paint etc.
(In reply to comment #1)
> oh heh, that line I pasted was already the result of a bit of local hacking.
> but the original code crashed too (the pixmap had no colormap iirc)

OK, the original code didn't crash, but didn't work either (nothing got painted in the window), with these console messages:

(Gecko:3849): Gdk-CRITICAL **: gdk_drawable_set_colormap: assertion `cmap == NULL || gdk_drawable_get_depth (drawable) == cmap->visual->depth' failed

(Gecko:3849): Gdk-CRITICAL **: gdk_x11_visual_get_xvisual: assertion `visual != NULL' failed

Attached patch patch?Splinter Review
this works, but is probably not a good idea...

Maybe RGB24 should get mapped to gdk_rgb_get_visual()->depth, and the caller that wants native theme drawing should use RGB24. That way, this function needs not ignore the request to use alpha. (NOTE, I haven't verified that alpha is actually asked for here). All the non-RGB24 variants could then use the XRenderPictFormat variant as in the above partial patch v2.
Attachment #208614 - Attachment is obsolete: true
Current state: 16bpp visuals work (vlad checked in a fix), but now my other machine is broken... mozilla tries to create a 32bpp visual but can't set a colormap on it:
(Gecko:7727): Gdk-CRITICAL **: gdk_drawable_set_colormap: assertion `cmap == NULL || gdk_drawable_get_depth (drawable) == cmap->visual->depth' failed

I guess cmap->visual->depth is 24 rather than 32.
I've just built a cairo-gtk2 firefox from CVS, and I'm having this error:

The error was 'RenderBadPicture (invalid Picture parameter)'.
  (Details: serial 2406 error_code 179 request_code 154 minor_code 7)

My xorg.conf is configured for 24 bit.

Do you think this is related ?
I believe that's a different bug... roc saw it, I think.
Trunk is in really bad shape for cairo-gtk2 right now. I've got some fixes to various X errors that hopefully will cover whatever was going on here.
Should this bug be closed as WFM or Fixed, or perhaps as a dupe of bug 318423?
This should be resolved by bug 327874's fixes.
Depends on: 327874
this bug has survived its usefulness. cairo works in 16bpp for me now (since the checkin mentioned in comment 7), as well as 24bpp (probably bug 327874), marking fixed.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.