From 2d52128c32c54eaf285d3cca0dbe07e9c27cb3f2 Mon Sep 17 00:00:00 2001 From: ketmar Date: Sat, 4 Dec 2021 12:01:11 +0000 Subject: [PATCH] egra: prepare agg mini before calling `onPaint()` (and cleanup afterwards) FossilOrigin-Name: 307f7f13f6d1111d03d5ab5492ea377d83652837ee2a3a855d6aaa6fcb2bc8aa --- egra/gfx/aggmini/enums.d | 5 ++++- egra/gui/subwindows.d | 2 ++ egra/gui/widgets/base.d | 8 +++++--- egra/gui/widgets/buttons.d | 2 ++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/egra/gfx/aggmini/enums.d b/egra/gfx/aggmini/enums.d index 3d5b0c8..35a3dbc 100644 --- a/egra/gfx/aggmini/enums.d +++ b/egra/gfx/aggmini/enums.d @@ -21,7 +21,7 @@ private: nothrow @safe @nogc: private import iv.egra.gfx.lowlevel : gxInterpolateColorI; -private import iv.egra.gfx.base : GxColor, gxTransparent; +private import iv.egra.gfx.base : GxColor, gxTransparent, gxUnknown; /* Bezier curve rasterizer. @@ -188,6 +188,9 @@ public: set(y0, c0, y1, c1, midpercent, midc); } + int getY (int idx) const pure { return (idx >= 0 && idx < yp.length ? yp[idx] : -666); } + GxColor getColor (int idx) const pure { return (idx >= 0 && idx < clr.length ? clr[idx] : gxUnknown); } + void set (in int y0, in GxColor c0, in int y1, in GxColor c1, in int midpercent=-1, in GxColor midc=gxTransparent) { if (y0 < y1) { yp.ptr[0] = y0; diff --git a/egra/gui/subwindows.d b/egra/gui/subwindows.d index 685f476..d6f2633 100644 --- a/egra/gui/subwindows.d +++ b/egra/gui/subwindows.d @@ -1018,6 +1018,8 @@ public: void onPaint () { if (closed) return; gxWithSavedClip { + gxagg.beginFrame(); + scope(exit) gxagg.cancelFrame(); drawDecoration(); if (!minimised) drawWidgets(); }; diff --git a/egra/gui/widgets/base.d b/egra/gui/widgets/base.d index 6ec3ae1..00b2724 100644 --- a/egra/gui/widgets/base.d +++ b/egra/gui/widgets/base.d @@ -639,17 +639,19 @@ public: if (nonVisual || rect.empty) return; // nothing to paint here if (gxClipRect.empty) return; // totally clipped away gxWithSavedClip { + gxagg.beginFrame(); + scope(exit) gxagg.cancelFrame(); immutable GxRect grect = globalRect; if (!gxClipRect.intersect(grect)) return; if (!gxClipRect.intersect(0, 0, VBufWidth, VBufHeight)) return; // before-children painter - gxWithSavedClip { doPaint(grect); }; + gxWithSavedClip { gxagg.cancelFrame(); doPaint(grect); }; // paint children foreach (Widget w; visualChildren) { - gxWithSavedClip { w.onPaint(); }; + gxWithSavedClip { gxagg.cancelFrame(); w.onPaint(); }; } // after-children painter - gxWithSavedClip { doPaintPost(grect); }; + gxWithSavedClip { gxagg.cancelFrame(); doPaintPost(grect); }; }; } diff --git a/egra/gui/widgets/buttons.d b/egra/gui/widgets/buttons.d index 840044a..a883895 100644 --- a/egra/gui/widgets/buttons.d +++ b/egra/gui/widgets/buttons.d @@ -113,7 +113,9 @@ public: auto grad = AGGVGradient3(grect.y0, getColor("grad0-back"), grect.y1, getColor("grad2-back"), getInt("grad-midp"), getColor("grad1-back")); + //conwritefln!"PAINT(%s): y0=%s; c0=0x%08x; y1=%s; c1=0x%08x; y2=%s; c2=0x%08x"(mTitle, grad.getY(0), grad.getColor(0), grad.getY(1), grad.getColor(1), grad.getY(2), grad.getColor(2)); gxagg + .resetParams() .beginPath() .roundedRect(grect.x0, grect.y0, width, height, rad) .fill() -- 2.11.4.GIT