poppler/Function.cc | 181 +++++++++++++++++++---------------------- qt4/tests/test-poppler-qt4.cpp | 2 2 files changed, 87 insertions(+), 96 deletions(-)
New commits: commit d09478fcc44b5c594f1803fc24654af5e10fa129 Author: Albert Astals Cid <[email protected]> Date: Sun Jun 7 01:34:01 2009 +0200 Move index and pop to class definition too diff --git a/poppler/Function.cc b/poppler/Function.cc index 071d052..b538f5f 100644 --- a/poppler/Function.cc +++ b/poppler/Function.cc @@ -922,8 +922,21 @@ public: (stack[sp+1].type == psInt || stack[sp+1].type == psReal); } void copy(int n); void roll(int n, int j); - void index(int i); - void pop(); + void index(int i) + { + if (!checkOverflow()) { + return; + } + --sp; + stack[sp] = stack[sp + 1 + i]; + } + void pop() + { + if (!checkUnderflow()) { + return; + } + ++sp; + } private: @@ -996,21 +1009,6 @@ void PSStack::roll(int n, int j) { } } -void PSStack::index(int i) { - if (!checkOverflow()) { - return; - } - --sp; - stack[sp] = stack[sp + 1 + i]; -} - -void PSStack::pop() { - if (!checkUnderflow()) { - return; - } - ++sp; -} - PostScriptFunction::PostScriptFunction(Object *funcObj, Dict *dict) { Stream *str; int codePtr; commit 2083264e8ab0fd9976294de08a18de615d5a1168 Author: Albert Astals Cid <[email protected]> Date: Sun Jun 7 01:21:19 2009 +0200 Move the implementations to the class definition Make gcc inline the functions and time to render a heavy PSFunction doc goes from 28 to 20 secs diff --git a/poppler/Function.cc b/poppler/Function.cc index 4159140..071d052 100644 --- a/poppler/Function.cc +++ b/poppler/Function.cc @@ -861,14 +861,54 @@ struct PSObject { class PSStack { public: - PSStack() { sp = psStackSize; } + PSStack() {sp = psStackSize; } void clear() { sp = psStackSize; } - void pushBool(GBool booln); - void pushInt(int intg); - void pushReal(double real); - GBool popBool(); - int popInt(); - double popNum(); + void pushBool(GBool booln) + { + if (checkOverflow()) { + stack[--sp].type = psBool; + stack[sp].booln = booln; + } + } + void pushInt(int intg) + { + if (checkOverflow()) { + stack[--sp].type = psInt; + stack[sp].intg = intg; + } + } + void pushReal(double real) + { + if (checkOverflow()) { + stack[--sp].type = psReal; + stack[sp].real = real; + } + } + GBool popBool() + { + if (checkUnderflow() && checkType(psBool, psBool)) { + return stack[sp++].booln; + } + return gFalse; + } + int popInt() + { + if (checkUnderflow() && checkType(psInt, psInt)) { + return stack[sp++].intg; + } + return 0; + } + double popNum() + { + double ret; + + if (checkUnderflow() && checkType(psInt, psReal)) { + ret = (stack[sp].type == psInt) ? (double)stack[sp].intg : stack[sp].real; + ++sp; + return ret; + } + return 0; + } GBool empty() { return sp == psStackSize; } GBool topIsInt() { return sp < psStackSize && stack[sp].type == psInt; } GBool topTwoAreInts() @@ -887,83 +927,34 @@ public: private: - GBool checkOverflow(int n = 1); - GBool checkUnderflow(); - GBool checkType(PSObjectType t1, PSObjectType t2); - - PSObject stack[psStackSize]; - int sp; -}; - -GBool PSStack::checkOverflow(int n) { - if (sp - n < 0) { - error(-1, "Stack overflow in PostScript function"); - return gFalse; - } - return gTrue; -} - -GBool PSStack::checkUnderflow() { - if (sp == psStackSize) { - error(-1, "Stack underflow in PostScript function"); - return gFalse; - } - return gTrue; -} - -GBool PSStack::checkType(PSObjectType t1, PSObjectType t2) { - if (stack[sp].type != t1 && stack[sp].type != t2) { - error(-1, "Type mismatch in PostScript function"); - return gFalse; - } - return gTrue; -} - -void PSStack::pushBool(GBool booln) { - if (checkOverflow()) { - stack[--sp].type = psBool; - stack[sp].booln = booln; - } -} - -void PSStack::pushInt(int intg) { - if (checkOverflow()) { - stack[--sp].type = psInt; - stack[sp].intg = intg; - } -} - -void PSStack::pushReal(double real) { - if (checkOverflow()) { - stack[--sp].type = psReal; - stack[sp].real = real; + GBool checkOverflow(int n = 1) + { + if (sp - n < 0) { + error(-1, "Stack overflow in PostScript function"); + return gFalse; + } + return gTrue; } -} - -GBool PSStack::popBool() { - if (checkUnderflow() && checkType(psBool, psBool)) { - return stack[sp++].booln; + GBool checkUnderflow() + { + if (sp == psStackSize) { + error(-1, "Stack underflow in PostScript function"); + return gFalse; + } + return gTrue; } - return gFalse; -} - -int PSStack::popInt() { - if (checkUnderflow() && checkType(psInt, psInt)) { - return stack[sp++].intg; + GBool checkType(PSObjectType t1, PSObjectType t2) + { + if (stack[sp].type != t1 && stack[sp].type != t2) { + error(-1, "Type mismatch in PostScript function"); + return gFalse; + } + return gTrue; } - return 0; -} - -double PSStack::popNum() { - double ret; + PSObject stack[psStackSize]; + int sp; +}; - if (checkUnderflow() && checkType(psInt, psReal)) { - ret = (stack[sp].type == psInt) ? (double)stack[sp].intg : stack[sp].real; - ++sp; - return ret; - } - return 0; -} void PSStack::copy(int n) { int i; commit 24580fcd2be74db5f3140bdb2ebff8431b7d3f1e Author: Albert Astals Cid <[email protected]> Date: Sat Jun 6 16:17:26 2009 +0200 Add a debug saying how much rendering took diff --git a/qt4/tests/test-poppler-qt4.cpp b/qt4/tests/test-poppler-qt4.cpp index 0ec917f..1726bfd 100644 --- a/qt4/tests/test-poppler-qt4.cpp +++ b/qt4/tests/test-poppler-qt4.cpp @@ -61,7 +61,9 @@ void PDFDisplay::display() Poppler::Page *page = doc->page(m_currentPage); if (page) { qDebug() << "Displaying page using" << backendString << "backend: " << m_currentPage; + QTime t = QTime::currentTime(); image = page->renderToImage(); + qDebug() << "Rendering took" << t.msecsTo(QTime::currentTime()) << "msecs"; qDeleteAll(textRects); if (showTextRects) { _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
