aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2017-04-12 12:59:18 +0200
committerGerd Hoffmann <kraxel@redhat.com>2017-04-12 12:59:18 +0200
commit0f6e0fd61163a48eb2aa2cd4109bb8773fc9a6af (patch)
treea016ed97f83654138cee4bac7a2e4f0d5039b572
parent9100b0dd30e511a64d60d1e004b70ba7b18b6571 (diff)
downloaddrminfo-0f6e0fd61163a48eb2aa2cd4109bb8773fc9a6af.tar.gz
egl rendering
-rw-r--r--drmtest.c36
-rw-r--r--render.c1
2 files changed, 23 insertions, 14 deletions
diff --git a/drmtest.c b/drmtest.c
index 95cb9f1..bbe733f 100644
--- a/drmtest.c
+++ b/drmtest.c
@@ -47,6 +47,7 @@ static EGLContext ctx;
static EGLSurface surface;
/* cairo */
+cairo_device_t *cd;
cairo_surface_t *cs;
cairo_t *cc;
@@ -164,6 +165,20 @@ static void drm_show_fb(void)
}
}
+static void drm_draw(const char *text)
+{
+ char name[64];
+ char info[80];
+ cairo_t *cr;
+
+ drm_conn_name(conn, name, sizeof(name));
+ snprintf(info, sizeof(info), "%s: %dx%d, %s",
+ name, mode->hdisplay, mode->vdisplay, text);
+ cr = cairo_create(cs);
+ render_test(cr, mode->hdisplay, mode->vdisplay, info);
+ cairo_destroy(cr);
+}
+
/* ------------------------------------------------------------------ */
static void drm_init_dumb_fb(void)
@@ -211,16 +226,7 @@ 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, info);
- cairo_destroy(cr);
+ drm_draw("dumb");
drmModeDirtyFB(fd, fb_id, 0, 0);
}
@@ -309,13 +315,17 @@ static void drm_init_egl(void)
fprintf(stderr, "egl: eglMakeCurrent(surface) failed\n");
exit(1);
}
+
+ cd = cairo_egl_device_create(dpy, ctx);
+ cs = cairo_gl_surface_create_for_egl(cd, surface,
+ mode->hdisplay,
+ mode->vdisplay);
}
static void drm_draw_egl(void)
{
- glViewport(0, 0, mode->hdisplay, mode->vdisplay);
- glClearColor(0.5, 0, 0, 0); /* red */
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ drm_draw("egl");
+ cairo_gl_surface_swapbuffers(cs);
}
static void drm_make_egl_fb(void)
diff --git a/render.c b/render.c
index 6334138..af40688 100644
--- a/render.c
+++ b/render.c
@@ -47,7 +47,6 @@ void render_test(cairo_t *cr, int width, int height, const char *info)
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");