Commit 064bbe4b authored by Albert Astals Cid's avatar Albert Astals Cid

Add some const to GfxState & friends

parent 1fa3cbd7
......@@ -712,7 +712,7 @@ void CairoOutputDev::updateFont(GfxState *state) {
/* Align stroke coordinate i if the point is the start or end of a
* horizontal or vertical line */
void CairoOutputDev::alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y)
void CairoOutputDev::alignStrokeCoords(const GfxSubpath *subpath, int i, double *x, double *y)
{
double x1, y1, x2, y2;
bool align = false;
......@@ -752,13 +752,12 @@ void CairoOutputDev::alignStrokeCoords(GfxSubpath *subpath, int i, double *x, do
#undef STROKE_COORD_TOLERANCE
void CairoOutputDev::doPath(cairo_t *c, GfxState *state, GfxPath *path) {
GfxSubpath *subpath;
void CairoOutputDev::doPath(cairo_t *c, GfxState *state, const GfxPath *path) {
int i, j;
double x, y;
cairo_new_path (c);
for (i = 0; i < path->getNumSubpaths(); ++i) {
subpath = path->getSubpath(i);
const GfxSubpath *subpath = path->getSubpath(i);
if (subpath->getNumPoints() > 0) {
if (align_stroke_coords) {
alignStrokeCoords(subpath, 0, &x, &y);
......
......@@ -274,7 +274,7 @@ public:
double *getType3GlyphBBox () { return t3_glyph_bbox; }
protected:
void doPath(cairo_t *cairo, GfxState *state, GfxPath *path);
void doPath(cairo_t *cairo, GfxState *state, const GfxPath *path);
cairo_surface_t *downscaleSurface(cairo_surface_t *orig_surface);
void getScaledSize(const cairo_matrix_t *matrix,
int orig_width, int orig_height,
......@@ -285,7 +285,7 @@ protected:
void setMimeData(GfxState *state, Stream *str, Object *ref,
GfxImageColorMap *colorMap, cairo_surface_t *image, int height);
void fillToStrokePathClip(GfxState *state);
void alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y);
void alignStrokeCoords(const GfxSubpath *subpath, int i, double *x, double *y);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
bool setMimeDataForJBIG2Globals (Stream *str, cairo_surface_t *image);
#endif
......
......@@ -4350,9 +4350,9 @@ void Gfx::doImage(Object *ref, Stream *str, bool inlineImg) {
char *tempIntent = nullptr;
Object objIntent = dict->lookup("Intent");
if (objIntent.isName()) {
tempIntent = state->getRenderingIntent();
if (tempIntent != nullptr) {
tempIntent = strdup(tempIntent);
const char *stateIntent = state->getRenderingIntent();
if (stateIntent != nullptr) {
tempIntent = strdup(stateIntent);
}
state->setRenderingIntent(objIntent.getName());
}
......
......@@ -437,7 +437,7 @@ void GfxColorSpace::createMapping(std::vector<GfxSeparationColorSpace*> *separat
}
void GfxColorSpace::getDefaultRanges(double *decodeLow, double *decodeRange,
int maxImgPixel) {
int maxImgPixel) const {
int i;
for (i = 0; i < getNComps(); ++i) {
......@@ -733,7 +733,7 @@ void GfxDeviceGrayColorSpace::getDeviceN(const GfxColor *color, GfxColor *device
deviceN->c[3] = clip01(gfxColorComp1 - color->c[0]);
}
void GfxDeviceGrayColorSpace::getDefaultColor(GfxColor *color) {
void GfxDeviceGrayColorSpace::getDefaultColor(GfxColor *color) const {
color->c[0] = 0;
}
......@@ -943,7 +943,7 @@ void GfxCalGrayColorSpace::getDeviceN(const GfxColor *color, GfxColor *deviceN)
deviceN->c[3] = cmyk.k;
}
void GfxCalGrayColorSpace::getDefaultColor(GfxColor *color) {
void GfxCalGrayColorSpace::getDefaultColor(GfxColor *color) const {
color->c[0] = 0;
}
......@@ -1085,7 +1085,7 @@ void GfxDeviceRGBColorSpace::getDeviceN(const GfxColor *color, GfxColor *deviceN
deviceN->c[3] = cmyk.k;
}
void GfxDeviceRGBColorSpace::getDefaultColor(GfxColor *color) {
void GfxDeviceRGBColorSpace::getDefaultColor(GfxColor *color) const {
color->c[0] = 0;
color->c[1] = 0;
color->c[2] = 0;
......@@ -1310,7 +1310,7 @@ void GfxCalRGBColorSpace::getDeviceN(const GfxColor *color, GfxColor *deviceN) c
deviceN->c[3] = cmyk.k;
}
void GfxCalRGBColorSpace::getDefaultColor(GfxColor *color) {
void GfxCalRGBColorSpace::getDefaultColor(GfxColor *color) const {
color->c[0] = 0;
color->c[1] = 0;
color->c[2] = 0;
......@@ -1442,7 +1442,7 @@ void GfxDeviceCMYKColorSpace::getDeviceN(const GfxColor *color, GfxColor *device
deviceN->c[3] = clip01(color->c[3]);
}
void GfxDeviceCMYKColorSpace::getDefaultColor(GfxColor *color) {
void GfxDeviceCMYKColorSpace::getDefaultColor(GfxColor *color) const {
color->c[0] = 0;
color->c[1] = 0;
color->c[2] = 0;
......@@ -1698,7 +1698,7 @@ void GfxLabColorSpace::getDeviceN(const GfxColor *color, GfxColor *deviceN) cons
deviceN->c[3] = cmyk.k;
}
void GfxLabColorSpace::getDefaultColor(GfxColor *color) {
void GfxLabColorSpace::getDefaultColor(GfxColor *color) const {
color->c[0] = 0;
if (aMin > 0) {
color->c[1] = dblToCol(aMin);
......@@ -1717,7 +1717,7 @@ void GfxLabColorSpace::getDefaultColor(GfxColor *color) {
}
void GfxLabColorSpace::getDefaultRanges(double *decodeLow, double *decodeRange,
int maxImgPixel) {
int maxImgPixel) const {
decodeLow[0] = 0;
decodeRange[0] = 100;
decodeLow[1] = aMin;
......@@ -2342,7 +2342,7 @@ void GfxICCBasedColorSpace::getDeviceN(const GfxColor *color, GfxColor *deviceN)
deviceN->c[3] = cmyk.k;
}
void GfxICCBasedColorSpace::getDefaultColor(GfxColor *color) {
void GfxICCBasedColorSpace::getDefaultColor(GfxColor *color) const {
int i;
for (i = 0; i < nComps; ++i) {
......@@ -2358,7 +2358,7 @@ void GfxICCBasedColorSpace::getDefaultColor(GfxColor *color) {
void GfxICCBasedColorSpace::getDefaultRanges(double *decodeLow,
double *decodeRange,
int maxImgPixel) {
int maxImgPixel) const {
alt->getDefaultRanges(decodeLow, decodeRange, maxImgPixel);
#if 0
......@@ -2591,13 +2591,13 @@ void GfxIndexedColorSpace::getDeviceN(const GfxColor *color, GfxColor *deviceN)
base->getDeviceN(mapColorToBase(color, &color2), deviceN);
}
void GfxIndexedColorSpace::getDefaultColor(GfxColor *color) {
void GfxIndexedColorSpace::getDefaultColor(GfxColor *color) const {
color->c[0] = 0;
}
void GfxIndexedColorSpace::getDefaultRanges(double *decodeLow,
double *decodeRange,
int maxImgPixel) {
int maxImgPixel) const {
decodeLow[0] = 0;
decodeRange[0] = maxImgPixel;
}
......@@ -2798,7 +2798,7 @@ void GfxSeparationColorSpace::getDeviceN(const GfxColor *color, GfxColor *device
}
}
void GfxSeparationColorSpace::getDefaultColor(GfxColor *color) {
void GfxSeparationColorSpace::getDefaultColor(GfxColor *color) const {
color->c[0] = gfxColorComp1;
}
......@@ -3079,7 +3079,7 @@ void GfxDeviceNColorSpace::getDeviceN(const GfxColor *color, GfxColor *deviceN)
}
}
void GfxDeviceNColorSpace::getDefaultColor(GfxColor *color) {
void GfxDeviceNColorSpace::getDefaultColor(GfxColor *color) const {
int i;
for (i = 0; i < nComps; ++i) {
......@@ -3235,7 +3235,7 @@ void GfxPatternColorSpace::getDeviceN(const GfxColor *color, GfxColor *deviceN)
deviceN->c[3] = 1;
}
void GfxPatternColorSpace::getDefaultColor(GfxColor *color) {
void GfxPatternColorSpace::getDefaultColor(GfxColor *color) const {
color->c[0]=0;
}
......@@ -4053,7 +4053,7 @@ GfxShading *GfxAxialShading::copy() {
return new GfxAxialShading(this);
}
double GfxAxialShading::getDistance(double sMin, double sMax) {
double GfxAxialShading::getDistance(double sMin, double sMax) const {
double xMin, yMin, xMax, yMax;
xMin = x0 + sMin * (x1 - x0);
......@@ -4232,7 +4232,7 @@ GfxShading *GfxRadialShading::copy() {
return new GfxRadialShading(this);
}
double GfxRadialShading::getDistance(double sMin, double sMax) {
double GfxRadialShading::getDistance(double sMin, double sMax) const {
double xMin, yMin, rMin, xMax, yMax, rMax;
xMin = x0 + sMin * (x1 - x0);
......@@ -6701,7 +6701,7 @@ void GfxState::setPath(GfxPath *pathA) {
}
void GfxState::getUserClipBBox(double *xMin, double *yMin,
double *xMax, double *yMax) {
double *xMax, double *yMax) const {
double ictm[6];
double xMin1, yMin1, xMax1, yMax1, tx, ty;
......@@ -6769,7 +6769,7 @@ void GfxState::getUserClipBBox(double *xMin, double *yMin,
*yMax = yMax1;
}
double GfxState::transformWidth(double w) {
double GfxState::transformWidth(double w) const {
double x, y;
x = ctm[0] + ctm[2];
......@@ -6777,7 +6777,7 @@ double GfxState::transformWidth(double w) {
return w * sqrt(0.5 * (x * x + y * y));
}
double GfxState::getTransformedFontSize() {
double GfxState::getTransformedFontSize() const {
double x1, y1, x2, y2;
x1 = textMat[2] * fontSize;
......@@ -6788,7 +6788,7 @@ double GfxState::getTransformedFontSize() {
}
void GfxState::getFontTransMat(double *m11, double *m12,
double *m21, double *m22) {
double *m21, double *m22) const {
*m11 = (textMat[0] * ctm[0] + textMat[1] * ctm[2]) * fontSize;
*m12 = (textMat[0] * ctm[1] + textMat[1] * ctm[3]) * fontSize;
*m21 = (textMat[2] * ctm[0] + textMat[3] * ctm[2]) * fontSize;
......
This diff is collapsed.
......@@ -1006,7 +1006,7 @@ private:
int width, height;
GfxImageColorMap *colorMap;
Function *func;
const Function *func;
ImageStream *imgStr;
int buf[gfxColorMaxComps];
int pixelIdx;
......@@ -4977,15 +4977,14 @@ void PSOutputDev::clipToStrokePath(GfxState *state) {
writePS("Ws\n");
}
void PSOutputDev::doPath(GfxPath *path) {
GfxSubpath *subpath;
void PSOutputDev::doPath(const GfxPath *path) {
double x0, y0, x1, y1, x2, y2, x3, y3, x4, y4;
int n, m, i, j;
n = path->getNumSubpaths();
if (n == 1 && path->getSubpath(0)->getNumPoints() == 5) {
subpath = path->getSubpath(0);
const GfxSubpath *subpath = path->getSubpath(0);
x0 = subpath->getX(0);
y0 = subpath->getY(0);
x4 = subpath->getX(4);
......@@ -5012,7 +5011,7 @@ void PSOutputDev::doPath(GfxPath *path) {
}
for (i = 0; i < n; ++i) {
subpath = path->getSubpath(i);
const GfxSubpath *subpath = path->getSubpath(i);
m = subpath->getNumPoints();
writePSFmt("{0:.6g} {1:.6g} m\n", subpath->getX(0), subpath->getY(0));
j = 1;
......@@ -6602,7 +6601,6 @@ void PSOutputDev::dumpColorSpaceL2(GfxColorSpace *colorSpace,
double low[gfxColorMaxComps], range[gfxColorMaxComps];
GfxColor color;
GfxCMYK cmyk;
Function *func;
int n, numComps, numAltComps;
int byte;
int i, j, k;
......@@ -6745,7 +6743,7 @@ void PSOutputDev::dumpColorSpaceL2(GfxColorSpace *colorSpace,
lookup = indexedCS->getLookup();
writePSFmt(" {0:d} <\n", n);
if (baseCS->getMode() == csDeviceN && level != psLevel3 && level != psLevel3Sep) {
func = ((GfxDeviceNColorSpace *)baseCS)->getTintTransformFunc();
const Function *func = ((GfxDeviceNColorSpace *)baseCS)->getTintTransformFunc();
baseCS->getDefaultRanges(low, range, indexedCS->getIndexHigh());
if (((GfxDeviceNColorSpace *)baseCS)->getAlt()->getMode() == csLab) {
labCS = (GfxLabColorSpace *)((GfxDeviceNColorSpace *)baseCS)->getAlt();
......
......@@ -383,7 +383,7 @@ private:
void setupForm(Ref id, Object *strObj);
void addProcessColor(double c, double m, double y, double k);
void addCustomColor(GfxSeparationColorSpace *sepCS);
void doPath(GfxPath *path);
void doPath(const GfxPath *path);
void maskToClippingPath(Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert);
void doImageL1(Object *ref, GfxImageColorMap *colorMap,
bool invert, bool inlineImg,
......
......@@ -2192,15 +2192,14 @@ void SplashOutputDev::clipToStrokePath(GfxState *state) {
delete path2;
}
SplashPath SplashOutputDev::convertPath(GfxState *state, GfxPath *path,
SplashPath SplashOutputDev::convertPath(GfxState *state, const GfxPath *path,
bool dropEmptySubpaths) {
SplashPath sPath;
GfxSubpath *subpath;
int n, i, j;
n = dropEmptySubpaths ? 1 : 0;
for (i = 0; i < path->getNumSubpaths(); ++i) {
subpath = path->getSubpath(i);
const GfxSubpath *subpath = path->getSubpath(i);
if (subpath->getNumPoints() > n) {
sPath.reserve(subpath->getNumPoints() + 1);
sPath.moveTo((SplashCoord)subpath->getX(0),
......
......@@ -404,7 +404,7 @@ private:
static void getMatteColor( SplashColorMode colorMode, GfxImageColorMap *colorMap, const GfxColor * matteColor, SplashColor splashMatteColor);
void setOverprintMask(GfxColorSpace *colorSpace, bool overprintFlag,
int overprintMode, const GfxColor *singleColor, bool grayIndexed = false);
SplashPath convertPath(GfxState *state, GfxPath *path,
SplashPath convertPath(GfxState *state, const GfxPath *path,
bool dropEmptySubpaths);
void drawType3Glyph(GfxState *state, T3FontCache *t3Font,
T3FontCacheTag *tag, unsigned char *data);
......
......@@ -5783,18 +5783,16 @@ void TextOutputDev::endActualText(GfxState *state)
}
void TextOutputDev::stroke(GfxState *state) {
GfxPath *path;
GfxSubpath *subpath;
double x[2], y[2];
if (!doHTML) {
return;
}
path = state->getPath();
const GfxPath *path = state->getPath();
if (path->getNumSubpaths() != 1) {
return;
}
subpath = path->getSubpath(0);
const GfxSubpath *subpath = path->getSubpath(0);
if (subpath->getNumPoints() != 2) {
return;
}
......@@ -5808,8 +5806,6 @@ void TextOutputDev::stroke(GfxState *state) {
}
void TextOutputDev::fill(GfxState *state) {
GfxPath *path;
GfxSubpath *subpath;
double x[5], y[5];
double rx0, ry0, rx1, ry1, t;
int i;
......@@ -5817,11 +5813,11 @@ void TextOutputDev::fill(GfxState *state) {
if (!doHTML) {
return;
}
path = state->getPath();
const GfxPath *path = state->getPath();
if (path->getNumSubpaths() != 1) {
return;
}
subpath = path->getSubpath(0);
const GfxSubpath *subpath = path->getSubpath(0);
if (subpath->getNumPoints() != 5) {
return;
}
......
......@@ -698,15 +698,14 @@ void ArthurOutputDev::updateFont(GfxState *state)
}
}
static QPainterPath convertPath(GfxState *state, GfxPath *path, Qt::FillRule fillRule)
static QPainterPath convertPath(GfxState *state, const GfxPath *path, Qt::FillRule fillRule)
{
GfxSubpath *subpath;
int i, j;
QPainterPath qPath;
qPath.setFillRule(fillRule);
for (i = 0; i < path->getNumSubpaths(); ++i) {
subpath = path->getSubpath(i);
const GfxSubpath *subpath = path->getSubpath(i);
if (subpath->getNumPoints() > 0) {
qPath.moveTo(subpath->getX(0), subpath->getY(0));
j = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment