[cairo] 64 bit fixed point in Cairo?
nick.allen at onlinehome.de
Wed Apr 13 07:35:31 PDT 2011
We have an application that has its own widget framework that uses cairo
to render its graphics. We are noticing graphical glitches and mistakes
when we pass large coordinates to cairo's functions (values in the range
of around 8 million). These large coordinates occur because we have a
scroller widget that contains a very large widget that the user can
scroll around. The user can zoom in and out of this widget so the widget
can easily get to much more than 8 million pixels wide. Ideally we would
like to support values upto around 1 << 50 (so 8 million is a extremely
low limit for us). When the widget being scrolled is painted we
translate by its position inside the scroller and then clip using the
widget's bounds and then the widget paints itself.
I have looked into the cairo code and noticed that it does all fixed
point stuff in 32 bits with an 8 bit fractional part. This would explain
the severely limiting values that cairo imposes on us and why this
problem occurs. It seems a shame that cairo uses 32 bit fixed point
values but 64 bit double values for non-fixed point stuff. Has anyone
worked on supporting larger fixed point values (eg 64 bit)? Are there
any branches that support this?
cairo-fixed-type-private.h file defines this:
/* Eventually, we should allow changing this, but I think
* there are some assumptions in the tesselator about the
* size of a fixed type. For now, it must be 32.
#define CAIRO_FIXED_BITS 32
/* The number of fractional bits. Changing this involves
* making sure that you compute a double-to-fixed magic number.
* (see below).
#define CAIRO_FIXED_FRAC_BITS 8
/* A signed type %CAIRO_FIXED_BITS in size; the main fixed point type */
typedef int32_t cairo_fixed_t;
/* An unsigned type of the same size as #cairo_fixed_t */
typedef uint32_t cairo_fixed_unsigned_t;
It seems cairo is stuck at using 32 bit fixed point because of the
tessalator. Can anyone comment on the state of this?
More information about the cairo