[pango: 1/4] [pango-view] Clear background in _render
- From: Behdad Esfahbod <behdad src gnome org>
- To: svn-commits-list gnome org
- Subject: [pango: 1/4] [pango-view] Clear background in _render
- Date: Mon, 16 Mar 2009 17:26:55 -0400 (EDT)
commit c4f9a30634779bc985a470df2bc9f7e4fa0e6ad0
Author: Behdad Esfahbod <behdad behdad org>
Date: Mon Mar 16 16:32:02 2009 -0400
[pango-view] Clear background in _render
---
pango-view/viewer-cairo.c | 90 ++++++++++++++++++++++++++----------------
pango-view/viewer-pangoxft.c | 21 ++++------
pango-view/viewer-x.c | 8 ----
3 files changed, 65 insertions(+), 54 deletions(-)
diff --git a/pango-view/viewer-cairo.c b/pango-view/viewer-cairo.c
index 579076e..1da05b8 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 9e2cc89..948cd90 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 89864c0..25492f3 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]