[poppler] poppler/poppler: CairoOutputDev.cc, 1.21, 1.22 CairoOutputDev.h, 1.8, 1.9 TextOutputDev.cc, 1.14, 1.15

Kristian Høgsberg krh at freedesktop.org
Sat Dec 3 13:55:38 PST 2005


Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv3997/poppler

Modified Files:
	CairoOutputDev.cc CairoOutputDev.h TextOutputDev.cc 
Log Message:
2005-12-03  Kristian Høgsberg  <krh at 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.



Index: CairoOutputDev.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.cc,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- CairoOutputDev.cc	30 Oct 2005 20:29:05 -0000	1.21
+++ CairoOutputDev.cc	3 Dec 2005 21:55:36 -0000	1.22
@@ -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 @@
   fontEngine = NULL;
   glyphs = NULL;
   surface = NULL;
+  fill_pattern = NULL;
+  stroke_pattern = NULL;
 }
 
 CairoOutputDev::~CairoOutputDev() {
@@ -63,6 +65,8 @@
   }
   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::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::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::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::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 @@
   
   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 @@
 
   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);

Index: CairoOutputDev.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- CairoOutputDev.h	30 Oct 2005 20:29:05 -0000	1.8
+++ CairoOutputDev.h	3 Dec 2005 21:55:36 -0000	1.9
@@ -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 @@
 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;

Index: TextOutputDev.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/TextOutputDev.cc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- TextOutputDev.cc	30 Oct 2005 20:29:05 -0000	1.14
+++ TextOutputDev.cc	3 Dec 2005 21:55:36 -0000	1.15
@@ -3414,8 +3414,8 @@
 	(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 @@
       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;
   }
 



More information about the poppler mailing list