From 6a3fb868b2b8af21f7b6140424b6f8377599a786 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Sat, 18 Jan 2014 18:17:52 -0500 Subject: Draw horizontal solid border lines directly in the pixel processor. This makes slightly skinnier solid lines which look better on screen. Change-Id: Ia7764be4a53d1dd6bb60ecb3ba5c8966403e4e6c --- .../source/processor2d/vclpixelprocessor2d.cxx | 66 +++++++++++++++++++++- .../source/processor2d/vclpixelprocessor2d.hxx | 2 + 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 9b020f73adb2..97a67910f7e7 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,8 @@ #include #include +#include + ////////////////////////////////////////////////////////////////////////////// using namespace com::sun::star; @@ -239,6 +242,63 @@ namespace drawinglayer return bTryWorked; } + bool VclPixelProcessor2D::tryDrawBorderLinePrimitive2DDirect( + const drawinglayer::primitive2d::BorderLinePrimitive2D& rSource) + { + if (rSource.getStyle() == table::BorderLineStyle::SOLID) + { + const basegfx::B2DPoint& rS = rSource.getStart(); + const basegfx::B2DPoint& rE = rSource.getEnd(); + + double nX1 = rS.getX(); + double nY1 = rS.getY(); + double nX2 = rE.getX(); + double nY2 = rE.getY(); + + if (nY1 == nY2) + { + // Horizontal line. Draw it as a rectangle. + basegfx::B2DPolygon aTarget; + + const basegfx::BColor aLineColor = + maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft()); + double nThick = rtl::math::round(rSource.getLeftWidth()); + + aTarget.append(basegfx::B2DPoint(nX1, nY1)); + aTarget.append(basegfx::B2DPoint(nX2, nY1)); + aTarget.append(basegfx::B2DPoint(nX2, nY1+nThick)); + aTarget.append(basegfx::B2DPoint(nX1, nY1+nThick)); + aTarget.setClosed(true); + aTarget.transform(maCurrentTransformation); + + basegfx::B2DRange aRange = aTarget.getB2DRange(); + double fH = aRange.getHeight(); + + if (fH <= 1.0) + { + // Draw it as a line. + aTarget.clear(); + aTarget.append(basegfx::B2DPoint(aRange.getMinX(), aRange.getMinY())); + aTarget.append(basegfx::B2DPoint(aRange.getMaxX(), aRange.getMinY())); + + mpOutputDevice->SetFillColor(); + mpOutputDevice->SetLineColor(Color(aLineColor)); + + mpOutputDevice->DrawPolyLine(aTarget); + return true; + } + + mpOutputDevice->SetFillColor(Color(aLineColor)); + mpOutputDevice->SetLineColor(); + + mpOutputDevice->DrawPolygon(aTarget); + return true; + } + + } + return false; + } + void VclPixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) { switch(rCandidate.getPrimitive2DID()) @@ -851,7 +911,11 @@ namespace drawinglayer sal_uInt16 nAntiAliasing = mpOutputDevice->GetAntialiasing(); mpOutputDevice->SetAntialiasing(nAntiAliasing & ~ANTIALIASING_ENABLE_B2DDRAW); - process(rCandidate.get2DDecomposition(getViewInformation2D())); + const drawinglayer::primitive2d::BorderLinePrimitive2D& rBorder = + static_cast(rCandidate); + + if (!tryDrawBorderLinePrimitive2DDirect(rBorder)) + process(rCandidate.get2DDecomposition(getViewInformation2D())); mpOutputDevice->SetAntialiasing(nAntiAliasing); break; diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx index a55962deb5b6..c9c2d7422dc6 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx @@ -34,6 +34,7 @@ namespace drawinglayer { namespace primitive2d { class PolyPolygonColorPrimitive2D; class PolygonHairlinePrimitive2D; class PolygonStrokePrimitive2D; + class BorderLinePrimitive2D; }} ////////////////////////////////////////////////////////////////////////////// @@ -64,6 +65,7 @@ namespace drawinglayer bool tryDrawPolyPolygonColorPrimitive2DDirect(const drawinglayer::primitive2d::PolyPolygonColorPrimitive2D& rSource, double fTransparency); bool tryDrawPolygonHairlinePrimitive2DDirect(const drawinglayer::primitive2d::PolygonHairlinePrimitive2D& rSource, double fTransparency); bool tryDrawPolygonStrokePrimitive2DDirect(const drawinglayer::primitive2d::PolygonStrokePrimitive2D& rSource, double fTransparency); + bool tryDrawBorderLinePrimitive2DDirect(const drawinglayer::primitive2d::BorderLinePrimitive2D& rSource); public: /// constructor/destructor -- cgit v1.2.3