support drawing invalid rects

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12422 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2005-04-15 17:45:10 +00:00
parent 961efda06b
commit a4365bfe01
2 changed files with 34 additions and 20 deletions

View File

@ -547,10 +547,13 @@ DisplayDriverPainter::FillRect(const BRect &r, const RGBColor &color)
{
if (Lock()) {
fPainter->SetHighColor(color);
BRect touched = fPainter->FillRect(r);
fPainter->FillRect(r, color.GetColor32());
BRect touched(min_c(r.left, r.right),
min_c(r.top, r.bottom),
max_c(r.left, r.right),
max_c(r.top, r.bottom));
fGraphicsCard->Invalidate(touched);
fGraphicsCard->Invalidate(fPainter->ClipRect(touched));
Unlock();
}
@ -712,7 +715,11 @@ DisplayDriverPainter::StrokeLine(const BPoint &start, const BPoint &end, const R
context.draw_mode = B_OP_COPY;
StrokeLine(start, end, &context);
} else {
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(start, end)));
BRect touched(min_c(start.x, end.x),
min_c(start.y, end.y),
max_c(start.x, end.x),
max_c(start.y, end.y));
fGraphicsCard->Invalidate(fPainter->ClipRect(touched));
}
Unlock();
}
@ -769,16 +776,22 @@ void
DisplayDriverPainter::StrokeRect(const BRect &r, const RGBColor &color)
{
if (Lock()) {
fPainter->StrokeRect(r, color.GetColor32());
// support invalid rects
BRect vr(min_c(r.left, r.right),
min_c(r.top, r.bottom),
max_c(r.left, r.right),
max_c(r.top, r.bottom));
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(r.left, r.top,
r.right, r.top)));
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(r.left, r.top + 1,
r.left, r.bottom - 1)));
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(r.right, r.top + 1,
r.right, r.bottom - 1)));
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(r.left, r.bottom,
r.right, r.bottom)));
fPainter->StrokeRect(vr, color.GetColor32());
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(vr.left, vr.top,
vr.right, vr.top)));
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(vr.left, vr.top + 1,
vr.left, vr.bottom - 1)));
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(vr.right, vr.top + 1,
vr.right, vr.bottom - 1)));
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(vr.left, vr.bottom,
vr.right, vr.bottom)));
Unlock();
}

View File

@ -340,7 +340,6 @@ Painter::StrokeLine(BPoint a, BPoint b, DrawData* context)
return _Clipped(touched);
}
}
//printf("StrokeLine((%.2f, %.2f)->(%.2f, %.2f)) -> AGG version\n", a.x, a.y, b.x, b.y);
// do the pixel center offset here
a.x += 0.5;
a.y += 0.5;
@ -529,8 +528,9 @@ Painter::FillShape(/*const */BShape* shape) const
BRect
Painter::StrokeRect(const BRect& r) const
{
BPoint a(r.left, r.top);
BPoint b(r.right, r.bottom);
// support invalid rects
BPoint a(min_c(r.left, r.right), min_c(r.top, r.bottom));
BPoint b(max_c(r.left, r.right), max_c(r.top, r.bottom));
_Transform(&a);
_Transform(&b);
@ -579,8 +579,9 @@ Painter::StrokeRect(const BRect& r, const rgb_color& c) const
BRect
Painter::FillRect(const BRect& r) const
{
BPoint a(r.left, r.top);
BPoint b(r.right, r.bottom);
// support invalid rects
BPoint a(min_c(r.left, r.right), min_c(r.top, r.bottom));
BPoint b(max_c(r.left, r.right), max_c(r.top, r.bottom));
_Transform(&a, false);
_Transform(&b, false);
@ -990,8 +991,8 @@ BRect
Painter::_Clipped(const BRect& rect) const
{
if (rect.IsValid() && fClippingRegion)
return rect & fClippingRegion->Frame();
return rect;
return BRect(rect & fClippingRegion->Frame());
return BRect(rect);
}
// _UpdateFont