summaryrefslogtreecommitdiff
path: root/atari/browser.c
diff options
context:
space:
mode:
authorOle Loots <ole@monochrom.net>2011-05-09 22:10:02 +0000
committerOle Loots <ole@monochrom.net>2011-05-09 22:10:02 +0000
commit3276ce5db94774c1afa3e6683f706023551a2dd8 (patch)
treef0af06355d5faaa7be19669b3a9bd43a1df08c00 /atari/browser.c
parent2f40a85b67a8257d991e2538f568ba8b41d9e175 (diff)
downloadnetsurf-3276ce5db94774c1afa3e6683f706023551a2dd8.tar.gz
netsurf-3276ce5db94774c1afa3e6683f706023551a2dd8.tar.bz2
rearranged includes, seperate redraw request areas.
svn path=/trunk/netsurf/; revision=12359
Diffstat (limited to 'atari/browser.c')
-rwxr-xr-xatari/browser.c179
1 files changed, 103 insertions, 76 deletions
diff --git a/atari/browser.c b/atari/browser.c
index fd858c045..e107b88cd 100755
--- a/atari/browser.c
+++ b/atari/browser.c
@@ -87,7 +87,7 @@ struct s_browser * browser_create( struct gui_window * gw,
bw->scale = clone->scale;
else
bw->scale = 1;
-
+ bnew->redraw.areas_used = 0;
bnew->compwin = mt_WindCreate( &app, VSLIDE|HSLIDE, 1, 1, app.w, app.h);
bnew->compwin->w_u = 1;
bnew->compwin->h_u = 1;
@@ -181,21 +181,10 @@ bool browser_attach_frame( struct gui_window * container, struct gui_window * fr
container->browser->compwin->w_max = 0;
container->browser->comp->flex = 0;
container->browser->comp->size = 300;
- //container->browser->comp->bounds.max_height = 0;
- //container->browser->comp->bounds.min_height = 0;
- //WindClose( container->browser->compwin );
-
container->browser->comp->type = lt;
mt_CompAttach( &app, container->browser->comp, frame->browser->comp );
- //win_comp_attach(&app, container->browser->compwin, frame->browser->comp);
browser_update_rects( container );
- frame->browser->attached = true;
- //container->browser->attached = true;
- /*browser_update_rects( frame );
- LGRECT brect;
- browser_get_rect( frame, BR_CONTENT, &brect );
- */
-
+ frame->browser->attached = true;
}
/* find the root of an frame ( or just return gw if is already the root) */
@@ -806,20 +795,17 @@ bool browser_redraw_required( struct gui_window * gw)
}
}
}
- ret = ( (b->redraw.required && frames == 0) ||
- b->scroll.required ||
- b->caret.redraw );
+ ret = ( ((b->redraw.areas_used > 0) && frames == 0)
+ || b->scroll.required
+ || b->caret.redraw );
return( ret );
}
/* schedule a redraw of content */
/* coords are relative to the framebuffer */
-/* the box is modified to fit the current viewport if it doesn't fit in */
void browser_schedule_redraw_rect(struct gui_window * gw, short x, short y, short w, short h)
{
- int diff;
-
if( x < 0 ){
w += x;
x = 0;
@@ -832,17 +818,32 @@ void browser_schedule_redraw_rect(struct gui_window * gw, short x, short y, shor
browser_schedule_redraw( gw, x, y, x+w, y+h );
}
-/* schedule a redraw of content */
-/* coords are relative to the framebuffer */
+static inline bool bbox_intersect(BBOX * box1, BBOX * box2)
+{
+ if (box2->x1 < box1->x0)
+ return false;
+
+ if (box2->y1 < box1->y0)
+ return false;
+
+ if (box2->x0 > box1->x1)
+ return false;
+
+ if (box2->y0 > box1->y1)
+ return false;
+
+ return true;
+}
+
+/*
+ schedule a redraw of content, coords are relative to the framebuffer
+*/
void browser_schedule_redraw(struct gui_window * gw, short x0, short y0, short x1, short y1)
{
assert( gw != NULL );
CMP_BROWSER b = gw->browser;
+ int i;
LGRECT work;
- /* TODO: add rectangle to list, instead of summarizing the rect.? */
- /* otherwise it can result in large areas, altough it isnt needed. ( like 1 px in the upper left,
- and 1px in bottom right corner )
- */
if( y1 < 0 || x1 < 0 )
return;
@@ -853,53 +854,65 @@ void browser_schedule_redraw(struct gui_window * gw, short x0, short y0, short x
if( y0 > work.g_h )
return;
- /* special handling of initial call: */
- if( b->redraw.required == false ) {
- b->redraw.required = true;
- b->redraw.area.x0 = x0;
- b->redraw.area.y0 = y0;
- b->redraw.area.x1 = x1;
- b->redraw.area.y1 = y1;
- } else {
- b->redraw.area.x0 = MIN(b->redraw.area.x0, x0);
- b->redraw.area.y0 = MIN(b->redraw.area.y0, y0);
- b->redraw.area.x1 = MAX(b->redraw.area.x1, x1);
- b->redraw.area.y1 = MAX(b->redraw.area.y1, y1);
+ for( i=0; i<b->redraw.areas_used; i++) {
+ if( b->redraw.areas[i].x0 <= x0
+ && b->redraw.areas[i].x1 >= x1
+ && b->redraw.areas[i].y0 <= y0
+ && b->redraw.areas[i].y1 >= y1 ){
+ /* the area is already queued for redraw */
+ return;
+ } else {
+ BBOX area;
+ area.x0 = x0;
+ area.y0 = y0;
+ area.x1 = x1;
+ area.y1 = y1;
+ if( bbox_intersect(&b->redraw.areas[i], &area ) ){
+ b->redraw.areas[i].x0 = MIN(b->redraw.areas[i].x0, x0);
+ b->redraw.areas[i].y0 = MIN(b->redraw.areas[i].y0, y0);
+ b->redraw.areas[i].x1 = MAX(b->redraw.areas[i].x1, x1);
+ b->redraw.areas[i].y1 = MAX(b->redraw.areas[i].y1, y1);
+ return;
+ }
+ }
}
+
+ if( b->redraw.areas_used < MAX_REDRW_SLOTS ) {
+ b->redraw.areas[b->redraw.areas_used].x0 = x0;
+ b->redraw.areas[b->redraw.areas_used].x1 = x1;
+ b->redraw.areas[b->redraw.areas_used].y0 = y0;
+ b->redraw.areas[b->redraw.areas_used].y1 = y1;
+ b->redraw.areas_used++;
+ } else {
+ /*
+ we are out of available slots, merge box with last slot
+ this is dumb... but also a very rare case.
+ */
+ b->redraw.areas[MAX_REDRW_SLOTS-1].x0 = MIN(b->redraw.areas[i].x0, x0);
+ b->redraw.areas[MAX_REDRW_SLOTS-1].y0 = MIN(b->redraw.areas[i].y0, y0);
+ b->redraw.areas[MAX_REDRW_SLOTS-1].x1 = MAX(b->redraw.areas[i].x1, x1);
+ b->redraw.areas[MAX_REDRW_SLOTS-1].y1 = MAX(b->redraw.areas[i].y1, y1);
+ }
+done:
+ return;
}
static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff )
{
LGRECT work;
CMP_BROWSER b = gw->browser;
- GRECT area;
struct rect clip;
LOG(("%s : %d,%d - %d,%d\n", b->bw->name, b->redraw.area.x0,
b->redraw.area.y0, b->redraw.area.x1, b->redraw.area.y1
));
- area.g_x = b->redraw.area.x0;
- area.g_y = b->redraw.area.y0;
- area.g_w = b->redraw.area.x1 - b->redraw.area.x0;
- area.g_h = b->redraw.area.y1 - b->redraw.area.y0;
current_redraw_browser = b->bw;
- clip.x0 = b->redraw.area.x0;
- clip.y0 = b->redraw.area.y0;
- clip.x1 = b->redraw.area.x1;
- clip.y1 = b->redraw.area.y1;
-
browser_window_redraw( b->bw, -b->scroll.current.x,
- -b->scroll.current.y, &clip );
+ -b->scroll.current.y, &b->redraw.area );
current_redraw_browser = NULL;
-
- /* reset redraw area */
- b->redraw.area.x0 = INT_MAX;
- b->redraw.area.y0 = INT_MAX;
- b->redraw.area.x1 = INT_MIN;
- b->redraw.area.y1 = INT_MIN;
}
@@ -961,41 +974,55 @@ void browser_redraw( struct gui_window * gw )
b->scroll.required = false;
}
- if (b->redraw.required == true && b->bw->current_content != NULL ) {
+ if ((b->redraw.areas_used > 0) && b->bw->current_content != NULL ) {
if( (plotter->flags & PLOT_FLAG_OFFSCREEN) == 0 ) {
+ int i;
GRECT area;
+ GRECT fbwork;
BBOX cliporg;
todo[0] = bwrect.g_x;
todo[1] = bwrect.g_y;
todo[2] = todo[0] + bwrect.g_w-1;
todo[3] = todo[1] + bwrect.g_h-1;
vs_clip(plotter->vdi_handle, 1, (short*)&todo[0]);
-
- area.g_x = b->redraw.area.x0;
- area.g_y = b->redraw.area.y0;
- area.g_w = b->redraw.area.x1 - b->redraw.area.x0;
- area.g_h = b->redraw.area.y1 - b->redraw.area.y0;
if( wind_get(gw->root->handle->handle, WF_FIRSTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
while (todo[2] && todo[3]) {
/* convert screen to framebuffer coords: */
- todo[0] -= bwrect.g_x;
- todo[1] -= bwrect.g_y;
- if( todo[0] < 0 ){
- todo[2] = todo[2] + todo[0];
- todo[0] = 0;
+ fbwork.g_x = todo[0] - bwrect.g_x;
+ fbwork.g_y = todo[1] - bwrect.g_y;
+ if( fbwork.g_x < 0 ){
+ fbwork.g_w = todo[2] + todo[0];
+ fbwork.g_x = 0;
+ } else {
+ fbwork.g_w = todo[2];
}
- if( todo[1] < 0 ){
- todo[3] = todo[3] + todo[1];
- todo[1] = 0;
+ if( fbwork.g_y < 0 ){
+ fbwork.g_h = todo[3] + todo[1];
+ fbwork.g_y = 0;
+ } else {
+ fbwork.g_h = todo[3];
}
-
- if (rc_intersect((GRECT *)&area,(GRECT *)&todo)) {
- b->redraw.area.x0 = todo[0];
- b->redraw.area.y0 = todo[1];
- b->redraw.area.x1 = b->redraw.area.x0 + todo[2];
- b->redraw.area.y1 = b->redraw.area.y0 + todo[3];
- browser_redraw_content( gw, 0, 0 );
+ /* walk the redraw requests: */
+ for( i=0; i<b->redraw.areas_used; i++ ){
+ area.g_x = b->redraw.areas[i].x0;
+ area.g_y = b->redraw.areas[i].y0;
+ area.g_w = b->redraw.areas[i].x1 - b->redraw.areas[i].x0;
+ area.g_h = b->redraw.areas[i].y1 - b->redraw.areas[i].y0;
+ if (rc_intersect((GRECT *)&fbwork,(GRECT *)&area)) {
+
+ b->redraw.area.x0 = area.g_x; //todo[0];
+ b->redraw.area.y0 = area.g_y; //todo[1];
+ b->redraw.area.x1 = area.g_x + area.g_w; //todo[0] + todo[2];
+ b->redraw.area.y1 = area.g_y + area.g_h; //todo[1] + todo[3];
+ browser_redraw_content( gw, 0, 0 );
+ } else {
+ /*
+ the area should be kept scheduled for later redraw, but because this
+ is onscreen plotter, it doesn't make much sense anyway...
+ */
+ }
+
}
if (wind_get(gw->root->handle->handle, WF_NEXTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3])==0) {
@@ -1007,7 +1034,7 @@ void browser_redraw( struct gui_window * gw )
} else {
/* its save to do a complete redraw :) */
}
- b->redraw.required = false;
+ b->redraw.areas_used = 0;
}
if( b->caret.redraw == true && b->bw->current_content != NULL ) {
GRECT area;