Draw: AddRefreshRect (extracted from X11 Invalidate)

git-svn-id: svn://ultimatepp.org/upp/trunk@3558 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-06-25 18:28:38 +00:00
parent 620735a96c
commit 17a01d00cf
4 changed files with 29 additions and 22 deletions

View file

@ -33,7 +33,6 @@ Vector<Rect> Subtract(const Vector<Rect>& r1, const Vector<Rect>& r2)
return q;
}
Vector<Rect> Xor(const Vector<Rect>& r1, const Vector<Rect>& r2)
{
Vector<Rect> is = Intersect(r1, r2);

View file

@ -964,27 +964,7 @@ void Ctrl::Invalidate(XWindow& xw, const Rect& _r)
GuiLock __;
LTIMING("Invalidate");
LLOG("Invalidate " << UPP::Name(xw.ctrl) << " " << _r);
Vector<Rect> inv;
Rect r = _r;
int ra = r.Width() * r.Height();
for(int i = 0; i < xw.invalid.GetCount(); i++) {
const Rect& ir = xw.invalid[i];
Rect ur = r | ir;
if(ur.Width() * ur.Height() < 2 * (ir.Width() * ir.Height() + ra))
r = ur;
else
if(!r.Contains(xw.invalid[i]))
inv.Add(xw.invalid[i]);
}
Vector<Rect> rs;
rs.Add(r);
for(int i = 0; i < inv.GetCount(); i++) {
bool ch = false;
Vector<Rect> rs1 = Subtract(rs, inv[i], ch);
if(ch) rs = rs1;
}
inv.AppendPick(rs);
xw.invalid = inv;
AddRefreshRect(xw.invalid, _r);
}
void Ctrl::AddGlobalRepaint()

View file

@ -792,6 +792,9 @@ Vector<Rect> Intersect(const Vector<Rect>& b, const Rect& a, bool& changed);
void Subtract(Vector<Rect>& rr, const Rect& sub);
void Union(Vector<Rect>& rr, const Rect& add);
void AddRefreshRect(Vector<Rect>& invalid, const Rect& _r);
void DrawRect(Draw& w, const Rect& rect, const Image& img, bool ralgn = false); //??? TODO
void DrawRect(Draw& w, int x, int y, int cx, int cy, const Image& img, bool ra = false);

View file

@ -88,6 +88,31 @@ Vector<Rect> Intersect(const Vector<Rect>& b, const Rect& a, bool& changed)
return result;
}
void AddRefreshRect(Vector<Rect>& invalid, const Rect& _r)
{
Vector<Rect> inv;
Rect r = _r;
int ra = r.Width() * r.Height();
for(int i = 0; i < invalid.GetCount(); i++) {
const Rect& ir = invalid[i];
Rect ur = r | ir;
if(ur.Width() * ur.Height() < 2 * (ir.Width() * ir.Height() + ra))
r = ur;
else
if(!r.Contains(ir))
inv.Add(ir);
}
Vector<Rect> rs;
rs.Add(r);
for(int i = 0; i < inv.GetCount(); i++) {
bool ch = false;
Vector<Rect> rs1 = Subtract(rs, inv[i], ch);
if(ch) rs = rs1;
}
inv.AppendPick(rs);
invalid = inv;
}
void DrawFatFrame(Draw& w, int x, int y, int cx, int cy, Color color, int n) {
if(n < 0) {
x += n;