Around 16 o''clock on Jul 16, "Matthew Allen" wrote:> I''m wondering whether there is a single pass method to draw text with a > background using Xft? Just flat color, nothing special.There is not currently such an API, but of course you could easily build one on top of the existing API if you like by allocating a temporary pixmap to build the composite image in. This is precisely what Xft would do internally as the X render extension doesn''t provide this operation. By allocating only a temporary pixmap, you wouldn''t introduce any permanant additional memory overhead. If you added this code to Xft, you might want to optimize the non-Render case to avoid the GetImage. -keith
On Wed, 2003-07-16 at 02:04, Matthew Allen wrote:> Hi, > > I''m wondering whether there is a single pass method to draw text with a background using Xft? Just flat color, nothing special. > > Something like XftDrawStringUtf8 with an extra couple of parameters for a rectangle and color. > > This would make it much easier to write flicker free code. Currently I have to fill the area behind the text using a > rectangle primitive and then overlay the text, and of course this doesn''t happen instantly so between the 2 operations you > get background color only on the screen... and thus flicker. Yes I know double buffering fixes this, but the speed + memory > hit is a bit much for simple things like standard GUI widgets (tree/list/button etc). > > This is one reason windows _looks_ a lot smoother than most X applications, because they can do this. I don''t see why it can''t be done > (maybe I''m missing something in the API?) because it''s fairly simple at a technical level.I think you''ll find that in any more than simplistic situation, you can''t reliably a "DrawImageString" type primitive to prevent flicker - e.g., modern toolkits allow buttons to have themed buttons with a gradient or pixmap. Double buffer. It''s not the speed hit you think it is; blits are *fast* these days. And there is no reason to keep double buffers around permanently. Regards, Owen (Note that there are *performance* reasons to special case drawing on a solid background, but it''s possible to optimize that without complicating the API with just a bit of cleverness.)
I dont have this problem, maybe you could post a snippet of your code which does this for you. -- Matthew Allum on Wed, Jul 16, 2003 at 04:04:38PM +1000, Matthew Allen wrote:> Hi, > > I''m wondering whether there is a single pass method to draw text with a background using Xft? Just flat color, nothing special. > > Something like XftDrawStringUtf8 with an extra couple of parameters for a rectangle and color. > > This would make it much easier to write flicker free code. Currently I have to fill the area behind the text using a rectangle primitive and then overlay the text, and of course this doesn''t happen instantly so between the 2 operations you get background color only on the screen... and thus flicker. Yes I know double buffering fixes this, but the speed + memory hit is a bit much for simple things like standard GUI widgets (tree/list/button etc). > > This is one reason windows _looks_ a lot smoother than most X applications, because they can do this. I don''t see why it can''t be done (maybe I''m missing something in the API?) because it''s fairly simple at a technical level. > > regards > -- > Matthew Allen > (fret@memecode.com) (http://www.memecode.com) > > > _______________________________________________ > Fontconfig mailing list > Fontconfig@fontconfig.org > http://mail.fontconfig.org/mailman/listinfo/fontconfig >
Hi, I''m wondering whether there is a single pass method to draw text with a background using Xft? Just flat color, nothing special. Something like XftDrawStringUtf8 with an extra couple of parameters for a rectangle and color. This would make it much easier to write flicker free code. Currently I have to fill the area behind the text using a rectangle primitive and then overlay the text, and of course this doesn''t happen instantly so between the 2 operations you get background color only on the screen... and thus flicker. Yes I know double buffering fixes this, but the speed + memory hit is a bit much for simple things like standard GUI widgets (tree/list/button etc). This is one reason windows _looks_ a lot smoother than most X applications, because they can do this. I don''t see why it can''t be done (maybe I''m missing something in the API?) because it''s fairly simple at a technical level. regards -- Matthew Allen (fret@memecode.com) (http://www.memecode.com)