Dear Tim, Just read whenever you are ready. No hurry. Before actually reading, just apply the patches to a test checkout and have a look.
I think I got the cairo stuff in a reasonable shape. In this mail there a two patches. One to solve the issues of the previous patch and another to add UDrawGraphic. The only thing missing is render.c. Everything made for ./configure --without-tcl --without-tk --with-cairo Tested that I did not screw up things for the following configurations ./configure --without-tcl --without-tk ./configure --with-tcl --with-tk The patches should be applied incrementally, first the one from the previous e-mail, then the ones attached here zcat xc_cairo.patch.gz | patch -p1 zcat xc_cairo2.patch.gz | patch -p1 zcat xc_cairo_graphic.patch.gz | patch -p1 What follow is a description of the patches: - The selection of the XOR drawing colour has been replaced by the 'normal' colour when using cairo in menucalls:setelementstyle and text.c:UDrawTextLine. Also replaced the XSetXORFg / XcSetXORFg defines in xcircuit.h, to not perform the XOR action anymore. - Added cairo:xc_cairo_set_matrix, which takes a 'xcircuit Matrix' and sets the cairo affine matrix accordingly. Also added checks in functions.c, that call this function, whenever the DCTM is changed during a redraw. - Added cairo_save/restore around cairo.c:draw_grids. This caused the affine matrix for the first element to be wrong. - I want SetForeground to select the colour used for the drawing area. I want to keep XSetForeground for the toolkit drawing, eg like drawing the scrollbars. So I replaced a few XSetForeground-s which should have been SetForeground-s IMHO. Specifically in elements.c:unjoin, menucalls.c:setelementstyle, netlist.c:highlightnet and text.c:joinlabels. - Moved SetForeground to a define, which calls cairo.c:xc_cairo_set_color. This function now properly gets the rgb values from a colour index (previously it was just shifting and masking). Obtaining the rgb values is done by adding a new function xcircuit.c:xc_get_color_rgb. Added this to xcircuit.c, as I try to keep toolkit dependencies outside of cairo.c. - text.c:ULength used a float for the x-position, whereas text.c:UDrawString0 used a short (XPoint). This caused the cursor to be way off for long lines. Since the cairo fonts have floating point widths, I changed text.c:UDrawString0 to also use floats (XfPoint). Furthermore, text.c:UDrawChar and cairo.c:UDrawchar now return float values. Also added a new function xc_cairo_get_char_extents to be used inside function.c:ULength. - text.c:ULength used a float for the x-position, whereas text.c:UDrawString0 used a short (XPoint). This caused the cursor to be way off for long lines. Since the cairo fonts have floating point widths, I changed text.c:UDrawString0 to also use floats (XfPoint). Furthermore, text.c:UDrawChar and cairo.c:UDrawchar now return float values. Also added a new function xc_cairo_get_char_extents to be used inside function.c:ULength. - Changed the way font dimensions are obtained. For smaller fonts the dimensions can change significantly due to hinting and/or grid-fitting. To remain independent of scale, the dimensions are obtained by using a fixed font size of 100. Each character is still drawn hinted, but the advancement/spacing between character as scale independent. TODO: for speed, since this is fixed, maybe obtain the dimensions in fontfile.c:loadfontfile. Or is cairo already caching font dimensions? - events.c:panhbar, events.c:panvbar and events.c:trackpan, now correctly update the drawing area. - fontfile.c:loadfontfile: added a missing check if the cairo font should be used or the 'old' xcircuit fonts. - splitted functions.c:UDrawRescaleBox into two function, functions.c:UGetRescaleBox for the logic and functions.c:UDrawRescaleBox for the actual drawing. This also removes all the xcircuit logic from cairo.c:UDrawRescaleBox TODO: Minor visual issue: When drawing, the selected parts and/or highlighted nets (Alt-w) are drawn first in the normal colour. Afterwards they are drawn over for the selected/highlighted items. This was never a problem, since the drawing was perfect. With cairo however the drawing of the edges of lines/fonts is partly transparent. This causes the underlying line to be partly seen. E.g. in the examples/buses.ps, when highlighting a net, the edges of the text (originally red) contrast very heavy with the highlight colour (green), showing minor artifacts. Also the highlighted nets are a somewhat darker green due to this effect. Maybe prevent selected parts from being drawn in the first place, or (Q&D) make highlighting one pixel wider than the original line. ------------------------------------ The next patch is a bit more intrusive. It adds a cairo version of graphic:UDrawGraphic. I made the behavior of UDrawGraphic the same as the postscript output. Maybe it is by design, but I cannot get the image to flip. A horizontal flip will rotate 180 degrees. A vertical flip won't do anything. I have to check this later. To make this patch reasonably clean, I had to make a combination of XImage and cairo_surface_t. Both have different access methods for the pixels, so I generalized it to an xcImage, with the following methods. img=xcImageCreate(w,h) xcImageDestroy(img) w=xcImageGetWidth(img) h=xcImageGetHeight(img) xcImagePutPixel(img,x,y,r,g,b) xcImageGetPixel(img,x,y,*r,*g,*b) Finally, is there a (technical) reason why importing graphics is not implemented for Xt? Opening files with graphics inside seems to works fine. I added a files.c:importgraphic and added this function to files.c:getfile. Also the menu option was added to menus.h. I put everything in between HAVE_CAIRO, in case there is a technical problem with Xt and graphics. Erik.
_______________________________________________ Xcircuit-dev mailing list Xcircuit-dev@opencircuitdesign.com http://www.opencircuitdesign.com/mailman/listinfo/xcircuit-dev