summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-04-23 16:15:05 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-04-23 16:15:05 +0200
commit285e8e843afa51e3e1ae2ffdd3b4161b566b160d (patch)
tree9a6ea2c713ad2d972db2500769621eca6d8d3fe5 /src/drivers
parent8e21120f75a0d791ce6f1cc26445f1978ed8875d (diff)
Create Fl_Cairo_Graphics_Driver::handle_dummy_cairo(cairo_t *cr).
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H3
-rw-r--r--src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx17
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx9
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx1
4 files changed, 18 insertions, 12 deletions
diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H
index 00ae55e61..d35d51804 100644
--- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H
+++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H
@@ -41,10 +41,11 @@ 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:
- PangoLayout *dummy_pango_layout_; // used to measure text width before showing a window
+ cairo_t *dummy_cairo_; // used to measure text width before showing a window
cairo_t *cairo_;
PangoLayout *pango_layout_;
int linestyle_;
+ void handle_dummy_cairo(cairo_t *);
public:
Fl_Cairo_Graphics_Driver();
virtual ~Fl_Cairo_Graphics_Driver();
diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
index 8651f3887..029a2eb4f 100644
--- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
+++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
@@ -69,7 +69,7 @@ static void draw_image_cb(void *data, int x, int y, int w, uchar *buf) {
Fl_Cairo_Graphics_Driver::Fl_Cairo_Graphics_Driver() : Fl_Graphics_Driver() {
cairo_ = NULL;
pango_layout_ = NULL;
- dummy_pango_layout_ = NULL;
+ dummy_cairo_ = NULL;
linestyle_ = FL_SOLID;
clip_ = NULL;
scale_x = scale_y = 1;
@@ -85,6 +85,15 @@ Fl_Cairo_Graphics_Driver::~Fl_Cairo_Graphics_Driver() {
const cairo_format_t Fl_Cairo_Graphics_Driver::cairo_format = CAIRO_FORMAT_ARGB32;
+void Fl_Cairo_Graphics_Driver::handle_dummy_cairo(cairo_t *cr) {
+ pango_cairo_update_layout(cr, pango_layout_); // 1.10
+ cairo_surface_t *surf = cairo_get_target(dummy_cairo_);
+ cairo_destroy(dummy_cairo_);
+ cairo_surface_destroy(surf);
+ dummy_cairo_ = NULL;
+}
+
+
void Fl_Cairo_Graphics_Driver::rectf(int x, int y, int w, int h) {
cairo_rectangle(cairo_, x-0.5, y-0.5, w, h);
cairo_fill(cairo_);
@@ -1078,8 +1087,10 @@ void Fl_Cairo_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize s) {
cairo_surface_t *surf = cairo_image_surface_create(Fl_Cairo_Graphics_Driver::cairo_format, 100, 100);
cairo_ = cairo_create(surf);
}
- pango_layout_ = pango_cairo_create_layout(cairo_);
- if (needs_dummy) dummy_pango_layout_ = pango_layout_;
+ pango_layout_ = pango_cairo_create_layout(cairo_); // 1.10
+ if (needs_dummy) {
+ dummy_cairo_ = cairo_;
+ }
}
if (s == 0) return;
if (font() == fnum && size() == s) return;
diff --git a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx
index 79044c522..18de912ce 100644
--- a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx
@@ -143,14 +143,7 @@ Fl_Wayland_Graphics_Driver::Fl_Wayland_Graphics_Driver () : Fl_Cairo_Graphics_Dr
void Fl_Wayland_Graphics_Driver::activate(struct fl_wld_buffer *buffer, float scale) {
- if (dummy_pango_layout_) {
- cairo_surface_t *surf = cairo_get_target(cairo_);
- cairo_destroy(cairo_);
- cairo_surface_destroy(surf);
- g_object_unref(dummy_pango_layout_);
- dummy_pango_layout_ = NULL;
- pango_layout_ = NULL;
- }
+ if (dummy_cairo_) handle_dummy_cairo(buffer->cairo_);
cairo_ = buffer->cairo_;
if (pango_layout_ != buffer->pango_layout_) {
if (pango_layout_) g_object_unref(pango_layout_);
diff --git a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx
index a5d97fdcd..d02e7272e 100644
--- a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx
@@ -47,6 +47,7 @@ Fl_Wayland_Image_Surface_Driver::Fl_Wayland_Image_Surface_Driver(int w, int h, i
Fl_Wayland_Image_Surface_Driver::~Fl_Wayland_Image_Surface_Driver() {
if (offscreen && !external_offscreen) {
+ cairo_destroy(offscreen->cairo_);
free(offscreen->draw_buffer);
free(offscreen);
}