From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx.sdf.org ([205.166.94.20]) by ewsd; Wed Feb 5 15:44:16 EST 2020 Received: from rustbucket.hsd1.il.comcast.net. (c-98-212-152-230.hsd1.il.comcast.net [98.212.152.230]) (authenticated (0 bits)) by mx.sdf.org (8.15.2/8.14.5) with ESMTPSA id 015KiFcV002111 (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128 bits) verified NO); Wed, 5 Feb 2020 20:44:16 GMT Message-ID: <3B93B5654A0D1D214B677E5BBDB09CBB@sdf.org> To: knusbaum@sdf.org, jamos@oboj.net, 9front@9front.org Subject: Re: [9front] Netsurf 3.9 for Plan 9 (work in progress) From: Kyle Nusbaum Date: Wed, 5 Feb 2020 14:56:03 -0600 In-Reply-To: <7EF13385591728EF7D553997D14B280D@sdf.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-rgaluujjqkcjjwpnoalzlbanpm" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: abstract compliant factory plugin layer This is a multi-part message in MIME format. --upas-rgaluujjqkcjjwpnoalzlbanpm Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Oops. One error in there. This fixes it: --- /mnt/git/branch/heads/disfix2/tree/src/surface/plan9.c Wed Feb 5 14:18:04 2020 +++ src/surface/plan9.c Wed Feb 5 14:51:10 2020 @@ -113,7 +113,7 @@ plan9_set_geometry(nsfb_t *nsfb, int wid /* select default sw plotters for format */ select_plotters(nsfb); - nsfb->plotter_fns->copy = p9copy; /* empty function */ + //nsfb->plotter_fns->copy = p9copy; /* empty function */ drawstate_t *drawstate = nsfb->surface_priv; --upas-rgaluujjqkcjjwpnoalzlbanpm Content-Type: message/rfc822 Content-Disposition: inline Received: from ewsd.inri.net (ewsd.inri.net [107.191.116.128]) by mx.sdf.org (8.15.2/8.14.5) with ESMTP id 015K7lWx022219; Wed, 5 Feb 2020 20:07:48 GMT Received: from mx.sdf.org ([205.166.94.20]) by ewsd; Wed Feb 5 15:05:36 EST 2020 Received: from rustbucket.hsd1.il.comcast.net. (c-98-212-152-230.hsd1.il.comcast.net [98.212.152.230]) (authenticated (0 bits)) by mx.sdf.org (8.15.2/8.14.5) with ESMTPSA id 015K5RKZ013728 (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128 bits) verified NO); Wed, 5 Feb 2020 20:05:28 GMT Message-ID: <7EF13385591728EF7D553997D14B280D@sdf.org> To: jamos@oboj.net, 9front@9front.org CC: knusbaum@sdf.org From: Kyle Nusbaum Date: Wed, 5 Feb 2020 14:17:13 -0600 In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-dvodesmrmnxjhihejqiiutzyyl" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: SSL over ORM standard replication control Subject: Re: [9front] Netsurf 3.9 for Plan 9 (work in progress) Reply-To: 9front@9front.org Precedence: bulk This is a multi-part message in MIME format. --upas-dvodesmrmnxjhihejqiiutzyyl Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Sorry for my previous, hasty patch. On closer inspection, it's not hard to incorporate my changes with yours. Please try out this new patch rather than the old one. It should work much better. --Kyle --upas-dvodesmrmnxjhihejqiiutzyyl Content-Type: message/rfc822 Content-Disposition: inline Received: from ewsd.inri.net (ewsd.inri.net [107.191.116.128]) by mx.sdf.org (8.15.2/8.14.5) with ESMTP id 015IehVG016293; Wed, 5 Feb 2020 18:40:43 GMT Received: from mail.oboj.net ([195.178.185.14]) by ewsd; Wed Feb 5 13:40:22 EST 2020 Received: from localhost (localhost [127.0.0.1]) by mail.oboj.net (Postfix) with ESMTP id CCDDDBF3BC8; Wed, 5 Feb 2020 19:40:14 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail.oboj.net Received: from mail.oboj.net ([127.0.0.1]) by localhost (mail.oboj.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qGw6p6a6hfbF; Wed, 5 Feb 2020 19:40:14 +0100 (CET) Received: from www.oboj.net (unknown [195.178.185.23]) by mail.oboj.net (Postfix) with ESMTP id 5C33FBF3BAD; Wed, 5 Feb 2020 19:40:14 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Date: Wed, 05 Feb 2020 20:40:14 +0200 From: jamos@oboj.net To: 9front@9front.org Cc: knusbaum@sdf.org In-Reply-To: <4C5612D4AF7609010D965A87B085FAA1@sdf.org> References: <4C5612D4AF7609010D965A87B085FAA1@sdf.org> Message-ID: X-Sender: jamos@oboj.net User-Agent: Roundcube Webmail/1.3.4 List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: distributed rich-client-based property just-in-time API callback app Subject: Re: [9front] Netsurf 3.9 for Plan 9 (work in progress) Reply-To: 9front@9front.org Precedence: bulk Content-Transfer-Encoding: 7bit I have now taken a look at your patch. The problem is that you send the whole image to libdraw every time, even if there is only a small update. I did that in an earlier version too, and it was also very slow if running remotely. E.g. only to draw the "back" and "forward" icon generates 2 MB of data each (if window is 800x600). The function copy_image_part() makes a copy of the updated rectangle (of the memory buffer) to another memory buffer, so that loadimage() can be done on a smaller portion of the image. You somehow eliminated the copy_image_part() in your patch, which probably doesn't matter performance wise if run locally, but makes it slower on a LAN and quite much slower on a WAN. I started on some code to also compress the image if it is larger than an certain size, and use cloadimage() for them, but I haven't got around to finish it. I think it would be possible to combine your patch with the earlier copy_image_part() - or something similar, to get both the resizeability and the less network traffic. If the goal is to implement a native frontend for Plan 9, it might not be super important to put too much work optimising the framebuffer driver, but I think the "copy only the updated part" is worth it, and maybe even the compressing part, as most part of a webpage would be quite compressable. Jonas On 2020-02-05 19:44, Kyle Nusbaum wrote: > Thanks, Jonas. > > I wouldn't expect the framebuffer patch to be so much slower, > but hopefully it's a silly mistake or some unnecessary draw calls > that can be eliminated. I'll take another look and see if anything > stands out. > > -- Kyle --upas-dvodesmrmnxjhihejqiiutzyyl Content-Disposition: attachment; filename=disfix2.patch Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit --- /mnt/git/branch/heads/plan9/tree/src/surface/plan9.c Wed Jan 29 13:58:39 2020 +++ src/surface/plan9.c Wed Feb 5 14:13:38 2020 @@ -31,8 +31,15 @@ #include #include -static Image *SrvImage=NULL; /* Global copy of drawstate->srvimg */ - /* that is used by eresized() */ +static bool inited; +static int gwidth; +static int gheight; +static bool perform_resize; + +static unsigned char * +create_local_image(int bytes); +Image * +create_draw_image(int width, int height, ulong chan); /* * A 'drawstate' contain all information about the @@ -86,20 +93,75 @@ static int plan9_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format) { + if(!inited) { + fprintf(stderr, "INITING display!\n"); + if (initdraw(0, 0, "netsurf-fb") < 0){ + fprintf(stderr, "initdraw failed\n"); + return -1; + } + inited=true; + } //fprintf(stderr, "DBG: plan9_set_geometry(%d,%d) - check p9copy()!\n", // width, height); - - if (nsfb->surface_priv != NULL) - return -1; /* if were already initialised fail */ nsfb->width = width; nsfb->height = height; nsfb->format = format; + gwidth=width; + gheight=height; + /* select default sw plotters for format */ select_plotters(nsfb); nsfb->plotter_fns->copy = p9copy; /* empty function */ + drawstate_t *drawstate = nsfb->surface_priv; + + /* sanity check bpp. */ + if ((nsfb->bpp != 32) && (nsfb->bpp != 16) && (nsfb->bpp != 8)) + return -1; + + if (drawstate == NULL) + drawstate = calloc(1, sizeof(drawstate_t)); + if (drawstate == NULL) + return -1; /* no memory */ + + /* create local framebuffer data storage */ + drawstate->imagebytes = + (nsfb->bpp * nsfb->width * nsfb->height) >> 3; + + if(drawstate->localimage) free(drawstate->localimage); + drawstate->localimage = calloc(1, drawstate->imagebytes); //create_local_image(drawstate->imagebytes); + if(drawstate->updateimage) free(drawstate->updateimage); + drawstate->updateimage = calloc(1, drawstate->imagebytes); //create_local_image(drawstate->imagebytes); + + if (drawstate->localimage == NULL || drawstate->updateimage == NULL){ + fprintf(stderr, "Unable to allocate memory " + "for local framebuffer images\n"); + free(drawstate); + return -1; + //drawshutdown(); /* to call this? */ + } + + /* crate a draw image on server side */ + drawstate->srvimage = create_draw_image(nsfb->width, + nsfb->height, XRGB32); + + if (drawstate->srvimage == NULL){ + fprintf(stderr, "Unable to create an image " + "on the display server\n"); + free(drawstate->localimage); + free(drawstate->updateimage); + free(drawstate); + return -1; + //drawshutdown(); /* to call this? */ + } + + /* ensure plotting information is stored */ + nsfb->surface_priv = drawstate; + nsfb->ptr = drawstate->localimage; + nsfb->linelen = (nsfb->width * nsfb->bpp) / 8; + return 0; } @@ -107,12 +169,9 @@ plan9_set_geometry(nsfb_t *nsfb, int wid void eresized(int new) /* callback also called by libdraw */ { + perform_resize=true; if (new && getwindow(display, Refmesg) < 0) fprintf(stderr,"can't reattach to window"); - - if(SrvImage != NULL) - draw(screen, screen->r, SrvImage, nil, ZP); - flushimage(display, 1); } /* create_local_image() @@ -166,65 +225,7 @@ create_draw_image(int width, int height, static int plan9_initialise(nsfb_t *nsfb) { - drawstate_t *drawstate = nsfb->surface_priv; - -// fprintf(stderr, "DBG: plan9_initialise()\n"); - - if (drawstate != NULL) - return -1; /* already initialised */ - - /* sanity check bpp. */ - if ((nsfb->bpp != 32) && (nsfb->bpp != 16) && (nsfb->bpp != 8)) - return -1; - - drawstate = calloc(1, sizeof(drawstate_t)); - if (drawstate == NULL) - return -1; /* no memory */ - - /* initialise the draw graphics in Plan 9 */ - - if (initdraw(0, 0, "netsurf-fb") < 0){ - fprintf(stderr, "initdraw failed\n"); - return -1; - } einit(Emouse|Ekeyboard); - - /* create local framebuffer data storage */ - - drawstate->imagebytes = - (nsfb->bpp * nsfb->width * nsfb->height) >> 3; - - drawstate->localimage = create_local_image(drawstate->imagebytes); - drawstate->updateimage = create_local_image(drawstate->imagebytes); - - if (drawstate->localimage == NULL || drawstate->updateimage == NULL){ - fprintf(stderr, "Unable to allocate memory " - "for local framebuffer images\n"); - free(drawstate); - return -1; - //drawshutdown(); /* to call this? */ - } - - /* crate a draw image on server side */ - drawstate->srvimage = create_draw_image(nsfb->width, - nsfb->height, XRGB32); - SrvImage = drawstate->srvimage; /* global copy for eresized() */ - - if (drawstate->srvimage == NULL){ - fprintf(stderr, "Unable to create an image " - "on the display server\n"); - free(drawstate->localimage); - free(drawstate->updateimage); - free(drawstate); - return -1; - //drawshutdown(); /* to call this? */ - } - - /* ensure plotting information is stored */ - nsfb->surface_priv = drawstate; - nsfb->ptr = drawstate->localimage; - nsfb->linelen = (nsfb->width * nsfb->bpp) / 8; - eresized(0); /* first drawing */ return 0; } @@ -385,6 +386,16 @@ trans_plan9_event(nsfb_t *nsfb, nsfb_eve nsevent->type = NSFB_EVENT_KEY_UP; button_changes++; } + if(evp->mouse.buttons & 8) { + nsevent->value.keycode = NSFB_KEY_MOUSE_4; + nsevent->type = NSFB_EVENT_KEY_DOWN; + button_changes++; + } + if(evp->mouse.buttons & 16) { + nsevent->value.keycode = NSFB_KEY_MOUSE_5; + nsevent->type = NSFB_EVENT_KEY_DOWN; + button_changes++; + } /* save new button status, for next event to compare with */ drawstate->mousebuttons = evp->mouse.buttons; @@ -432,6 +443,16 @@ debug_event(nsfb_event_t *nsevent, Event static bool plan9_input(nsfb_t *nsfb, nsfb_event_t *nsevent, int timeout) { + if(perform_resize) { + perform_resize=false; + int w = screen->r.max.x - screen->r.min.x; + int h = screen->r.max.y - screen->r.min.y; + fprintf(stderr, "RESIZE_EVENT.\n"); + nsevent->type = NSFB_EVENT_RESIZE; + nsevent->value.resize.w = w; + nsevent->value.resize.h = h; + return true; + } drawstate_t *drawstate = nsfb->surface_priv; // static int once = 0; /* ensure etimer() is only called once */ int e; /* type of event */ --upas-dvodesmrmnxjhihejqiiutzyyl-- --upas-rgaluujjqkcjjwpnoalzlbanpm--