[poppler] poppler/Gfx.cc poppler/OutputDev.h poppler/SplashOutputDev.cc poppler/SplashOutputDev.h splash/Splash.cc splash/Splash.h splash/SplashState.cc splash/SplashState.h

Albert Astals Cid aacid at kemper.freedesktop.org
Wed Oct 28 15:14:08 PDT 2015


 poppler/Gfx.cc             |    4 +++-
 poppler/OutputDev.h        |    4 +++-
 poppler/SplashOutputDev.cc |    8 ++++++++
 poppler/SplashOutputDev.h  |    2 ++
 splash/Splash.cc           |   16 ++++++++++++++--
 splash/Splash.h            |    2 ++
 splash/SplashState.cc      |   11 ++++++++++-
 splash/SplashState.h       |    5 ++++-
 8 files changed, 46 insertions(+), 6 deletions(-)

New commits:
commit 3167964d70647d7b04e3ef8f415d5935990ecc9a
Author: Thomas Freitag <Thomas.Freitag at alfa.de>
Date:   Wed Oct 28 23:13:44 2015 +0100

    Multiply opacity in case of pattern colorspace
    
    Bug #92592

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 07d95b3..577c482 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -28,7 +28,7 @@
 // Copyright (C) 2008 Michael Vrable <mvrable at cs.ucsd.edu>
 // Copyright (C) 2008 Hib Eris <hib at hiberis.nl>
 // Copyright (C) 2009 M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
-// Copyright (C) 2009-2014 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2009-2015 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2009 William Bader <williambader at hotmail.com>
 // Copyright (C) 2009, 2010 David Benjamin <davidben at mit.edu>
 // Copyright (C) 2010 Nils Höglund <nils.hoglund at gmail.com>
@@ -2283,6 +2283,7 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
 		       xi0, yi0, xi1, yi1, xstep, ystep)) {
     goto restore;
   } else {
+    out->updatePatternOpacity(state);
     for (yi = yi0; yi < yi1; ++yi) {
       for (xi = xi0; xi < xi1; ++xi) {
         x = xi * xstep;
@@ -2293,6 +2294,7 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
         	  m1, tPat->getBBox());
       }
     }
+    out->clearPatternOpacity(state);
   }
 
   // restore graphics state
diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h
index e8a7a47..a15d56b 100644
--- a/poppler/OutputDev.h
+++ b/poppler/OutputDev.h
@@ -17,7 +17,7 @@
 // Copyright (C) 2006 Thorkild Stray <thorkild at ifi.uio.no>
 // Copyright (C) 2007 Jeff Muizelaar <jeff at infidigm.net>
 // Copyright (C) 2007, 2011 Adrian Johnson <ajohnson at redneon.com>
-// Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2009-2013, 2015 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2009, 2011 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2009, 2012, 2013 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger at googlemail.com>
@@ -185,6 +185,8 @@ public:
   virtual void updateBlendMode(GfxState * /*state*/) {}
   virtual void updateFillOpacity(GfxState * /*state*/) {}
   virtual void updateStrokeOpacity(GfxState * /*state*/) {}
+  virtual void updatePatternOpacity(GfxState * /*state*/) {}
+  virtual void clearPatternOpacity(GfxState * /*state*/) {}
   virtual void updateFillOverprint(GfxState * /*state*/) {}
   virtual void updateStrokeOverprint(GfxState * /*state*/) {}
   virtual void updateOverprintMode(GfxState * /*state*/) {}
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 6d41616..d2827d1 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -1842,6 +1842,14 @@ void SplashOutputDev::updateStrokeOpacity(GfxState *state) {
   }
 }
 
+void SplashOutputDev::updatePatternOpacity(GfxState *state) {
+  splash->setPatternAlpha((SplashCoord)state->getStrokeOpacity(), (SplashCoord)state->getFillOpacity());
+}
+
+void SplashOutputDev::clearPatternOpacity(GfxState *state) {
+  splash->clearPatternAlpha();
+}
+
 void SplashOutputDev::updateFillOverprint(GfxState *state) {
   splash->setFillOverprint(state->getFillOverprint());
 }
diff --git a/poppler/SplashOutputDev.h b/poppler/SplashOutputDev.h
index d34426c..ce4082f 100644
--- a/poppler/SplashOutputDev.h
+++ b/poppler/SplashOutputDev.h
@@ -231,6 +231,8 @@ public:
   virtual void updateBlendMode(GfxState *state);
   virtual void updateFillOpacity(GfxState *state);
   virtual void updateStrokeOpacity(GfxState *state);
+  virtual void updatePatternOpacity(GfxState *state);
+  virtual void clearPatternOpacity(GfxState *state);
   virtual void updateFillOverprint(GfxState *state);
   virtual void updateStrokeOverprint(GfxState *state);
   virtual void updateOverprintMode(GfxState *state);
diff --git a/splash/Splash.cc b/splash/Splash.cc
index 7453822..5bc7767 100644
--- a/splash/Splash.cc
+++ b/splash/Splash.cc
@@ -1752,11 +1752,23 @@ void Splash::setBlendFunc(SplashBlendFunc func) {
 }
 
 void Splash::setStrokeAlpha(SplashCoord alpha) {
-  state->strokeAlpha = alpha;
+  state->strokeAlpha = (state->multiplyPatternAlpha) ? alpha *  state->patternStrokeAlpha : alpha;
 }
 
 void Splash::setFillAlpha(SplashCoord alpha) {
-  state->fillAlpha = alpha;
+  state->fillAlpha = (state->multiplyPatternAlpha) ? alpha *  state->patternFillAlpha : alpha;
+}
+
+void Splash::setPatternAlpha(SplashCoord strokeAlpha, SplashCoord fillAlpha) {
+  state->patternStrokeAlpha = strokeAlpha;
+  state->patternFillAlpha = fillAlpha;
+  state->multiplyPatternAlpha = gTrue;
+}
+
+void Splash::clearPatternAlpha() {
+  state->patternStrokeAlpha = 1;
+  state->patternFillAlpha = 1;
+  state->multiplyPatternAlpha = gFalse;
 }
 
 void Splash::setFillOverprint(GBool fop) {
diff --git a/splash/Splash.h b/splash/Splash.h
index 7576454..3ca15c3 100644
--- a/splash/Splash.h
+++ b/splash/Splash.h
@@ -129,6 +129,8 @@ public:
   void setBlendFunc(SplashBlendFunc func);
   void setStrokeAlpha(SplashCoord alpha);
   void setFillAlpha(SplashCoord alpha);
+  void setPatternAlpha(SplashCoord strokeAlpha, SplashCoord fillAlpha);
+  void clearPatternAlpha();
   void setFillOverprint(GBool fop);
   void setStrokeOverprint(GBool sop);
   void setOverprintMode(int opm);
diff --git a/splash/SplashState.cc b/splash/SplashState.cc
index fd2789d..f0c98c5 100644
--- a/splash/SplashState.cc
+++ b/splash/SplashState.cc
@@ -11,7 +11,7 @@
 // All changes made under the Poppler project to this file are licensed
 // under GPL version 2 or later
 //
-// Copyright (C) 2009, 2011, 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2009, 2011, 2012, 2015 Thomas Freitag <Thomas.Freitag at alfa.de>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -59,6 +59,9 @@ SplashState::SplashState(int width, int height, GBool vectorAntialias,
   blendFunc = NULL;
   strokeAlpha = 1;
   fillAlpha = 1;
+  multiplyPatternAlpha = gFalse;
+  patternStrokeAlpha = 1;
+  patternFillAlpha = 1;
   lineWidth = 0;
   lineCap = splashLineCapButt;
   lineJoin = splashLineJoinMiter;
@@ -109,6 +112,9 @@ SplashState::SplashState(int width, int height, GBool vectorAntialias,
   blendFunc = NULL;
   strokeAlpha = 1;
   fillAlpha = 1;
+  multiplyPatternAlpha = gFalse;
+  patternStrokeAlpha = 1;
+  patternFillAlpha = 1;
   lineWidth = 0;
   lineCap = splashLineCapButt;
   lineJoin = splashLineJoinMiter;
@@ -152,6 +158,9 @@ SplashState::SplashState(SplashState *state) {
   blendFunc = state->blendFunc;
   strokeAlpha = state->strokeAlpha;
   fillAlpha = state->fillAlpha;
+  multiplyPatternAlpha = state->multiplyPatternAlpha;
+  patternStrokeAlpha = state->patternStrokeAlpha;
+  patternFillAlpha = state->patternFillAlpha;
   lineWidth = state->lineWidth;
   lineCap = state->lineCap;
   lineJoin = state->lineJoin;
diff --git a/splash/SplashState.h b/splash/SplashState.h
index 2c60353..fea7603 100644
--- a/splash/SplashState.h
+++ b/splash/SplashState.h
@@ -11,7 +11,7 @@
 // All changes made under the Poppler project to this file are licensed
 // under GPL version 2 or later
 //
-// Copyright (C) 2011, 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2011, 2012, 2015 Thomas Freitag <Thomas.Freitag at alfa.de>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -101,6 +101,9 @@ private:
   SplashBlendFunc blendFunc;
   SplashCoord strokeAlpha;
   SplashCoord fillAlpha;
+  GBool multiplyPatternAlpha;
+  SplashCoord patternStrokeAlpha;
+  SplashCoord patternFillAlpha;
   SplashCoord lineWidth;
   int lineCap;
   int lineJoin;


More information about the poppler mailing list