Monday 20 February 2006
Cairo, Linux And GTK2 Themes
In the last week or two I've been spending most of my time working on cairo-gtk2 trunk builds, trying to get them back into shape. Vlad did some wonderful, long-needed work to move all double-buffering and window translucency management out of the view manager into into platform-specific windowing code, in a very elegant way, but he only updated Windows, so GTK2 needed to catch up there. When I fixed that, I encountered a serious cairo issue --- it was creating 24-bit temporary pixmaps for the offscreen buffer, which was killing performance on my 16-bit display setup --- and it took a while to diagnose and fix (in cairo).
But the biggest chunk of work has been reenabling GTK2 native themes in cairo builds, without which Firefox looks completely naff. This isn't easy since we want to be able to render GTK2 themes to any cairo context (e.g., a PDF context, or a screen context with some rotation applied) but GTK2 themes expect to be rendering to an X pixmap or window. We can hack around this by having the theme render to an offscreen pixmap and then extracting the data, but that's painful and slow especially when the theme paints with transparency or translucency. It's important that the common case of painting the theme to an X window with no scaling or rotation remain as efficient as it is today. Well, it's done :-).
One bonus of this work is that we can finally enable GTK2 themes for HTML content. We never did so before because we never wrote the code to handle rendering to a non-X printing context (i.e. render to temporary pixmaps and send them as images to the printer). Now that we've solved this problem in a general way, we will (when my patches land) turn on GTK2 themes for HTML. The screenshot below is using the "Industrial" theme. The Cancel button is being hovered.
But the biggest chunk of work has been reenabling GTK2 native themes in cairo builds, without which Firefox looks completely naff. This isn't easy since we want to be able to render GTK2 themes to any cairo context (e.g., a PDF context, or a screen context with some rotation applied) but GTK2 themes expect to be rendering to an X pixmap or window. We can hack around this by having the theme render to an offscreen pixmap and then extracting the data, but that's painful and slow especially when the theme paints with transparency or translucency. It's important that the common case of painting the theme to an X window with no scaling or rotation remain as efficient as it is today. Well, it's done :-).
One bonus of this work is that we can finally enable GTK2 themes for HTML content. We never did so before because we never wrote the code to handle rendering to a non-X printing context (i.e. render to temporary pixmaps and send them as images to the printer). Now that we've solved this problem in a general way, we will (when my patches land) turn on GTK2 themes for HTML. The screenshot below is using the "Industrial" theme. The Cancel button is being hovered.
Comments
But how about to enable current Firefox skins for HTML content (buttons, etc.)?
RichB: No, I didn't know that. Interesting...
Eike: These widgets are still stylable by Web authors. We disable GTK2 themes on styled widgets in exactly the same way Firefox does on Windows --- which is pretty close to what IE does --- so I think that's what people and authors will expect...
I sometimes see other widgets painting, but almost instantaneously they are overdrawn by the background color.
~Grauw
Eike: how do you know GTK2 themes look out of place on some Websites? I'm not aware of any other implementation of GTK2 themes for HTML.
"Going native" has significant potential benefits for UI consistency and aesthetic appeal. In any case I'm afraid that your opinion has not won the day, almost all users use a browser that supports native themes, and if you don't like it, you still have the option of changing your GTK2 theme to somethine more "neutral".
Nico: I'm not 100% sure what you mean, but "print to PDF" is definitely a feature we're planning to have for 1.9. How well it works will depend more on cairo than on our code.
_FrenchFrgg_: Yes. My changes fix these issues.
I see one small bug: in that screenshot <select>s look like combo boxes, when they should look like option menus (what the HIG calls "drop-down lists"). These two controls have identical appearance on Windows for some bizarre reason, but on other platforms, including GTK, they look different.
[BTW, the comment preview on your Weblog is broken.]
Thanks
What's with the:
TAKING FAST PATH
TAKING SLOW PATH: unsupported clip
??
i tried latest trunk from ftp://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/experimental/cairo/
but i still get the old style html buttons etc
I mean, new trunk builds have the cairo enabled, but I can't get gtk forms in my PC... Is there something that should be enabled?