From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54543) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za19u-0004h8-Bi for qemu-devel@nongnu.org; Thu, 10 Sep 2015 08:41:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Za19s-00048m-Os for qemu-devel@nongnu.org; Thu, 10 Sep 2015 08:40:58 -0400 Received: from mail-ob0-x231.google.com ([2607:f8b0:4003:c01::231]:33173) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za19r-00048H-Ry for qemu-devel@nongnu.org; Thu, 10 Sep 2015 08:40:56 -0400 Received: by obbbh8 with SMTP id bh8so33195101obb.0 for ; Thu, 10 Sep 2015 05:40:54 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1441797654-15350-4-git-send-email-kraxel@redhat.com> References: <1441797654-15350-1-git-send-email-kraxel@redhat.com> <1441797654-15350-4-git-send-email-kraxel@redhat.com> Date: Thu, 10 Sep 2015 14:40:54 +0200 Message-ID: From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 3/9] ui/console: add opengl context and scanout support interfaces. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: QEMU On Wed, Sep 9, 2015 at 1:20 PM, Gerd Hoffmann wrote: > Add callbacks for opengl context management and scanout texture > configuration to DisplayChangeListenerOps. > > Signed-off-by: Gerd Hoffmann > --- > include/ui/console.h | 36 ++++++++++++++++++++++++++++ > ui/console.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++= ++++-- > 2 files changed, 101 insertions(+), 2 deletions(-) > > diff --git a/include/ui/console.h b/include/ui/console.h > index 047a2b4..df92ccd 100644 > --- a/include/ui/console.h > +++ b/include/ui/console.h > @@ -157,6 +157,13 @@ void cursor_set_mono(QEMUCursor *c, > void cursor_get_mono_image(QEMUCursor *c, int foreground, uint8_t *mask)= ; > void cursor_get_mono_mask(QEMUCursor *c, int transparent, uint8_t *mask)= ; > > +typedef void *qemu_gl_context; > + > +struct qemu_gl_params { > + int major_ver; > + int minor_ver; > +}; > + > typedef struct DisplayChangeListenerOps { > const char *dpy_name; > > @@ -183,6 +190,21 @@ typedef struct DisplayChangeListenerOps { > int x, int y, int on); > void (*dpy_cursor_define)(DisplayChangeListener *dcl, > QEMUCursor *cursor); > + > + qemu_gl_context (*dpy_gl_ctx_create)(DisplayChangeListener *dcl, > + struct qemu_gl_params *params); > + void (*dpy_gl_ctx_destroy)(DisplayChangeListener *dcl, > + qemu_gl_context ctx); > + int (*dpy_gl_ctx_make_current)(DisplayChangeListener *dcl, > + qemu_gl_context ctx); > + qemu_gl_context (*dpy_gl_ctx_get_current)(DisplayChangeListener *dcl= ); > + > + void (*dpy_gl_scanout)(DisplayChangeListener *dcl, > + uint32_t backing_id, bool backing_y_0_top, > + uint32_t x, uint32_t y, uint32_t w, uint32_t = h); > + void (*dpy_gl_update)(DisplayChangeListener *dcl, > + uint32_t x, uint32_t y, uint32_t w, uint32_t h= ); > + > } DisplayChangeListenerOps; > > struct DisplayChangeListener { > @@ -244,6 +266,20 @@ bool dpy_cursor_define_supported(QemuConsole *con); > bool dpy_gfx_check_format(QemuConsole *con, > pixman_format_code_t format); > > +void dpy_gl_scanout(QemuConsole *con, > + uint32_t backing_id, bool backing_y_0_top, > + uint32_t x, uint32_t y, uint32_t w, uint32_t h); > +void dpy_gl_update(QemuConsole *con, > + uint32_t x, uint32_t y, uint32_t w, uint32_t h); > + > +qemu_gl_context dpy_gl_ctx_create(QemuConsole *con, > + struct qemu_gl_params *params); > +void dpy_gl_ctx_destroy(QemuConsole *con, qemu_gl_context ctx); > +int dpy_gl_ctx_make_current(QemuConsole *con, qemu_gl_context ctx); > +qemu_gl_context dpy_gl_ctx_get_current(QemuConsole *con); > + > +bool console_has_gl(QemuConsole *con); > + > static inline int surface_stride(DisplaySurface *s) > { > return pixman_image_get_stride(s->image); > diff --git a/ui/console.c b/ui/console.c > index 75fc492..61e45af 100644 > --- a/ui/console.c > +++ b/ui/console.c > @@ -121,6 +121,7 @@ struct QemuConsole { > DisplayState *ds; > DisplaySurface *surface; > int dcls; > + DisplayChangeListener *gl; > > /* Graphic console state. */ > Object *device; > @@ -1332,6 +1333,11 @@ void qemu_free_displaysurface(DisplaySurface *surf= ace) > g_free(surface); > } > > +bool console_has_gl(QemuConsole *con) > +{ > + return con->gl !=3D NULL; > +} > + > void register_displaychangelistener(DisplayChangeListener *dcl) > { > static const char nodev[] =3D > @@ -1339,6 +1345,17 @@ void register_displaychangelistener(DisplayChangeL= istener *dcl) > static DisplaySurface *dummy; > QemuConsole *con; > > + if (dcl->ops->dpy_gl_ctx_create) { > + /* display has opengl support */ > + assert(dcl->con); > + if (dcl->con->gl) { > + fprintf(stderr, "can't register two opengl displays (%s, %s)= \n", > + dcl->ops->dpy_name, dcl->con->gl->ops->dpy_name); > + exit(1); > + } > + dcl->con->gl =3D dcl; > + } > + > trace_displaychangelistener_register(dcl, dcl->ops->dpy_name); > dcl->ds =3D get_alloc_displaystate(); > QLIST_INSERT_HEAD(&dcl->ds->listeners, dcl, next); > @@ -1417,9 +1434,13 @@ void dpy_gfx_update(QemuConsole *con, int x, int y= , int w, int h) > { > DisplayState *s =3D con->ds; > DisplayChangeListener *dcl; > - int width =3D surface_width(con->surface); > - int height =3D surface_height(con->surface); > + int width =3D w; > + int height =3D h; > > + if (con->surface) { > + width =3D surface_width(con->surface); > + height =3D surface_height(con->surface); > + } > x =3D MAX(x, 0); > y =3D MAX(y, 0); > x =3D MIN(x, width); > @@ -1619,6 +1640,48 @@ bool dpy_cursor_define_supported(QemuConsole *con) > return false; > } > > +qemu_gl_context dpy_gl_ctx_create(QemuConsole *con, > + struct qemu_gl_params *qparams) > +{ > + assert(con->gl); > + return con->gl->ops->dpy_gl_ctx_create(con->gl, qparams); > +} > + > +void dpy_gl_ctx_destroy(QemuConsole *con, qemu_gl_context ctx) > +{ > + assert(con->gl); > + con->gl->ops->dpy_gl_ctx_destroy(con->gl, ctx); > +} > + > +int dpy_gl_ctx_make_current(QemuConsole *con, qemu_gl_context ctx) > +{ > + assert(con->gl); > + return con->gl->ops->dpy_gl_ctx_make_current(con->gl, ctx); > +} > + > +qemu_gl_context dpy_gl_ctx_get_current(QemuConsole *con) > +{ > + assert(con->gl); > + return con->gl->ops->dpy_gl_ctx_get_current(con->gl); > +} > + > +void dpy_gl_scanout(QemuConsole *con, > + uint32_t backing_id, bool backing_y_0_top, > + uint32_t x, uint32_t y, uint32_t width, uint32_t hei= ght) > +{ > + assert(con->gl); > + con->gl->ops->dpy_gl_scanout(con->gl, backing_id, > + backing_y_0_top, > + x, y, width, height); > +} > + > +void dpy_gl_update(QemuConsole *con, > + uint32_t x, uint32_t y, uint32_t w, uint32_t h) > +{ > + assert(con->gl); > + con->gl->ops->dpy_gl_update(con->gl, x, y, w, h); > +} > + > /***********************************************************/ > /* register display */ > > -- > 1.8.3.1 > > dpy_gl_scanout() will eventually need to be extended to provide more details, but that can be changed later. Reviewed-by: Marc-Andr=C3=A9 Lureau --=20 Marc-Andr=C3=A9 Lureau