FLTK logo

[master] a118732 - Improve rectf() and push_clip() under cairo and GUI scaling.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] a118732 - Improve rectf() and push_clip() under cairo and GUI scaling. "ManoloFLTK" May 25, 2022  
 
commit a118732f7c10da03196ebd9207007686163114f4
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Wed May 25 16:05:36 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Wed May 25 16:05:36 2022 +0200

    Improve rectf() and push_clip() under cairo and GUI scaling.

 src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
index 9c5d829..5a09902 100644
--- src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
+++ src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
@@ -104,7 +104,10 @@ void Fl_Cairo_Graphics_Driver::set_cairo(cairo_t *cr, float s) {
 
 
 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_matrix_t mat;
+  cairo_get_matrix(cairo_, &mat);
+  double s = 1 / mat.xx;
+  cairo_rectangle(cairo_, x - 0.5, y - 0.5, w + s, h + s);
   cairo_fill(cairo_);
   check_status();
   surface_needs_commit();
@@ -499,7 +502,12 @@ void Fl_Cairo_Graphics_Driver::push_clip(int x, int y, int w, int h) {
   c->prev = clip_;
   clip_ = c;
   cairo_save(cairo_);
-  cairo_rectangle(cairo_, clip_->x-0.5 , clip_->y-0.5 , clip_->w  , clip_->h);
+  cairo_matrix_t mat;
+  cairo_get_matrix(cairo_, &mat);
+  double s = 1 / mat.xx;
+  double ss = (2 * s < 1 ? s : 1/2.);
+  cairo_rectangle(cairo_, clip_->x - 0.5 - ss, clip_->y - 0.5 - ss ,
+                  clip_->w + s + 2 * ss, clip_->h + s + 2 * ss);
   cairo_clip(cairo_);
   check_status();
 }
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.