diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2017-04-12 12:27:29 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2017-04-12 12:27:29 +0200 |
commit | f4622608baf58fed2d7d2b6cf2326b595c906d0d (patch) | |
tree | 46c426ea5c099939c5d01261d6177f597b514ddc /drmtest.c | |
parent | 5db94c2bb0f900b4e6b4287764f49658535fb9d1 (diff) | |
download | drminfo-f4622608baf58fed2d7d2b6cf2326b595c906d0d.tar.gz |
cairo rendering
Diffstat (limited to 'drmtest.c')
-rw-r--r-- | drmtest.c | 31 |
1 files changed, 19 insertions, 12 deletions
@@ -18,7 +18,11 @@ #include <epoxy/gl.h> #include <epoxy/egl.h> +#include <cairo.h> +#include <cairo-gl.h> + #include "drmtools.h" +#include "render.h" /* ------------------------------------------------------------------ */ @@ -42,6 +46,10 @@ static EGLConfig cfg; static EGLContext ctx; static EGLSurface surface; +/* cairo */ +cairo_surface_t *cs; +cairo_t *cc; + /* ------------------------------------------------------------------ */ static void drm_init_dev(int devnr, const char *output, @@ -193,22 +201,21 @@ static void drm_init_dumb_fb(void) fprintf(stderr, "framebuffer mmap: %s\n", strerror(errno)); exit(1); } + + cs = cairo_image_surface_create_for_data(fbmem, + CAIRO_FORMAT_ARGB32, + creq.width, + creq.height, + creq.pitch); } static void drm_draw_dumb_fb(void) { - int x, y; - uint8_t *ptr; - - for (y = 0; y < creq.height; y++) { - for (x = 0; x < creq.width; x++) { - ptr = fbmem + creq.pitch * y + 4 * x; - ptr[0] = 0; /* blue */ - ptr[1] = x & 0xff; /* green */ - ptr[2] = y & 0xff; /* red */ - ptr[3] = 0; /* alpha */ - } - } + cairo_t *cr; + + cr = cairo_create(cs); + render_test(cr, mode->hdisplay, mode->vdisplay); + cairo_destroy(cr); drmModeDirtyFB(fd, fb_id, 0, 0); } |