[poppler] [PATCH 3/5] Maintain the height of the stack in Gfx

David Benjamin davidben at MIT.EDU
Thu Jan 21 21:27:01 PST 2010


Introduces a new variable Gfx::stackHeight that maintains up-to-date
information about the current height of the stack.
---
 poppler/Gfx.cc |    4 ++++
 poppler/Gfx.h  |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index d8e144f..c7a3ef7 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -525,6 +525,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata
   // initialize
   out = outA;
   state = new GfxState(hDPI, vDPI, box, rotate, out->upsideDown());
+  stackHeight = 1;
   fontChanged = gFalse;
   clip = clipNone;
   ignoreUndef = 0;
@@ -577,6 +578,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA,
   // initialize
   out = outA;
   state = new GfxState(72, 72, box, 0, gFalse);
+  stackHeight = 1;
   fontChanged = gFalse;
   clip = clipNone;
   ignoreUndef = 0;
@@ -4730,11 +4732,13 @@ void Gfx::drawAnnot(Object *str, AnnotBorder *border, AnnotColor *aColor, double
 void Gfx::saveState() {
   out->saveState(state);
   state = state->save();
+  stackHeight++;
 }
 
 void Gfx::restoreState() {
   state = state->restore();
   out->restoreState(state);
+  stackHeight--;
 }
 
 void Gfx::pushResources(Dict *resDict) {
diff --git a/poppler/Gfx.h b/poppler/Gfx.h
index ef1977a..3071f6e 100644
--- a/poppler/Gfx.h
+++ b/poppler/Gfx.h
@@ -191,6 +191,7 @@ private:
   int updateLevel;
 
   GfxState *state;		// current graphics state
+  int stackHeight;		// the height of the current graphics stack
   GBool fontChanged;		// set if font or text matrix has changed
   GfxClipType clip;		// do a clip?
   int ignoreUndef;		// current BX/EX nesting level
-- 
1.6.6.137.g8333d.dirty



More information about the poppler mailing list