diff --git a/poppler/FontInfo.cc b/poppler/FontInfo.cc index e7805ec..df65327 100644 --- a/poppler/FontInfo.cc +++ b/poppler/FontInfo.cc @@ -131,7 +131,7 @@ void FontInfoScanner::scanFonts(Dict *resDict, GooList *fontsList) { // recursively scan any resource dictionaries in objects in this // resource dictionary char *resTypes[] = { "XObject", "Pattern" }; - for (uint resType = 0; resType < sizeof(resTypes) / sizeof(resTypes[0]); ++resType) { + for (Guint resType = 0; resType < sizeof(resTypes) / sizeof(resTypes[0]); ++resType) { resDict->lookup(resTypes[resType], &objDict); if (objDict.isDict()) { for (i = 0; i < objDict.dictGetLength(); ++i) { diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc index 6b80e90..43dd99f 100644 --- a/poppler/Gfx.cc +++ b/poppler/Gfx.cc @@ -110,7 +110,7 @@ // shading fill. #define gouraudColorDelta (dblToCol(3. / 256.0)) -// Gouraud triangle: if the three color parameters differ by at more than this percend of +// Gouraud triangle: if the three color parameters differ by at more than this percend of // the total color parameter range, the triangle will be refined #define gouraudParameterizedColorDelta 5e-3 @@ -496,7 +496,7 @@ GBool GfxResources::lookupGState(char *name, Object *obj) { if (!obj->isRef()) return gTrue; - + const Ref ref = obj->getRef(); if (!gStateCache.lookup(ref, obj)->isNull()) return gTrue; @@ -725,7 +725,7 @@ void Gfx::go(GBool topLevel) { data_p = new ProfileData(); hash->add (cmd_g, data_p); } - + data_p->addElement(timer.getElapsed ()); } } @@ -2195,7 +2195,7 @@ void Gfx::doShadingPatternFill(GfxShadingPattern *sPat, #if 1 //~tmp: turn off anti-aliasing temporarily GBool vaa = out->getVectorAntialias(); - if (vaa) { + if (vaa && shading->getType() != 3) { out->setVectorAntialias(gFalse); } #endif @@ -2405,14 +2405,14 @@ void Gfx::doFunctionShFill1(GfxFunctionShading *shading, colors2[2] = colorM0; colors2[3] = colorMM; doFunctionShFill1(shading, x0, y0, xM, yM, colors2, depth + 1); - + // lower-left sub-rectangle colors2[0] = color0M; colors2[1] = colors[1]; colors2[2] = colorMM; colors2[3] = colorM1; doFunctionShFill1(shading, x0, yM, xM, y1, colors2, depth + 1); - + // upper-right sub-rectangle colors2[0] = colorM0; colors2[1] = colorMM; @@ -2610,10 +2610,10 @@ void Gfx::doAxialShFill(GfxAxialShading *shading) { } shading->getColor(tt, &color1); if (isSameGfxColor(color1, color0, nComps, axialColorDelta)) { - // in these two if what we guarantee is that if we are skipping lots of + // in these two if what we guarantee is that if we are skipping lots of // positions because the colors are the same, we still create a region // with vertexs passing by bboxIntersections[1] and bboxIntersections[2] - // otherwise we can have empty regions that should really be painted + // otherwise we can have empty regions that should really be painted // like happened in bug 19896 // What we do to ensure that we pass a line through this points // is making sure use the exact bboxIntersections[] value as one of the used ta[] values @@ -2924,18 +2924,27 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) { tb = t0 + sb * (t1 - t0); getShadingColorRadialHelper(t0, t1, tb, shading, &colorB); while (ib - ia > 1) { + if (isSameGfxColor(colorB, colorA, nComps, radialColorDelta) && ib < radialMaxSplits) { // The shading is not necessarily lineal so having two points with the // same color does not mean all the areas in between have the same color too - // Do another bisection to be a bit more sure we are not doing something wrong - GfxColor colorC; - int ic = (ia + ib) / 2; - double sc = sMin + ((double)ic / (double)radialMaxSplits) * (sMax - sMin); - double tc = t0 + sc * (t1 - t0); - getShadingColorRadialHelper(t0, t1, tc, shading, &colorC); - if (isSameGfxColor(colorC, colorA, nComps, radialColorDelta)) - break; + int ic = ia + 1; + for (; ic <= ib; ic++) { + GfxColor colorC; + double sc = sMin + ((double)ic / (double)radialMaxSplits) * (sMax - sMin); + double tc = t0 + sc * (t1 - t0); + getShadingColorRadialHelper(t0, t1, tc, shading, &colorC); + if (!isSameGfxColor(colorC, colorA, nComps, radialColorDelta)) { + break; + } + } + ib = (ic > ia + 1)? ic - 1 : ia + 1; + sb = sMin + ((double)ib / (double)radialMaxSplits) * (sMax - sMin); + tb = t0 + sb * (t1 - t0); + getShadingColorRadialHelper(t0, t1, tb, shading, &colorB); + break; } + ib = (ia + ib) / 2; sb = sMin + ((double)ib / (double)radialMaxSplits) * (sMax - sMin); tb = t0 + sb * (t1 - t0); @@ -2959,55 +2968,55 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) { if (needExtend) { if (enclosed) { - // construct path for first circle (counterclockwise) - state->moveTo(xa + ra, ya); - for (k = 1; k < n; ++k) { - angle = ((double)k / (double)n) * 2 * M_PI; - state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); - } - state->closePath(); - - // construct and append path for second circle (clockwise) - state->moveTo(xb + rb, yb); - for (k = 1; k < n; ++k) { - angle = -((double)k / (double)n) * 2 * M_PI; - state->lineTo(xb + rb * cos(angle), yb + rb * sin(angle)); - } - state->closePath(); - } else { - // construct the first subpath (clockwise) - state->moveTo(xa + ra * cos(alpha + theta + 0.5 * M_PI), - ya + ra * sin(alpha + theta + 0.5 * M_PI)); - for (k = 0; k < n; ++k) { - angle = alpha + theta + 0.5 * M_PI - - ((double)k / (double)n) * (2 * theta + M_PI); - state->lineTo(xb + rb * cos(angle), yb + rb * sin(angle)); - } - for (k = 0; k < n; ++k) { - angle = alpha - theta - 0.5 * M_PI - + ((double)k / (double)n) * (2 * theta - M_PI); - state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); - } - state->closePath(); - - // construct the second subpath (counterclockwise) - state->moveTo(xa + ra * cos(alpha + theta + 0.5 * M_PI), - ya + ra * sin(alpha + theta + 0.5 * M_PI)); - for (k = 0; k < n; ++k) { - angle = alpha + theta + 0.5 * M_PI - + ((double)k / (double)n) * (-2 * theta + M_PI); - state->lineTo(xb + rb * cos(angle), yb + rb * sin(angle)); - } - for (k = 0; k < n; ++k) { - angle = alpha - theta - 0.5 * M_PI - + ((double)k / (double)n) * (2 * theta + M_PI); - state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); + // construct path for first circle (counterclockwise) + state->moveTo(xa + ra, ya); + for (k = 1; k < n; ++k) { + angle = ((double)k / (double)n) * 2 * M_PI; + state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); + } + state->closePath(); + + // construct and append path for second circle (clockwise) + state->moveTo(xb + rb, yb); + for (k = 1; k < n; ++k) { + angle = -((double)k / (double)n) * 2 * M_PI; + state->lineTo(xb + rb * cos(angle), yb + rb * sin(angle)); + } + state->closePath(); + } else { + // construct the first subpath (clockwise) + state->moveTo(xa + ra * cos(alpha + theta + 0.5 * M_PI), + ya + ra * sin(alpha + theta + 0.5 * M_PI)); + for (k = 0; k < n; ++k) { + angle = alpha + theta + 0.5 * M_PI + - ((double)k / (double)n) * (2 * theta + M_PI); + state->lineTo(xb + rb * cos(angle), yb + rb * sin(angle)); + } + for (k = 0; k < n; ++k) { + angle = alpha - theta - 0.5 * M_PI + + ((double)k / (double)n) * (2 * theta - M_PI); + state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); + } + state->closePath(); + + // construct the second subpath (counterclockwise) + state->moveTo(xa + ra * cos(alpha + theta + 0.5 * M_PI), + ya + ra * sin(alpha + theta + 0.5 * M_PI)); + for (k = 0; k < n; ++k) { + angle = alpha + theta + 0.5 * M_PI + + ((double)k / (double)n) * (-2 * theta + M_PI); + state->lineTo(xb + rb * cos(angle), yb + rb * sin(angle)); + } + for (k = 0; k < n; ++k) { + angle = alpha - theta - 0.5 * M_PI + + ((double)k / (double)n) * (2 * theta + M_PI); + state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); + } + state->closePath(); + } } - state->closePath(); - } - } - if (!out->useFillColorStop()) { + if (!out->useFillColorStop()) { // fill the path if (!contentIsHidden()) out->fill(state); @@ -3139,7 +3148,7 @@ void Gfx::doGouraudTriangleShFill(GfxGouraudTriangleShading *shading) { } else { // this always produces output -- even for parameterized ranges. - // But it ignores the parameterized color map (the function). + // But it ignores the parameterized color map (the function). // // Note that using this code in for parameterized shadings might be // correct in circumstances (namely if the function is linear in the actual @@ -3174,11 +3183,11 @@ void Gfx::gouraudFillTriangle(double x0, double y0, GfxColor *color0, state->setFillColor(color0); out->updateFillColor(state); - path->reset(); assert(!path->isEnd()); - path->setCoord(x0,y0); path->next(); assert(!path->isEnd()); - path->setCoord(x1,y1); path->next(); assert(!path->isEnd()); - path->setCoord(x2,y2); path->next(); assert(!path->isEnd()); - path->setCoord(x0,y0); path->next(); assert( path->isEnd()); + path->reset(); assert(!path->isEnd()); + path->setCoord(x0,y0); path->next(); assert(!path->isEnd()); + path->setCoord(x1,y1); path->next(); assert(!path->isEnd()); + path->setCoord(x2,y2); path->next(); assert(!path->isEnd()); + path->setCoord(x0,y0); path->next(); assert( path->isEnd()); if (!contentIsHidden()) out->fill(state); @@ -3210,7 +3219,7 @@ void Gfx::gouraudFillTriangle(double x0, double y0, double color0, double refineColorThreshold, int depth, GfxGouraudTriangleShading *shading, GfxState::ReusablePathIterator *path) { const double meanColor = (color0 + color1 + color2) / 3; - const bool isFineEnough = + const bool isFineEnough = fabs(color0 - meanColor) < refineColorThreshold && fabs(color1 - meanColor) < refineColorThreshold && fabs(color2 - meanColor) < refineColorThreshold; @@ -3222,11 +3231,11 @@ void Gfx::gouraudFillTriangle(double x0, double y0, double color0, state->setFillColor(&color); out->updateFillColor(state); - path->reset(); assert(!path->isEnd()); - path->setCoord(x0,y0); path->next(); assert(!path->isEnd()); - path->setCoord(x1,y1); path->next(); assert(!path->isEnd()); - path->setCoord(x2,y2); path->next(); assert(!path->isEnd()); - path->setCoord(x0,y0); path->next(); assert( path->isEnd()); + path->reset(); assert(!path->isEnd()); + path->setCoord(x0,y0); path->next(); assert(!path->isEnd()); + path->setCoord(x1,y1); path->next(); assert(!path->isEnd()); + path->setCoord(x2,y2); path->next(); assert(!path->isEnd()); + path->setCoord(x0,y0); path->next(); assert( path->isEnd()); if (!contentIsHidden()) out->fill(state); @@ -3238,24 +3247,24 @@ void Gfx::gouraudFillTriangle(double x0, double y0, double color0, const double x20 = 0.5 * (x2 + x0); const double y20 = 0.5 * (y2 + y0); const double color01 = (color0 + color1) / 2.; - const double color12 = (color1 + color2) / 2.; + const double color12 = (color1 + color2) / 2.; const double color20 = (color2 + color0) / 2.; ++depth; - gouraudFillTriangle(x0, y0, color0, + gouraudFillTriangle(x0, y0, color0, x01, y01, color01, - x20, y20, color20, + x20, y20, color20, refineColorThreshold, depth, shading, path); - gouraudFillTriangle(x01, y01, color01, + gouraudFillTriangle(x01, y01, color01, x1, y1, color1, - x12, y12, color12, + x12, y12, color12, refineColorThreshold, depth, shading, path); - gouraudFillTriangle(x01, y01, color01, + gouraudFillTriangle(x01, y01, color01, x12, y12, color12, - x20, y20, color20, + x20, y20, color20, refineColorThreshold, depth, shading, path); - gouraudFillTriangle(x20, y20, color20, + gouraudFillTriangle(x20, y20, color20, x12, y12, color12, - x2, y2, color2, + x2, y2, color2, refineColorThreshold, depth, shading, path); } } @@ -3296,7 +3305,7 @@ void Gfx::doPatchMeshShFill(GfxPatchMeshShading *shading) { for (i = 0; i < shading->getNPatches(); ++i) { fillPatch(shading->getPatch(i), - colorComps, + colorComps, shading->isParameterized() ? 1 : colorComps, refineColorThreshold, start, @@ -4516,7 +4525,7 @@ void Gfx::doForm1(Object *str, Dict *resDict, double *matrix, double *bbox, // draw the form display(str, gFalse); - + if (stateBefore != state) { if (state->isParentState(stateBefore)) { error(-1, "There's a form with more q than Q, trying to fix"); @@ -4569,7 +4578,7 @@ void Gfx::opBeginImage(Object args[], int numArgs) { // display the image if (str) { doImage(NULL, str, gTrue); - + // skip 'EI' tag c1 = str->getUndecodedStream()->getChar(); c2 = str->getUndecodedStream()->getChar(); @@ -4696,7 +4705,7 @@ GBool Gfx::contentIsHidden() { void Gfx::opBeginMarkedContent(Object args[], int numArgs) { // push a new stack entry pushMarkedContent(); - + OCGs *contentConfig = catalog->getOptContentConfig(); char* name0 = args[0].getName(); if ( strncmp( name0, "OC", 2) == 0 && contentConfig) { diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index 687b2ae..4c12bfd 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -178,7 +178,7 @@ PDFDoc::PDFDoc(wchar_t *fileNameA, int fileNameLen, GooString *ownerPassword, // try to open file // NB: _wfopen is only available in NT - struct stat buf; + struct _stat buf; int size; version.dwOSVersionInfoSize = sizeof(version); GetVersionEx(&version); @@ -188,7 +188,7 @@ PDFDoc::PDFDoc(wchar_t *fileNameA, int fileNameLen, GooString *ownerPassword, } file = _wfopen(fileName2, L"rb"); } else { - if (_wstat(fileName->getCString(), &buf) == 0) { + if (_wstat(reinterpret_cast(fileName->getCString()), &buf) == 0) { size = buf.st_size; } file = fopen(fileName->getCString(), "rb");