From 17360617d2bd2d5fb1226f77b0195632b89064c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Fri, 15 Apr 2005 08:15:04 +0000 Subject: [PATCH] fixed a really lame bug in the StrokeLine call that caused all these problems with line drawing and or invalidation afterwards, avoid transforming the clipping region into another format used by AGG by using a special BRegion based renderer git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12400 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/servers/app/Painter.h | 2 +- src/servers/app/drawing/Painter/Painter.cpp | 28 +++++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/headers/private/servers/app/Painter.h b/headers/private/servers/app/Painter.h index f308a2c5a6..2adcce957a 100644 --- a/headers/private/servers/app/Painter.h +++ b/headers/private/servers/app/Painter.h @@ -255,7 +255,7 @@ class Painter { BRect _Transform(const BRect& rect) const; BRect _Clipped(const BRect& rect) const; - void _RebuildClipping(); +// void _RebuildClipping(); void _UpdateFont(); void _UpdateLineWidth(); diff --git a/src/servers/app/drawing/Painter/Painter.cpp b/src/servers/app/drawing/Painter/Painter.cpp index fa0c4e73cd..72ed1eb336 100644 --- a/src/servers/app/drawing/Painter/Painter.cpp +++ b/src/servers/app/drawing/Painter/Painter.cpp @@ -107,6 +107,7 @@ Painter::AttachToBuffer(RenderingBuffer* buffer) false)); fBaseRenderer = new renderer_base(*fPixelFormat); + fBaseRenderer->set_clipping_region(fClippingRegion); // These are the AGG renderes and rasterizes which // will be used for stroking paths @@ -135,7 +136,7 @@ rgb_color color = fPatternHandler->HighColor().GetColor32(); fFontRendererBin = new font_renderer_bin_type(*fBaseRenderer); _SetRendererColor(fPatternHandler->HighColor().GetColor32()); - _RebuildClipping(); +// _RebuildClipping(); } } @@ -176,11 +177,14 @@ Painter::ConstrainClipping(const BRegion& region) // never constrained, there is *no* clipping. // This is of course different from having // an *empty* clipping region. - if (!fClippingRegion) + if (!fClippingRegion) { fClippingRegion = new BRegion(region); - else + // attach the base renderer to our clipping region + if (fBaseRenderer) + fBaseRenderer->set_clipping_region(fClippingRegion); + } else *fClippingRegion = region; - _RebuildClipping(); +// _RebuildClipping(); } // SetHighColor @@ -203,7 +207,7 @@ Painter::SetScale(float scale) { if (fScale != scale) { fScale = scale; - _RebuildClipping(); +// _RebuildClipping(); _UpdateLineWidth(); } } @@ -229,7 +233,7 @@ Painter::SetOrigin(const BPoint& origin) // I don't know yet what actually happens if you still // try to call SetOrigin() from within BView::Draw() fOrigin = origin; - _RebuildClipping(); +// _RebuildClipping(); } // SetDrawingMode @@ -310,12 +314,14 @@ Painter::StrokeLine(BPoint a, BPoint b, DrawData* context) SetPenSize(context->pensize); float penSize = _Transform(fPenSize); - BRect touched(a, b); + BRect touched(min_c(a.x, b.x), min_c(a.y, b.y), + max_c(a.x, b.x), max_c(a.y, b.y)); // This is supposed to stop right here if we can see // that we're definitaly outside the clipping reagion. - // It is not really correct, but fast and only triggers - // unnecessary calculation in a few edge cases + // Extending by penSize like that is not really correct, + // but fast and only triggers unnecessary calculation + // in a few edge cases touched.InsetBy(-(penSize - 1), -(penSize - 1)); if (!touched.Intersects(fClippingRegion->Frame())) { touched.Set(0.0, 0.0, -1.0, -1.0); @@ -1061,7 +1067,7 @@ Painter::_Clipped(const BRect& rect) const } // #pragma mark - - +/* // _RebuildClipping void Painter::_RebuildClipping() @@ -1099,7 +1105,7 @@ Painter::_RebuildClipping() } } } -} +}*/ // _UpdateFont void