Commit 64079ad8 authored by Kristian Høgsberg's avatar Kristian Høgsberg

2005-12-03 Kristian Høgsberg <krh@redhat.com>

        Fixes from Nickolay V. Shmyrev:

        * poppler/TextOutputDev.cc (TextLine::visitSelection,
        TextBlock::visitSelection): Fix selection crash with zero-width
        word boxes or zero-height line boxes (#4402).

        * poppler/CairoOutputDev.h: Fix wrong cairo-ft.h include (#4413).

        * poppler/CairoOutputDev.cc (eoFill, fill):
        * glib/poppler-page.cc (poppler_page_render_selection): Update to
        work with new GfxColor definition and use
        cairo_pattern_create_rgba() to cache cairo_pattern_t's for the
        fill and stroke colors.

        * glib/poppler-page.cc (poppler_page_set_selection_alpha): Zero
        out pixbuf first.
parent f3da21a3
2005-12-03 Kristian Høgsberg <krh@redhat.com>
Fixes from Nickolay V. Shmyrev:
* poppler/TextOutputDev.cc (TextLine::visitSelection,
TextBlock::visitSelection): Fix selection crash with zero-width
word boxes or zero-height line boxes (#4402).
* poppler/CairoOutputDev.h: Fix wrong cairo-ft.h include (#4413).
* poppler/CairoOutputDev.cc (eoFill, fill):
* glib/poppler-page.cc (poppler_page_render_selection): Update to
work with new GfxColor definition and use
cairo_pattern_create_rgba() to cache cairo_pattern_t's for the
fill and stroke colors.
* glib/poppler-page.cc (poppler_page_set_selection_alpha): Zero
out pixbuf first.
2005-12-03 Albert Astals Cid <aacid@kde.org>
* qt4/src/poppler-page.cc:
* qt4/src/Doxyfile:
* qt4/src/poppler-qt4.h:
......@@ -7,6 +27,7 @@
BC. Patch by Stefan Kebekus
2005-12-01 Albert Astals Cid <aacid@kde.org>
* poppler/JPXStream.cc:
* poppler/Stream.cc:
* poppler/Stream.h: Fix CAN-2005-3193 based on
......
......@@ -390,7 +390,7 @@ poppler_page_set_selection_alpha (PopplerPage *page,
PopplerRectangle *selection)
{
GdkRegion *region;
gint n_rectangles, i, x, y;
gint n_rectangles, i, x, y, width, height;
GdkRectangle *rectangles;
int pixbuf_rowstride, pixbuf_n_channels;
guchar *pixbuf_data, *dst;
......@@ -398,10 +398,14 @@ poppler_page_set_selection_alpha (PopplerPage *page,
pixbuf_data = gdk_pixbuf_get_pixels (pixbuf);
pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
if (pixbuf_n_channels != 4)
return;
gdk_pixbuf_fill(pixbuf, 0);
region = poppler_page_get_selection_region (page, scale, selection);
gdk_region_get_rectangles (region, &rectangles, &n_rectangles);
......@@ -460,14 +464,14 @@ poppler_page_render_selection (PopplerPage *page,
selection->x2, selection->y2);
GfxColor gfx_background_color = {
background_color->red / 65535.0,
background_color->green / 65535.0,
background_color->blue / 65535.0
background_color->red,
background_color->green,
background_color->blue
};
GfxColor gfx_glyph_color = {
glyph_color->red / 65535.0,
glyph_color->green / 65535.0,
glyph_color->blue / 65535.0
glyph_color->red,
glyph_color->green,
glyph_color->blue
};
text_dev = poppler_page_get_text_output_dev (page);
......
......@@ -35,7 +35,7 @@
#define soutRound(x) ((int)(x + 0.5))
//#define LOG_CAIRO
// #define LOG_CAIRO
#ifdef LOG_CAIRO
#define LOG(x) (x)
......@@ -55,6 +55,8 @@ CairoOutputDev::CairoOutputDev() {
fontEngine = NULL;
glyphs = NULL;
surface = NULL;
fill_pattern = NULL;
stroke_pattern = NULL;
}
CairoOutputDev::~CairoOutputDev() {
......@@ -63,6 +65,8 @@ CairoOutputDev::~CairoOutputDev() {
}
FT_Done_FreeType(ft_lib);
cairo_surface_destroy (surface);
cairo_pattern_destroy (stroke_pattern);
cairo_pattern_destroy (fill_pattern);
}
void CairoOutputDev::setSurface(cairo_surface_t *surface)
......@@ -194,21 +198,51 @@ void CairoOutputDev::updateLineWidth(GfxState *state) {
void CairoOutputDev::updateFillColor(GfxState *state) {
state->getFillRGB(&fill_color);
LOG(printf ("fill color: %f %f %f\n", fill_color.r, fill_color.g, fill_color.b));
cairo_pattern_destroy(fill_pattern);
fill_pattern = cairo_pattern_create_rgba(fill_color.r / 65535.0,
fill_color.g / 65535.0,
fill_color.b / 65535.0,
fill_opacity);
LOG(printf ("fill color: %d %d %d\n",
fill_color.r, fill_color.g, fill_color.b));
}
void CairoOutputDev::updateStrokeColor(GfxState *state) {
state->getStrokeRGB(&stroke_color);
LOG(printf ("stroke color: %f %f %f\n", stroke_color.r, stroke_color.g, stroke_color.b));
cairo_pattern_destroy(stroke_pattern);
stroke_pattern = cairo_pattern_create_rgba(stroke_color.r / 65535.0,
stroke_color.g / 65535.0,
stroke_color.b / 65535.0,
stroke_opacity);
LOG(printf ("stroke color: %d %d %d\n",
stroke_color.r, stroke_color.g, stroke_color.b));
}
void CairoOutputDev::updateFillOpacity(GfxState *state) {
fill_opacity = state->getFillOpacity();
cairo_pattern_destroy(fill_pattern);
fill_pattern = cairo_pattern_create_rgba(fill_color.r / 65535.0,
fill_color.g / 65535.0,
fill_color.b / 65535.0,
fill_opacity);
LOG(printf ("fill opacity: %f\n", fill_opacity));
}
void CairoOutputDev::updateStrokeOpacity(GfxState *state) {
stroke_opacity = state->getStrokeOpacity();
cairo_pattern_destroy(stroke_pattern);
stroke_pattern = cairo_pattern_create_rgba(stroke_color.r / 65535.0,
stroke_color.g / 65535.0,
stroke_color.b / 65535.0,
stroke_opacity);
LOG(printf ("stroke opacity: %f\n", stroke_opacity));
}
......@@ -294,9 +328,7 @@ void CairoOutputDev::doPath(GfxState *state, GfxPath *path,
void CairoOutputDev::stroke(GfxState *state) {
doPath (state, state->getPath(), gFalse);
cairo_set_source_rgba (cairo,
stroke_color.r, stroke_color.g, stroke_color.b,
stroke_opacity);
cairo_set_source (cairo, stroke_pattern);
LOG(printf ("stroke\n"));
cairo_stroke (cairo);
}
......@@ -304,9 +336,7 @@ void CairoOutputDev::stroke(GfxState *state) {
void CairoOutputDev::fill(GfxState *state) {
doPath (state, state->getPath(), gFalse);
cairo_set_fill_rule (cairo, CAIRO_FILL_RULE_WINDING);
cairo_set_source_rgba (cairo,
fill_color.r, fill_color.g, fill_color.b,
fill_opacity);
cairo_set_source (cairo, fill_pattern);
LOG(printf ("fill\n"));
cairo_fill (cairo);
}
......@@ -314,8 +344,7 @@ void CairoOutputDev::fill(GfxState *state) {
void CairoOutputDev::eoFill(GfxState *state) {
doPath (state, state->getPath(), gFalse);
cairo_set_fill_rule (cairo, CAIRO_FILL_RULE_EVEN_ODD);
cairo_set_source_rgb (cairo,
fill_color.r, fill_color.g, fill_color.b);
cairo_set_source (cairo, fill_pattern);
LOG(printf ("fill-eo\n"));
cairo_fill (cairo);
}
......@@ -380,16 +409,14 @@ void CairoOutputDev::endString(GfxState *state)
if (!(render & 1)) {
LOG (printf ("fill string\n"));
cairo_set_source_rgb (cairo,
fill_color.r, fill_color.g, fill_color.b);
cairo_set_source (cairo, fill_pattern);
cairo_show_glyphs (cairo, glyphs, glyphCount);
}
// stroke
if ((render & 3) == 1 || (render & 3) == 2) {
LOG (printf ("stroke string\n"));
cairo_set_source_rgb (cairo,
stroke_color.r, stroke_color.g, stroke_color.b);
cairo_set_source (cairo, stroke_pattern);
cairo_glyph_path (cairo, glyphs, glyphCount);
cairo_stroke (cairo);
}
......@@ -490,7 +517,7 @@ void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
cairo_pattern_set_filter (pattern, CAIRO_FILTER_BEST);
/* FIXME: Doesn't the image mask support any colorspace? */
cairo_set_source_rgb (cairo, fill_color.r, fill_color.g, fill_color.b);
cairo_set_source (cairo, fill_pattern);
cairo_mask (cairo, pattern);
cairo_pattern_destroy (pattern);
......
......@@ -15,7 +15,7 @@
#endif
#include "goo/gtypes.h"
#include <cairo/cairo-ft.h>
#include <cairo-ft.h>
#include "OutputDev.h"
#include "GfxState.h"
......@@ -135,8 +135,8 @@ public:
protected:
void doPath(GfxState *state, GfxPath *path, GBool snapToGrid);
GfxRGB fill_color;
GfxRGB stroke_color;
GfxRGB fill_color, stroke_color;
cairo_pattern_t *fill_pattern, *stroke_pattern;
double fill_opacity;
double stroke_opacity;
CairoFont *currentFont;
......
......@@ -3414,8 +3414,8 @@ void TextLine::visitSelection(TextSelectionVisitor *visitor,
(selection->x2 < p->xMax && selection->y2 < p->yMax))
if (begin == NULL)
begin = p;
if ((selection->x1 > p->xMin && selection->y1 > p->yMin) ||
(selection->x2 > p->xMin && selection->y2 > p->yMin))
if ((selection->x1 > p->xMin && selection->y1 > p->yMin ||
selection->x2 > p->xMin && selection->y2 > p->yMin) && (begin != NULL))
end = p->next;
}
......@@ -3482,8 +3482,8 @@ void TextBlock::visitSelection(TextSelectionVisitor *visitor,
stop_y = selection->y1;
}
if (selection->x1 > p->xMin && selection->y1 > p->yMin ||
selection->x2 > p->xMin && selection->y2 > p->yMin)
if ((selection->x1 > p->xMin && selection->y1 > p->yMin ||
selection->x2 > p->xMin && selection->y2 > p->yMin) && (begin != NULL))
end = p->next;
}
......
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