From nobody Wed Nov 5 15:40:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1497429803595228.85280087961883; Wed, 14 Jun 2017 01:43:23 -0700 (PDT) Received: from localhost ([::1]:47225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL3tZ-00024W-Ra for importer@patchew.org; Wed, 14 Jun 2017 04:43:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL3sA-0000cA-UX for qemu-devel@nongnu.org; Wed, 14 Jun 2017 04:41:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dL3s7-0007bD-J2 for qemu-devel@nongnu.org; Wed, 14 Jun 2017 04:41:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44722) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dL3s7-0007at-A2 for qemu-devel@nongnu.org; Wed, 14 Jun 2017 04:41:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D2D14E4CA; Wed, 14 Jun 2017 08:41:50 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 827A28972F; Wed, 14 Jun 2017 08:41:47 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EA1E616E33; Wed, 14 Jun 2017 10:41:49 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4D2D14E4CA Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4D2D14E4CA From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 14 Jun 2017 10:41:47 +0200 Message-Id: <20170614084149.31314-3-kraxel@redhat.com> In-Reply-To: <20170614084149.31314-1-kraxel@redhat.com> References: <20170614084149.31314-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 14 Jun 2017 08:41:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/4] egl-headless: use framebuffer helper functions. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Gerd Hoffmann --- ui/egl-headless.c | 67 ++++++++++++++-------------------------------------= ---- 1 file changed, 17 insertions(+), 50 deletions(-) diff --git a/ui/egl-headless.c b/ui/egl-headless.c index d8d800f8a6..809bfde99c 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -8,14 +8,13 @@ typedef struct egl_dpy { DisplayChangeListener dcl; DisplaySurface *ds; - int width, height; - GLuint texture; - GLuint framebuffer; - GLuint blit_texture; - GLuint blit_framebuffer; + egl_fb guest_fb; + egl_fb blit_fb; bool y_0_top; } egl_dpy; =20 +/* ------------------------------------------------------------------ */ + static void egl_refresh(DisplayChangeListener *dcl) { graphic_hw_update(dcl->con); @@ -38,8 +37,8 @@ static void egl_scanout_disable(DisplayChangeListener *dc= l) { egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); =20 - edpy->texture =3D 0; - /* XXX: delete framebuffers here ??? */ + egl_fb_destroy(&edpy->guest_fb); + egl_fb_destroy(&edpy->blit_fb); } =20 static void egl_scanout_texture(DisplayChangeListener *dcl, @@ -52,34 +51,17 @@ static void egl_scanout_texture(DisplayChangeListener *= dcl, { egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); =20 - edpy->texture =3D backing_id; edpy->y_0_top =3D backing_y_0_top; =20 /* source framebuffer */ - if (!edpy->framebuffer) { - glGenFramebuffers(1, &edpy->framebuffer); - } - glBindFramebuffer(GL_FRAMEBUFFER_EXT, edpy->framebuffer); - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, edpy->texture, 0); + egl_fb_create_for_tex(&edpy->guest_fb, + backing_width, backing_height, backing_id); =20 /* dest framebuffer */ - if (!edpy->blit_framebuffer) { - glGenFramebuffers(1, &edpy->blit_framebuffer); - glGenTextures(1, &edpy->blit_texture); - edpy->width =3D 0; - edpy->height =3D 0; - } - if (edpy->width !=3D backing_width || edpy->height !=3D backing_height= ) { - edpy->width =3D backing_width; - edpy->height =3D backing_height; - glBindTexture(GL_TEXTURE_2D, edpy->blit_texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, - edpy->width, edpy->height, - 0, GL_BGRA, GL_UNSIGNED_BYTE, 0); - glBindFramebuffer(GL_FRAMEBUFFER_EXT, edpy->blit_framebuffer); - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0= _EXT, - GL_TEXTURE_2D, edpy->blit_texture, 0); + if (edpy->blit_fb.width !=3D backing_width || + edpy->blit_fb.height !=3D backing_height) { + egl_fb_destroy(&edpy->blit_fb); + egl_fb_create_new_tex(&edpy->blit_fb, backing_width, backing_heigh= t); } } =20 @@ -88,32 +70,17 @@ static void egl_scanout_flush(DisplayChangeListener *dc= l, uint32_t w, uint32_t h) { egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); - GLuint y1, y2; =20 - if (!edpy->texture || !edpy->ds) { + if (!edpy->guest_fb.texture || !edpy->ds) { return; } - assert(surface_width(edpy->ds) =3D=3D edpy->width); - assert(surface_height(edpy->ds) =3D=3D edpy->height); + assert(surface_width(edpy->ds) =3D=3D edpy->guest_fb.width); + assert(surface_height(edpy->ds) =3D=3D edpy->guest_fb.height); assert(surface_format(edpy->ds) =3D=3D PIXMAN_x8r8g8b8); =20 - /* blit framebuffer, flip if needed */ - glBindFramebuffer(GL_READ_FRAMEBUFFER, edpy->framebuffer); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, edpy->blit_framebuffer); - glViewport(0, 0, edpy->width, edpy->height); - y1 =3D edpy->y_0_top ? edpy->height : 0; - y2 =3D edpy->y_0_top ? 0 : edpy->height; - glBlitFramebuffer(0, y1, edpy->width, y2, - 0, 0, edpy->width, edpy->height, - GL_COLOR_BUFFER_BIT, GL_NEAREST); + egl_fb_blit(&edpy->blit_fb, &edpy->guest_fb, edpy->y_0_top); + egl_fb_read(surface_data(edpy->ds), &edpy->blit_fb); =20 - /* read pixels to surface */ - glBindFramebuffer(GL_READ_FRAMEBUFFER, edpy->blit_framebuffer); - glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); - glReadPixels(0, 0, edpy->width, edpy->height, - GL_BGRA, GL_UNSIGNED_BYTE, surface_data(edpy->ds)); - - /* notify about updates */ dpy_gfx_update(edpy->dcl.con, x, y, w, h); } =20 --=20 2.9.3