From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx.sdf.org ([205.166.94.20]) by ewsd; Tue Feb 4 20:08:53 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 01518gNm001208 (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128 bits) verified NO); Wed, 5 Feb 2020 01:08:43 GMT Message-ID: <067C80BCA9CD8836F8C8CE520DF82361@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) From: Kyle Nusbaum Date: Tue, 4 Feb 2020 19:20:26 -0600 In-Reply-To: <8D34CD631EB2A3983305713F243B7430@eigenstate.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-ngbudqdmxurvhlezyetrxresoa" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: proven scripting rails rich-client strategy-scale hosting enhancement manager This is a multi-part message in MIME format. --upas-ngbudqdmxurvhlezyetrxresoa Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit 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 --upas-ngbudqdmxurvhlezyetrxresoa 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 014Nx1OR016396; Tue, 4 Feb 2020 23:59:01 GMT Received: from mimir.eigenstate.org ([206.124.132.107]) by ewsd; Tue Feb 4 18:58:54 EST 2020 Received: from stockyard.bk.recurse-network.net (gateway.bk.recurse-network.net [185.230.222.2]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id e4556ca5 (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO); Tue, 4 Feb 2020 15:58:46 -0800 (PST) Message-ID: <8D34CD631EB2A3983305713F243B7430@eigenstate.org> To: knusbaum@sdf.org, kokamoto@hera.eonet.ne.jp, 9front@9front.org Date: Tue, 4 Feb 2020 15:58:44 -0800 From: ori@eigenstate.org In-Reply-To: <955870EE382B37038C6DC9E0099709AD@sdf.org> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: stable enhancement general-purpose optimizer Subject: Re: [9front] Netsurf 3.9 for Plan 9 (work in progress) Reply-To: 9front@9front.org Precedence: bulk Content-Transfer-Encoding: 7bit > 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 :) --upas-ngbudqdmxurvhlezyetrxresoa Content-Disposition: attachment; filename=disfix.patch Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit --- /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; } --upas-ngbudqdmxurvhlezyetrxresoa--