Remove class Fl_Translated_Xlib_Graphics_Driver and move its processing to Fl_Xlib_Graphics_Driver.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12205 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2017-03-17 16:33:14 +00:00
parent 300e0b32a9
commit 367e567b7b
11 changed files with 100 additions and 342 deletions

View File

@ -1,75 +0,0 @@
//
// "$Id$"
//
// Draw-to-image code for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2016 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// http://www.fltk.org/COPYING.php
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
#ifndef Fl_Translated_Xlib_Graphics_Driver_h
#define Fl_Translated_Xlib_Graphics_Driver_h
#ifndef FL_DOXYGEN
#include <src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H>
/* graphics driver that translates all graphics coordinates before calling Xlib */
class Fl_Translated_Xlib_Graphics_Driver : public Fl_Xlib_Graphics_Driver {
int offset_x, offset_y; // translation between user and graphical coordinates: graphical = user + offset
unsigned depth; // depth of translation stack
int stack_x[20], stack_y[20]; // translation stack allowing cumulative translations
public:
Fl_Translated_Xlib_Graphics_Driver();
virtual ~Fl_Translated_Xlib_Graphics_Driver();
void translate_all(int dx, int dy);
void untranslate_all();
void rect(int x, int y, int w, int h);
void rectf(int x, int y, int w, int h);
void xyline(int x, int y, int x1);
void xyline(int x, int y, int x1, int y2);
void xyline(int x, int y, int x1, int y2, int x3);
void yxline(int x, int y, int y1);
void yxline(int x, int y, int y1, int x2);
void yxline(int x, int y, int y1, int x2, int y3);
void line(int x, int y, int x1, int y1);
void line(int x, int y, int x1, int y1, int x2, int y2);
void draw(const char* str, int n, int x, int y);
void draw(int angle, const char *str, int n, int x, int y);
void rtl_draw(const char* str, int n, int x, int y);
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0);
void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0) ;
void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1);
void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
void push_clip(int x, int y, int w, int h);
int not_clipped(int x, int y, int w, int h);
int clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H);
void pie(int x, int y, int w, int h, double a1, double a2);
void arc(int x, int y, int w, int h, double a1, double a2);
void polygon(int x0, int y0, int x1, int y1, int x2, int y2);
void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
void loop(int x0, int y0, int x1, int y1, int x2, int y2);
void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
void point(int x, int y);
};
#endif // FL_DOXYGEN
#endif /* Fl_Translated_Xlib_Graphics_Driver_h */
//
// End of "$Id$".
//

View File

@ -1,203 +0,0 @@
//
// "$Id$"
//
// Draw-to-image code for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2016 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// http://www.fltk.org/COPYING.php
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
#include <config.h>
#include "Fl_Translated_Xlib_Graphics_Driver.H"
#include <FL/Fl.H>
#ifndef FL_DOXYGEN
Fl_Translated_Xlib_Graphics_Driver::Fl_Translated_Xlib_Graphics_Driver() {
offset_x = 0; offset_y = 0;
depth = 0;
}
Fl_Translated_Xlib_Graphics_Driver::~Fl_Translated_Xlib_Graphics_Driver() {}
void Fl_Translated_Xlib_Graphics_Driver::translate_all(int dx, int dy) { // reversibly adds dx,dy to the offset between user and graphical coordinates
stack_x[depth] = offset_x;
stack_y[depth] = offset_y;
offset_x = stack_x[depth] + dx;
offset_y = stack_y[depth] + dy;
push_matrix();
translate(dx, dy);
if (depth < sizeof(stack_x)/sizeof(int)) depth++;
else Fl::warning("%s: translate stack overflow!", "Fl_Translated_Xlib_Graphics_Driver");
}
void Fl_Translated_Xlib_Graphics_Driver::untranslate_all() { // undoes previous translate_all()
if (depth > 0) depth--;
offset_x = stack_x[depth];
offset_y = stack_y[depth];
pop_matrix();
}
void Fl_Translated_Xlib_Graphics_Driver::rect(int x, int y, int w, int h) {
Fl_Xlib_Graphics_Driver::rect(x+offset_x, y+offset_y, w, h);
}
void Fl_Translated_Xlib_Graphics_Driver::rectf(int x, int y, int w, int h) {
Fl_Xlib_Graphics_Driver::rectf(x+offset_x, y+offset_y, w, h);
}
void Fl_Translated_Xlib_Graphics_Driver::xyline(int x, int y, int x1) {
Fl_Xlib_Graphics_Driver::xyline(x+offset_x, y+offset_y, x1+offset_x);
}
void Fl_Translated_Xlib_Graphics_Driver::xyline(int x, int y, int x1, int y2) {
Fl_Xlib_Graphics_Driver::xyline(x+offset_x, y+offset_y, x1+offset_x, y2+offset_y);
}
void Fl_Translated_Xlib_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3) {
Fl_Xlib_Graphics_Driver::xyline(x+offset_x, y+offset_y, x1+offset_x, y2+offset_y, x3+offset_x);
}
void Fl_Translated_Xlib_Graphics_Driver::yxline(int x, int y, int y1) {
Fl_Xlib_Graphics_Driver::yxline(x+offset_x, y+offset_y, y1+offset_y);
}
void Fl_Translated_Xlib_Graphics_Driver::yxline(int x, int y, int y1, int x2) {
Fl_Xlib_Graphics_Driver::yxline(x+offset_x, y+offset_y, y1+offset_y, x2+offset_x);
}
void Fl_Translated_Xlib_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3) {
Fl_Xlib_Graphics_Driver::yxline(x+offset_x, y+offset_y, y1+offset_y, x2+offset_x, y3+offset_y);
}
void Fl_Translated_Xlib_Graphics_Driver::line(int x, int y, int x1, int y1) {
Fl_Xlib_Graphics_Driver::line(x+offset_x, y+offset_y, x1+offset_x, y1+offset_y);
}
void Fl_Translated_Xlib_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2) {
Fl_Xlib_Graphics_Driver::line(x+offset_x, y+offset_y, x1+offset_x, y1+offset_y, x2+offset_x, y2+offset_y);
}
void Fl_Translated_Xlib_Graphics_Driver::draw(const char* str, int n, int x, int y) {
Fl_Xlib_Graphics_Driver::draw(str, n, x+offset_x, y+offset_y);
}
void Fl_Translated_Xlib_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) {
Fl_Xlib_Graphics_Driver::draw(angle, str, n, x+offset_x, y+offset_y);
}
void Fl_Translated_Xlib_Graphics_Driver::rtl_draw(const char* str, int n, int x, int y) {
Fl_Xlib_Graphics_Driver::rtl_draw(str, n, x+offset_x, y+offset_y);
}
void Fl_Translated_Xlib_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) {
XP += offset_x; YP += offset_y;
translate_all(-offset_x, -offset_y);
Fl_Xlib_Graphics_Driver::draw(pxm, XP, YP, WP,HP,cx,cy);
untranslate_all();
}
void Fl_Translated_Xlib_Graphics_Driver::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {
XP += offset_x; YP += offset_y;
translate_all(-offset_x, -offset_y);
Fl_Xlib_Graphics_Driver::draw(bm, XP, YP, WP,HP,cx,cy);
untranslate_all();
}
void Fl_Translated_Xlib_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) {
XP += offset_x; YP += offset_y;
translate_all(-offset_x, -offset_y);
Fl_Xlib_Graphics_Driver::draw(img, XP, YP, WP,HP,cx,cy);
untranslate_all();
}
void Fl_Translated_Xlib_Graphics_Driver::draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L) {
X += offset_x; Y += offset_y;
translate_all(-offset_x, -offset_y);
Fl_Xlib_Graphics_Driver::draw_image(buf, X, Y, W,H,D,L);
untranslate_all();
}
void Fl_Translated_Xlib_Graphics_Driver::draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D) {
X += offset_x; Y += offset_y;
translate_all(-offset_x, -offset_y);
Fl_Xlib_Graphics_Driver::draw_image(cb, data, X, Y, W,H,D);
untranslate_all();
}
void Fl_Translated_Xlib_Graphics_Driver::draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D, int L) {
X += offset_x; Y += offset_y;
translate_all(-offset_x, -offset_y);
Fl_Xlib_Graphics_Driver::draw_image_mono(buf, X, Y, W,H,D,L);
untranslate_all();
}
void Fl_Translated_Xlib_Graphics_Driver::draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D) {
X += offset_x; Y += offset_y;
translate_all(-offset_x, -offset_y);
Fl_Xlib_Graphics_Driver::draw_image_mono(cb, data, X, Y, W,H,D);
untranslate_all();
}
void Fl_Translated_Xlib_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) {
Fl_Xlib_Graphics_Driver::copy_offscreen(x+offset_x, y+offset_y, w, h,pixmap,srcx,srcy);
}
void Fl_Translated_Xlib_Graphics_Driver::push_clip(int x, int y, int w, int h) {
Fl_Xlib_Graphics_Driver::push_clip(x+offset_x, y+offset_y, w, h);
}
int Fl_Translated_Xlib_Graphics_Driver::not_clipped(int x, int y, int w, int h) {
return Fl_Xlib_Graphics_Driver::not_clipped(x + offset_x, y + offset_y, w, h);
}
int Fl_Translated_Xlib_Graphics_Driver::clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H) {
int retval = Fl_Xlib_Graphics_Driver::clip_box(x + offset_x, y + offset_y, w,h,X,Y,W,H);
X -= offset_x;
Y -= offset_y;
return retval;
}
void Fl_Translated_Xlib_Graphics_Driver::pie(int x, int y, int w, int h, double a1, double a2) {
Fl_Xlib_Graphics_Driver::pie(x+offset_x,y+offset_y,w,h,a1,a2);
}
void Fl_Translated_Xlib_Graphics_Driver::arc(int x, int y, int w, int h, double a1, double a2) {
Fl_Xlib_Graphics_Driver::arc(x+offset_x,y+offset_y,w,h,a1,a2);
}
void Fl_Translated_Xlib_Graphics_Driver::polygon(int x0, int y0, int x1, int y1, int x2, int y2) {
Fl_Xlib_Graphics_Driver::polygon(x0+offset_x,y0+offset_y,x1+offset_x,y1+offset_y,x2+offset_x,y2+offset_y);
}
void Fl_Translated_Xlib_Graphics_Driver::polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
Fl_Xlib_Graphics_Driver::polygon(x0+offset_x,y0+offset_y,x1+offset_x,y1+offset_y,x2+offset_x,y2+offset_y,x3+offset_x,y3+offset_y);
}
void Fl_Translated_Xlib_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2) {
Fl_Xlib_Graphics_Driver::loop(x0+offset_x,y0+offset_y,x1+offset_x,y1+offset_y,x2+offset_x,y2+offset_y);
}
void Fl_Translated_Xlib_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
Fl_Xlib_Graphics_Driver::loop(x0+offset_x,y0+offset_y,x1+offset_x,y1+offset_y,x2+offset_x,y2+offset_y,x3+offset_x,y3+offset_y);
}
void Fl_Translated_Xlib_Graphics_Driver::point(int x, int y) {
Fl_Xlib_Graphics_Driver::point(x+offset_x, y+offset_y);
}
#endif // FL_DOXYGEN
//
// End of "$Id$".
//

View File

@ -23,7 +23,7 @@
#include <FL/Fl.H>
#include <FL/x.H>
#include <FL/fl_draw.H>
#include "Fl_Translated_Xlib_Graphics_Driver.H"
#include "Fl_Xlib_Graphics_Driver.H"
#include "../X11/Fl_X11_Screen_Driver.H"
class Fl_Xlib_Copy_Surface_Driver : public Fl_Copy_Surface_Driver {
@ -50,7 +50,7 @@ Fl_Copy_Surface_Driver *Fl_Copy_Surface_Driver::newCopySurfaceDriver(int w, int
Fl_Xlib_Copy_Surface_Driver::Fl_Xlib_Copy_Surface_Driver(int w, int h) : Fl_Copy_Surface_Driver(w, h) {
driver(new Fl_Translated_Xlib_Graphics_Driver());
driver(new Fl_Xlib_Graphics_Driver());
oldwindow = fl_window;
xid = fl_create_offscreen(w,h);
driver()->push_no_clip();
@ -85,12 +85,12 @@ void Fl_Xlib_Copy_Surface_Driver::end_current_() {
}
void Fl_Xlib_Copy_Surface_Driver::translate(int x, int y) {
((Fl_Translated_Xlib_Graphics_Driver*)driver())->translate_all(x, y);
((Fl_Xlib_Graphics_Driver*)driver())->translate_all(x, y);
}
void Fl_Xlib_Copy_Surface_Driver::untranslate() {
((Fl_Translated_Xlib_Graphics_Driver*)driver())->untranslate_all();
((Fl_Xlib_Graphics_Driver*)driver())->untranslate_all();
}
#endif // FL_CFG_GFX_XLIB

View File

@ -53,6 +53,10 @@ struct _XRegion {
This class is implemented only on the Xlib platform.
*/
class FL_EXPORT Fl_Xlib_Graphics_Driver : public Fl_Graphics_Driver {
private:
int offset_x_, offset_y_; // translation between user and graphical coordinates: graphical = user + offset
unsigned depth_; // depth of translation stack
int stack_x_[20], stack_y_[20]; // translation stack allowing cumulative translations
#if USE_XFT
void drawUCS4(const void *str, int n, int x, int y);
#endif
@ -84,6 +88,8 @@ protected:
public:
Fl_Xlib_Graphics_Driver(void);
virtual ~Fl_Xlib_Graphics_Driver();
void translate_all(int dx, int dy);
void untranslate_all();
virtual int has_feature(driver_feature mask) { return mask & NATIVE; }
virtual void *gc() { return gc_; }
virtual void gc(void *value);

View File

@ -61,6 +61,8 @@ Fl_Xlib_Graphics_Driver::Fl_Xlib_Graphics_Driver(void) {
pfd_ = pango_font_description_new();
Fl_Graphics_Driver::font(0, 0);
#endif
offset_x_ = 0; offset_y_ = 0;
depth_ = 0;
}
Fl_Xlib_Graphics_Driver::~Fl_Xlib_Graphics_Driver() {
@ -77,7 +79,7 @@ void Fl_Xlib_Graphics_Driver::gc(void *value) {
}
void Fl_Xlib_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) {
XCopyArea(fl_display, pixmap, fl_window, gc_, srcx, srcy, w, h, x, y);
XCopyArea(fl_display, pixmap, fl_window, gc_, srcx, srcy, w, h, x+offset_x_, y+offset_y_);
}
#ifndef FL_DOXYGEN
@ -102,7 +104,7 @@ void Fl_Xlib_Graphics_Driver::copy_offscreen_with_alpha(int x, int y, int w, int
XRenderSetPictureClipRegion(fl_display, dst, clipr);
XRenderComposite(fl_display, PictOpOver, src, None, dst, srcx, srcy, 0, 0,
x, y, w, h);
x+offset_x_, y+offset_y_, w, h);
XRenderFreePicture(fl_display, src);
XRenderFreePicture(fl_display, dst);
@ -231,6 +233,24 @@ void Fl_Xlib_Graphics_Driver::font_name(int num, const char *name) {
s->first = 0;
}
void Fl_Xlib_Graphics_Driver::translate_all(int dx, int dy) { // reversibly adds dx,dy to the offset between user and graphical coordinates
stack_x_[depth_] = offset_x_;
stack_y_[depth_] = offset_y_;
offset_x_ = stack_x_[depth_] + dx;
offset_y_ = stack_y_[depth_] + dy;
push_matrix();
translate(dx, dy);
if (depth_ < sizeof(stack_x_)/sizeof(int)) depth_++;
else Fl::warning("%s: translate stack overflow!", "Fl_Xlib_Graphics_Driver");
}
void Fl_Xlib_Graphics_Driver::untranslate_all() { // undoes previous translate_all()
if (depth_ > 0) depth_--;
offset_x_ = stack_x_[depth_];
offset_y_ = stack_y_[depth_];
pop_matrix();
}
//
// End of "$Id$".
//

View File

@ -28,11 +28,13 @@
void Fl_Xlib_Graphics_Driver::arc(int x,int y,int w,int h,double a1,double a2) {
if (w <= 0 || h <= 0) return;
XDrawArc(fl_display, fl_window, gc_, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64));
XDrawArc(fl_display, fl_window, gc_, x+offset_x_,y+offset_y_,w-1,h-1, int(a1*64),int((a2-a1)*64));
}
void Fl_Xlib_Graphics_Driver::pie(int x,int y,int w,int h,double a1,double a2) {
if (w <= 0 || h <= 0) return;
x += offset_x_;
y += offset_y_;
XDrawArc(fl_display, fl_window, gc_, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64));
XFillArc(fl_display, fl_window, gc_, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64));
}

View File

@ -655,7 +655,7 @@ void Fl_Xlib_Graphics_Driver::draw(const char* c, int n, int x, int y) {
font_gc = gc_;
XSetFont(fl_display, gc_, font_descriptor()->font->fid);
}
if (gc_) XUtf8DrawString(fl_display, fl_window, font_descriptor()->font, gc_, x, y, c, n);
if (gc_) XUtf8DrawString(fl_display, fl_window, font_descriptor()->font, gc_, x+offset_x_, y+offset_y_, c, n);
}
void Fl_Xlib_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) {
@ -674,7 +674,7 @@ void Fl_Xlib_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
if (!font_descriptor()) this->font(FL_HELVETICA, FL_NORMAL_SIZE);
font_gc = gc_;
}
if (gc_) XUtf8DrawRtlString(fl_display, fl_window, font_descriptor()->font, gc_, x, y, c, n);
if (gc_) XUtf8DrawRtlString(fl_display, fl_window, font_descriptor()->font, gc_, x+offset_x_, y+offset_y_, c, n);
}
float Fl_Xlib_Graphics_Driver::scale_font_for_PostScript(Fl_Font_Descriptor *desc, int s) {

View File

@ -1181,12 +1181,12 @@ void Fl_Xlib_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
}
void Fl_Xlib_Graphics_Driver::draw(const char *str, int n, int x, int y) {
do_draw(0, str, n, x, y);
do_draw(0, str, n, x+offset_x_, y+offset_y_);
}
void Fl_Xlib_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) {
PangoMatrix mat = PANGO_MATRIX_INIT; // 1.6
pango_matrix_translate(&mat, x, y); // 1.6
pango_matrix_translate(&mat, x+offset_x_, y+offset_y_); // 1.6
pango_matrix_rotate(&mat, angle); // 1.6
pango_context_set_matrix(pctxt_, &mat); // 1.6
do_draw(0, str, n, 0, 0);
@ -1194,7 +1194,7 @@ void Fl_Xlib_Graphics_Driver::draw(int angle, const char *str, int n, int x, int
}
void Fl_Xlib_Graphics_Driver::rtl_draw(const char* str, int n, int x, int y) {
do_draw(1, str, n, x, y);
do_draw(1, str, n, x+offset_x_, y+offset_y_);
}
void Fl_Xlib_Graphics_Driver::do_draw(int from_right, const char *str, int n, int x, int y) {

View File

@ -580,7 +580,7 @@ void Fl_Xlib_Graphics_Driver::draw_image(const uchar* buf, int x, int y, int w,
if (alpha) d ^= FL_IMAGE_WITH_ALPHA;
const int mono = (d>-3 && d<3);
innards(buf,x,y,w,h,d,l,mono,0,0,alpha,gc_);
innards(buf,x+offset_x_,y+offset_y_,w,h,d,l,mono,0,0,alpha,gc_);
}
void Fl_Xlib_Graphics_Driver::draw_image(Fl_Draw_Image_Cb cb, void* data,
@ -590,16 +590,16 @@ void Fl_Xlib_Graphics_Driver::draw_image(Fl_Draw_Image_Cb cb, void* data,
if (alpha) d ^= FL_IMAGE_WITH_ALPHA;
const int mono = (d>-3 && d<3);
innards(0,x,y,w,h,d,0,mono,cb,data,alpha,gc_);
innards(0,x+offset_x_,y+offset_y_,w,h,d,0,mono,cb,data,alpha,gc_);
}
void Fl_Xlib_Graphics_Driver::draw_image_mono(const uchar* buf, int x, int y, int w, int h, int d, int l){
innards(buf,x,y,w,h,d,l,1,0,0,0,gc_);
innards(buf,x+offset_x_,y+offset_y_,w,h,d,l,1,0,0,0,gc_);
}
void Fl_Xlib_Graphics_Driver::draw_image_mono(Fl_Draw_Image_Cb cb, void* data,
int x, int y, int w, int h,int d) {
innards(0,x,y,w,h,d,0,1,cb,data,0,gc_);
innards(0,x+offset_x_,y+offset_y_,w,h,d,0,1,cb,data,0,gc_);
}
void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b) {
@ -624,7 +624,7 @@ void Fl_Xlib_Graphics_Driver::delete_bitmask(Fl_Bitmask bm) {
void Fl_Xlib_Graphics_Driver::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {
int X, Y, W, H;
if (Fl_Graphics_Driver::prepare(bm, XP, YP, WP, HP, cx, cy, X, Y, W, H)) {
if (Fl_Graphics_Driver::prepare(bm, XP+offset_x_, YP+offset_y_, WP, HP, cx, cy, X, Y, W, H)) {
return;
}
@ -717,6 +717,8 @@ static Fl_Offscreen cache_rgb(Fl_RGB_Image *img) {
void Fl_Xlib_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) {
int X, Y, W, H;
XP += offset_x_;
YP += offset_y_;
// Don't draw an empty image...
if (!img->d() || !img->array) {
Fl_Graphics_Driver::draw_empty(img, XP, YP);
@ -730,9 +732,9 @@ void Fl_Xlib_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, in
}
if (*Fl_Graphics_Driver::id(img)) {
if (img->d() == 4 || img->d() == 2)
copy_offscreen_with_alpha(X, Y, W, H, *Fl_Graphics_Driver::id(img), cx, cy);
copy_offscreen_with_alpha(X - offset_x_, Y - offset_y_, W, H, *Fl_Graphics_Driver::id(img), cx, cy);
else
copy_offscreen(X, Y, W, H, *Fl_Graphics_Driver::id(img), cx, cy);
copy_offscreen(X - offset_x_, Y - offset_y_, W, H, *Fl_Graphics_Driver::id(img), cx, cy);
} else {
// Composite image with alpha manually each time...
alpha_blend(img, X, Y, W, H, cx, cy);
@ -753,7 +755,7 @@ fl_uintptr_t Fl_Xlib_Graphics_Driver::cache(Fl_Bitmap*, int w, int h, const ucha
void Fl_Xlib_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) {
int X, Y, W, H;
if (Fl_Graphics_Driver::prepare(pxm, XP, YP, WP, HP, cx, cy, X, Y, W, H)) return;
if (Fl_Graphics_Driver::prepare(pxm, XP+offset_x_, YP+offset_y_, WP, HP, cx, cy, X, Y, W, H)) return;
if (*Fl_Graphics_Driver::mask(pxm)) {
// make X use the bitmap as a mask:
XSetClipMask(fl_display, gc_, *Fl_Graphics_Driver::mask(pxm));
@ -776,17 +778,17 @@ void Fl_Xlib_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int H
Y1 = r->rects[i].y1;
W1 = r->rects[i].x2 - r->rects[i].x1;
H1 = r->rects[i].y2 - r->rects[i].y1;
copy_offscreen(X1, Y1, W1, H1, *Fl_Graphics_Driver::id(pxm), cx + (X1 - X), cy + (Y1 - Y));
copy_offscreen(X1-offset_x_, Y1-offset_y_, W1, H1, *Fl_Graphics_Driver::id(pxm), cx + (X1 - X), cy + (Y1 - Y));
}
XDestroyRegion(r);
} else {
copy_offscreen(X, Y, W, H, *Fl_Graphics_Driver::id(pxm), cx, cy);
copy_offscreen(X-offset_x_, Y-offset_y_, W, H, *Fl_Graphics_Driver::id(pxm), cx, cy);
}
// put the old clip region back
XSetClipOrigin(fl_display, gc_, 0, 0);
restore_clip();
}
else copy_offscreen(X, Y, W, H, *Fl_Graphics_Driver::id(pxm), cx, cy);
else copy_offscreen(X-offset_x_, Y-offset_y_, W, H, *Fl_Graphics_Driver::id(pxm), cx, cy);
}

View File

@ -164,107 +164,109 @@ void Fl_Xlib_Graphics_Driver::XDestroyRegion(Fl_Region r) {
// --- line and polygon drawing with integer coordinates
void Fl_Xlib_Graphics_Driver::point(int x, int y) {
XDrawPoint(fl_display, fl_window, gc_, clip_x(x), clip_x(y));
XDrawPoint(fl_display, fl_window, gc_, clip_x(x+offset_x_), clip_x(y+offset_y_));
}
void Fl_Xlib_Graphics_Driver::rect(int x, int y, int w, int h) {
if (w<=0 || h<=0) return;
x+=offset_x_; y+=offset_y_;
if (!clip_to_short(x, y, w, h, line_width_))
XDrawRectangle(fl_display, fl_window, gc_, x, y, w-1, h-1);
}
void Fl_Xlib_Graphics_Driver::rectf(int x, int y, int w, int h) {
if (w<=0 || h<=0) return;
x+=offset_x_; y+=offset_y_;
if (!clip_to_short(x, y, w, h, line_width_))
XFillRectangle(fl_display, fl_window, gc_, x, y, w, h);
}
void Fl_Xlib_Graphics_Driver::line(int x, int y, int x1, int y1) {
XDrawLine(fl_display, fl_window, gc_, x, y, x1, y1);
XDrawLine(fl_display, fl_window, gc_, x+offset_x_, y+offset_y_, x1+offset_x_, y1+offset_y_);
}
void Fl_Xlib_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2) {
XPoint p[3];
p[0].x = x; p[0].y = y;
p[1].x = x1; p[1].y = y1;
p[2].x = x2; p[2].y = y2;
p[0].x = x+offset_x_; p[0].y = y+offset_y_;
p[1].x = x1+offset_x_; p[1].y = y1+offset_y_;
p[2].x = x2+offset_x_; p[2].y = y2+offset_y_;
XDrawLines(fl_display, fl_window, gc_, p, 3, 0);
}
void Fl_Xlib_Graphics_Driver::xyline(int x, int y, int x1) {
XDrawLine(fl_display, fl_window, gc_, clip_x(x), clip_x(y), clip_x(x1), clip_x(y));
XDrawLine(fl_display, fl_window, gc_, clip_x(x+offset_x_), clip_x(y+offset_y_), clip_x(x1+offset_x_), clip_x(y+offset_y_));
}
void Fl_Xlib_Graphics_Driver::xyline(int x, int y, int x1, int y2) {
XPoint p[3];
p[0].x = clip_x(x); p[0].y = p[1].y = clip_x(y);
p[1].x = p[2].x = clip_x(x1); p[2].y = clip_x(y2);
p[0].x = clip_x(x+offset_x_); p[0].y = p[1].y = clip_x(y+offset_y_);
p[1].x = p[2].x = clip_x(x1+offset_x_); p[2].y = clip_x(y2+offset_y_);
XDrawLines(fl_display, fl_window, gc_, p, 3, 0);
}
void Fl_Xlib_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3) {
XPoint p[4];
p[0].x = clip_x(x); p[0].y = p[1].y = clip_x(y);
p[1].x = p[2].x = clip_x(x1); p[2].y = p[3].y = clip_x(y2);
p[3].x = clip_x(x3);
p[0].x = clip_x(x+offset_x_); p[0].y = p[1].y = clip_x(y+offset_y_);
p[1].x = p[2].x = clip_x(x1+offset_x_); p[2].y = p[3].y = clip_x(y2+offset_y_);
p[3].x = clip_x(x3+offset_x_);
XDrawLines(fl_display, fl_window, gc_, p, 4, 0);
}
void Fl_Xlib_Graphics_Driver::yxline(int x, int y, int y1) {
XDrawLine(fl_display, fl_window, gc_, clip_x(x), clip_x(y), clip_x(x), clip_x(y1));
XDrawLine(fl_display, fl_window, gc_, clip_x(x+offset_x_), clip_x(y+offset_y_), clip_x(x+offset_x_), clip_x(y1+offset_y_));
}
void Fl_Xlib_Graphics_Driver::yxline(int x, int y, int y1, int x2) {
XPoint p[3];
p[0].x = p[1].x = clip_x(x); p[0].y = clip_x(y);
p[1].y = p[2].y = clip_x(y1); p[2].x = clip_x(x2);
p[0].x = p[1].x = clip_x(x+offset_x_); p[0].y = clip_x(y+offset_y_);
p[1].y = p[2].y = clip_x(y1+offset_y_); p[2].x = clip_x(x2+offset_x_);
XDrawLines(fl_display, fl_window, gc_, p, 3, 0);
}
void Fl_Xlib_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3) {
XPoint p[4];
p[0].x = p[1].x = clip_x(x); p[0].y = clip_x(y);
p[1].y = p[2].y = clip_x(y1); p[2].x = p[3].x = clip_x(x2);
p[3].y = clip_x(y3);
p[0].x = p[1].x = clip_x(x+offset_x_); p[0].y = clip_x(y+offset_y_);
p[1].y = p[2].y = clip_x(y1+offset_y_); p[2].x = p[3].x = clip_x(x2+offset_x_);
p[3].y = clip_x(y3+offset_y_);
XDrawLines(fl_display, fl_window, gc_, p, 4, 0);
}
void Fl_Xlib_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2) {
XPoint p[4];
p[0].x = x; p[0].y = y;
p[1].x = x1; p[1].y = y1;
p[2].x = x2; p[2].y = y2;
p[3].x = x; p[3].y = y;
p[0].x = x+offset_x_; p[0].y = y+offset_y_;
p[1].x = x1+offset_x_; p[1].y = y1+offset_y_;
p[2].x = x2+offset_x_; p[2].y = y2+offset_y_;
p[3].x = x+offset_x_; p[3].y = y+offset_y_;
XDrawLines(fl_display, fl_window, gc_, p, 4, 0);
}
void Fl_Xlib_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
XPoint p[5];
p[0].x = x; p[0].y = y;
p[1].x = x1; p[1].y = y1;
p[2].x = x2; p[2].y = y2;
p[3].x = x3; p[3].y = y3;
p[4].x = x; p[4].y = y;
p[0].x = x+offset_x_; p[0].y = y+offset_y_;
p[1].x = x1+offset_x_; p[1].y = y1+offset_y_;
p[2].x = x2+offset_x_; p[2].y = y2+offset_y_;
p[3].x = x3+offset_x_; p[3].y = y3+offset_y_;
p[4].x = x+offset_x_; p[4].y = y+offset_y_;
XDrawLines(fl_display, fl_window, gc_, p, 5, 0);
}
void Fl_Xlib_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int y2) {
XPoint p[4];
p[0].x = x; p[0].y = y;
p[1].x = x1; p[1].y = y1;
p[2].x = x2; p[2].y = y2;
p[3].x = x; p[3].y = y;
p[0].x = x+offset_x_; p[0].y = y+offset_y_;
p[1].x = x1+offset_x_; p[1].y = y1+offset_y_;
p[2].x = x2+offset_x_; p[2].y = y2+offset_y_;
p[3].x = x+offset_x_; p[3].y = y+offset_y_;
XFillPolygon(fl_display, fl_window, gc_, p, 3, Convex, 0);
XDrawLines(fl_display, fl_window, gc_, p, 4, 0);
}
void Fl_Xlib_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
XPoint p[5];
p[0].x = x; p[0].y = y;
p[1].x = x1; p[1].y = y1;
p[2].x = x2; p[2].y = y2;
p[3].x = x3; p[3].y = y3;
p[4].x = x; p[4].y = y;
p[0].x = x+offset_x_; p[0].y = y+offset_y_;
p[1].x = x1+offset_x_; p[1].y = y1+offset_y_;
p[2].x = x2+offset_x_; p[2].y = y2+offset_y_;
p[3].x = x3+offset_x_; p[3].y = y3+offset_y_;
p[4].x = x+offset_x_; p[4].y = y+offset_y_;
XFillPolygon(fl_display, fl_window, gc_, p, 4, Convex, 0);
XDrawLines(fl_display, fl_window, gc_, p, 5, 0);
}
@ -274,7 +276,7 @@ void Fl_Xlib_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int
void Fl_Xlib_Graphics_Driver::push_clip(int x, int y, int w, int h) {
Fl_Region r;
if (w > 0 && h > 0) {
r = XRectangleRegion(x,y,w,h);
r = XRectangleRegion(x+offset_x_,y+offset_y_,w,h);
Fl_Region current = rstack[rstackptr];
if (current) {
Fl_Region temp = XCreateRegion();
@ -292,6 +294,8 @@ void Fl_Xlib_Graphics_Driver::push_clip(int x, int y, int w, int h) {
int Fl_Xlib_Graphics_Driver::clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
X = x; Y = y; W = w; H = h;
x += offset_x_;
y += offset_y_;
Fl_Region r = rstack[rstackptr];
if (!r) return 0;
switch (XRectInRegion(r, x, y, w, h)) {
@ -308,13 +312,15 @@ int Fl_Xlib_Graphics_Driver::clip_box(int x, int y, int w, int h, int& X, int& Y
XIntersectRegion(r, rr, temp);
XRectangle rect;
XClipBox(temp, &rect);
X = rect.x; Y = rect.y; W = rect.width; H = rect.height;
X = rect.x - offset_x_; Y = rect.y - offset_y_; W = rect.width; H = rect.height;
XDestroyRegion(temp);
XDestroyRegion(rr);
return 1;
}
int Fl_Xlib_Graphics_Driver::not_clipped(int x, int y, int w, int h) {
x += offset_x_;
y += offset_y_;
if (x+w <= 0 || y+h <= 0) return 0;
Fl_Region r = rstack[rstackptr];
if (!r) return 1;

View File

@ -23,7 +23,7 @@
#ifdef FL_CFG_GFX_XLIB
#include "Fl_Xlib_Graphics_Driver.H"
#include <FL/Fl_Image_Surface.H>
#include "Fl_Translated_Xlib_Graphics_Driver.H"
#include "Fl_Xlib_Graphics_Driver.H"
class Fl_Xlib_Image_Surface_Driver : public Fl_Image_Surface_Driver {
friend class Fl_Image_Surface;
@ -49,7 +49,7 @@ Fl_Xlib_Image_Surface_Driver::Fl_Xlib_Image_Surface_Driver(int w, int h, int hig
fl_open_display();
offscreen = XCreatePixmap(fl_display, RootWindow(fl_display, fl_screen), w, h, fl_visual->depth);
}
driver(new Fl_Translated_Xlib_Graphics_Driver());
driver(new Fl_Xlib_Graphics_Driver());
}
Fl_Xlib_Image_Surface_Driver::~Fl_Xlib_Image_Surface_Driver() {
@ -65,11 +65,11 @@ void Fl_Xlib_Image_Surface_Driver::set_current() {
}
void Fl_Xlib_Image_Surface_Driver::translate(int x, int y) {
((Fl_Translated_Xlib_Graphics_Driver*)driver())->translate_all(x, y);
((Fl_Xlib_Graphics_Driver*)driver())->translate_all(x, y);
}
void Fl_Xlib_Image_Surface_Driver::untranslate() {
((Fl_Translated_Xlib_Graphics_Driver*)driver())->untranslate_all();
((Fl_Xlib_Graphics_Driver*)driver())->untranslate_all();
}
Fl_RGB_Image* Fl_Xlib_Image_Surface_Driver::image()