summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-06-05 15:23:54 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-06-06 10:47:42 +0200
commitae6dbb573e4cd992b1ad92325203c721b3c8e8ab (patch)
treeaa73dc6a44c8716897c567403340ed41fdd53b27 /drawinglayer
parent790cc0cc928f1c04bace552a813a5dbf0a8b3424 (diff)
fdo#49438: heuristic pseudo-hack to use hair-lines if width <= 0.5 pixel
Change-Id: I089d0eea5a0d597705405072de285251a91dfbcc Signed-off-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/inc/drawinglayer/primitive2d/borderlineprimitive2d.hxx34
-rw-r--r--drawinglayer/inc/drawinglayer/primitive2d/clippedborderlineprimitive2d.hxx3
-rw-r--r--drawinglayer/source/primitive2d/borderlineprimitive2d.cxx75
-rw-r--r--drawinglayer/source/primitive2d/clippedborderlineprimitive2d.cxx3
4 files changed, 66 insertions, 49 deletions
diff --git a/drawinglayer/inc/drawinglayer/primitive2d/borderlineprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/borderlineprimitive2d.hxx
index 6ca9643c60ab..1c9c1a911dbb 100644
--- a/drawinglayer/inc/drawinglayer/primitive2d/borderlineprimitive2d.hxx
+++ b/drawinglayer/inc/drawinglayer/primitive2d/borderlineprimitive2d.hxx
@@ -83,35 +83,8 @@ namespace drawinglayer
unsigned mbCreateOutside : 1;
/// local helpers
- double getCorrectedLeftWidth() const
- {
- return mfLeftWidth <= 0.1 ? 0.0 : mfLeftWidth;
- }
-
- double getCorrectedDistance() const
- {
- return mfDistance <= 0.1 ? 0.0 : mfDistance;
- }
-
- double getCorrectedRightWidth() const
- {
- return mfRightWidth <= 0.1 ? 0.0 : mfRightWidth;
- }
-
- double getWidth() const
- {
- return getCorrectedLeftWidth() + getCorrectedDistance() + getCorrectedRightWidth();
- }
-
- bool leftIsHairline() const
- {
- return 0 < mfLeftWidth && mfLeftWidth <= 0.1;
- }
-
- bool rightIsHairline() const
- {
- return 0 < mfRightWidth && mfRightWidth <= 0.1;
- }
+ double getWidth(
+ const geometry::ViewInformation2D& rViewInformation) const;
bool isSolidLine() const
{
@@ -129,7 +102,8 @@ namespace drawinglayer
}
protected:
- virtual basegfx::B2DPolyPolygon getClipPolygon( ) const;
+ virtual basegfx::B2DPolyPolygon getClipPolygon(
+ const geometry::ViewInformation2D& rViewInformation) const;
/// create local decomposition
virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
diff --git a/drawinglayer/inc/drawinglayer/primitive2d/clippedborderlineprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/clippedborderlineprimitive2d.hxx
index 9c1495b0d582..689f35888d5f 100644
--- a/drawinglayer/inc/drawinglayer/primitive2d/clippedborderlineprimitive2d.hxx
+++ b/drawinglayer/inc/drawinglayer/primitive2d/clippedborderlineprimitive2d.hxx
@@ -49,7 +49,8 @@ namespace drawinglayer
const basegfx::B2DPolygon maIntersection;
protected:
- virtual basegfx::B2DPolyPolygon getClipPolygon( ) const;
+ virtual basegfx::B2DPolyPolygon getClipPolygon(
+ const geometry::ViewInformation2D& rViewInformation) const;
public:
/// constructor
diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
index 86f58d653c49..4591330655e4 100644
--- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
@@ -41,9 +41,45 @@
namespace drawinglayer
{
+ // fdo#49438: heuristic pseudo hack
+ static bool lcl_UseHairline(double const fW,
+ basegfx::B2DPoint const& rStart, basegfx::B2DPoint const& rEnd,
+ geometry::ViewInformation2D const& rViewInformation)
+ {
+ basegfx::B2DTuple scale;
+ basegfx::B2DTuple translation;
+ double fRotation;
+ double fShear;
+ rViewInformation.getObjectToViewTransformation().decompose(
+ scale, translation, fRotation, fShear);
+ double const fScale(
+ (rEnd.getX() - rStart.getX() > rEnd.getY() - rStart.getY())
+ ? scale.getY() : scale.getX());
+ return (fW * fScale < 0.51);
+ }
+
+ static double lcl_GetCorrectedWidth(double const fW,
+ basegfx::B2DPoint const& rStart, basegfx::B2DPoint const& rEnd,
+ geometry::ViewInformation2D const& rViewInformation)
+ {
+ return (lcl_UseHairline(fW, rStart, rEnd, rViewInformation)) ? 0.0 : fW;
+ }
+
namespace primitive2d
{
- basegfx::B2DPolyPolygon BorderLinePrimitive2D::getClipPolygon( ) const
+ double BorderLinePrimitive2D::getWidth(
+ geometry::ViewInformation2D const& rViewInformation) const
+ {
+ return lcl_GetCorrectedWidth(mfLeftWidth, getStart(), getEnd(),
+ rViewInformation)
+ + lcl_GetCorrectedWidth(mfDistance, getStart(), getEnd(),
+ rViewInformation)
+ + lcl_GetCorrectedWidth(mfRightWidth, getStart(), getEnd(),
+ rViewInformation);
+ }
+
+ basegfx::B2DPolyPolygon BorderLinePrimitive2D::getClipPolygon(
+ geometry::ViewInformation2D const& rViewInformation) const
{
basegfx::B2DPolygon clipPolygon;
@@ -53,8 +89,8 @@ namespace drawinglayer
const basegfx::B2DVector aPerpendicular(basegfx::getPerpendicular(aVector));
// Get the points
- const basegfx::B2DVector aLeftOff(aPerpendicular * (-0.5 * (getWidth())));
- const basegfx::B2DVector aRightOff(aPerpendicular * (0.5 * (getWidth())));
+ const basegfx::B2DVector aLeftOff(aPerpendicular * (-0.5 * (getWidth(rViewInformation))));
+ const basegfx::B2DVector aRightOff(aPerpendicular * (0.5 * (getWidth(rViewInformation))));
const basegfx::B2DVector aSLVector( aLeftOff - ( getExtendLeftStart() * aVector ) );
clipPolygon.append( basegfx::B2DPoint( getStart() + aSLVector * 2.0 ) );
@@ -84,16 +120,17 @@ namespace drawinglayer
if(!getStart().equal(getEnd()) && ( isInsideUsed() || isOutsideUsed() ) )
{
// get data and vectors
- const double fWidth(getWidth());
+ const double fWidth(getWidth(rViewInformation));
basegfx::B2DVector aVector(getEnd() - getStart());
aVector.normalize();
const basegfx::B2DVector aPerpendicular(basegfx::getPerpendicular(aVector));
- const basegfx::B2DPolyPolygon& aClipRegion = getClipPolygon( );
+ const basegfx::B2DPolyPolygon& aClipRegion =
+ getClipPolygon(rViewInformation);
if(isOutsideUsed() && isInsideUsed())
{
- const double fExt = getWidth( ); // Extend a lot: it'll be clipped after
+ const double fExt = getWidth(rViewInformation); // Extend a lot: it'll be clipped after
// both used, double line definition. Create left and right offset
xRetval.realloc(2);
@@ -103,12 +140,13 @@ namespace drawinglayer
{
// create geometry for left
- const basegfx::B2DVector aLeftOff(aPerpendicular * (0.5 * (getCorrectedLeftWidth() - fWidth + 1)));
+ const basegfx::B2DVector aLeftOff(aPerpendicular * (0.5 * (lcl_GetCorrectedWidth(mfLeftWidth, getStart(), getEnd(), rViewInformation) - fWidth + 1)));
const basegfx::B2DPoint aTmpStart(getStart() + aLeftOff - ( fExt * aVector));
const basegfx::B2DPoint aTmpEnd(getEnd() + aLeftOff + ( fExt * aVector));
basegfx::B2DPolygon aLeft;
- if(leftIsHairline())
+ if (lcl_UseHairline(mfLeftWidth, getStart(), getEnd(),
+ rViewInformation))
{
// create hairline primitive
aLeft.append(aTmpStart);
@@ -132,7 +170,7 @@ namespace drawinglayer
// with the correct LineWidth, but this leads to problems when no AA
// is available and fat line special case reductions between 0.5 < x < 2.5 line widths
// are executed due to the FilledPolygon-do-not-paint-their-bottom-and-right-lines.
- const basegfx::B2DVector aLineWidthOffset((getCorrectedLeftWidth() * 0.5) * aPerpendicular);
+ const basegfx::B2DVector aLineWidthOffset((lcl_GetCorrectedWidth(mfLeftWidth, getStart(), getEnd(), rViewInformation) * 0.5) * aPerpendicular);
aLeft.append(aTmpStart + aLineWidthOffset);
aLeft.append(aTmpEnd + aLineWidthOffset);
@@ -153,12 +191,13 @@ namespace drawinglayer
{
// create geometry for right
- const basegfx::B2DVector aRightOff(aPerpendicular * (0.5 * (fWidth - getCorrectedRightWidth() + 1)));
+ const basegfx::B2DVector aRightOff(aPerpendicular * (0.5 * (fWidth - lcl_GetCorrectedWidth(mfRightWidth, getStart(), getEnd(), rViewInformation) + 1)));
const basegfx::B2DPoint aTmpStart(getStart() + aRightOff - ( fExt * aVector));
const basegfx::B2DPoint aTmpEnd(getEnd() + aRightOff + ( fExt * aVector));
basegfx::B2DPolygon aRight;
- if(rightIsHairline())
+ if (lcl_UseHairline(mfRightWidth, getStart(), getEnd(),
+ rViewInformation))
{
// create hairline primitive
aRight.append(aTmpStart);
@@ -179,7 +218,7 @@ namespace drawinglayer
else
{
// create filled polygon primitive
- const basegfx::B2DVector aLineWidthOffset((getCorrectedRightWidth() * 0.5) * aPerpendicular);
+ const basegfx::B2DVector aLineWidthOffset((lcl_GetCorrectedWidth(mfRightWidth, getStart(), getEnd(), rViewInformation) * 0.5) * aPerpendicular);
aRight.append(aTmpStart + aLineWidthOffset);
aRight.append(aTmpEnd + aLineWidthOffset);
@@ -215,22 +254,24 @@ namespace drawinglayer
{
// single line, create geometry
basegfx::B2DPolygon aPolygon;
- const double fExt = getWidth( ); // Extend a lot: it'll be clipped after
+ const double fExt = getWidth(rViewInformation); // Extend a lot: it'll be clipped after
const basegfx::B2DPoint aTmpStart(getStart() - (fExt * aVector));
const basegfx::B2DPoint aTmpEnd(getEnd() + (fExt * aVector));
xRetval.realloc(1);
// Get which is the line to show
- bool bIsHairline = leftIsHairline();
bool bIsSolidline = isSolidLine();
- double nWidth = getCorrectedLeftWidth();
+ double nWidth = getLeftWidth();
basegfx::BColor aColor = getRGBColorLeft();
if ( basegfx::fTools::equal( 0.0, mfLeftWidth ) )
{
- bIsHairline = rightIsHairline();
- nWidth = getCorrectedRightWidth();
+ nWidth = getRightWidth();
aColor = getRGBColorRight();
}
+ bool const bIsHairline = lcl_UseHairline(
+ nWidth, getStart(), getEnd(), rViewInformation);
+ nWidth = lcl_GetCorrectedWidth(nWidth,
+ getStart(), getEnd(), rViewInformation);
if(bIsHairline && bIsSolidline)
{
diff --git a/drawinglayer/source/primitive2d/clippedborderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/clippedborderlineprimitive2d.cxx
index 874c61746d48..3b9f82ed0599 100644
--- a/drawinglayer/source/primitive2d/clippedborderlineprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/clippedborderlineprimitive2d.cxx
@@ -33,7 +33,8 @@ namespace drawinglayer
{
namespace primitive2d
{
- basegfx::B2DPolyPolygon ClippedBorderLinePrimitive2D::getClipPolygon( ) const
+ basegfx::B2DPolyPolygon ClippedBorderLinePrimitive2D::getClipPolygon(
+ geometry::ViewInformation2D const&) const
{
basegfx::B2DPolyPolygon aPolyPolygon;
aPolyPolygon.append( maIntersection );