Commit 39bf7755 authored by Christian Persch's avatar Christian Persch Committed by Albert Astals Cid

poppler: cairo: Don't override the antialias settings from the cairo_t

This partially reverts commit 853e9499, which made CairoOutputDev store
the antialias setting, and applying it to its cairo context.

Instead, just copy the antialias (and font antialias) setting from the
passed cairo context to newly created contexts.  That way, the application
can control the antialias settings.

Use this in pdftocairo to implement its -antialias option.

https://bugs.freedesktop.org/show_bug.cgi?id=94977
poppler/poppler!89
parent c4f8555b
Pipeline #94089 passed with stage
in 3 minutes and 17 seconds
......@@ -150,7 +150,6 @@ CairoOutputDev::CairoOutputDev() {
inType3Char = false;
t3_glyph_has_bbox = false;
text_matrix_valid = true;
antialias = CAIRO_ANTIALIAS_DEFAULT;
groupColorSpaceStack = nullptr;
maskStack = nullptr;
......@@ -207,7 +206,6 @@ void CairoOutputDev::setCairo(cairo_t *c)
/* save the initial matrix so that we can use it for type3 fonts. */
//XXX: is this sufficient? could we miss changes to the matrix somehow?
cairo_get_matrix(cairo, &orig_matrix);
setContextAntialias(cairo, antialias);
} else {
cairo = nullptr;
cairo_shape = nullptr;
......@@ -230,22 +228,13 @@ void CairoOutputDev::setTextPage(TextPage *text)
}
}
void CairoOutputDev::setAntialias(cairo_antialias_t a)
void CairoOutputDev::copyAntialias(cairo_t *cr,
cairo_t *source_cr)
{
antialias = a;
if (cairo)
setContextAntialias (cairo, antialias);
if (cairo_shape)
setContextAntialias (cairo_shape, antialias);
}
cairo_set_antialias (cr, cairo_get_antialias (source_cr));
void CairoOutputDev::setContextAntialias(cairo_t *cr, cairo_antialias_t antialias)
{
cairo_font_options_t *font_options;
cairo_set_antialias (cr, antialias);
font_options = cairo_font_options_create ();
cairo_get_font_options (cr, font_options);
cairo_font_options_set_antialias (font_options, antialias);
auto font_options = cairo_font_options_create ();
cairo_get_font_options (source_cr, font_options);
cairo_set_font_options (cr, font_options);
cairo_font_options_destroy (font_options);
}
......@@ -937,7 +926,7 @@ bool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat,
old_cairo = cairo;
cairo = cairo_create (surface);
cairo_surface_destroy (surface);
setContextAntialias(cairo, antialias);
copyAntialias(cairo, old_cairo);
box.x1 = bbox[0]; box.y1 = bbox[1];
box.x2 = bbox[2]; box.y2 = bbox[3];
......@@ -1636,7 +1625,8 @@ void CairoOutputDev::beginTransparencyGroup(GfxState * /*state*/, const double *
cairo_surface_t *cairo_shape_surface = cairo_surface_create_similar_clip (cairo, CAIRO_CONTENT_ALPHA);
cairo_shape = cairo_create (cairo_shape_surface);
cairo_surface_destroy (cairo_shape_surface);
setContextAntialias(cairo_shape, antialias);
copyAntialias(cairo_shape, cairo);
/* the color doesn't matter as long as it is opaque */
cairo_set_source_rgb (cairo_shape, 0, 0, 0);
......@@ -1790,7 +1780,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, const double * bbox, bool alp
cairo_surface_t *source = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t *maskCtx = cairo_create(source);
setContextAntialias(maskCtx, antialias);
copyAntialias (maskCtx, cairo);
//XXX: hopefully this uses the correct color space */
if (!alpha && groupColorSpaceStack->cs) {
......
......@@ -265,9 +265,10 @@ public:
bool isReverseVideo() { return false; }
void setCairo (cairo_t *cr);
void copyAntialias(cairo_t *cr,
cairo_t *source_cr);
void setTextPage (TextPage *text);
void setPrinting (bool printingA) { printing = printingA; needFontUpdate = true; }
void setAntialias(cairo_antialias_t antialias);
void setInType3Char(bool inType3CharA) { inType3Char = inType3CharA; }
void getType3GlyphWidth (double *wx, double *wy) { *wx = t3_glyph_wx; *wy = t3_glyph_wy; }
......@@ -293,7 +294,6 @@ protected:
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
bool setMimeDataForCCITTParams(Stream *str, cairo_surface_t *image, int height);
#endif
static void setContextAntialias(cairo_t *cr, cairo_antialias_t antialias);
GfxRGB fill_color, stroke_color;
cairo_pattern_t *fill_pattern, *stroke_pattern;
......@@ -345,7 +345,6 @@ protected:
double t3_glyph_wx, t3_glyph_wy;
bool t3_glyph_has_bbox;
double t3_glyph_bbox[4];
cairo_antialias_t antialias;
bool prescaleImages;
TextPage *textPage; // text for the current page
......
......@@ -704,12 +704,20 @@ static void renderPage(PDFDoc *doc, CairoOutputDev *cairoOut, int pg,
cairo_t *cr;
cairo_status_t status;
cairo_matrix_t m;
cairo_font_options_t *font_options;
cr = cairo_create(surface);
cairo_set_antialias (cr, antialiasEnum);
font_options = cairo_font_options_create ();
cairo_get_font_options (cr, font_options);
cairo_font_options_set_antialias (font_options, antialiasEnum);
cairo_set_font_options (cr, font_options);
cairo_font_options_destroy (font_options);
cairoOut->setCairo(cr);
cairoOut->setPrinting(printing);
cairoOut->setAntialias(antialiasEnum);
cairo_save(cr);
if (ps && output_w > output_h) {
......
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