summaryrefslogtreecommitdiff
path: root/drawinglayer/source/processor2d
diff options
context:
space:
mode:
Diffstat (limited to 'drawinglayer/source/processor2d')
-rw-r--r--drawinglayer/source/processor2d/vclpixelprocessor2d.cxx395
-rw-r--r--drawinglayer/source/processor2d/vclpixelprocessor2d.hxx1
2 files changed, 15 insertions, 381 deletions
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 4b5e45c7ef04..a93f85df4595 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -70,34 +70,6 @@ T round(T x)
using namespace com::sun::star;
-namespace {
-
-basegfx::B2DPolygon makeRectPolygon( double fX, double fY, double fW, double fH )
-{
- basegfx::B2DPolygon aPoly;
- aPoly.append(basegfx::B2DPoint(fX, fY));
- aPoly.append(basegfx::B2DPoint(fX+fW, fY));
- aPoly.append(basegfx::B2DPoint(fX+fW, fY+fH));
- aPoly.append(basegfx::B2DPoint(fX, fY+fH));
- aPoly.setClosed(true);
- return aPoly;
-}
-
-void drawHairLine(
- OutputDevice* pOutDev, double fX1, double fY1, double fX2, double fY2,
- const basegfx::BColor& rColor )
-{
- basegfx::B2DPolygon aTarget;
- aTarget.append(basegfx::B2DPoint(fX1, fY1));
- aTarget.append(basegfx::B2DPoint(fX2, fY2));
-
- pOutDev->SetFillColor();
- pOutDev->SetLineColor(Color(rColor));
- pOutDev->DrawPolyLine(aTarget);
-}
-
-}
-
namespace drawinglayer
{
namespace processor2d
@@ -306,341 +278,6 @@ namespace drawinglayer
return bTryWorked;
}
- bool VclPixelProcessor2D::tryDrawBorderLinePrimitive2DDirect(
- const drawinglayer::primitive2d::BorderLinePrimitive2D& rSource)
- {
- const basegfx::B2DPoint& rS = rSource.getStart();
- const basegfx::B2DPoint& rE = rSource.getEnd();
-
- double fX1 = rS.getX();
- double fY1 = rS.getY();
- double fX2 = rE.getX();
- double fY2 = rE.getY();
-
- bool bHorizontal = false;
- if (fX1 == fX2)
- {
- // Vertical line.
- }
- else if (fY1 == fY2)
- {
- // Horizontal line.
- bHorizontal = true;
- }
- else
- // Neither. Bail out.
- return false;
-
- switch (rSource.getStyle())
- {
- case SvxBorderLineStyle::SOLID:
- case SvxBorderLineStyle::DOUBLE_THIN:
- {
- const basegfx::BColor aLineColor =
- maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft());
- double nThick = rtl::math::round(rSource.getLeftWidth());
-
- bool bDouble = rSource.getStyle() == SvxBorderLineStyle::DOUBLE_THIN;
-
- basegfx::B2DPolygon aTarget;
-
- if (bHorizontal)
- {
- // Horizontal line. Draw it as a rectangle.
-
- aTarget = makeRectPolygon(fX1, fY1, fX2-fX1, nThick);
- aTarget.transform(maCurrentTransformation);
-
- basegfx::B2DRange aRange = aTarget.getB2DRange();
- double fH = aRange.getHeight();
-
- if (bDouble)
- {
- // Double line
- drawHairLine(
- mpOutputDevice, aRange.getMinX(), aRange.getMinY()-1.0, aRange.getMaxX(), aRange.getMinY()-1.0,
- aLineColor);
-
- drawHairLine(
- mpOutputDevice, aRange.getMinX(), aRange.getMinY()+1.0, aRange.getMaxX(), aRange.getMinY()+1.0,
- aLineColor);
-
- return true;
- }
-
- if (fH <= 1.0)
- {
- // Draw it as a line.
- drawHairLine(
- mpOutputDevice, aRange.getMinX(), aRange.getMinY(), aRange.getMaxX(), aRange.getMinY(),
- aLineColor);
-
- return true;
- }
-
- double fOffset = rtl::math::round(fH/2.0, 0, rtl_math_RoundingMode_Down);
- if (fOffset != 0.0)
- {
- // Move it up a bit to align it vertically centered.
- basegfx::B2DHomMatrix aMat;
- aMat.set(1, 2, -fOffset);
- aTarget.transform(aMat);
- }
- }
- else
- {
- // Vertical line. Draw it as a rectangle.
-
- aTarget = makeRectPolygon(fX1, fY1, nThick, fY2-fY1);
- aTarget.transform(maCurrentTransformation);
-
- basegfx::B2DRange aRange = aTarget.getB2DRange();
- double fW = aRange.getWidth();
-
- if (bDouble)
- {
- // Draw it as a line.
- drawHairLine(
- mpOutputDevice, aRange.getMinX()-1.0, aRange.getMinY(), aRange.getMinX()-1.0, aRange.getMaxY(),
- aLineColor);
-
- drawHairLine(
- mpOutputDevice, aRange.getMinX()+1.0, aRange.getMinY(), aRange.getMinX()+1.0, aRange.getMaxY(),
- aLineColor);
-
- return true;
- }
-
- if (fW <= 1.0)
- {
- // Draw it as a line.
- drawHairLine(
- mpOutputDevice, aRange.getMinX(), aRange.getMinY(), aRange.getMinX(), aRange.getMaxY(),
- aLineColor);
-
- return true;
- }
-
- double fOffset = rtl::math::round(fW/2.0, 0, rtl_math_RoundingMode_Down);
- if (fOffset != 0.0)
- {
- // Move it to the left a bit to center it horizontally.
- basegfx::B2DHomMatrix aMat;
- aMat.set(0, 2, -fOffset);
- aTarget.transform(aMat);
- }
- }
-
- mpOutputDevice->SetFillColor(Color(aLineColor));
- mpOutputDevice->SetLineColor();
- mpOutputDevice->DrawPolygon(aTarget);
- return true;
- }
- break;
- case SvxBorderLineStyle::DOTTED:
- case SvxBorderLineStyle::DASHED:
- case SvxBorderLineStyle::DASH_DOT:
- case SvxBorderLineStyle::DASH_DOT_DOT:
- case SvxBorderLineStyle::FINE_DASHED:
- {
- std::vector<double> aPattern =
- svtools::GetLineDashing(rSource.getStyle(), rSource.getPatternScale()*10.0);
-
- if (aPattern.empty())
- // Failed to get pattern values.
- return false;
-
- double nThick = rtl::math::round(rSource.getLeftWidth());
-
- const basegfx::BColor aLineColor =
- maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft());
-
- // Transform the current line range before using it for rendering.
- basegfx::B2DRange aRange(fX1, fY1, fX2, fY2);
- aRange.transform(maCurrentTransformation);
- fX1 = aRange.getMinX();
- fX2 = aRange.getMaxX();
- fY1 = aRange.getMinY();
- fY2 = aRange.getMaxY();
-
- basegfx::B2DPolyPolygon aTarget;
-
- if (bHorizontal)
- {
- // Horizontal line.
-
- if (basegfx::fTools::equalZero(nThick))
- {
- // Dash line segment too small to draw. Substitute it with a solid line.
- drawHairLine(mpOutputDevice, fX1, fY1, fX2, fY1, aLineColor);
- return true;
- }
-
- // Create a dash unit polygon set.
- basegfx::B2DPolyPolygon aDashes;
- std::vector<double>::const_iterator it = aPattern.begin(), itEnd = aPattern.end();
- for (; it != itEnd; ++it)
- aDashes.append(makeRectPolygon(0, 0, *it, nThick));
-
- aDashes.transform(maCurrentTransformation);
- rtl::math::setNan(&nThick);
-
- // Pixelize the dash unit. We use the same height for
- // all dash polygons.
- basegfx::B2DPolyPolygon aDashesPix;
-
- for (sal_uInt32 i = 0, n = aDashes.count(); i < n; ++i)
- {
- basegfx::B2DPolygon aPoly = aDashes.getB2DPolygon(i);
- aRange = aPoly.getB2DRange();
- double fW = rtl::math::round(aRange.getWidth());
- if (basegfx::fTools::equalZero(fW))
- {
- // Dash line segment too small to draw. Substitute it with a solid line.
- drawHairLine(mpOutputDevice, fX1, fY1, fX2, fY1, aLineColor);
- return true;
- }
-
- if (rtl::math::isNan(nThick))
- nThick = rtl::math::round(aRange.getHeight());
-
- aDashesPix.append(makeRectPolygon(0, 0, fW, nThick));
- }
-
- // Make all dash polygons and render them.
- double fX = fX1;
- bool bLine = true;
- sal_uInt32 i = 0, n = aDashesPix.count();
- while (fX <= fX2)
- {
- basegfx::B2DPolygon aPoly = aDashesPix.getB2DPolygon(i);
- aRange = aPoly.getB2DRange();
- if (bLine)
- {
- double fBlockW = aRange.getWidth();
- if (fX + fBlockW > fX2)
- // Clip the right end in case it spills over the range.
- fBlockW = fX2 - fX + 1;
-
- double fH = aRange.getHeight();
- if (basegfx::fTools::equalZero(fH))
- fH = 1.0;
-
- aTarget.append(makeRectPolygon(fX, fY1, fBlockW, fH));
- }
-
- bLine = !bLine; // line and blank alternate.
- fX += aRange.getWidth();
-
- ++i;
- if (i >= n)
- i = 0;
- }
-
- double fOffset = rtl::math::round(nThick/2.0, 0, rtl_math_RoundingMode_Down);
- if (fOffset != 0.0)
- {
- // Move it up a bit to align it vertically centered.
- basegfx::B2DHomMatrix aMat;
- aMat.set(1, 2, -fOffset);
- aTarget.transform(aMat);
- }
- }
- else
- {
- // Vertical line.
-
- if (basegfx::fTools::equalZero(nThick))
- {
- // Dash line segment too small to draw. Substitute it with a solid line.
- drawHairLine(mpOutputDevice, fX1, fY1, fX1, fY2, aLineColor);
- return true;
- }
-
- // Create a dash unit polygon set.
- basegfx::B2DPolyPolygon aDashes;
- std::vector<double>::const_iterator it = aPattern.begin(), itEnd = aPattern.end();
- for (; it != itEnd; ++it)
- aDashes.append(makeRectPolygon(0, 0, nThick, *it));
-
- aDashes.transform(maCurrentTransformation);
- rtl::math::setNan(&nThick);
-
- // Pixelize the dash unit. We use the same width for
- // all dash polygons.
- basegfx::B2DPolyPolygon aDashesPix;
-
- for (sal_uInt32 i = 0, n = aDashes.count(); i < n; ++i)
- {
- basegfx::B2DPolygon aPoly = aDashes.getB2DPolygon(i);
- aRange = aPoly.getB2DRange();
- double fH = rtl::math::round(aRange.getHeight());
- if (basegfx::fTools::equalZero(fH))
- {
- // Dash line segment too small to draw. Substitute it with a solid line.
- drawHairLine(mpOutputDevice, fX1, fY1, fX1, fY2, aLineColor);
- return true;
- }
-
- if (rtl::math::isNan(nThick))
- nThick = rtl::math::round(aRange.getWidth());
-
- aDashesPix.append(makeRectPolygon(0, 0, nThick, fH));
- }
-
- // Make all dash polygons and render them.
- double fY = fY1;
- bool bLine = true;
- sal_uInt32 i = 0, n = aDashesPix.count();
- while (fY <= fY2)
- {
- basegfx::B2DPolygon aPoly = aDashesPix.getB2DPolygon(i);
- aRange = aPoly.getB2DRange();
- if (bLine)
- {
- double fBlockH = aRange.getHeight();
- if (fY + fBlockH > fY2)
- // Clip the bottom end in case it spills over the range.
- fBlockH = fY2 - fY + 1;
-
- double fW = aRange.getWidth();
- if (basegfx::fTools::equalZero(fW))
- fW = 1.0;
-
- aTarget.append(makeRectPolygon(fX1, fY, fW, fBlockH));
- }
-
- bLine = !bLine; // line and blank alternate.
- fY += aRange.getHeight();
-
- ++i;
- if (i >= n)
- i = 0;
- }
-
- double fOffset = rtl::math::round(nThick/2.0, 0, rtl_math_RoundingMode_Down);
- if (fOffset != 0.0)
- {
- // Move it to the left a bit to center it horizontally.
- basegfx::B2DHomMatrix aMat;
- aMat.set(0, 2, -fOffset);
- aTarget.transform(aMat);
- }
- }
-
- mpOutputDevice->SetFillColor(Color(aLineColor));
- mpOutputDevice->SetLineColor();
- mpOutputDevice->DrawPolyPolygon(aTarget);
-
- return true;
- }
- break;
- default:
- ;
- }
- return false;
- }
-
void VclPixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
{
switch(rCandidate.getPrimitive2DID())
@@ -1253,28 +890,26 @@ namespace drawinglayer
}
case PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D:
{
- // process recursively, but turn off anti-aliasing. Border
- // lines are always rectangular, and look horrible when
- // the anti-aliasing is enabled.
- AntialiasingFlags nAntiAliasing = mpOutputDevice->GetAntialiasing();
- mpOutputDevice->SetAntialiasing(nAntiAliasing & ~AntialiasingFlags::EnableB2dDraw);
-
+ // process recursively, but switch off AntiAliasing for
+ // horizontal/vertical lines (*not* diagonal lines).
+ // Checked using AntialiasingFlags::PixelSnapHairline instead,
+ // but with AntiAliasing on the display really is too 'ghosty' when
+ // using fine stroking. Correct, but 'ghosty'.
const drawinglayer::primitive2d::BorderLinePrimitive2D& rBorder =
static_cast<const drawinglayer::primitive2d::BorderLinePrimitive2D&>(rCandidate);
- if (!tryDrawBorderLinePrimitive2DDirect(rBorder))
+ if (rBorder.isHorizontalOrVertical(getViewInformation2D()))
{
- if (rBorder.getStyle() == SvxBorderLineStyle::DOUBLE)
- {
- primitive2d::Primitive2DContainer aContainer;
- rBorder.createDecomposition(aContainer, getViewInformation2D(), true);
- process(aContainer);
- }
- else
- process(rCandidate);
- }
+ AntialiasingFlags nAntiAliasing = mpOutputDevice->GetAntialiasing();
+ mpOutputDevice->SetAntialiasing(nAntiAliasing & ~AntialiasingFlags::EnableB2dDraw);
- mpOutputDevice->SetAntialiasing(nAntiAliasing);
+ process(rCandidate);
+ mpOutputDevice->SetAntialiasing(nAntiAliasing);
+ }
+ else
+ {
+ process(rCandidate);
+ }
break;
}
default :
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx
index 0a8e97d748b8..19c0282ffc5a 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx
@@ -64,7 +64,6 @@ 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