support cairo 0.5

svn: r459
This commit is contained in:
Matthew Flatt 2005-07-27 15:14:17 +00:00
parent 7a2aa170fb
commit 62d6db95c2
6 changed files with 80 additions and 58 deletions

View File

@ -415,15 +415,14 @@ case $OS in
X_CFLAGS="-I/usr/contrib/X11R6/include/ $X_CFLAGS"
X_LIBS="-L/usr/contrib/X11R6/lib/ $X_LIBS"
;;
SCO) # How do you really recognize SCO?
LIBS="$LIBS -lc -lsocket"
;;
CYGWIN*)
MZBINTARGET=cygwin-bin
MZINSTALLTARGET=cygwin-install
EXTRALIBS="$LIBS gmzwin.exp"
MZOPTIONS="$MZOPTIONS -DGC_DLL"
CGCOPTIONS="$CGCOPTIONS -DGC_DLL -DGC_BUILD -DUSE_MSVC_MD_LIBRARY -DMD_LIB_MAIN"
# Old cygwin approach, to make it Windows-like instead of Unix-like:
# MZBINTARGET=cygwin-bin
# MZINSTALLTARGET=cygwin-install
# EXTRALIBS="$LIBS gmzwin.exp"
# MZOPTIONS="$MZOPTIONS -DGC_DLL"
# CGCOPTIONS="$CGCOPTIONS -DGC_DLL -DGC_BUILD -DUSE_MSVC_MD_LIBRARY -DMD_LIB_MAIN"
BUILD_CYGWIN_LIKE_UNIX=yes
;;
BeOS)
if test "${enable_sgcdebug}" = "yes" ; then

View File

@ -1065,23 +1065,18 @@ double wxPathRgn::XFormH(double _h, double _y, Bool align)
return _h;
}
long wxPathRgn::PrepareScale(long target, Bool oe, Bool align)
void wxPathRgn::PrepareScale(long target, Bool oe, Bool align, void *_m)
{
#ifdef wx_xt
# ifdef WX_USE_CAIRO
if (align)
return 0;
else {
cairo_matrix_t *m;
m = cairo_matrix_create();
cairo_current_matrix(CAIRO_DEV, m);
if (!align) {
cairo_matrix_p *m = (cairo_matrix_p *)_m;
cairo_set_matrix_create(*m);
cairo_current_matrix(CAIRO_DEV, *m);
cairo_default_matrix(CAIRO_DEV);
cairo_translate(CAIRO_DEV, ox, oy);
cairo_scale(CAIRO_DEV, sx, sy);
return (long)m;
}
# else
return 0;
# endif
#endif
#ifdef wx_mac
@ -1091,21 +1086,19 @@ long wxPathRgn::PrepareScale(long target, Bool oe, Bool align)
current_xform = CGAffineTransformMakeTranslation(ox, oy);
current_xform = CGAffineTransformScale(current_xform, sx, sy);
}
return 0;
#endif
#ifdef wx_msw
current_path = wxGPathNew(oe ? FillModeAlternate : FillModeWinding);
return 0;
#endif
}
void wxPathRgn::RestoreScale(long target, long v, Bool align)
void wxPathRgn::RestoreScale(long target, Bool align, void *_m)
{
#ifdef WX_USE_CAIRO
if (v) {
cairo_matrix_t *m = (cairo_matrix_t *)v;
cairo_set_matrix(CAIRO_DEV, m);
cairo_matrix_destroy(m);
if (!align) {
cairo_matrix_p *m = (cairo_matrix_p *)_m;
cairo__set_matrix(CAIRO_DEV, *m);
cairo_matrix_destroy(*m);
}
#endif
#ifdef wx_mac
@ -1137,8 +1130,9 @@ wxRectanglePathRgn::wxRectanglePathRgn(wxDC *dc_for_scale, double _x, double _y,
Bool wxRectanglePathRgn::Install(long target, Bool reverse, Bool align)
{
double xx, yy, ww, hh;
long m;
m = PrepareScale(target, TRUE, align);
cairo_matrix_p m;
PrepareScale(target, TRUE, align, &m);
xx = XFormXB(x, align);
yy = XFormYB(y, align);
@ -1184,7 +1178,7 @@ Bool wxRectanglePathRgn::Install(long target, Bool reverse, Bool align)
wxGPathCloseFigure(CURRENT_GP);
#endif
RestoreScale(target, m, align);
RestoreScale(target, align, &m);
return FALSE;
}
@ -1229,8 +1223,9 @@ wxRoundedRectanglePathRgn::wxRoundedRectanglePathRgn(wxDC *dc_for_scale,
Bool wxRoundedRectanglePathRgn::Install(long target, Bool reverse, Bool align)
{
double xx, yy, ww, hh, rr, rr2;
long m;
m = PrepareScale(target, TRUE, align);
cairo_matrix_p m;
PrepareScale(target, TRUE, align, &m);
xx = XFormXB(x, align);
yy = XFormYB(y, align);
@ -1313,7 +1308,7 @@ Bool wxRoundedRectanglePathRgn::Install(long target, Bool reverse, Bool align)
wxGPathCloseFigure(CURRENT_GP);
#endif
RestoreScale(target, m, align);
RestoreScale(target, align, &m);
return FALSE;
}
@ -1371,8 +1366,9 @@ wxPolygonPathRgn::wxPolygonPathRgn(wxDC *dc_for_scale,
Bool wxPolygonPathRgn::Install(long target, Bool reverse, Bool align)
{
double xx, yy;
long m;
m = PrepareScale(target, fillStyle == wxODDEVEN_RULE, align);
cairo_matrix_p m;
PrepareScale(target, fillStyle == wxODDEVEN_RULE, align, &m);
#ifdef WX_USE_CAIRO
if (reverse) {
@ -1447,7 +1443,7 @@ Bool wxPolygonPathRgn::Install(long target, Bool reverse, Bool align)
wxGPathCloseFigure(CURRENT_GP);
#endif
RestoreScale(target, m, align);
RestoreScale(target, align, &m);
return (fillStyle == wxODDEVEN_RULE);
}
@ -1487,9 +1483,9 @@ wxPathPathRgn::wxPathPathRgn(wxDC *dc_for_scale,
Bool wxPathPathRgn::Install(long target, Bool reverse, Bool align)
{
wxPath *q;
long m;
cairo_matrix_p m;
m = PrepareScale(target, fillStyle == wxODDEVEN_RULE, align);
PrepareScale(target, fillStyle == wxODDEVEN_RULE, align, &m);
if (reverse) {
q = new wxPath();
@ -1520,7 +1516,7 @@ Bool wxPathPathRgn::Install(long target, Bool reverse, Bool align)
#endif
}
RestoreScale(target, m, align);
RestoreScale(target, align, &m);
return (fillStyle == wxODDEVEN_RULE);
}
@ -1546,9 +1542,9 @@ wxArcPathRgn::wxArcPathRgn(wxDC *dc_for_scale,
Bool wxArcPathRgn::Install(long target, Bool reverse, Bool align)
{
double xx, yy, ww, hh;
long m;
cairo_matrix_p m;
m = PrepareScale(target, TRUE, align);
PrepareScale(target, TRUE, align, &m);
xx = XFormXB(x, align);
yy = XFormYB(y, align);
@ -1611,7 +1607,7 @@ Bool wxArcPathRgn::Install(long target, Bool reverse, Bool align)
}
#endif
RestoreScale(target, m, align);
RestoreScale(target, align, &m);
return FALSE;
}

View File

@ -101,8 +101,8 @@ class wxPathRgn : public wxObject
~wxPathRgn();
virtual Bool Install(long target, Bool reverse, Bool align) = 0;
long PrepareScale(long target, Bool oe, Bool align);
void RestoreScale(long target, long v, Bool align);
void PrepareScale(long target, Bool oe, Bool align, void *m);
void RestoreScale(long target, Bool align, void *m);
virtual Bool InstallPS(wxPostScriptDC *dc, wxPSStream *s) = 0;

View File

@ -49,14 +49,7 @@
#endif
#include <X11/Intrinsic.h>
#ifdef WX_USE_CAIRO
extern "C" {
# include <cairo.h>
# ifndef WX_CAIRO_NO_XLIBH
# include <cairo-xlib.h>
# endif
};
#endif
#include "../wx_cairo.h"
#define UseXtRegions
#include "wx_rgn.h"
@ -1213,20 +1206,20 @@ void wxWindowDC::DrawArc(double x, double y, double w, double h, double start, d
if (SetCairoPen()) {
double xx, yy, ww, hh;
cairo_matrix_t *m;
cairo_matrix_p m;
xx = SmoothingXFormX(x);
yy = SmoothingXFormY(y);
ww = SmoothingXFormWL(w, x);
hh = SmoothingXFormHL(h, y);
m = cairo_matrix_create();
cairo_set_matrix_create(m);
cairo_current_matrix (CAIRO_DEV, m);
cairo_translate(CAIRO_DEV, xx, yy);
cairo_scale(CAIRO_DEV, ww, hh);
cairo_new_path(CAIRO_DEV);
cairo_arc_negative(CAIRO_DEV, 0.5, 0.5, 0.5, start, end);
cairo_set_matrix(CAIRO_DEV, m);
cairo__set_matrix(CAIRO_DEV, m);
cairo_stroke(CAIRO_DEV);
cairo_matrix_destroy(m);
}
@ -3616,9 +3609,10 @@ void wxWindowDC::InitCairoDev()
{
if (!X->cairo_dev) {
cairo_t *dev;
double ww, hh;
dev = cairo_create();
cairo_set_target_drawable(dev, wxAPP_DISPLAY, DRAWABLE);
GetSize(&ww, &hh);
cairo_set_create_xlib(dev, wxAPP_DISPLAY, DRAWABLE, wxAPP_VISUAL, (int)ww, (int)hh);
X->cairo_dev = (long)dev;
X->reset_cairo_clip = 1;
}

View File

@ -34,9 +34,7 @@
#define Uses_wxPostScriptDC
#include "wx.h"
#ifdef WX_USE_CAIRO
# include <cairo.h>
#endif
#include "../wx_cairo.h"
#include <math.h>

35
src/wxxt/src/wx_cairo.h Normal file
View File

@ -0,0 +1,35 @@
#ifdef WX_USE_CAIRO
extern "C" {
# include <cairo.h>
# ifndef WX_CAIRO_NO_XLIBH
# include <cairo-xlib.h>
# endif
};
/* Check API version: */
# ifdef cairo_set_rgb_color
/* New Cairo API (0.5 and up) */
typedef cairo_matrix_t cairo_matrix_p;
# undef cairo_set_rgb_color
# define cairo_set_rgb_color(d, r, g, b) cairo_set_source_rgb(d, r, g, b)
# define cairo_set_matrix_create(m) /* no op */
# undef cairo_current_matrix
# define cairo_current_matrix(d, m) cairo_get_matrix(d, &(m))
# undef cairo_matrix_destroy
# define cairo_matrix_destroy(m) /* no op */
# define cairo__set_matrix(CAIRO_DEV, m) cairo_set_matrix(CAIRO_DEV, &(m))
# define cairo_set_create_xlib(dev, display, drawable, vis, w, h) \
dev = cairo_create(cairo_xlib_surface_create(wxAPP_DISPLAY, DRAWABLE, vis, w, h))
# undef cairo_default_matrix
# define cairo_default_matrix(dev) cairo_identity_matrix(dev)
# undef cairo_init_clip
# define cairo_init_clip(dev) cairo_reset_clip(dev)
# else
/* Old Cairo API (0.5 and up) */
typedef cairo_matrix_t *cairo_matrix_p;
# define cairo_set_matrix_create(m) (m) = cairo_matrix_create();
# define cairo__set_matrix(CAIRO_DEV, m) cairo_set_matrix(CAIRO_DEV, m)
# define cairo_set_create_xlib(dev, display, drawable, vis, w, h) \
dev = cario_create(); cairo_set_target_drawable(dev, wxAPP_DISPLAY, DRAWABLE)
# endif
#endif