summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Device.cxx10
-rw-r--r--src/Fl_Gl_Device_Plugin.cxx3
-rw-r--r--src/Fl_PostScript.cxx3
-rw-r--r--src/fl_rect.cxx16
-rw-r--r--src/fl_vertex.cxx90
-rw-r--r--src/gl_start.cxx6
6 files changed, 33 insertions, 95 deletions
diff --git a/src/Fl_Device.cxx b/src/Fl_Device.cxx
index 0a099bc85..790545703 100644
--- a/src/Fl_Device.cxx
+++ b/src/Fl_Device.cxx
@@ -51,6 +51,16 @@ void Fl_Surface_Device::set_current(void)
_surface = this;
}
+static matrix m0 = {1, 0, 0, 1, 0, 0};
+
+Fl_Graphics_Driver::Fl_Graphics_Driver() {
+ sptr=0; rstackptr=0;
+ fl_clip_state_number=0;
+ m = m0;
+ fl_matrix = &m;
+ p = (XPOINT *)0;
+};
+
//
// End of "$Id$".
//
diff --git a/src/Fl_Gl_Device_Plugin.cxx b/src/Fl_Gl_Device_Plugin.cxx
index 135ec78a2..ffb714014 100644
--- a/src/Fl_Gl_Device_Plugin.cxx
+++ b/src/Fl_Gl_Device_Plugin.cxx
@@ -53,7 +53,9 @@ static void print_gl_window(Fl_Gl_Window *glw, int x, int y, int height)
_XGC *save_gc = fl_gc;
const int bytesperpixel = 3;
#endif
+ Fl_Surface_Device *save_surface = Fl_Surface_Device::surface();
fl_gc = NULL;
+ Fl_Display_Device::display_device()->set_current();
#ifdef WIN32
Fl::check();
Fl_Window *win = (Fl_Window*)glw;
@@ -89,6 +91,7 @@ static void print_gl_window(Fl_Gl_Window *glw, int x, int y, int height)
#endif
baseAddress);
glPopClientAttrib();
+ save_surface->set_current();
fl_gc = save_gc;
#if defined(__APPLE__)
// kCGBitmapByteOrder32Host and CGBitmapInfo are supposed to arrive with 10.4
diff --git a/src/Fl_PostScript.cxx b/src/Fl_PostScript.cxx
index c317beeef..aecfe9af8 100644
--- a/src/Fl_PostScript.cxx
+++ b/src/Fl_PostScript.cxx
@@ -1115,9 +1115,6 @@ void Fl_PostScript_Graphics_Driver::rtl_draw(const char* str, int n, int x, int
delete [] out;
}
-struct matrix {double a, b, c, d, x, y;};
-extern matrix * fl_matrix;
-
void Fl_PostScript_Graphics_Driver::concat(){
fprintf(output,"[%g %g %g %g %g %g] CT\n", fl_matrix->a , fl_matrix->b , fl_matrix->c , fl_matrix->d , fl_matrix->x , fl_matrix->y);
}
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx
index ea9c10949..703dd82bd 100644
--- a/src/fl_rect.cxx
+++ b/src/fl_rect.cxx
@@ -507,12 +507,6 @@ void Fl_Graphics_Driver::point(int x, int y) {
////////////////////////////////////////////////////////////////
-#define STACK_SIZE 10
-#define STACK_MAX (STACK_SIZE - 1)
-static Fl_Region rstack[STACK_SIZE];
-static int rstackptr=0;
-int fl_clip_state_number=0; // used by gl_begin.cxx to update GL clip
-
#if !defined(WIN32) && !defined(__APPLE__)
// Missing X call: (is this the fastest way to init a 1-rectangle region?)
// MSWindows equivalent exists, implemented inline in win32.H
@@ -526,7 +520,7 @@ Fl_Region XRectangleRegion(int x, int y, int w, int h) {
}
#endif
-void fl_restore_clip() {
+void Fl_Graphics_Driver::restore_clip() {
fl_clip_state_number++;
Fl_Region r = rstack[rstackptr];
#if defined(USE_X11)
@@ -554,14 +548,14 @@ void fl_restore_clip() {
#endif
}
-void fl_clip_region(Fl_Region r) {
+void Fl_Graphics_Driver::clip_region(Fl_Region r) {
Fl_Region oldr = rstack[rstackptr];
if (oldr) XDestroyRegion(oldr);
rstack[rstackptr] = r;
fl_restore_clip();
}
-Fl_Region fl_clip_region() {
+Fl_Region Fl_Graphics_Driver::clip_region() {
return rstack[rstackptr];
}
@@ -596,14 +590,14 @@ void Fl_Graphics_Driver::push_clip(int x, int y, int w, int h) {
# error unsupported platform
#endif
}
- if (rstackptr < STACK_MAX) rstack[++rstackptr] = r;
+ if (rstackptr < REGION_STACK_MAX) rstack[++rstackptr] = r;
else Fl::warning("fl_push_clip: clip stack overflow!\n");
fl_restore_clip();
}
// make there be no clip (used by fl_begin_offscreen() only!)
void Fl_Graphics_Driver::push_no_clip() {
- if (rstackptr < STACK_MAX) rstack[++rstackptr] = 0;
+ if (rstackptr < REGION_STACK_MAX) rstack[++rstackptr] = 0;
else Fl::warning("fl_push_no_clip: clip stack overflow!\n");
fl_restore_clip();
}
diff --git a/src/fl_vertex.cxx b/src/fl_vertex.cxx
index 69db92944..bb123e9a0 100644
--- a/src/fl_vertex.cxx
+++ b/src/fl_vertex.cxx
@@ -44,42 +44,21 @@
#include <FL/math.h>
#include <stdlib.h>
-struct matrix {double a, b, c, d, x, y;};
-
-static matrix m = {1, 0, 0, 1, 0, 0};
-
-static matrix stack[32];
-matrix * fl_matrix = &m;
-static int sptr = 0;
-
-/**
- Saves the current transformation matrix on the stack.
- The maximum depth of the stack is 4.
-*/
-void fl_push_matrix() {
- if (sptr==32)
+void Fl_Graphics_Driver::push_matrix() {
+ if (sptr==MATRIX_STACK_SIZE)
Fl::error("fl_push_matrix(): matrix stack overflow.");
else
stack[sptr++] = m;
}
-/**
- Restores the current transformation matrix from the stack.
-*/
-void fl_pop_matrix() {
+void Fl_Graphics_Driver::pop_matrix() {
if (sptr==0)
Fl::error("fl_pop_matrix(): matrix stack underflow.");
else
m = stack[--sptr];
}
-/**
- Concatenates another transformation onto the current one.
-
- \param[in] a,b,c,d,x,y transformation matrix elements such that
- <tt> X' = aX + cY + x </tt> and <tt> Y' = bX +dY + y </tt>
-*/
-void fl_mult_matrix(double a, double b, double c, double d, double x, double y) {
+void Fl_Graphics_Driver::mult_matrix(double a, double b, double c, double d, double x, double y) {
matrix o;
o.a = a*m.a + b*m.c;
o.b = a*m.b + b*m.d;
@@ -124,27 +103,6 @@ void fl_rotate(double d) {
}
}
-// typedef what the x,y fields in a point are:
-#ifdef WIN32
-typedef int COORD_T;
-# define XPOINT XPoint
-#elif defined(__APPLE_QUARTZ__)
-typedef float COORD_T;
-typedef struct { float x; float y; } QPoint;
-# define XPOINT QPoint
-extern float fl_quartz_line_width_;
-#else
-typedef short COORD_T;
-# define XPOINT XPoint
-#endif
-
-static XPOINT *p = (XPOINT *)0;
-
-static int p_size;
-static int n;
-static int what;
-enum {LINE, LOOP, POLYGON, POINT_};
-
void Fl_Graphics_Driver::begin_points() {n = 0; what = POINT_;}
void Fl_Graphics_Driver::begin_line() {n = 0; what = LINE;}
@@ -153,31 +111,15 @@ void Fl_Graphics_Driver::begin_loop() {n = 0; what = LOOP;}
void Fl_Graphics_Driver::begin_polygon() {n = 0; what = POLYGON;}
-/**
- Transforms coordinate using the current transformation matrix.
- \param[in] x,y coordinate
-*/
-double fl_transform_x(double x, double y) {return x*m.a + y*m.c + m.x;}
+double Fl_Graphics_Driver::transform_x(double x, double y) {return x*m.a + y*m.c + m.x;}
-/**
- Transform coordinate using the current transformation matrix.
- \param[in] x,y coordinate
-*/
-double fl_transform_y(double x, double y) {return x*m.b + y*m.d + m.y;}
+double Fl_Graphics_Driver::transform_y(double x, double y) {return x*m.b + y*m.d + m.y;}
-/**
- Transforms distance using current transformation matrix.
- \param[in] x,y coordinate
-*/
-double fl_transform_dx(double x, double y) {return x*m.a + y*m.c;}
+double Fl_Graphics_Driver::transform_dx(double x, double y) {return x*m.a + y*m.c;}
-/**
- Transforms distance using current transformation matrix.
- \param[in] x,y coordinate
-*/
-double fl_transform_dy(double x, double y) {return x*m.b + y*m.d;}
+double Fl_Graphics_Driver::transform_dy(double x, double y) {return x*m.b + y*m.d;}
-static void fl_transformed_vertex(COORD_T x, COORD_T y) {
+void Fl_Graphics_Driver::transformed_vertex0(COORD_T x, COORD_T y) {
if (!n || x != p[n-1].x || y != p[n-1].y) {
if (n >= p_size) {
p_size = p ? 2*p_size : 16;
@@ -191,14 +133,14 @@ static void fl_transformed_vertex(COORD_T x, COORD_T y) {
void Fl_Graphics_Driver::transformed_vertex(double xf, double yf) {
#ifdef __APPLE_QUARTZ__
- fl_transformed_vertex(COORD_T(xf), COORD_T(yf));
+ transformed_vertex0(COORD_T(xf), COORD_T(yf));
#else
- fl_transformed_vertex(COORD_T(rint(xf)), COORD_T(rint(yf)));
+ transformed_vertex0(COORD_T(rint(xf)), COORD_T(rint(yf)));
#endif
}
void Fl_Graphics_Driver::vertex(double x,double y) {
- fl_transformed_vertex(x*m.a + y*m.c + m.x, x*m.b + y*m.d + m.y);
+ transformed_vertex0(COORD_T(x*m.a + y*m.c + m.x), COORD_T(x*m.b + y*m.d + m.y));
}
void Fl_Graphics_Driver::end_points() {
@@ -241,7 +183,7 @@ void Fl_Graphics_Driver::end_line() {
#endif
}
-static void fixloop() { // remove equal points from closed path
+void Fl_Graphics_Driver::fixloop() { // remove equal points from closed path
while (n>2 && p[n-1].x == p[0].x && p[n-1].y == p[0].y) n--;
}
@@ -278,12 +220,6 @@ void Fl_Graphics_Driver::end_polygon() {
#endif
}
-static int gap_;
-#if defined(WIN32)
-static int counts[20];
-static int numcount;
-#endif
-
void Fl_Graphics_Driver::begin_complex_polygon() {
fl_begin_polygon();
gap_ = 0;
diff --git a/src/gl_start.cxx b/src/gl_start.cxx
index 7338f4494..22674e428 100644
--- a/src/gl_start.cxx
+++ b/src/gl_start.cxx
@@ -46,8 +46,6 @@
#include <FL/fl_draw.H>
#include "Fl_Gl_Choice.H"
-extern int fl_clip_state_number; // in fl_rect.cxx
-
static GLContext context;
static int clip_state_number=-1;
static int pw, ph;
@@ -89,8 +87,8 @@ void gl_start() {
glOrtho(0, pw, 0, ph, -1, 1);
glDrawBuffer(GL_FRONT);
}
- if (clip_state_number != fl_clip_state_number) {
- clip_state_number = fl_clip_state_number;
+ if (clip_state_number != fl_graphics_driver->fl_clip_state_number) {
+ clip_state_number = fl_graphics_driver->fl_clip_state_number;
int x, y, w, h;
if (fl_clip_box(0, 0, Fl_Window::current()->w(), Fl_Window::current()->h(),
x, y, w, h)) {