diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-12-19 10:22:22 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-12-19 10:22:22 +0100 |
| commit | 84c5992d9f286c84ef0f45e27c6b880a6fea67fc (patch) | |
| tree | 9cc456dc95d00f9595561c986bc8ca55e202862d /src/drivers | |
| parent | e7630e045ad3fb654d292e5be5a3af7cfe532c59 (diff) | |
Complete Fl_Cairo_Graphics_Driver::restore_clip()
The driver's clip_ member was not updated to the new Cairo clip state
which rendered function Fl_Cairo_Graphics_Driver::clip_box() inaccurate.
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx index 577ee0930..50a4dbae7 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx @@ -1340,6 +1340,8 @@ void Fl_Cairo_Graphics_Driver::XDestroyRegion(Fl_Region r_) { } } +#define fl_max(a,b) ((a) > (b) ? (a) : (b)) +#define fl_min(a,b) ((a) < (b) ? (a) : (b)) void Fl_Cairo_Graphics_Driver::restore_clip() { if (cairo_) { @@ -1347,10 +1349,28 @@ void Fl_Cairo_Graphics_Driver::restore_clip() { // apply what's in rstack struct flCairoRegion *r = (struct flCairoRegion*)rstack[rstackptr]; if (r) { + if (!clip_) { + clip_ = new Clip(); + clip_->prev = NULL; + } for (int i = 0; i < r->count; i++) { cairo_rectangle(cairo_, r->rects[i].x - 0.5, r->rects[i].y - 0.5, r->rects[i].width, r->rects[i].height); + // put in clip_ the bounding rect of region r + if (i == 0) { + clip_->x = r->rects[0].x; clip_->y = r->rects[0].y; + clip_->w = r->rects[0].width; clip_->h = r->rects[0].height; + } else { + int R = fl_max(r->rects[i].x + r->rects[i].width, clip_->x + clip_->w); + int B = fl_max(r->rects[i].y + r->rects[i].height, clip_->y + clip_->h); + clip_->x = fl_min(r->rects[i].x, clip_->x) ; + clip_->y = fl_min(r->rects[i].y, clip_->y); + clip_->w = R - clip_->x; + clip_->h = B - clip_->y; + } } cairo_clip(cairo_); + } else if (clip_) { + clip_->w = -1; } } } |
