summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2018-08-24 13:01:08 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2018-08-30 19:48:46 +0200
commitb9fa01a8d1137a95af9865a3e47995734c40da6e (patch)
tree6d1e0a3e44b1a96fe5302d779c00fbee55cf8d24 /drawinglayer
parentf4a9ce33415a85d0b86ced3a0bf780f4ec61e25f (diff)
Support buffering SystemDependent GraphicData
This is a first step to allow buffering of system dependent data, especially (but not only) for the system-dependent implementations of graphic output. For example, for B2DPolygon and Win output, it allows buffering the Gdiplus::GraphicsPath instead of re- creating it all the time. To support that, the change includes forwarding the current transformation to the renderers in SalGraphics. The current state in VCL is to transform all and everything to device coordinates at every single paint. I have currently started to do this for ::drawPolyLine implementations. The fallbacks for all systems will at the start of that method just transform the data to device coordinates, so all works as before. This may also be done for FilledPolygon paint in a later step, but most urgent is FatLine painting. An arrangement of shared_ptr/weak_ptr is used so that either the instance buffering (in the example B2DPolygon) or the instance managing it can delete it. The instance managing it currently uses a 1s Timer and a cycle-lifetime management, but that can be extended in the future to e.g. include size hints, too. The mechanism it designed to support multiple Data per buffering element, e.g. for B2DPolygon at the same time system-dependent instances of Gdiplus and Cairo can be buffered, but also PDF-data. This is achieved semi-automatic by using typeid(class).hash_code() as key for organization. The mechanism will be used for now at B2DPolygon, but is not limited to. There is already a similar but less general buffer (see GdiPlusBuffer) that can and will be converted to use this new mechanism. Added vcl/headless Cairo renderer to support given ObjectToDevice transformation (not to transform given B2DPolygon) Added support for CairoPath buffered at B2DPolygon, seems to work well. Need to do more tests Moved usage to templates suggested by Noel Grandin (Noel Grandin <noelgrandin@gmail.com>), thanks for these suggestions. Adapted Win usage to that, too. Converted Win-specific GdiPlus BitmapBuffer to new mechanism, works well. Checked, the manager holds now a mix of bitmap and path data under Win Added a cleanup mechanism to flush all buffered data at DeInitVCL() using flushAll() at SystemDependentDataBuffer Adapted Linux-versions of ::drawPolyLine to support PixelSnapHairline, for now in a simplified version that still allows buffering. This will also be used (and use buffering) for the Cairo-fallback in X11SalGraphics Change-Id: I88d7e438a20b96ddab7707050893bdd590c098c7 Reviewed-on: https://gerrit.libreoffice.org/59555 Tested-by: Armin Le Grand <Armin.Le.Grand@cib.de> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/primitive2d/polygonprimitive2d.cxx6
-rw-r--r--drawinglayer/source/processor2d/vclpixelprocessor2d.cxx42
2 files changed, 31 insertions, 17 deletions
diff --git a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx
index e296f397e01b..2350f28699fc 100644
--- a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx
@@ -291,6 +291,9 @@ namespace drawinglayer
maLineAttribute(rLineAttribute),
maStrokeAttribute(rStrokeAttribute)
{
+ // simplify curve segments: moved here to not need to use it
+ // at VclPixelProcessor2D::tryDrawPolygonStrokePrimitive2DDirect
+ maPolygon = basegfx::utils::simplifyCurveSegments(maPolygon);
}
PolygonStrokePrimitive2D::PolygonStrokePrimitive2D(
@@ -301,6 +304,9 @@ namespace drawinglayer
maLineAttribute(rLineAttribute),
maStrokeAttribute()
{
+ // simplify curve segments: moved here to not need to use it
+ // at VclPixelProcessor2D::tryDrawPolygonStrokePrimitive2DDirect
+ maPolygon = basegfx::utils::simplifyCurveSegments(maPolygon);
}
bool PolygonStrokePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 0845c3316643..3295a97129f3 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -127,9 +127,9 @@ namespace drawinglayer
bool VclPixelProcessor2D::tryDrawPolygonHairlinePrimitive2DDirect(const drawinglayer::primitive2d::PolygonHairlinePrimitive2D& rSource, double fTransparency)
{
- basegfx::B2DPolygon aLocalPolygon(rSource.getB2DPolygon());
+ const basegfx::B2DPolygon& rLocalPolygon(rSource.getB2DPolygon());
- if(!aLocalPolygon.count())
+ if(!rLocalPolygon.count())
{
// no geometry, done
return true;
@@ -139,10 +139,14 @@ namespace drawinglayer
mpOutputDevice->SetFillColor();
mpOutputDevice->SetLineColor(Color(aLineColor));
- aLocalPolygon.transform(maCurrentTransformation);
+ //aLocalPolygon.transform(maCurrentTransformation);
// try drawing; if it did not work, use standard fallback
- return mpOutputDevice->DrawPolyLineDirect( aLocalPolygon, 0.0, fTransparency);
+ return mpOutputDevice->DrawPolyLineDirect(
+ maCurrentTransformation,
+ rLocalPolygon,
+ 0.0,
+ fTransparency);
}
bool VclPixelProcessor2D::tryDrawPolygonStrokePrimitive2DDirect(const drawinglayer::primitive2d::PolygonStrokePrimitive2D& rSource, double fTransparency)
@@ -158,7 +162,8 @@ namespace drawinglayer
basegfx::B2DPolyPolygon aHairLinePolyPolygon;
// simplify curve segments
- aLocalPolygon = basegfx::utils::simplifyCurveSegments(aLocalPolygon);
+ // moved to PolygonStrokePrimitive2D::PolygonStrokePrimitive2D
+ // aLocalPolygon = basegfx::utils::simplifyCurveSegments(aLocalPolygon);
if(rSource.getStrokeAttribute().isDefault() || 0.0 == rSource.getStrokeAttribute().getFullDotDashLen())
{
@@ -182,24 +187,24 @@ namespace drawinglayer
return true;
}
+ // check if LineWidth can be simplified in world coordinates
double fLineWidth(rSource.getLineAttribute().getWidth());
if(basegfx::fTools::more(fLineWidth, 0.0))
{
basegfx::B2DVector aLineWidth(fLineWidth, 0.0);
-
aLineWidth = maCurrentTransformation * aLineWidth;
- fLineWidth = aLineWidth.getLength();
- }
+ const double fWorldLineWidth(aLineWidth.getLength());
- // draw simple hairline for small line widths
- // see also RenderPolygonStrokePrimitive2D which is used if this try fails
- bool bIsAntiAliasing = getOptionsDrawinglayer().IsAntiAliasing();
- if ( (basegfx::fTools::lessOrEqual(fLineWidth, 1.0) && bIsAntiAliasing)
- || (basegfx::fTools::lessOrEqual(fLineWidth, 1.5) && !bIsAntiAliasing))
- {
- // draw simple hairline
- fLineWidth = 0.0;
+ // draw simple hairline for small line widths
+ // see also RenderPolygonStrokePrimitive2D which is used if this try fails
+ bool bIsAntiAliasing = getOptionsDrawinglayer().IsAntiAliasing();
+ if ( (basegfx::fTools::lessOrEqual(fWorldLineWidth, 1.0) && bIsAntiAliasing)
+ || (basegfx::fTools::lessOrEqual(fWorldLineWidth, 1.5) && !bIsAntiAliasing))
+ {
+ // draw simple hairline
+ fLineWidth = 0.0;
+ }
}
const basegfx::BColor aLineColor(
@@ -208,7 +213,9 @@ namespace drawinglayer
mpOutputDevice->SetFillColor();
mpOutputDevice->SetLineColor(Color(aLineColor));
- aHairLinePolyPolygon.transform(maCurrentTransformation);
+
+ // do not transform self
+ // aHairLinePolyPolygon.transform(maCurrentTransformation);
bool bHasPoints(false);
bool bTryWorked(false);
@@ -222,6 +229,7 @@ namespace drawinglayer
bHasPoints = true;
if(mpOutputDevice->DrawPolyLineDirect(
+ maCurrentTransformation,
aSingle,
fLineWidth,
fTransparency,