Ignore:
Timestamp:
Aug 27, 2010, 11:00:52 AM (11 years ago)
Author:
Silvan Scherrer
Message:

poppler update to 0.14.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/poppler/mypoppler/poppler/Gfx.cc

    r277 r461  
    1515//
    1616// Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com>
    17 // Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org>
     17// Copyright (C) 2005-2010 Albert Astals Cid <aacid@kde.org>
    1818// Copyright (C) 2006 Thorkild Stray <thorkild@ifi.uio.no>
    1919// Copyright (C) 2006 Kristian HÞgsberg <krh@redhat.com>
    20 // Copyright (C) 2006-2009 Carlos Garcia Campos <carlosgc@gnome.org>
     20// Copyright (C) 2006-2010 Carlos Garcia Campos <carlosgc@gnome.org>
    2121// Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net>
    2222// Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org>
     
    2929// Copyright (C) 2008 Hib Eris <hib@hiberis.nl>
    3030// Copyright (C) 2009 M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
    31 // Copyright (C) 2009 Thomas Freitag <Thomas.Freitag@alfa.de>
     31// Copyright (C) 2009, 2010 Thomas Freitag <Thomas.Freitag@alfa.de>
    3232// Copyright (C) 2009 William Bader <williambader@hotmail.com>
    33 // Copyright (C) 2009 David Benjamin <davidben@mit.edu>
     33// Copyright (C) 2009, 2010 David Benjamin <davidben@mit.edu>
     34// Copyright (C) 2010 Nils Höglund <nils.hoglund@gmail.com>
    3435//
    3536// To see a description of the changes please see the Changelog file that
     
    308309//------------------------------------------------------------------------
    309310
    310 GfxResources::GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA) {
     311GfxResources::GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA) :
     312    gStateCache(2, xref) {
    311313  Object obj1, obj2;
    312314  Ref r;
     
    481483
    482484GBool GfxResources::lookupGState(char *name, Object *obj) {
     485  if (!lookupGStateNF(name, obj))
     486    return gFalse;
     487
     488  if (!obj->isRef())
     489    return gTrue;
     490 
     491  const Ref ref = obj->getRef();
     492  if (!gStateCache.lookup(ref, obj)->isNull())
     493    return gTrue;
     494  obj->free();
     495
     496  gStateCache.put(ref)->copy(obj);
     497  return gTrue;
     498}
     499
     500GBool GfxResources::lookupGStateNF(char *name, Object *obj) {
    483501  GfxResources *resPtr;
    484502
    485503  for (resPtr = this; resPtr; resPtr = resPtr->next) {
    486504    if (resPtr->gStateDict.isDict()) {
    487       if (!resPtr->gStateDict.dictLookup(name, obj)->isNull()) {
     505      if (!resPtr->gStateDict.dictLookupNF(name, obj)->isNull()) {
    488506        return gTrue;
    489507      }
     
    526544  out = outA;
    527545  state = new GfxState(hDPI, vDPI, box, rotate, out->upsideDown());
     546  stackHeight = 1;
     547  pushStateGuard();
    528548  fontChanged = gFalse;
    529549  clip = clipNone;
     
    578598  out = outA;
    579599  state = new GfxState(72, 72, box, 0, gFalse);
     600  stackHeight = 1;
     601  pushStateGuard();
    580602  fontChanged = gFalse;
    581603  clip = clipNone;
     
    602624
    603625Gfx::~Gfx() {
     626  while (stateGuards.size()) {
     627    popStateGuard();
     628  }
     629  // There shouldn't be more saves, but pop them if there were any
    604630  while (state->hasSaves()) {
     631    error(-1, "Found state under last state guard. Popping.");
    605632    restoreState();
    606633  }
     
    650677
    651678  // scan a sequence of objects
     679  pushStateGuard();
    652680  updateLevel = lastAbortCheck = 0;
    653681  numArgs = 0;
    654682  parser->getObj(&obj);
    655683  while (!obj.isEOF()) {
     684    commandAborted = gFalse;
    656685
    657686    // got a command - execute it
     
    701730      }
    702731
     732      // did the command throw an exception
     733      if (commandAborted) {
     734        // don't propogate; recursive drawing comes from Form XObjects which
     735        // should probably be drawn in a separate context anyway for caching
     736        commandAborted = gFalse;
     737        break;
     738      }
     739
    703740      // check for an abort
    704741      if (abortCheckCbk) {
     
    748785  }
    749786
     787  popStateGuard();
     788
    750789  // update display
    751790  if (topLevel && updateLevel > 0) {
     
    773812    if (numArgs < op->numArgs) {
    774813      error(getPos(), "Too few (%d) args to '%s' operator", numArgs, name);
     814      commandAborted = gTrue;
    775815      return;
    776816    }
     
    12581298  GfxColor color;
    12591299
    1260   if (textHaveCSPattern) {
     1300  if (textHaveCSPattern && drawText) {
    12611301    GBool needFill = out->deviceHasTextClip(state);
    12621302    out->endTextObject(state);
     
    12651305    }
    12661306    out->restoreState(state);
    1267     state->setFillPattern(NULL);
    1268     state->setFillColorSpace(new GfxDeviceGrayColorSpace());
    1269     out->updateFillColorSpace(state);
    1270     color.c[0] = dblToCol(args[0].getNum());
    1271     state->setFillColor(&color);
    1272     out->updateFillColor(state);
     1307  }
     1308  state->setFillPattern(NULL);
     1309  state->setFillColorSpace(new GfxDeviceGrayColorSpace());
     1310  out->updateFillColorSpace(state);
     1311  color.c[0] = dblToCol(args[0].getNum());
     1312  state->setFillColor(&color);
     1313  out->updateFillColor(state);
     1314  if (textHaveCSPattern) {
    12731315    out->beginTextObject(state);
    12741316    out->updateRender(state);
     
    12761318    out->updateTextPos(state);
    12771319    textHaveCSPattern = gFalse;
    1278   } else {
    1279     state->setFillPattern(NULL);
    1280     state->setFillColorSpace(new GfxDeviceGrayColorSpace());
    1281     out->updateFillColorSpace(state);
    1282     color.c[0] = dblToCol(args[0].getNum());
    1283     state->setFillColor(&color);
    1284     out->updateFillColor(state);
    12851320  }
    12861321}
     
    13011336  int i;
    13021337
     1338  if (textHaveCSPattern && drawText) {
     1339    GBool needFill = out->deviceHasTextClip(state);
     1340    out->endTextObject(state);
     1341    if (needFill) {
     1342      doPatternFill(gTrue);
     1343    }
     1344    out->restoreState(state);
     1345  }
     1346  state->setFillPattern(NULL);
     1347  state->setFillColorSpace(new GfxDeviceCMYKColorSpace());
     1348  out->updateFillColorSpace(state);
     1349  for (i = 0; i < 4; ++i) {
     1350    color.c[i] = dblToCol(args[i].getNum());
     1351  }
     1352  state->setFillColor(&color);
     1353  out->updateFillColor(state);
    13031354  if (textHaveCSPattern) {
    1304     colorSpaceText = new GfxDeviceCMYKColorSpace();
    1305     for (i = 0; i < 4; ++i) {
    1306       colorText.c[i] = dblToCol(args[i].getNum());
    1307     }
    1308   } else {
    1309     state->setFillPattern(NULL);
    1310     state->setFillColorSpace(new GfxDeviceCMYKColorSpace());
    1311     out->updateFillColorSpace(state);
    1312     for (i = 0; i < 4; ++i) {
    1313       color.c[i] = dblToCol(args[i].getNum());
    1314     }
    1315     state->setFillColor(&color);
    1316     out->updateFillColor(state);
     1355    out->beginTextObject(state);
     1356    out->updateRender(state);
     1357    out->updateTextMat(state);
     1358    out->updateTextPos(state);
     1359    textHaveCSPattern = gFalse;
    13171360  }
    13181361}
     
    13361379  int i;
    13371380
     1381  if (textHaveCSPattern && drawText) {
     1382    GBool needFill = out->deviceHasTextClip(state);
     1383    out->endTextObject(state);
     1384    if (needFill) {
     1385      doPatternFill(gTrue);
     1386    }
     1387    out->restoreState(state);
     1388  }
     1389  state->setFillPattern(NULL);
     1390  state->setFillColorSpace(new GfxDeviceRGBColorSpace());
     1391  out->updateFillColorSpace(state);
     1392  for (i = 0; i < 3; ++i) {
     1393    color.c[i] = dblToCol(args[i].getNum());
     1394  }
     1395  state->setFillColor(&color);
     1396  out->updateFillColor(state);
    13381397  if (textHaveCSPattern) {
    1339     colorSpaceText = new GfxDeviceRGBColorSpace();
    1340     for (i = 0; i < 3; ++i) {
    1341       colorText.c[i] = dblToCol(args[i].getNum());
    1342     }
    1343   } else {
    1344     state->setFillPattern(NULL);
    1345     state->setFillColorSpace(new GfxDeviceRGBColorSpace());
    1346     out->updateFillColorSpace(state);
    1347     for (i = 0; i < 3; ++i) {
    1348       color.c[i] = dblToCol(args[i].getNum());
    1349     }
    1350     state->setFillColor(&color);
    1351     out->updateFillColor(state);
     1398    out->beginTextObject(state);
     1399    out->updateRender(state);
     1400    out->updateTextMat(state);
     1401    out->updateTextPos(state);
     1402    textHaveCSPattern = gFalse;
    13521403  }
    13531404}
     
    13721423  GfxColor color;
    13731424
    1374   state->setFillPattern(NULL);
    13751425  res->lookupColorSpace(args[0].getName(), &obj);
    13761426  if (obj.isNull()) {
     
    13811431  obj.free();
    13821432  if (colorSpace) {
     1433    if (textHaveCSPattern && drawText) {
     1434      GBool needFill = out->deviceHasTextClip(state);
     1435      out->endTextObject(state);
     1436      if (needFill) {
     1437        doPatternFill(gTrue);
     1438      }
     1439      out->restoreState(state);
     1440    }
     1441    state->setFillPattern(NULL);
    13831442    state->setFillColorSpace(colorSpace);
    13841443    out->updateFillColorSpace(state);
     
    13861445    state->setFillColor(&color);
    13871446    out->updateFillColor(state);
    1388     if (drawText) {
    1389       if (colorSpace->getMode() == csPattern) {
    1390         colorSpaceText = NULL;
    1391         textHaveCSPattern = gTrue;
    1392         out->beginTextObject(state);
    1393       } else if (textHaveCSPattern) {
    1394         GBool needFill = out->deviceHasTextClip(state);
    1395         out->endTextObject(state);
    1396         if (needFill) {
    1397           doPatternFill(gTrue);
    1398         }
    1399         out->beginTextObject(state);
    1400         out->updateRender(state);
    1401         out->updateTextMat(state);
    1402         out->updateTextPos(state);
    1403         textHaveCSPattern = gFalse;
    1404       }
     1447    if (textHaveCSPattern) {
     1448      out->beginTextObject(state);
     1449      out->updateRender(state);
     1450      out->updateTextMat(state);
     1451      out->updateTextPos(state);
     1452      textHaveCSPattern = colorSpace->getMode() == csPattern;
     1453    } else if (drawText && out->supportTextCSPattern(state)) {
     1454      out->beginTextObject(state);
     1455      textHaveCSPattern = gTrue;
    14051456    }
    14061457  } else {
     
    20552106    state->closePath();
    20562107    state->clip();
    2057     out->clip(state);
     2108    if (!textHaveCSPattern && !maskHaveCSPattern)
     2109      out->clip(state);
    20582110    state->setPath(savedPath->copy());
    20592111  }
     
    24732525    // make sure we add stop color when t = tMin
    24742526    state->setFillColor(&color0);
    2475     out->updateFillColorStop(state, (tt - tMin)/(tMax - tMin));
     2527    out->updateFillColorStop(state, 0);
    24762528  }
    24772529
     
    32823334  fontChanged = gTrue;
    32833335  if (out->supportTextCSPattern(state)) {
    3284     colorSpaceText = NULL;
    32853336    textHaveCSPattern = gTrue;
    32863337  }
     
    32913342  out->endTextObject(state);
    32923343  drawText = gFalse;
    3293   if (out->supportTextCSPattern(state) && textHaveCSPattern) {
     3344  if (textHaveCSPattern) {
    32943345    if (needFill) {
    32953346      doPatternFill(gTrue);
    32963347    }
    32973348    out->restoreState(state);
    3298     if (colorSpaceText != NULL) {
    3299       state->setFillPattern(NULL);
    3300       state->setFillColorSpace(colorSpaceText);
    3301       out->updateFillColorSpace(state);
    3302       state->setFillColor(&colorText);
    3303       out->updateFillColor(state);
    3304       colorSpaceText = NULL;
    3305     }
    33063349  }
    33073350  textHaveCSPattern = gFalse;
     
    45174560  if(numArgs == 2 && args[1].isDict ()) {
    45184561    out->beginMarkedContent(args[0].getName(),args[1].getDict());
     4562  } else if(numArgs == 1) {
     4563    out->beginMarkedContent(args[0].getName(),NULL);
    45194564  }
    45204565}
     
    46774722    }
    46784723    if (aColor && (aColor->getSpace() == AnnotColor::colorRGB)) {
    4679       double *values = aColor->getValues();
     4724      const double *values = aColor->getValues();
    46804725      r = values[0];
    46814726      g = values[1];
     
    47214766}
    47224767
     4768int Gfx::bottomGuard() {
     4769    return stateGuards[stateGuards.size()-1];
     4770}
     4771
     4772void Gfx::pushStateGuard() {
     4773    stateGuards.push_back(stackHeight);
     4774}
     4775
     4776void Gfx::popStateGuard() {
     4777    while (stackHeight > bottomGuard() && state->hasSaves())
     4778        restoreState();
     4779    stateGuards.pop_back();
     4780}
     4781
    47234782void Gfx::saveState() {
    47244783  out->saveState(state);
    47254784  state = state->save();
     4785  stackHeight++;
    47264786}
    47274787
    47284788void Gfx::restoreState() {
     4789  if (stackHeight <= bottomGuard() || !state->hasSaves()) {
     4790    error(-1, "Restoring state when no valid states to pop");
     4791    commandAborted = gTrue;
     4792    return;
     4793  }
    47294794  state = state->restore();
    47304795  out->restoreState(state);
     4796  stackHeight--;
    47314797}
    47324798
Note: See TracChangeset for help on using the changeset viewer.