proposed change to canvases
- From: mike engber <engber eazel com>
- To: gnome-hackers gnome org
- Subject: proposed change to canvases
- Date: Wed, 22 Nov 2000 17:58:32 -0800
I would like to add support to anti-aliased canvases for
drawing dithered. For nautilus, this will enable us to
draw gradients that look smooth in 16 bit mode - right
now gradients look really bad in 16 bit mode.
Below are proposed patches for gnome-canvas .c and .h.
The current canvas code has a hard-coded value of GDK_RGB_DITHER_NONE.
My patches provide an API to change this value. Existing canvas code
will be unaffected. You have to explicitly make a call to turn on
dithering.
The change adds two fns, gnome_canvas_get_dither and
gnome_canvas_set_dither; and one GnomeCanvas field,
to hold the dither value.
The unusual thing is that this new field is a 2-bit bitfield.
The reason is to maintain binary compatibility with existing
code (one of the goals of the 1.4 release).
There are six 1-bit bitfields prior to the new field I'm
adding - so the sizeof should not be changed (for any
reasonable C implementation).
Yes, it's ugly, but remember this only has to tide us
over till 2.0 when we'll be able break binary compatibility
and give this field the full int it deserves.
If anyone has any strenuous objections, speak up.
-ME
---
Index: gnome-canvas.h
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-canvas.h,v
retrieving revision 1.47.4.2
diff -p -u -r1.47.4.2 gnome-canvas.h
--- gnome-canvas.h 2000/06/29 04:20:38 1.47.4.2
+++ gnome-canvas.h 2000/11/23 00:26:34
@@ -465,6 +465,7 @@ struct _GnomeCanvas {
/* GC for temporary draw pixmap */
GdkGC *pixmap_gc;
+
/* Whether items need update at next idle loop iteration */
unsigned int need_update : 1;
@@ -482,6 +483,9 @@ struct _GnomeCanvas {
/* Whether the canvas is in antialiased mode or not */
unsigned int aa : 1;
+
+ /* dither mode for aa drawing */
+ unsigned int dither : 2;
};
struct _GnomeCanvasClass {
@@ -594,6 +598,15 @@ gulong gnome_canvas_get_color_pixel (Gno
*/
void gnome_canvas_set_stipple_origin (GnomeCanvas *canvas, GdkGC *gc);
+/* Controls the dithering used when the canvase renders.
+ * Only applicable to aa canvases - ingnored by non-aa canvases.
+ */
+void gnome_canvas_set_dither (GnomeCanvas *canvas, GdkRgbDither
dither);
+
+/* Returns the dither mode of an aa canvas.
+ * Only applicable to aa canvases - ingnored by non-aa canvases.
+ */
+GdkRgbDither gnome_canvas_get_dither (GnomeCanvas *canvas);
END_GNOME_DECLS
Index: gnome-canvas.c
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-canvas.c,v
retrieving revision 1.93.4.13
diff -p -u -r1.93.4.13 gnome-canvas.c
--- gnome-canvas.c 2000/06/29 04:20:38 1.93.4.13
+++ gnome-canvas.c 2000/11/23 00:26:23
@@ -3272,7 +3272,7 @@ paint (GnomeCanvas *canvas)
(draw_y1 - DISPLAY_Y1 (canvas)
+ canvas->zoom_yofs),
width, height,
- GDK_RGB_DITHER_NONE,
+ canvas->dither,
buf.buf,
IMAGE_WIDTH_AA * 3);
}
@@ -4136,4 +4136,35 @@ gnome_canvas_set_stipple_origin (GnomeCa
g_return_if_fail (gc != NULL);
gdk_gc_set_ts_origin (gc, -canvas->draw_xofs, -canvas->draw_yofs);
+}
+
+/**
+ * gnome_canvas_set_dither:
+ * @canvas: A canvas.
+ * dither: used when rendering an aa canvas.
+ *
+ * Turns on/off dithered rendering for aa canvases.
+ **/
+void
+gnome_canvas_set_dither (GnomeCanvas *canvas, GdkRgbDither dither)
+{
+ g_return_if_fail (canvas != NULL);
+ g_return_if_fail (GNOME_IS_CANVAS (canvas));
+
+ canvas->dither = dither;
+}
+
+/**
+ * gnome_canvas_get_dither:
+ * @canvas: A canvas.
+ *
+ * Returns the dither setting.
+ **/
+GdkRgbDither
+gnome_canvas_get_dither (GnomeCanvas *canvas)
+{
+ g_return_if_fail (canvas != NULL);
+ g_return_if_fail (GNOME_IS_CANVAS (canvas));
+
+ return canvas->dither;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]