r20066 by fschmid - Better handling of DropShadows when the Object has no fill.

scribus-commit scribus-commit at lists.scribus.net
Sat May 9 08:37:22 UTC 2015


Author: fschmid
Date: Sat May  9 08:37:22 2015
New Revision: 20066

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20066
Log:
Better handling of DropShadows when the Object has no fill.

Modified:
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/scpainter.cpp

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20066&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Sat May  9 08:37:22 2015
@@ -43,7 +43,6 @@
 #include "canvas.h"
 #include "cmsettings.h"
 #include "colorblind.h"
-#include "commonstrings.h"
 #include "desaxe/saxXML.h"
 #include "marks.h"
 #include "pageitem_arc.h"
@@ -2338,11 +2337,30 @@
 	p->setupPolygon(&sh);
 	p->setBrush(tmp);
 	p->setFillMode(ScPainter::Solid);
-	p->setStrokeMode(ScPainter::Solid);
-	p->setPen(tmp, lwCorr, PLineArt, PLineEnd, PLineJoin);
 	p->fillPath();
-	p->strokePath();
+	if (hasStroke())
+	{
+		p->setStrokeMode(ScPainter::Solid);
+		p->setPen(tmp, lwCorr, PLineArt, PLineEnd, PLineJoin);
+		p->strokePath();
+	}
 	p->blur(m_softShadowBlurRadius * sc);
+	if (!hasFill())
+	{
+		sh = PoLine.copy();
+		p->setupPolygon(&sh);
+		p->setBrush(tmp);
+		p->setFillMode(ScPainter::Solid);
+		p->setBlendModeFill(19);
+		p->fillPath();
+		if (hasStroke())
+		{
+			p->setBlendModeStroke(19);
+			p->setStrokeMode(ScPainter::Solid);
+			p->setPen(tmp, lwCorr, PLineArt, PLineEnd, PLineJoin);
+			p->strokePath();
+		}
+	}
 	p->endLayer();
 	p->restore();
 }

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20066&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Sat May  9 08:37:22 2015
@@ -38,6 +38,7 @@
 
 #include "scribusapi.h"
 #include "annotation.h"
+#include "commonstrings.h"
 #include "colormgmt/sccolormgmtstructs.h"
 #include "desaxe/saxio.h"
 #include "observable.h"
@@ -1193,6 +1194,8 @@
 	QString getItemTextSaxed(int selStart, int selLength); ///< used by notes frames to get content of notes from itemText
 	bool groupClipping() { return m_groupClips; }
 	void setGroupClipping(bool val) { m_groupClips = val; }
+	bool hasFill() { return ((fillColor() != CommonStrings::None) || (GrType != 0)); }
+	bool hasStroke() { return ((lineColor() != CommonStrings::None) || (GrTypeStroke != 0) || (!NamedLStyle.isEmpty()) || (!patternStrokeVal.isEmpty())); }
 
 		// End public functions
 

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20066&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Sat May  9 08:37:22 2015
@@ -3521,19 +3521,57 @@
 	maxSize = qMin(3000.0, maxSize * (softShadowDPI / 72.0));
 	bool savedShadow = ite->hasSoftShadow();
 	ite->setHasSoftShadow(false);
+	bool tmpFillNeeded = false;
+	if (!ite->hasFill())
+	{
+		tmpFillNeeded = true;
+		ite->setFillColor("White");
+	}
 	QImage imgC = ite->DrawObj_toImage(maxSize, PageItem::NoRotation);
+	imgC = imgC.copy(-pixelRadius,-pixelRadius,imgC.width()+2*pixelRadius,imgC.height()+2*pixelRadius); // Add border
+	ScPainter *p = new ScPainter(&imgC, imgC.width(), imgC.height(), 1, 0);
+	p->setZoomFactor(softShadowDPI / 72.0);
+	p->save();
+	p->blur(pixelRadius);
+	p->restore();
+	p->end();
+	delete p;
+	if (tmpFillNeeded)
+	{
+		ScPainter *p = new ScPainter(&imgC, imgC.width(), imgC.height(), 1, 0);
+		p->setZoomFactor(softShadowDPI / 72.0);
+		p->save();
+		FPointArray sh = ite->PoLine.copy();
+		p->setupPolygon(&sh);
+		p->setBrush(Qt::white);
+		p->setFillMode(ScPainter::Solid);
+		p->setBlendModeFill(19);
+		p->fillPath();
+		if (ite->hasStroke())
+		{
+			p->setBlendModeStroke(19);
+			p->setStrokeMode(ScPainter::Solid);
+			p->setPen(Qt::white);
+			p->setLineWidth(ite->lineWidth());
+			p->strokePath();
+		}
+		p->restore();
+		p->end();
+		delete p;
+	}
+
 	ite->setHasSoftShadow(savedShadow);
-
-	imgC = imgC.copy(-pixelRadius,-pixelRadius,imgC.width()+2*pixelRadius,imgC.height()+2*pixelRadius); // Add border
+	if (tmpFillNeeded)
+		ite->setFillColor(CommonStrings::None);
 	ScImage img = imgC.alphaChannel().convertToFormat(QImage::Format_RGB32);
-
+/*
 	ImageEffect eff;
 	ScImageEffectList el;
 	eff.effectCode = ScImage::EF_BLUR;
 	eff.effectParameters = QString("%1 1.0").arg(pixelRadius);
 	el.append(eff);
 	img.applyEffect(el,ite->doc()->PageColors,false);
-
+*/
 	uint maskObj = newObject();
 	StartObj(maskObj);
 	PutDoc("<<\n/Type /XObject\n/Subtype /Image\n");

Modified: trunk/Scribus/scribus/scpainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20066&path=/trunk/Scribus/scribus/scpainter.cpp
==============================================================================
--- trunk/Scribus/scribus/scpainter.cpp (original)
+++ trunk/Scribus/scribus/scpainter.cpp Sat May  9 08:37:22 2015
@@ -540,6 +540,8 @@
 		cairo_set_operator(m_cr, CAIRO_OPERATOR_DEST_IN);
 	else if (blendMode == 18)
 		cairo_set_operator(m_cr, CAIRO_OPERATOR_DEST_OUT);
+	else if (blendMode == 19)
+		cairo_set_operator(m_cr, CAIRO_OPERATOR_CLEAR);
 	else
 		cairo_set_operator(m_cr, CAIRO_OPERATOR_OVER);
 }




More information about the scribus-commit mailing list