summaryrefslogtreecommitdiff
path: root/test/test.c
diff options
context:
space:
mode:
authorRamiro Estrugo <ramiro@src.gnome.org>2001-02-13 12:01:16 +0000
committerRamiro Estrugo <ramiro@src.gnome.org>2001-02-13 12:01:16 +0000
commitb075065c7fbd08a6c7de5c196412015436951ba2 (patch)
tree43df6f3e8319af5e514f53d3b1831e1eaa466c32 /test/test.c
parent25dcf28b44ff1d4bb0dce83270677d071cd1fa81 (diff)
downloadnautilus-b075065c7fbd08a6c7de5c196412015436951ba2.tar.gz
reviewed by: Maciej Stachowiak <mjs@eazel.com>
* libnautilus-extensions/Makefile.am: * libnautilus-extensions/nautilus-glyph.h: * libnautilus-extensions/nautilus-glyph.c: New class. A wrapper on RsvgGlyph that makes it simple and fast to draw smooth text on pixbufs * libnautilus-extensions/nautilus-clickable-image.c: (nautilus_clickable_image_initialize_class), (nautilus_clickable_image_realize): Remove unrealize() method that was a noop. * libnautilus-extensions/nautilus-debug-drawing.c: (nautilus_debug_pixbuf_draw_point), (nautilus_debug_pixbuf_draw_rectangle), (nautilus_debug_pixbuf_draw_rectangle_inset): * libnautilus-extensions/nautilus-debug-drawing.h: Add some pixbuf drawing functions to debug clip areas in pixbufs. * libnautilus-extensions/nautilus-image-table.c: (nautilus_image_table_initialize_class), (nautilus_image_table_remove): Remove add() method that was a noop. * test/.cvsignore: * test/Makefile.am: * test/test-nautilus-font-simple.c: (main): * test/test-nautilus-font.c: (main): * test/test-nautilus-glyph-simple.c: (glyph_new), (main): * test/test-nautilus-glyph.c: (glyph_new), (main): * test/test.c: (test_window_set_title_with_pid), (test_pixbuf_draw_rectangle_tiled): * test/test.h: New NautilusGlyph tests. Also remove the broken pixbuf drawing debug code. Use the debugging code in nautilus-debug-drawing.[ch] instead.
Diffstat (limited to 'test/test.c')
-rw-r--r--test/test.c259
1 files changed, 48 insertions, 211 deletions
diff --git a/test/test.c b/test/test.c
index ad1ba0be8..c32b84313 100644
--- a/test/test.c
+++ b/test/test.c
@@ -212,217 +212,6 @@ test_label_new (const char *text,
return label;
}
-static void
-rgba_run_alpha (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n)
-{
- int i;
- int v;
-
- for (i = 0; i < n; i++)
- {
- v = *buf;
- *buf++ = v + (((r - v) * alpha + 0x80) >> 8);
- v = *buf;
- *buf++ = v + (((g - v) * alpha + 0x80) >> 8);
- v = *buf;
- *buf++ = v + (((b - v) * alpha + 0x80) >> 8);
-
- *buf++ = 255;
- }
-}
-
-typedef void (*FillRunCallback) (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n);
-
-/* This function is totally broken.
- * Amongst other interesting things it will write outside
- * the pixbufs pixels.
- */
-static void
-pixbuf_draw_rectangle (GdkPixbuf *pixbuf,
- const ArtIRect *rectangle,
- guint32 color,
- gboolean filled)
-{
- guchar r;
- guchar g;
- guchar b;
- guchar opacity;
-
- guint width;
- guint height;
- guchar *pixels;
- guint rowstride;
- int y;
- gboolean has_alpha;
- guint pixel_offset;
- guchar *offset;
-
- guint rect_width;
- guint rect_height;
-
- ArtIRect draw_area;
-
- FillRunCallback fill_run_callback;
-
- g_return_if_fail (pixbuf != NULL);
-
- width = gdk_pixbuf_get_width (pixbuf);
- height = gdk_pixbuf_get_height (pixbuf);
- pixels = gdk_pixbuf_get_pixels (pixbuf);
- rowstride = gdk_pixbuf_get_rowstride (pixbuf);
- has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
- pixel_offset = has_alpha ? 4 : 3;
-
- r = NAUTILUS_RGBA_COLOR_GET_R (color);
- g = NAUTILUS_RGBA_COLOR_GET_G (color);
- b = NAUTILUS_RGBA_COLOR_GET_B (color);
- opacity = NAUTILUS_RGBA_COLOR_GET_A (color);
-
- fill_run_callback = has_alpha ? rgba_run_alpha : art_rgb_run_alpha;
-
- if (rectangle != NULL) {
- g_return_if_fail (rectangle->x1 > rectangle->x0);
- g_return_if_fail (rectangle->y1 > rectangle->y0);
-
- rect_width = rectangle->x1 - rectangle->x0;
- rect_height = rectangle->y1 - rectangle->y0;
-
- draw_area = *rectangle;
- }
- else {
- rect_width = width;
- rect_height = height;
-
- draw_area.x0 = 0;
- draw_area.y0 = 0;
- draw_area.x1 = width;
- draw_area.y1 = height;
- }
-
- if (filled) {
- offset = pixels + (draw_area.y0 * rowstride) + (draw_area.x0 * pixel_offset);
-
- for (y = draw_area.y0; y < draw_area.y1; y++) {
- (* fill_run_callback) (offset, r, g, b, opacity, rect_width);
- offset += rowstride;
- }
- }
- else {
- /* top */
- offset = pixels + (draw_area.y0 * rowstride) + (draw_area.x0 * pixel_offset);
- (* fill_run_callback) (offset, r, g, b, opacity, rect_width);
-
- /* bottom */
- offset += ((rect_height - 1) * rowstride);
- (* fill_run_callback) (offset, r, g, b, opacity, rect_width);
-
- for (y = draw_area.y0 + 1; y < (draw_area.y1 - 1); y++) {
- /* left */
- offset = pixels + (y * rowstride) + (draw_area.x0 * pixel_offset);
- (* fill_run_callback) (offset, r, g, b, opacity, 1);
-
- /* right */
- offset += (rect_width - 1) * pixel_offset;
- (* fill_run_callback) (offset, r, g, b, opacity, 1);
- }
- }
-}
-
-void
-test_pixbuf_draw_rectangle (GdkPixbuf *pixbuf,
- int x0,
- int y0,
- int x1,
- int y1,
- int inset,
- gboolean filled,
- guint32 color,
- int opacity)
-{
-
- g_return_if_fail (nautilus_gdk_pixbuf_is_valid (pixbuf));
- g_return_if_fail (opacity > NAUTILUS_OPACITY_FULLY_TRANSPARENT);
- g_return_if_fail (opacity <= NAUTILUS_OPACITY_FULLY_OPAQUE);
-
- color = NAUTILUS_RGBA_COLOR_PACK (NAUTILUS_RGBA_COLOR_GET_R (color),
- NAUTILUS_RGBA_COLOR_GET_G (color),
- NAUTILUS_RGBA_COLOR_GET_B (color),
- opacity);
-
- if (x0 == -1 && y0 == -1 && x1 == -1 && y1 == -1) {
- pixbuf_draw_rectangle (pixbuf, NULL, color, filled);
- } else {
- ArtIRect rect;
-
- g_return_if_fail (x0 >= 0);
- g_return_if_fail (y0 >= 0);
- g_return_if_fail (x1 > x0);
- g_return_if_fail (y1 > y0);
-
- rect.x0 = x0;
- rect.y0 = y0;
- rect.x1 = x1;
- rect.y1 = y1;
-
- rect.x0 += inset;
- rect.y0 += inset;
- rect.x1 -= inset;
- rect.y1 -= inset;
-
- g_return_if_fail (!art_irect_empty (&rect));
-
- pixbuf_draw_rectangle (pixbuf, &rect, color, filled);
- }
-}
-
-void
-test_pixbuf_draw_rectangle_tiled (GdkPixbuf *pixbuf,
- const char *tile_name,
- int x0,
- int y0,
- int x1,
- int y1,
- int opacity)
-{
- ArtIRect area;
- GdkPixbuf *tile_pixbuf;
-
- g_return_if_fail (nautilus_gdk_pixbuf_is_valid (pixbuf));
- g_return_if_fail (tile_name != NULL);
- g_return_if_fail (opacity > NAUTILUS_OPACITY_FULLY_TRANSPARENT);
- g_return_if_fail (opacity <= NAUTILUS_OPACITY_FULLY_OPAQUE);
-
- tile_pixbuf = test_pixbuf_new_named (tile_name, 1.0);
-
- g_return_if_fail (tile_pixbuf != NULL);
-
- if (x0 == -1 && y0 == -1 && x1 == -1 && y1 == -1) {
- area = nautilus_gdk_pixbuf_get_frame (pixbuf);
- } else {
- g_return_if_fail (x0 >= 0);
- g_return_if_fail (y0 >= 0);
- g_return_if_fail (x1 > x0);
- g_return_if_fail (y1 > y0);
-
- area.x0 = x0;
- area.y0 = y0;
- area.x1 = x1;
- area.y1 = y1;
- }
-
- nautilus_gdk_pixbuf_draw_to_pixbuf_tiled (tile_pixbuf,
- pixbuf,
- &area,
- gdk_pixbuf_get_width (tile_pixbuf),
- gdk_pixbuf_get_height (tile_pixbuf),
- x0,
- y0,
- opacity,
- GDK_INTERP_NEAREST);
-
- gdk_pixbuf_unref (tile_pixbuf);
-}
-
/* Preferences hacks */
void
test_text_caption_set_text_for_int_preferences (NautilusTextCaption *text_caption,
@@ -521,3 +310,51 @@ test_window_set_title_with_pid (GtkWindow *window,
gtk_window_set_title (GTK_WINDOW (window), tmp);
g_free (tmp);
}
+
+void
+test_pixbuf_draw_rectangle_tiled (GdkPixbuf *pixbuf,
+ const char *tile_name,
+ int x0,
+ int y0,
+ int x1,
+ int y1,
+ int opacity)
+{
+ ArtIRect area;
+ GdkPixbuf *tile_pixbuf;
+
+ g_return_if_fail (nautilus_gdk_pixbuf_is_valid (pixbuf));
+ g_return_if_fail (tile_name != NULL);
+ g_return_if_fail (opacity > NAUTILUS_OPACITY_FULLY_TRANSPARENT);
+ g_return_if_fail (opacity <= NAUTILUS_OPACITY_FULLY_OPAQUE);
+
+ tile_pixbuf = test_pixbuf_new_named (tile_name, 1.0);
+
+ g_return_if_fail (tile_pixbuf != NULL);
+
+ if (x0 == -1 && y0 == -1 && x1 == -1 && y1 == -1) {
+ area = nautilus_gdk_pixbuf_get_frame (pixbuf);
+ } else {
+ g_return_if_fail (x0 >= 0);
+ g_return_if_fail (y0 >= 0);
+ g_return_if_fail (x1 > x0);
+ g_return_if_fail (y1 > y0);
+
+ area.x0 = x0;
+ area.y0 = y0;
+ area.x1 = x1;
+ area.y1 = y1;
+ }
+
+ nautilus_gdk_pixbuf_draw_to_pixbuf_tiled (tile_pixbuf,
+ pixbuf,
+ &area,
+ gdk_pixbuf_get_width (tile_pixbuf),
+ gdk_pixbuf_get_height (tile_pixbuf),
+ x0,
+ y0,
+ opacity,
+ GDK_INTERP_NEAREST);
+
+ gdk_pixbuf_unref (tile_pixbuf);
+}