summaryrefslogtreecommitdiff
path: root/canvas/source/vcl/impltools.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'canvas/source/vcl/impltools.cxx')
-rw-r--r--canvas/source/vcl/impltools.cxx63
1 files changed, 53 insertions, 10 deletions
diff --git a/canvas/source/vcl/impltools.cxx b/canvas/source/vcl/impltools.cxx
index 754a34ce0806..7b431bdf7258 100644
--- a/canvas/source/vcl/impltools.cxx
+++ b/canvas/source/vcl/impltools.cxx
@@ -27,12 +27,13 @@
#include <basegfx/utils/canvastools.hxx>
#include <basegfx/tuple/b2dtuple.hxx>
#include <rtl/math.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/canvastools.hxx>
#include <vcl/BitmapTools.hxx>
#include <vcl/metric.hxx>
+#include <vcl/skia/SkiaHelper.hxx>
#include <canvas/canvastools.hxx>
@@ -72,7 +73,7 @@ namespace vclcanvas::tools
xBitmap, uno::UNO_QUERY_THROW );
::BitmapEx aBmpEx = vcl::unotools::bitmapExFromXBitmap( xIntBmp );
- if( !!aBmpEx )
+ if( !aBmpEx.IsEmpty() )
return aBmpEx;
// TODO(F1): extract pixel from XBitmap interface
@@ -122,18 +123,45 @@ namespace vclcanvas::tools
if( !::rtl::math::approxEqual(aScale.getY(), 1.0) )
{
const sal_Int32 nFontHeight( io_rVCLFont.GetFontHeight() );
- io_rVCLFont.SetFontHeight( ::basegfx::fround(nFontHeight * aScale.getY()) );
+ io_rVCLFont.SetFontHeight( ::basegfx::fround<::tools::Long>(nFontHeight * aScale.getY()) );
}
- io_rVCLFont.SetOrientation( static_cast< short >( ::basegfx::fround(-fmod(nRotate, 2*M_PI)*(1800.0/M_PI)) ) );
+ io_rVCLFont.SetOrientation( Degree10( ::basegfx::fround(-basegfx::rad2deg<10>(fmod(nRotate, 2*M_PI))) ) );
// TODO(F2): Missing functionality in VCL: shearing
- o_rPoint.setX( ::basegfx::fround(aTranslate.getX()) );
- o_rPoint.setY( ::basegfx::fround(aTranslate.getY()) );
+ o_rPoint.setX( ::basegfx::fround<::tools::Long>(aTranslate.getX()) );
+ o_rPoint.setY( ::basegfx::fround<::tools::Long>(aTranslate.getY()) );
return true;
}
+ void setupFontWidth(const css::geometry::Matrix2D& rFontMatrix,
+ vcl::Font& rFont,
+ OutputDevice& rOutDev)
+ {
+ rFont.SetFontSize(Size(0, rFont.GetFontHeight()));
+
+ if (!::rtl::math::approxEqual(rFontMatrix.m00, rFontMatrix.m11))
+ {
+ const bool bOldMapState(rOutDev.IsMapModeEnabled());
+ rOutDev.EnableMapMode(false);
+
+ const Size aSize = rOutDev.GetFontMetric(rFont).GetFontSize();
+
+ const double fDividend(rFontMatrix.m10 + rFontMatrix.m11);
+ double fStretch = rFontMatrix.m00 + rFontMatrix.m01;
+
+ if (!::basegfx::fTools::equalZero(fDividend))
+ fStretch /= fDividend;
+
+ const ::tools::Long nNewWidth = ::basegfx::fround<::tools::Long>(aSize.Width() * fStretch);
+
+ rFont.SetAverageFontWidth(nNewWidth);
+
+ rOutDev.EnableMapMode(bOldMapState);
+ }
+ }
+
bool isRectangle( const ::tools::PolyPolygon& rPolyPoly )
{
// exclude some cheap cases first
@@ -195,13 +223,12 @@ namespace vclcanvas::tools
// deleted from the transformation; this can be handled by
// an offset when painting the bitmap
const Size aBmpSize( rBitmap.GetSizePixel() );
- ::basegfx::B2DRectangle aDestRect;
// calc effective transformation for bitmap
const ::basegfx::B2DRectangle aSrcRect( 0, 0,
aBmpSize.Width(),
aBmpSize.Height() );
- ::canvas::tools::calcTransformedRectBounds( aDestRect,
+ ::basegfx::B2DRectangle aDestRect = ::canvas::tools::calcTransformedRectBounds(
aSrcRect,
rTransform );
@@ -209,13 +236,29 @@ namespace vclcanvas::tools
// aligned with (0,0). The method takes the given
// rectangle, and calculates a transformation that maps
// this rectangle unscaled to the origin.
- ::basegfx::B2DHomMatrix aLocalTransform;
- ::canvas::tools::calcRectToOriginTransform( aLocalTransform,
+ ::basegfx::B2DHomMatrix aLocalTransform = ::canvas::tools::calcRectToOriginTransform(
aSrcRect,
rTransform );
return vcl::bitmap::CanvasTransformBitmap(rBitmap, rTransform, aDestRect, aLocalTransform);
}
+
+ void SetDefaultDeviceAntiAliasing( OutputDevice* pDevice )
+ {
+#if defined( MACOSX )
+ // use AA on VCLCanvas for Mac
+ pDevice->SetAntialiasing( AntialiasingFlags::Enable | pDevice->GetAntialiasing() );
+#else
+ // switch off AA for WIN32 and UNIX, the VCLCanvas does not look good with it and
+ // is not required to do AA. It would need to be adapted to use it correctly
+ // (especially gradient painting). This will need extra work.
+ if( SkiaHelper::isVCLSkiaEnabled()) // But Skia handles AA fine.
+ pDevice->SetAntialiasing( AntialiasingFlags::Enable | pDevice->GetAntialiasing() );
+ else
+ pDevice->SetAntialiasing(pDevice->GetAntialiasing() & ~AntialiasingFlags::Enable);
+#endif
+ }
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */