diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2017-04-12 12:39:09 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2017-04-12 12:39:09 +0200 |
commit | 8e4aa8e602b7400c9a9edafbfc9c966bd85ec92c (patch) | |
tree | e69a28d0e7baece34413e7feb0b2319be44184c4 | |
parent | f4622608baf58fed2d7d2b6cf2326b595c906d0d (diff) | |
download | drminfo-8e4aa8e602b7400c9a9edafbfc9c966bd85ec92c.tar.gz |
info tweaks
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | drmtest.c | 7 | ||||
-rw-r--r-- | gtktest.c | 5 | ||||
-rw-r--r-- | render.c | 23 | ||||
-rw-r--r-- | render.h | 2 |
5 files changed, 26 insertions, 13 deletions
@@ -17,7 +17,7 @@ all: $(TARGETS) clean: rm -f $(TARGETS) - rm -f *~ + rm -f *~ *.o drminfo: drminfo.o drmtools.o drmtest: drmtest.o drmtools.o render.o @@ -211,10 +211,15 @@ static void drm_init_dumb_fb(void) static void drm_draw_dumb_fb(void) { + char name[64]; + char info[80]; cairo_t *cr; + drm_conn_name(conn, name, sizeof(name)); + snprintf(info, sizeof(info), "%s: %dx%d", + name, mode->hdisplay, mode->vdisplay); cr = cairo_create(cs); - render_test(cr, mode->hdisplay, mode->vdisplay); + render_test(cr, mode->hdisplay, mode->vdisplay, info); cairo_destroy(cr); drmModeDirtyFB(fd, fb_id, 0, 0); } @@ -6,11 +6,14 @@ static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr, gpointer user_data) { + char info[80]; int width, height; width = gtk_widget_get_allocated_width(widget); height = gtk_widget_get_allocated_height(widget); - render_test(cr, width, height); + snprintf(info, sizeof(info), "gtktest: %dx%d", + width, height); + render_test(cr, width, height, info); return FALSE; } @@ -1,5 +1,7 @@ #include <cairo.h> +#include "render.h" + static int pad = 10; static void render_color_bar(cairo_t *cr, int x, int y, int w, int h, @@ -26,11 +28,11 @@ static void render_color_bar(cairo_t *cr, int x, int y, int w, int h, cairo_show_text(cr, name); } -void render_test(cairo_t *cr, int width, int height) +void render_test(cairo_t *cr, int width, int height, const char *info) { int bar = 100; - while (6 * bar + 2 * pad > height && + while (7 * bar + 2 * pad > height && bar > 4 * pad) bar -= 10; @@ -40,15 +42,18 @@ void render_test(cairo_t *cr, int width, int height) cairo_set_line_width (cr, 1); cairo_set_source_rgb (cr, 1, 1, 1); - cairo_rectangle (cr, pad - 0.5, pad - 0.5, width - 2*pad + 1, 6*bar + 1); + cairo_rectangle (cr, pad - 0.5, pad - 0.5, width - 2*pad + 1, 7*bar + 1); cairo_stroke (cr); - render_color_bar(cr, pad, bar * 0 + pad, width - 2*pad, bar, 1, 0, 0, "red"); - render_color_bar(cr, pad, bar * 1 + pad, width - 2*pad, bar, 1, 1, 0, "yellow"); - render_color_bar(cr, pad, bar * 2 + pad, width - 2*pad, bar, 0, 1, 0, "green"); - render_color_bar(cr, pad, bar * 3 + pad, width - 2*pad, bar, 0, 1, 1, "cyan"); - render_color_bar(cr, pad, bar * 4 + pad, width - 2*pad, bar, 0, 0, 1, "blue"); - render_color_bar(cr, pad, bar * 5 + pad, width - 2*pad, bar, 1, 0, 1, "magenta"); + render_color_bar(cr, pad, bar * 0 + pad, width - 2*pad, bar, + 0.8, 0.8, 0.8, info); + + render_color_bar(cr, pad, bar * 1 + pad, width - 2*pad, bar, 1, 0, 0, "red"); + render_color_bar(cr, pad, bar * 2 + pad, width - 2*pad, bar, 1, 1, 0, "yellow"); + render_color_bar(cr, pad, bar * 3 + pad, width - 2*pad, bar, 0, 1, 0, "green"); + render_color_bar(cr, pad, bar * 4 + pad, width - 2*pad, bar, 0, 1, 1, "cyan"); + render_color_bar(cr, pad, bar * 5 + pad, width - 2*pad, bar, 0, 0, 1, "blue"); + render_color_bar(cr, pad, bar * 6 + pad, width - 2*pad, bar, 1, 0, 1, "magenta"); } @@ -1 +1 @@ -void render_test(cairo_t *cr, int width, int height); +void render_test(cairo_t *cr, int width, int height, const char *info); |