From: Kyle Nusbaum <knusbaum@sdf.org>
To: knusbaum@sdf.org, jamos@oboj.net, 9front@9front.org
Subject: Re: [9front] Netsurf 3.9 for Plan 9 (work in progress)
Date: Wed, 5 Feb 2020 14:56:03 -0600 [thread overview]
Message-ID: <3B93B5654A0D1D214B677E5BBDB09CBB@sdf.org> (raw)
In-Reply-To: <7EF13385591728EF7D553997D14B280D@sdf.org>
[-- Attachment #1: Type: text/plain, Size: 474 bytes --]
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;
[-- Attachment #2: Type: message/rfc822, Size: 11126 bytes --]
[-- Attachment #2.1.1: Type: text/plain, Size: 201 bytes --]
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
[-- Attachment #2.1.2: Type: message/rfc822, Size: 3113 bytes --]
From: jamos@oboj.net
To: 9front@9front.org
Cc: knusbaum@sdf.org
Subject: Re: [9front] Netsurf 3.9 for Plan 9 (work in progress)
Date: Wed, 05 Feb 2020 20:40:14 +0200
Message-ID: <fc492aa90120b98cbbc6078bfc440afc@oboj.net>
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
[-- Attachment #2.1.3: disfix2.patch --]
[-- Type: text/plain, Size: 6210 bytes --]
--- /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 <draw.h>
#include <event.h>
-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 */
next prev parent reply other threads:[~2020-02-05 20:56 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-05 2:13 kokamoto
2020-02-05 2:28 ` Kyle Nusbaum
2020-02-05 10:00 ` jamos
2020-02-05 17:44 ` Kyle Nusbaum
2020-02-05 18:40 ` jamos
2020-02-05 18:48 ` Eli Cohen
2020-02-05 19:04 ` Kyle Nusbaum
2020-02-05 19:10 ` ori
2020-02-05 19:06 ` Kyle Nusbaum
2020-02-05 20:17 ` Kyle Nusbaum
2020-02-05 20:56 ` Kyle Nusbaum [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-02-08 0:15 kokamoto
2020-02-08 0:19 ` ori
2020-02-07 3:12 kokamoto
2020-02-06 0:08 kokamoto
2020-02-06 0:24 ` Kyle Nusbaum
2020-02-06 11:26 ` jamos
2020-02-06 14:42 ` hiro
2020-02-07 12:04 ` Steve Simon
2020-02-05 6:44 kokamoto
2020-02-05 3:25 kokamoto
2020-02-05 3:10 kokamoto
2020-02-04 23:40 kokamoto
2020-02-04 23:57 ` Kyle Nusbaum
2020-02-04 23:58 ` ori
2020-02-05 1:20 ` Kyle Nusbaum
2020-02-06 7:04 ` ori
2020-02-06 8:16 ` hiro
2020-02-06 10:10 ` Steve Simon
2020-02-06 15:29 ` ori
2020-02-03 2:08 kokamoto
2020-02-03 3:03 ` ori
2020-02-03 3:16 ` Kurt H Maier
2020-02-01 23:46 kokamoto
2020-02-02 15:24 ` jamos
2020-02-03 1:31 ` ori
2020-02-03 5:54 ` telephil9
2020-02-03 5:58 ` telephil9
2020-01-31 10:38 kokamoto
2020-01-31 16:34 ` ori
2020-01-01 22:02 jamos
2020-01-01 22:57 ` [9front] " ori
2020-01-02 0:59 ` jamos
2020-01-02 16:45 ` ori
2020-01-03 3:12 ` Kyle Nusbaum
2020-01-03 3:30 ` ori
2020-01-03 20:14 ` Kyle Nusbaum
2020-01-03 21:01 ` ori
2020-01-03 21:35 ` Kyle Nusbaum
2020-01-04 0:22 ` hiro
2020-01-04 10:21 ` Steve Simon
2020-01-04 12:08 ` jamos
2020-01-04 17:14 ` ori
2020-01-04 21:33 ` jamos
2020-01-08 4:23 ` Kyle Nusbaum
2020-01-08 4:25 ` Kyle Nusbaum
2020-01-24 8:09 ` Eli Cohen
2020-01-24 10:09 ` hiro
2020-01-24 18:16 ` Kyle Nusbaum
2020-01-24 18:40 ` jamos
2020-01-25 15:11 ` Eli Cohen
2020-01-26 21:10 ` jamos
2020-01-29 20:42 ` Ori Bernstein
2020-02-03 16:00 ` ori
2020-02-04 20:19 ` Kyle Nusbaum
2020-02-04 20:11 ` ori
2020-02-04 20:29 ` Kyle Nusbaum
2020-01-03 10:39 ` telephil9
2020-01-03 10:44 ` telephil9
2020-01-03 15:07 ` ori
2020-01-03 15:14 ` telephil9
2020-01-03 11:55 ` Steve Simon
2020-01-03 15:08 ` telephil9
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3B93B5654A0D1D214B677E5BBDB09CBB@sdf.org \
--to=knusbaum@sdf.org \
--cc=9front@9front.org \
--cc=jamos@oboj.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).