In article
<[email protected]>,
   Chris Young <[email protected]> wrote:

> content_redraw makes me very confused, and there doesn't seem to be
> any documentation on it.  Furthermore, my values always appear to be
> "inverted" compared to eg the RISC OS implementation (the first four
> and the second four coordinates are swapped, otherwise I get no output
> or the wrong output).

I asked jmb, adrianl and joty about it and have come up with:

--------------------------------------------------------------------------

struct os_box {
        int x0;
        int y0;
        int x1;
        iny y1;
};

struct wimp_draw {
        wimp_w w;
        os_box box;
        int xscroll;
        int yscroll;
        os_box clip;
};

os_box box  - The 'visible work area', the portion of window contents
              that's shown.
os_box clip - The region to be redrawn
xscroll     - How far the window is scrolled down
yscroll     - How far the window is scrolled left


  | NOTE: For an os_box:
  |       - (x0, y0) is bottom left
  |       - (x1, y1) is top right
  |       - coordinate origin at bottom left of screen,
  |         +ve y upwards, +ve x right
  |       - units are 2 per px
  |
  |       However in NetSurf:
  |       - (x0, y0) is top left
  |       - (x1, y1) is bottom right
  |       - coordinate origin at top left of page,
  |         +ve y downwards, +ve x right
  |       - units are px


So in riscos/window.c, ro_gui_window_redraw:

        ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
        ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;

Gets the coordinates of the top left of the area of the page/canvas
which is at the top left of the visible area.

        clip_x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2;
        clip_y0 = (ro_plot_origin_y - redraw->clip.y1) / 2;
        clip_x1 = (redraw->clip.x1 - ro_plot_origin_x) / 2;
        clip_y1 = (ro_plot_origin_y - redraw->clip.y0) / 2;

Gets the area of the page/canvas requested for redraw in NetSurf units,
from top left of visible content display area:

    left:   clip_x0
    top:    clip_y0
    right:  clip_x1
    bottom: clip_y1

These are used to call 

        plot.clip(clip_x0, clip_y0, clip_x1, clip_y1);

which sets up the clip rectangle for the plotters, and

        content_redraw(c, 0, 0,
                        c->width * scale, c->height * scale,
                        clip_x0, clip_y0, clip_x1, clip_y1,
                        g->bw->scale,
                        0xFFFFFF);

the arguments to which are:

        c                  content of type CONTENT_HTML
        x                  coordinate for top-left of redraw
        y                  coordinate for top-left of redraw
        width              width
        height             height
        clip_x0            clip rectangle
        clip_y0            clip rectangle
        clip_x1            clip rectangle
        clip_y1            clip rectangle
        scale              scale for redraw
        background_colour  the background colour

The 'while(more)' thing is because the RISC OS Wimp gives one
rectangle at a time to have redrawn and you need to check for more
rectangles until there are none.

--------------------------------------------------------------------------

Does that help at all? Are there other bits which are uninteligable?

Cheers,

Michael

-- 

Michael Drake (tlsa)                  http://www.netsurf-browser.org/


Reply via email to