summaryrefslogtreecommitdiff
path: root/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-03-06 19:47:06 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-03-06 19:47:06 +0100
commitf8db18597a545c245b885ad18dbfb8862161966a (patch)
treee093eea6a0fcb62f9a110e85b80b40ba64a17930 /src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H
parent272bc2560cad49bc5d504e2cede7c55d4518791a (diff)
Complete class Fl_Cairo_Graphics_Driver using Fl_Wayland_Graphics_Driver
Diffstat (limited to 'src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H')
-rw-r--r--src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H65
1 files changed, 53 insertions, 12 deletions
diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H
index d2b24cb30..98253ffbc 100644
--- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H
+++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H
@@ -1,7 +1,7 @@
//
// Support for Cairo graphics for the Fast Light Tool Kit (FLTK).
//
-// Copyright 2021 by Bill Spitzak and others.
+// Copyright 2021-2022 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
@@ -22,16 +22,28 @@
# define FL_CAIRO_GRAPHICS_DRIVER_H
#include <FL/Fl_Graphics_Driver.H>
+#include <cairo/cairo.h>
-typedef struct _cairo cairo_t;
typedef struct _PangoLayout PangoLayout;
typedef struct _PangoFontDescription PangoFontDescription;
+
+class Fl_Cairo_Font_Descriptor : public Fl_Font_Descriptor {
+public:
+ Fl_Cairo_Font_Descriptor(const char* fontname, Fl_Fontsize size);
+ FL_EXPORT ~Fl_Cairo_Font_Descriptor();
+ PangoFontDescription *fontref;
+ int **width; // array of arrays of character widths
+};
+
+
class FL_EXPORT Fl_Cairo_Graphics_Driver : public Fl_Graphics_Driver {
+private:
+ bool *needs_commit_tag_; // NULL or points to whether cairo surface was drawn to
protected:
cairo_t *cairo_;
PangoLayout *pango_layout_;
- void draw_rgb_bitmap_(Fl_Image *img,int XP, int YP, int WP, int HP, int cx, int cy);
+ int linestyle_;
public:
Fl_Cairo_Graphics_Driver();
virtual ~Fl_Cairo_Graphics_Driver();
@@ -63,8 +75,12 @@ public:
float angle;
int left_margin;
int top_margin;
+ static const cairo_format_t cairo_format;
- void transformed_draw(const char* s, int n, double x, double y); //precise text placing
+ void surface_needs_commit() {
+ if (needs_commit_tag_) *needs_commit_tag_ = true;
+ }
+ void needs_commit_tag(bool *tag) { needs_commit_tag_ = tag; }
// implementation of drawing methods
void color(Fl_Color c);
@@ -95,6 +111,11 @@ public:
void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
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 point(int x, int y);
+ void overlay_rect(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 restore_clip();
+ int not_clipped(int x, int y, int w, int h);
void begin_points();
void begin_line();
@@ -118,20 +139,40 @@ public:
void draw_image_mono(const uchar* d, int x,int y,int w,int h, int delta=1, int ld=0);
void draw_image(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=3);
void draw_image_mono(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=1);
-
- void draw(const char* s, int nBytes, int x, int y) { transformed_draw(s,nBytes,x,y); }
- void draw(const char* s, int nBytes, float x, float y) { transformed_draw(s,nBytes,x,y); }
- void draw(int angle, const char *str, int n, int x, int y);
- void rtl_draw(const char* s, int n, int x, int y);
- void draw_pixmap(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy);
- void draw_bitmap(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy);
- void draw_rgb(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy);
// ---
Fl_Bitmask create_bitmask(int /*w*/, int /*h*/, const uchar */*array*/) { return 0L; }
void ps_origin(int x, int y);
void ps_translate(int, int);
void ps_untranslate();
+
+ void draw_cached_pattern_(Fl_Image *img, cairo_pattern_t *pat, int X, int Y, int W, int H, int cx, int cy);
+ void draw_image(const uchar *data, int ix, int iy, int iw, int ih, int D, int LD);
+ void draw_rgb(Fl_RGB_Image *rgb,int XP, int YP, int WP, int HP, int cx, int cy);
+ void cache(Fl_RGB_Image *rgb);
+ void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_);
+ void draw_bitmap(Fl_Bitmap *bm,int XP, int YP, int WP, int HP, int cx, int cy);
+ void cache(Fl_Bitmap *img);
+ void delete_bitmask(Fl_Bitmask bm);
+ void cache(Fl_Pixmap *pxm);
+ void draw_pixmap(Fl_Pixmap *rgb,int XP, int YP, int WP, int HP, int cx, int cy);
+ void uncache_pixmap(fl_uintptr_t p);
+
+ void font(Fl_Font fnum, Fl_Fontsize s);
+ Fl_Font font() { return Fl_Graphics_Driver::font(); }
+ void draw(const char* s, int nBytes, int x, int y) { draw(s, nBytes, float(x), float(y)); }
+ void draw(const char* s, int nBytes, float x, float 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);
+ int height();
+ int descent();
+ double width(const char *str, int n);
+ double width(unsigned c);
+ void text_extents(const char* txt, int n, int& dx, int& dy, int& w, int& h);
+ virtual PangoFontDescription* pango_font_description(Fl_Font /*fnum*/) {
+ return ((Fl_Cairo_Font_Descriptor*)font_descriptor())->fontref;
+ }
+
};
#endif // FL_CAIRO_GRAPHICS_DRIVER_H