Skip to content

Commit ebc11ae

Browse files
Thorsten BehrensThorsten Behrens
authored andcommitted
emfplus: cut over to new EMF+ renderer
We're on par with the old functionality now (modulo a few smaller issues); overall QoS is much better, we get vector output on pdf and print, and the need for large offscreen bitmap rendering goes away. Change-Id: I1fa92c5cad67579c3fcfa78f1bc68696bf1623ec Reviewed-on: https://gerrit.libreoffice.org/41406 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Patrick Jaap <patrick.jaap@tu-dresden.de> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
1 parent a3782f1 commit ebc11ae

File tree

4 files changed

+1
-180
lines changed

4 files changed

+1
-180
lines changed

drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,40 +1714,6 @@ namespace drawinglayer
17141714

17151715
break;
17161716
}
1717-
case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D :
1718-
{
1719-
const primitive2d::MetafilePrimitive2D& aMetafile = static_cast< const primitive2d::MetafilePrimitive2D& >(rCandidate);
1720-
1721-
if(!aMetafile.getMetaFile().GetUseCanvas())
1722-
{
1723-
// Use new Metafile decomposition.
1724-
// TODO EMF+ stuffed into METACOMMENT support required
1725-
process(rCandidate);
1726-
}
1727-
else
1728-
{
1729-
#ifdef DBG_UTIL
1730-
// switch to test EMFPlus-enhanced MetafileDecomposition, don't do
1731-
// this by default in debug mode
1732-
static bool bTestEMFPDecomposition(false);
1733-
1734-
if (bTestEMFPDecomposition)
1735-
{
1736-
process(rCandidate);
1737-
}
1738-
else
1739-
{
1740-
// direct draw of MetaFile
1741-
RenderMetafilePrimitive2D(aMetafile);
1742-
}
1743-
#else // DBG_UTIL
1744-
// direct draw of MetaFile, use default processing
1745-
RenderMetafilePrimitive2D(aMetafile);
1746-
#endif // DBG_UTIL
1747-
}
1748-
1749-
break;
1750-
}
17511717
case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
17521718
{
17531719
// mask group. Special handling for MetaFiles.

drawinglayer/source/processor2d/vclpixelprocessor2d.cxx

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -485,59 +485,7 @@ namespace drawinglayer
485485
mpOutputDevice->SetAntialiasing(nOldAntiAliase | AntialiasingFlags::PixelSnapHairline);
486486
}
487487

488-
const primitive2d::MetafilePrimitive2D& rMetafilePrimitive( static_cast< const primitive2d::MetafilePrimitive2D& >(rCandidate) );
489-
490-
if( !rMetafilePrimitive.getMetaFile().GetUseCanvas() )
491-
{
492-
// use new Metafile decomposition
493-
process(rCandidate);
494-
}
495-
else
496-
{
497-
#ifdef DBG_UTIL
498-
// switch to test EMFPlus-enhanced MetafileDecomposition, don't do
499-
// this by default in debug mode
500-
static bool bTestEMFPDecomposition(false);
501-
502-
// switch to show the new visualization color changed behind
503-
// the original output vor visual testing, also not by default in debug mode
504-
static bool bUseChangedColorObject(false);
505-
506-
if (bTestEMFPDecomposition)
507-
{
508-
if (bUseChangedColorObject)
509-
{
510-
primitive2d::Primitive2DContainer aDecomposition;
511-
rMetafilePrimitive.get2DDecomposition(aDecomposition, getViewInformation2D());
512-
primitive2d::BasePrimitive2D* pBasePrimitive = nullptr;
513-
const primitive2d::Primitive2DReference aPrimitiveR(
514-
pBasePrimitive = new primitive2d::ModifiedColorPrimitive2D(
515-
aDecomposition,
516-
basegfx::BColorModifierSharedPtr(
517-
new basegfx::BColorModifier_RGBLuminanceContrast(
518-
0.5, // red
519-
-0.5, // green
520-
-0.5, // blue
521-
0.0, // luminance
522-
0.0)))); // contrast
523-
processBasePrimitive2D(*pBasePrimitive);
524-
RenderMetafilePrimitive2D(rMetafilePrimitive);
525-
}
526-
else
527-
{
528-
process(rCandidate);
529-
}
530-
}
531-
else
532-
{
533-
// direct draw of MetaFile
534-
RenderMetafilePrimitive2D(rMetafilePrimitive);
535-
}
536-
#else // DBG_UTIL
537-
// direct draw of MetaFile
538-
RenderMetafilePrimitive2D(rMetafilePrimitive);
539-
#endif // DBG_UTIL
540-
}
488+
process(rCandidate);
541489

542490
if(bForceLineSnap)
543491
{

drawinglayer/source/processor2d/vclprocessor2d.cxx

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,6 @@ namespace
8787

8888
return nSteps;
8989
}
90-
91-
// get metafile (copy it)
92-
GDIMetaFile GetMetaFile(const drawinglayer::primitive2d::MetafilePrimitive2D& rMetaCandidate, const basegfx::BColorModifierStack& rColorModifierStack)
93-
{
94-
if (rColorModifierStack.count())
95-
{
96-
const basegfx::BColor aRGBBaseColor(0, 0, 0);
97-
const basegfx::BColor aRGBColor(rColorModifierStack.getModifiedColor(aRGBBaseColor));
98-
return rMetaCandidate.getMetaFile().GetMonochromeMtf(Color(aRGBColor));
99-
}
100-
return rMetaCandidate.getMetaFile();
101-
}
10290
}
10391

10492
namespace drawinglayer
@@ -713,86 +701,6 @@ namespace drawinglayer
713701
}
714702
}
715703

716-
// direct draw of MetaFile
717-
void VclProcessor2D::RenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rMetaCandidate)
718-
{
719-
// decompose matrix to check for shear, rotate and mirroring
720-
basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rMetaCandidate.getTransform());
721-
basegfx::B2DVector aScale, aTranslate;
722-
double fRotate, fShearX;
723-
aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
724-
725-
if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
726-
{
727-
// #i102175# handle special case: If scale is negative in (x,y) (3rd quadrant), it can
728-
// be expressed as rotation by PI. This needs to be done for Metafiles since
729-
// these can be rotated, but not really mirrored
730-
aScale = basegfx::absolute(aScale);
731-
fRotate += F_PI;
732-
}
733-
734-
// get BoundRect
735-
basegfx::B2DRange aOutlineRange(rMetaCandidate.getB2DRange(getViewInformation2D()));
736-
aOutlineRange.transform(maCurrentTransformation);
737-
738-
// Due to the integer MapModes used from VCL aind inside MetaFiles errors of up to three
739-
// pixels in size may happen. As long as there is no better way (e.g. convert the MetaFile
740-
// to primitives) it is necessary to reduce maximum pixel size by 1 in X and Y and to use
741-
// the inner pixel bounds accordingly (ceil resp. floor). This will also be done for logic
742-
// units e.g. when creating a new MetaFile, but since much huger value ranges are used
743-
// there typically will be okay for this compromise.
744-
tools::Rectangle aDestRectView(
745-
// !!CAUTION!! Here, ceil and floor are exchanged BY PURPOSE, do NOT copy when
746-
// looking for a standard conversion to rectangle (!)
747-
(sal_Int32)ceil(aOutlineRange.getMinX()), (sal_Int32)ceil(aOutlineRange.getMinY()),
748-
(sal_Int32)floor(aOutlineRange.getMaxX()), (sal_Int32)floor(aOutlineRange.getMaxY()));
749-
750-
// get metafile (copy it)
751-
GDIMetaFile aMetaFile(GetMetaFile(rMetaCandidate, maBColorModifierStack));
752-
753-
// rotation
754-
if(!basegfx::fTools::equalZero(fRotate))
755-
{
756-
// #i103530#
757-
// MetaFile::Rotate has no input parameter check, so the parameter needs to be
758-
// well-aligned to the old range [0..3600] 10th degrees with inverse orientation
759-
sal_Int16 nRotation((sal_Int16)((fRotate / F_PI180) * -10.0));
760-
761-
while(nRotation < 0)
762-
nRotation += 3600;
763-
764-
while(nRotation >= 3600)
765-
nRotation -= 3600;
766-
767-
aMetaFile.Rotate(nRotation);
768-
}
769-
770-
// Prepare target output size
771-
Size aDestSize(aDestRectView.GetSize());
772-
773-
if(aDestSize.getWidth() > 0 && aDestSize.getHeight() > 0)
774-
{
775-
// Get preferred Metafile output size. When it's very equal to the output size, it's probably
776-
// a rounding error somewhere, so correct it to get a 1:1 output without single pixel scalings
777-
// of the Metafile (esp. for contained Bitmaps, e.g 3D charts)
778-
const Size aPrefSize(mpOutputDevice->LogicToPixel(aMetaFile.GetPrefSize(), aMetaFile.GetPrefMapMode()));
779-
780-
if(aPrefSize.getWidth() && (aPrefSize.getWidth() - 1 == aDestSize.getWidth() || aPrefSize.getWidth() + 1 == aDestSize.getWidth()))
781-
{
782-
aDestSize.setWidth(aPrefSize.getWidth());
783-
}
784-
785-
if(aPrefSize.getHeight() && (aPrefSize.getHeight() - 1 == aDestSize.getHeight() || aPrefSize.getHeight() + 1 == aDestSize.getHeight()))
786-
{
787-
aDestSize.setHeight(aPrefSize.getHeight());
788-
}
789-
790-
// paint it
791-
aMetaFile.WindStart();
792-
aMetaFile.Play(mpOutputDevice, aDestRectView.TopLeft(), aDestSize);
793-
}
794-
}
795-
796704
// mask group. Force output to VDev and create mask from given mask
797705
void VclProcessor2D::RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate)
798706
{

drawinglayer/source/processor2d/vclprocessor2d.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ namespace drawinglayer
106106
void RenderEpsPrimitive2D(const primitive2d::EpsPrimitive2D& rEpsPrimitive2D);
107107
void RenderSvgLinearAtomPrimitive2D(const primitive2d::SvgLinearAtomPrimitive2D& rCandidate);
108108
void RenderSvgRadialAtomPrimitive2D(const primitive2d::SvgRadialAtomPrimitive2D& rCandidate);
109-
void RenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rPolygonCandidate);
110109

111110
// DrawMode adaption support
112111
void adaptLineToFillDrawMode() const;

0 commit comments

Comments
 (0)