summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFabien Costantini <fabien@onepost.net>2008-10-19 01:42:35 +0000
committerFabien Costantini <fabien@onepost.net>2008-10-19 01:42:35 +0000
commit268ffc6ef2477f83a0d48af2d64baf3c00e6cddc (patch)
tree4a500fa6716a5334f705d7d2d761771d6e28fba7 /src
parent7a5e64a4f3c8e1126dba6909ba7379c2100b055c (diff)
Cairo increment 2: Finer cairo granularity, less deps, new fltk_cairo lib
+ added new USE_CAIRO config preprocessor def. to differentiate from HAVE_CAIRO so that we can use the cairo lib without forcing the full fltk lib to be linked against it. In that case, cairo autolink context functionality which needs fltk lib instrumentation is disabled. + added new --enable-cairoext, which correspond to previous --enable-cairo. now, --enable-cairo only adds HAVE_CAIRO def. and keeps fltk lib from referencing cairo. In both cases (--enable-cairo & --enable-cairoext), a new fltk_cairo lib is created. This lib, similarly to local versions of png,jpeg and zlib, is not generated if cairo is not enabled. + added cairo to fltk-config : now new --use-cairo flag is available + modified all unix like makefiles to now generate minimum cairo deps and also new libfltk_cairo lib. + added new cairo subdir to permit conditional fltk_cairo lib generation. + vc2005 project minimum update to compile without be broken, but still needs to create a similar fltk_cairo independent lib. For now, it works as before with a dedicated cairo env. similar to --enable-cairoext context in unix. + regression tested ok with cairo disabled on win32, mac osx, mingw. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6462 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl.cxx2
-rw-r--r--src/Fl_Cairo.cxx149
-rw-r--r--src/Fl_Double_Window.cxx2
-rw-r--r--src/Fl_Menu_Window.cxx4
-rw-r--r--src/Fl_Overlay_Window.cxx2
-rw-r--r--src/Fl_Window.cxx2
-rw-r--r--src/Fl_mac.cxx8
-rw-r--r--src/Makefile10
8 files changed, 15 insertions, 164 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 3c826e774..57d8cf778 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -1184,7 +1184,7 @@ void Fl_Window::hide() {
fl_release_dc(fl_window, fl_gc);
fl_window = (HWND)-1;
fl_gc = 0;
-# ifdef HAVE_CAIRO
+# ifdef USE_CAIRO
if (Fl::cairo_autolink_context()) Fl::cairo_make_current((Fl_Window*) 0);
# endif
}
diff --git a/src/Fl_Cairo.cxx b/src/Fl_Cairo.cxx
deleted file mode 100644
index eb79c37de..000000000
--- a/src/Fl_Cairo.cxx
+++ /dev/null
@@ -1,149 +0,0 @@
-//
-// "$Id$"
-//
-// Main header file for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 1998-2008 by Bill Spitzak and others.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Library General Public
-// License as published by the Free Software Foundation; either
-// version 2 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Library General Public License for more details.
-//
-// You should have received a copy of the GNU Library General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-//
-// Please report all bugs and problems on the following page:
-//
-// http://www.fltk.org/str.php
-//
-
-#include <config.h>
-
-#ifdef HAVE_CAIRO
-#include <FL/Fl.H>
-#include <FL/x.H>
-#include <FL/Fl_Window.H>
-
-// static Fl module initialization :
-Fl_Cairo_State Fl::cairo_state_; ///< contains all necesary info for current cairo context mapping
-// Fl cairo features implementation
-
-/**
- Provides a corresponding cairo context for window \a wi.
- This is needed in a draw() override if Fl::cairo_autolink_context()
- returns false, which is the default.
- The cairo_context() does not need to be freed as it is freed every time
- a new cairo context is created. When the program terminates,
- a call to Fl::cairo_make_current(0) will destroy any residual context.
- \note A new cairo context is not always re-created when this method
- is used. In particular, if the current graphical context and the current
- window didn't change between two calls, the previous gc is internally kept,
- thus optimizing the drawing performances.
- Also, after this call, Fl::cairo_gc() is adequately updated with this
- cairo context.
- \note Only available when configure has the --enable-cairo option
- \return the valid cairo_t* cairo context associated to this window.
-*/
-cairo_t * Fl::cairo_make_current(Fl_Window* wi) {
- if (!wi) return NULL; // Precondition
-
- if (fl_gc==0) { // means remove current cc
- Fl::cairo_cc(0); // destroy any previous cc
- cairo_state_.window(0);
- return 0;
- }
-
- // don't re-create a context if it's the same gc/window couple
- if (fl_gc==Fl::cairo_state_.gc() && fl_xid(wi) == (Window) Fl::cairo_state_.window())
- return Fl::cairo_cc();
-
- cairo_state_.window(wi);
-
-#if defined(USE_X11)
- return Fl::cairo_make_current(0, wi->w(), wi->h());
-#else
- return Fl::cairo_make_current(fl_gc, wi->w(), wi->h());
-#endif
-}
-
-/*
- Creates transparently a cairo_surface_t object.
- gc is an HDC context in WIN32, a CGContext* in Quartz, a display on X11
- */
-static cairo_surface_t * cairo_create_surface(void * gc, int W, int H) {
-# if defined(USE_X11)
- return cairo_xlib_surface_create(fl_display, fl_window, fl_visual->visual, W, H);
-# elif defined(WIN32)
- return cairo_win32_surface_create((HDC) gc);
-# elif defined(__APPLE_QUARTZ__)
- return cairo_quartz_surface_create_for_cg_context((CGContext*) gc, W, H);
-# else
-# error Cairo is not supported under this platform.
-# endif
-}
-
-/**
- Creates a cairo context from a \a gc only, get its window size or offscreen size if fl_window is null.
- \note Only available when configure has the --enable-cairo option
-*/
-cairo_t * Fl::cairo_make_current(void *gc) {
- int W=0,H=0;
-#if defined(USE_X11)
- //FIXME X11 get W,H
- // gc will be the window handle here
-# warning FIXME get W,H for cairo_make_current(void*)
-#elif defined(__APPLE_QUARTZ__)
- if (fl_window) {
- Rect portRect;
- GetPortBounds(GetWindowPort( fl_window ), &portRect);
- W = portRect.right-portRect.left;
- H = portRect.bottom-portRect.top;
- }
- else {
- W = CGBitmapContextGetHeight(fl_gc);
- H = CGBitmapContextGetHeight(fl_gc);
- }
-#elif defined(WIN32)
- // we don't need any W,H for WIN32
-#else
-# error Cairo is not supported under this platform.
-#endif
- if (!gc) {
- Fl::cairo_cc(0);
- cairo_state_.gc(0); // keep track for next time
- return 0;
- }
- if (gc==Fl::cairo_state_.gc() && fl_window== (Window) Fl::cairo_state_.window())
- return Fl::cairo_cc();
- cairo_state_.gc(fl_gc); // keep track for next time
- cairo_surface_t * s = cairo_create_surface(gc, W, H);
- cairo_t * c = cairo_create(s);
- cairo_surface_destroy(s);
- Fl::cairo_cc(c);
- return c;
-}
-
-/**
- Creates a cairo context from a \a gc and its size
- \note Only available when configure has the --enable-cairo option
-*/
-cairo_t * Fl::cairo_make_current(void *gc, int W, int H) {
- cairo_surface_t * s = cairo_create_surface(gc, W, H);
- cairo_t * c = cairo_create(s);
- cairo_surface_destroy(s);
- Fl::cairo_cc(c);
- return c;
-}
-#endif // HAVE_CAIRO
-
-//
-// End of "$Id$" .
-//
diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx
index ffaff2663..5dcd2dd5d 100644
--- a/src/Fl_Double_Window.cxx
+++ b/src/Fl_Double_Window.cxx
@@ -323,7 +323,7 @@ void Fl_Double_Window::flush(int eraseoverlay) {
RestoreDC(fl_gc, save);
DeleteDC(fl_gc);
fl_gc = _sgc;
- //# if defined(HAVE_CAIRO)
+ //# if defined(USE_CAIRO)
//if Fl::cairo_autolink_context() Fl::cairo_make_current(this); // capture gc changes automatically to update the cairo context adequately
//# endif
#elif defined(__APPLE__)
diff --git a/src/Fl_Menu_Window.cxx b/src/Fl_Menu_Window.cxx
index a7f17c7d0..ba6cb7043 100644
--- a/src/Fl_Menu_Window.cxx
+++ b/src/Fl_Menu_Window.cxx
@@ -69,8 +69,8 @@ void Fl_Menu_Window::flush() {
fl_window = myi->xid;
if (!gc) {
gc = XCreateGC(fl_display, myi->xid, 0, 0);
-# if defined(HAVE_CAIRO)
- Fl::cairo_make_current(gc); // capture gc changes automatically to update the cairo context adequately
+# if defined(USE_CAIRO)
+ if(Fl::autolink_context()) Fl::cairo_make_current(gc); // capture gc changes automatically to update the cairo context adequately
# endif
}
fl_gc = gc;
diff --git a/src/Fl_Overlay_Window.cxx b/src/Fl_Overlay_Window.cxx
index 4e76566c9..0d9551968 100644
--- a/src/Fl_Overlay_Window.cxx
+++ b/src/Fl_Overlay_Window.cxx
@@ -135,7 +135,7 @@ void _Fl_Overlay::flush() {
gc = XCreateGC(fl_display, fl_xid(this), 0, 0);
}
fl_gc = gc;
-#if defined(HAVE_CAIRO)
+#if defined(USE_CAIRO)
if (Fl::cairo_autolink_context()) Fl::cairo_make_current(this); // capture gc changes automatically to update the cairo context adequately
#endif
fl_overlay = 1;
diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx
index 70b9c7f47..3c6b17e0e 100644
--- a/src/Fl_Window.cxx
+++ b/src/Fl_Window.cxx
@@ -133,7 +133,7 @@ void Fl_Window::draw() {
y(savey);
x(savex);
-# if defined(HAVE_CAIRO)
+# if defined(USE_CAIRO)
Fl::cairo_make_current(this); // checkout if an update is necessary
# endif
}
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx
index e889db4d8..c7737213c 100644
--- a/src/Fl_mac.cxx
+++ b/src/Fl_mac.cxx
@@ -2351,7 +2351,7 @@ void Fl_Window::make_current()
fl_gc = i->gc;
CGContextSaveGState(fl_gc);
Fl_X::q_fill_context();
-#if defined(HAVE_CAIRO) && defined (__APPLE_QUARTZ__)
+#if defined(USE_CAIRO) && defined (__APPLE_QUARTZ__)
if (Fl::cairo_autolink_context()) Fl::cairo_make_current(this); // capture gc changes automatically to update the cairo context adequately
#endif
@@ -2359,7 +2359,7 @@ void Fl_Window::make_current()
fl_clip_region( 0 );
SetPortClipRegion( GetWindowPort(i->xid), fl_window_region );
-#if defined(__APPLE_QUARTZ__) && defined(HAVE_CAIRO)
+#if defined(__APPLE_QUARTZ__) && defined(USE_CAIRO)
// update the cairo_t context
if (Fl::cairo_autolink_context()) Fl::cairo_make_current(this);
#endif
@@ -2410,8 +2410,8 @@ void Fl_X::q_release_context(Fl_X *x) {
fprintf(stderr, "Error %d in QDEndCGContext\n", (int)err);
}
fl_gc = 0;
-#if defined(HAVE_CAIRO) && defined (__APPLE_QUARTZ__)
- Fl::cairo_make_current((Fl_Window*) 0); // capture gc changes automatically to update the cairo context adequately
+#if defined(USE_CAIRO) && defined (__APPLE_QUARTZ__)
+ if (Fl::cairo_autolink_context()) Fl::cairo_make_current((Fl_Window*) 0); // capture gc changes automatically to update the cairo context adequately
#endif
}
diff --git a/src/Makefile b/src/Makefile
index f7d15b793..30a623d65 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -34,7 +34,6 @@ CPPFILES = \
Fl_Browser_load.cxx \
Fl_Box.cxx \
Fl_Button.cxx \
- Fl_Cairo.cxx \
Fl_Chart.cxx \
Fl_Check_Browser.cxx \
Fl_Check_Button.cxx \
@@ -188,6 +187,7 @@ IMGCPPFILES = \
Fl_PNG_Image.cxx \
Fl_PNM_Image.cxx
+
CFILES = fl_call_main.c flstring.c scandir.c numericsort.c vsnprintf.c fl_utf.c
UTF8CFILES = \
@@ -211,7 +211,7 @@ IMGOBJECTS = $(IMGCPPFILES:.cxx=.o)
all: $(LIBNAME) $(DSONAME) \
$(FLLIBNAME) $(FLDSONAME) \
$(GLLIBNAME) $(GLDSONAME) \
- $(IMGLIBNAME) $(IMGDSONAME)
+ $(IMGLIBNAME) $(IMGDSONAME)
$(LIBNAME): $(OBJECTS)
echo $(LIBCOMMAND) $@ ...
@@ -418,7 +418,7 @@ mgwfltknox_images-1.3.dll: $(IMGLIBNAME) mgwfltknox-1.3.dll
$(IMAGELIBS) $(LDLIBS)
clean:
- -$(RM) *.o *.dll.a core.* *~ *.bck *.bck
+ -$(RM) *.o *.dll.a core.* *~ *.bak *.bck
-$(RM) $(DSONAME) $(FLDSONAME) $(GLDSONAME) $(IMGDSONAME) \
$(LIBNAME) $(FLLIBNAME) $(GLLIBNAME) \
$(IMGLIBNAME) \
@@ -500,7 +500,7 @@ gl_start.o: ../FL/mac.H ../FL/win32.H
install: $(LIBNAME) $(DSONAME) \
$(FLLIBNAME) $(FLDSONAME) \
$(GLLIBNAME) $(GLDSONAME) \
- $(IMGLIBNAME) $(IMGDSONAME)
+ $(IMGLIBNAME) $(IMGDSONAME)
echo "Installing libraries in $(DESTDIR)$(libdir)..."
-$(INSTALL_DIR) $(DESTDIR)$(libdir)
-$(INSTALL_DIR) $(DESTDIR)$(bindir)
@@ -640,6 +640,7 @@ install: $(LIBNAME) $(DSONAME) \
$(INSTALL_LIB) libfltk_images.dll.a $(DESTDIR)$(libdir); \
fi
+
uninstall:
echo "Uninstalling libraries..."
$(RM) $(DESTDIR)$(libdir)/$(LIBNAME)
@@ -731,7 +732,6 @@ uninstall:
$(RM) $(DESTDIR)$(libdir)/libfltk_images.dll.a;\
fi
-
#
# End of "$Id$".
#