From: Kyle Nusbaum <knusbaum@sdf.org>
To: ori@eigenstate.org, kokamoto@hera.eonet.ne.jp, 9front@9front.org
Subject: Re: [9front] Netsurf 3.9 for Plan 9 (work in progress)
Date: Tue, 4 Feb 2020 19:20:26 -0600 [thread overview]
Message-ID: <067C80BCA9CD8836F8C8CE520DF82361@sdf.org> (raw)
In-Reply-To: <8D34CD631EB2A3983305713F243B7430@eigenstate.org>
[-- Attachment #1: Type: text/plain, Size: 414 bytes --]
That was a patch for the netsurf subproject, if that wasn't clear.
Here's one for libnsfb that fixes scrolling and allows resizing.
If you see part of the UI disappearing, it's because I added
code that only redraws necessary parts of the window, and
the stdout/stderr flicker causes issues. If you pipe stdout/stderr
somewhere else, everything should look ok.
Try resizing the window and let me know.
-- Kyle
[-- Attachment #2: Type: message/rfc822, Size: 1909 bytes --]
From: ori@eigenstate.org
To: knusbaum@sdf.org, kokamoto@hera.eonet.ne.jp, 9front@9front.org
Subject: Re: [9front] Netsurf 3.9 for Plan 9 (work in progress)
Date: Tue, 4 Feb 2020 15:58:44 -0800
Message-ID: <8D34CD631EB2A3983305713F243B7430@eigenstate.org>
> Yes! I've just applied my changes and have it compiling and loading web pages.
> I've just taken the git/diff and dumped it. (That's attached)
>
> The code still contains debugging fprintf and may contain leaks, etc. It's not done, but it's what I
> have at the moment.
>
> It's kind of a hack, as it hijacks the llcache mechanism, but the higher-level fetcher interface isn't
> really compatible with webfs.
>
> I also have changes that implement correct scrolling and resizing. I'll try to get those into patch
> format when I get a chance. Hopefully some time this week.
Nice! Thanks!
I'll be playing around a bit with this tomorrow. From a quick skim,
it feels too intrusive to upstream, but I think we can use it to
start a discussion on the right way to do things.
But we can definitely commit this, and start using it :)
[-- Attachment #3: disfix.patch --]
[-- Type: text/plain, Size: 8800 bytes --]
--- /mnt/git/branch/heads/visfix/tree/src/surface/plan9.c Wed Jan 29 13:58:39 2020
+++ src/surface/plan9.c Tue Feb 4 19:13:09 2020
@@ -33,6 +33,12 @@
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; /* Used to trigger a resize of the window */
+
+Image *create_draw_image(int width, int height, ulong chan);
/*
* A 'drawstate' contain all information about the
@@ -69,16 +75,26 @@ mssleep(int ms) /* sleep milliseconds *
}
-/* I am not sure if this routine is needed to be implemented.
- * I think it makes a copy of the display if the resolution is
- * changed on the fly. But I am not sure that is even supported
- * in framebuffer mode
+/*
+ * It's not clear that this is any faster than the default implementation.
+ * I don't see any visible performance change when commenting
+ * nsfb->plotter_fns->copy = p9copy; in plan9_set_geometry
*/
-
static bool
p9copy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox)
{
- return true;
+ Point srcpt;
+ srcpt.x=srcbox->x0 + screen->r.min.x;
+ srcpt.y=srcbox->y0 + screen->r.min.y;
+
+ Rectangle dstrect;
+ dstrect.min.x = dstbox->x0 + screen->r.min.x;
+ dstrect.min.y = dstbox->y0 + screen->r.min.y;
+ dstrect.max.x = dstbox->x1 + screen->r.min.x;
+ dstrect.max.y = dstbox->y1 + screen->r.min.y;
+
+ draw(screen, dstrect, screen, nil, srcpt);
+ return true;
}
@@ -86,19 +102,71 @@ static int
plan9_set_geometry(nsfb_t *nsfb, int width, int height,
enum nsfb_format_e format)
{
- //fprintf(stderr, "DBG: plan9_set_geometry(%d,%d) - check p9copy()!\n",
- // width, height);
+ if(!inited) {
+ fprintf(stderr, "INITING display!\n");
+ if (initdraw(0, 0, "netsurf-fb") < 0){
+ fprintf(stderr, "initdraw failed\n");
+ return -1;
+ }
+ inited=true;
+ }
- 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 */
+ nsfb->plotter_fns->copy = p9copy;
+
+ 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->localimage == NULL){
+ fprintf(stderr, "Unable to allocate memory "
+ "for local framebuffer image\n");
+ free(drawstate);
+ return -1;
+ //drawshutdown(); /* to call this? */
+ }
+
+ /* crate a draw image on server side */
+ if(drawstate->srvimage) freeimage(drawstate->srvimage);
+ 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);
+ 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 +175,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,66 +231,12 @@ 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 */
-
+ fprintf(stderr, "Starting INITIALISE\n");
/* 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 */
+ eresized(0);
return 0;
}
@@ -385,6 +396,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 +453,17 @@ 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 */
@@ -590,36 +622,42 @@ redraw_srvimage(drawstate_t *drawstate)
*/
static int
-update_and_redraw_srvimage(drawstate_t *drawstate, Rectangle r,
- int width, int height, int bpp)
+update_and_redraw_srvimage(drawstate_t *drawstate, int x, int y,
+ int width, int height)
{
- copy_image_part(drawstate->updateimage,
- drawstate->localimage + buffer_offset(r.min, width, bpp),
- r, width, bpp);
+ int loaded;
+ Rectangle r;
+ Point pt;
+
+ r.min.x=0;
+ r.min.y=0;
+ r.max.x=gwidth;
+ r.max.y=gheight;
+
+ //fprintf(stderr, "DBG: update_and_redraw_srvimage(x=%d, y=%d "
+ // "w=%d, h=%d)\n", x, y, width, height);
+
+ loaded = loadimage(drawstate->srvimage, r, drawstate->localimage,
+ drawstate->imagebytes);
+
+ r.min.x=screen->r.min.x+x;
+ r.min.y=screen->r.min.y+y;
+ r.max.x=screen->r.min.x+x+width;
+ r.max.y=screen->r.min.y+y+height;
+
+ pt.x = x;
+ pt.y = y;
+ draw(screen, r, drawstate->srvimage, nil, pt);
+ flushimage(display, 1);
- loadimage(drawstate->srvimage, r, drawstate->updateimage,
- rect_bytes(r, bpp));
-
- redraw_srvimage(drawstate);
return 0;
}
static int plan9_update(nsfb_t *nsfb, nsfb_bbox_t *box)
{
drawstate_t *drawstate = nsfb->surface_priv;
- Rectangle r;
-
- r.min.x = box->x0;
- r.min.y = box->y0;
- r.max.x = box->x1;
- r.max.y = box->y1;
-
-// fprintf(stderr, "DBG: %4d KB update (%3d,%3d) to (%3d, %3d)\n",
-// (r.max.x-r.min.x)*(r.max.y-r.min.y)*(nsfb->bpp>>3) >> 10,
-// r.min.x, r.min.y, r.max.x, r.max.y);
-
- update_and_redraw_srvimage(drawstate, r,
- nsfb->width, nsfb->height, nsfb->bpp);
+ update_and_redraw_srvimage(drawstate ,box->x0, box->y0,
+ box->x1 - box->x0, box->y1 - box->y0);
return 0;
}
next prev parent reply other threads:[~2020-02-05 1:20 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
-- 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-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
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=067C80BCA9CD8836F8C8CE520DF82361@sdf.org \
--to=knusbaum@sdf.org \
--cc=9front@9front.org \
--cc=kokamoto@hera.eonet.ne.jp \
--cc=ori@eigenstate.org \
/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).