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

View File

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

View File

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

View File

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

View File

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