[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] NetSurf menu redraw / was: Menu redraw



2013/4/14 Jo Even Skarstein <joska@online.no>
This is not obvious at all. There could perfectly well be just one
rectangle in the rectangle list even if the first rectangle is different
from the dirty rectangle. The only case where the dirty rectangle and
the first rectangle in the list is identical is when an area completely
within the window's work area is uncovered (e.g. by closing a dialog or
a window).

Ok, my example was probably a bit ambiguous. Watch my old Conholio code below.

> 3b. redraw without using rectangle list (since there are no more
> entries anyway)

I don't think this optimisation can be measured. Yes, you save one call
to wind_get(), but at the cost of comparing two rectangles and also
complicating the code a bit.

It's a minor optimization, and we're talking 1 extra if-construct around a very simple redraw loop, not a distributed continuum transfunctioner.
 
Normally you would do something like...

GRECT r;

wind_get(handle, WF_FIRSTXYWH, &r.x, &r.y, &r.w, &r.h);
while (r.w && r.h)
{
        if (intersect(dirty, &r))
        {
                redraw(r);
        }

        wind_get(handle, WF_NEXTXYWH, &r.x, &r.y, &r.w, &r.h);
}

Now the following code is taken out of context, but it is what I did in Conholio.

  GRECT tmp;
wind_get_grect(w->handle, WF_FIRSTXYWH, &tmp);

if(rc_equal(dirty, &tmp))
{
(*w->redraw)(w->content, dirty);
}
else
{
while(tmp.g_w && tmp.g_h)
{
if(rc_intersect(dirty, &tmp))
(*w->redraw)(w->content, &tmp);
wind_get_grect(w->handle, WF_NEXTXYWH, &tmp);
}
}

It seems to match your second example, more or less. Can't see anything obviously wrong with it, but feel free to shoot some mind bullets on it, because - who knows - it might be used again.

It's probably a tiny bit faster, but not in real life because it only
affects single redraws like closing a dialog that's completely within
the window's work area. It has no effect in situations like dragging a
window across another window.

I've never claimed that this optimization alone makes a noticable difference, but there are applications which does benefit from this, when combined with several other optimizations.
 
-- PeP