summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2009-03-16 16:32:02 -0400
committerBehdad Esfahbod <behdad@behdad.org>2009-03-16 16:32:02 -0400
commitc4f9a30634779bc985a470df2bc9f7e4fa0e6ad0 (patch)
tree344109f3cf5591ba3afb0a137a18abd3f9250082
parenta6af36b9c06b81ab8095afff85f68f37c27a4b3b (diff)
downloadpango-c4f9a30634779bc985a470df2bc9f7e4fa0e6ad0.tar.gz
[pango-view] Clear background in _render
-rw-r--r--pango-view/viewer-cairo.c90
-rw-r--r--pango-view/viewer-pangoxft.c21
-rw-r--r--pango-view/viewer-x.c8
3 files changed, 65 insertions, 54 deletions
diff --git a/pango-view/viewer-cairo.c b/pango-view/viewer-cairo.c
index 579076e1..1da05b8a 100644
--- a/pango-view/viewer-cairo.c
+++ b/pango-view/viewer-cairo.c
@@ -33,37 +33,6 @@
#include "viewer-x.h"
#include <cairo-xlib.h>
-static void
-cairo_view_iface_paint_background_over (gpointer instance G_GNUC_UNUSED,
- cairo_t *cr)
-{
- if (opt_bg_set)
- {
- cairo_set_source_rgba (cr,
- opt_bg_color.red / 65535.,
- opt_bg_color.green / 65535.,
- opt_bg_color.blue / 65535.,
- opt_bg_alpha / 65535.);
- cairo_paint (cr);
- }
-}
-
-static void
-cairo_view_iface_paint_background_source (gpointer instance G_GNUC_UNUSED,
- cairo_t *cr)
-{
- if (opt_bg_set)
- {
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- cairo_set_source_rgba (cr,
- opt_bg_color.red / 65535.,
- opt_bg_color.green / 65535.,
- opt_bg_color.blue / 65535.,
- opt_bg_alpha / 65535.);
- cairo_paint (cr);
- }
-}
-
static cairo_surface_t *
@@ -80,10 +49,28 @@ cairo_x_view_iface_create_surface (gpointer instance,
width, height);
}
+static void
+cairo_x_view_iface_paint_background (gpointer instance G_GNUC_UNUSED,
+ cairo_t *cr)
+{
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+
+ if (opt_bg_set)
+ {
+ cairo_set_source_rgba (cr,
+ opt_bg_color.red / 65535.,
+ opt_bg_color.green / 65535.,
+ opt_bg_color.blue / 65535.,
+ opt_bg_alpha / 65535.);
+ cairo_paint (cr);
+ }
+}
+
static CairoViewerIface cairo_x_viewer_iface = {
&x_viewer,
cairo_x_view_iface_create_surface,
- cairo_view_iface_paint_background_over
+ cairo_x_view_iface_paint_background
};
#endif /* HAVE_CAIRO_XLIB */
@@ -154,10 +141,29 @@ const PangoViewer cairo_image_viewer = {
NULL
};
+static void
+cairo_image_view_iface_paint_background (gpointer instance G_GNUC_UNUSED,
+ cairo_t *cr)
+{
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+
+ if (opt_bg_set)
+ {
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_rgba (cr,
+ opt_bg_color.red / 65535.,
+ opt_bg_color.green / 65535.,
+ opt_bg_color.blue / 65535.,
+ opt_bg_alpha / 65535.);
+ cairo_paint (cr);
+ }
+}
+
static CairoViewerIface cairo_image_viewer_iface = {
&cairo_image_viewer,
cairo_view_iface_create_surface,
- cairo_view_iface_paint_background_source
+ cairo_image_view_iface_paint_background
};
@@ -307,10 +313,26 @@ const PangoViewer cairo_vector_viewer = {
NULL
};
+static void
+cairo_vector_view_iface_paint_background (gpointer instance G_GNUC_UNUSED,
+ cairo_t *cr)
+{
+ if (opt_bg_set)
+ {
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_rgba (cr,
+ opt_bg_color.red / 65535.,
+ opt_bg_color.green / 65535.,
+ opt_bg_color.blue / 65535.,
+ opt_bg_alpha / 65535.);
+ cairo_paint (cr);
+ }
+}
+
static CairoViewerIface cairo_vector_viewer_iface = {
&cairo_vector_viewer,
cairo_view_iface_create_surface,
- cairo_view_iface_paint_background_over
+ cairo_vector_view_iface_paint_background
};
diff --git a/pango-view/viewer-pangoxft.c b/pango-view/viewer-pangoxft.c
index 9e2cc89c..948cd90e 100644
--- a/pango-view/viewer-pangoxft.c
+++ b/pango-view/viewer-pangoxft.c
@@ -114,18 +114,15 @@ pangoxft_view_render (gpointer instance,
DefaultVisual (x->display, x->screen),
DefaultColormap (x->display, x->screen));
- if (opt_bg_set)
- {
- /* XftDrawRect only fills solid.
- * Flatten with white.
- */
- color.color.red = ((opt_bg_color.red * opt_bg_alpha) >> 16) + (65535 - opt_bg_alpha);
- color.color.green = ((opt_bg_color.green * opt_bg_alpha) >> 16) + (65535 - opt_bg_alpha);
- color.color.blue = ((opt_bg_color.blue * opt_bg_alpha) >> 16) + (65535 - opt_bg_alpha);
- color.color.alpha = 65535;
-
- XftDrawRect (draw, &color, 0, 0, *width, *height);
- }
+ /* XftDrawRect only fills solid.
+ * Flatten with white.
+ */
+ color.color.red = ((opt_bg_color.red * opt_bg_alpha) >> 16) + (65535 - opt_bg_alpha);
+ color.color.green = ((opt_bg_color.green * opt_bg_alpha) >> 16) + (65535 - opt_bg_alpha);
+ color.color.blue = ((opt_bg_color.blue * opt_bg_alpha) >> 16) + (65535 - opt_bg_alpha);
+ color.color.alpha = 65535;
+
+ XftDrawRect (draw, &color, 0, 0, *width, *height);
color.color.red = opt_fg_color.red;
color.color.blue = opt_fg_color.green;
diff --git a/pango-view/viewer-x.c b/pango-view/viewer-x.c
index 89864c08..25492f33 100644
--- a/pango-view/viewer-x.c
+++ b/pango-view/viewer-x.c
@@ -66,18 +66,10 @@ x_view_create_surface (gpointer instance,
{
XViewer *x = (XViewer *) instance;
Pixmap pixmap;
- GC gc;
pixmap = XCreatePixmap (x->display, DefaultRootWindow (x->display), width, height,
DefaultDepth (x->display, x->screen));
- gc = XCreateGC (x->display, pixmap, 0, NULL);
-
- XSetForeground (x->display, gc, WhitePixel (x->display, x->screen));
- XFillRectangle (x->display, pixmap, gc, 0, 0, width, height);
-
- XFreeGC (x->display, gc);
-
return (gpointer) pixmap;
}