RISC OS: Unify both browser window redraw call paths.
This commit is contained in:
parent
6f659da675
commit
ce23f500d1
|
@ -1639,6 +1639,57 @@ static void ro_gui_window_close(wimp_w w)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for calls to browser_window_redraw for a wimp_draw rectangle.
|
||||
*
|
||||
* \param[in] gui_win Window to render.
|
||||
* \param[in] wimp_rect The area of gui_win to render into.
|
||||
* \param[in] use_buffer Whether to use buffered rendering.
|
||||
*/
|
||||
static inline void ro_gui_window__redraw_rect(
|
||||
const struct gui_window *gui_win,
|
||||
const wimp_draw *wimp_rect,
|
||||
bool use_buffer)
|
||||
{
|
||||
struct redraw_context ctx = {
|
||||
.interactive = true,
|
||||
.background_images = true,
|
||||
.plot = &ro_plotters
|
||||
};
|
||||
struct rect clip;
|
||||
|
||||
/* OS's redraw request coordinates are in screen coordinates,
|
||||
* with an origin at the bottom left of the screen.
|
||||
* Find the coordinate of the top left of the document in terms
|
||||
* of OS screen coordinates.
|
||||
* NOTE: OS units are 2 per px. */
|
||||
ro_plot_origin_x = wimp_rect->box.x0 - wimp_rect->xscroll;
|
||||
ro_plot_origin_y = wimp_rect->box.y1 - wimp_rect->yscroll;
|
||||
|
||||
/* Adjust clip rect for origin. */
|
||||
ro_plot_clip_rect.x0 = wimp_rect->clip.x0 - ro_plot_origin_x;
|
||||
ro_plot_clip_rect.y0 = ro_plot_origin_y - wimp_rect->clip.y0;
|
||||
ro_plot_clip_rect.x1 = wimp_rect->clip.x1 - ro_plot_origin_x;
|
||||
ro_plot_clip_rect.y1 = ro_plot_origin_y - wimp_rect->clip.y1;
|
||||
|
||||
/* Convert OS redraw rectangle request coordinates into NetSurf
|
||||
* coordinates. NetSurf coordinates have origin at top left of
|
||||
* document and units are in px. */
|
||||
clip.x0 = (ro_plot_clip_rect.x0 ) / 2; /* left */
|
||||
clip.y0 = (ro_plot_clip_rect.y1 ) / 2; /* top */
|
||||
clip.x1 = (ro_plot_clip_rect.x1 + 1) / 2; /* right */
|
||||
clip.y1 = (ro_plot_clip_rect.y0 + 1) / 2; /* bottom */
|
||||
|
||||
if (use_buffer) {
|
||||
ro_gui_buffer_open(wimp_rect);
|
||||
}
|
||||
|
||||
browser_window_redraw(gui_win->bw, 0, 0, &clip, &ctx);
|
||||
|
||||
if (use_buffer) {
|
||||
ro_gui_buffer_close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a Redraw_Window_Request for a browser window.
|
||||
|
@ -1650,11 +1701,6 @@ static void ro_gui_window_redraw(wimp_draw *redraw)
|
|||
osbool more;
|
||||
struct gui_window *g;
|
||||
os_error *error;
|
||||
struct redraw_context ctx = {
|
||||
.interactive = true,
|
||||
.background_images = true,
|
||||
.plot = &ro_plotters
|
||||
};
|
||||
|
||||
g = (struct gui_window *)ro_gui_wimp_event_get_user_data(redraw->w);
|
||||
|
||||
|
@ -1675,37 +1721,8 @@ static void ro_gui_window_redraw(wimp_draw *redraw)
|
|||
return;
|
||||
}
|
||||
while (more) {
|
||||
struct rect clip;
|
||||
|
||||
/* OS's redraw request coordinates are in screen coordinates,
|
||||
* with an origin at the bottom left of the screen.
|
||||
* Find the coordinate of the top left of the document in terms
|
||||
* of OS screen coordinates.
|
||||
* NOTE: OS units are 2 per px. */
|
||||
ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
|
||||
ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;
|
||||
|
||||
/* Adjust clip rect for origin. */
|
||||
ro_plot_clip_rect.x0 = redraw->clip.x0 - ro_plot_origin_x;
|
||||
ro_plot_clip_rect.y0 = ro_plot_origin_y - redraw->clip.y0;
|
||||
ro_plot_clip_rect.x1 = redraw->clip.x1 - ro_plot_origin_x;
|
||||
ro_plot_clip_rect.y1 = ro_plot_origin_y - redraw->clip.y1;
|
||||
|
||||
/* Convert OS redraw rectangle request coordinates into NetSurf
|
||||
* coordinates. NetSurf coordinates have origin at top left of
|
||||
* document and units are in px. */
|
||||
clip.x0 = (ro_plot_clip_rect.x0 ) / 2; /* left */
|
||||
clip.y0 = (ro_plot_clip_rect.y1 ) / 2; /* top */
|
||||
clip.x1 = (ro_plot_clip_rect.x1 + 1) / 2; /* right */
|
||||
clip.y1 = (ro_plot_clip_rect.y0 + 1) / 2; /* bottom */
|
||||
|
||||
if (ro_gui_current_redraw_gui->option.buffer_everything)
|
||||
ro_gui_buffer_open(redraw);
|
||||
|
||||
browser_window_redraw(g->bw, 0, 0, &clip, &ctx);
|
||||
|
||||
if (ro_gui_current_redraw_gui->option.buffer_everything)
|
||||
ro_gui_buffer_close();
|
||||
ro_gui_window__redraw_rect(g, redraw,
|
||||
ro_gui_current_redraw_gui->option.buffer_everything);
|
||||
|
||||
/* Check to see if there are more rectangles to draw and
|
||||
* get next one */
|
||||
|
@ -4676,22 +4693,15 @@ void ro_gui_window_redraw_all(void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* exported interface documented in riscos/window.h */
|
||||
void ro_gui_window_update_boxes(void)
|
||||
{
|
||||
osbool more;
|
||||
bool use_buffer;
|
||||
wimp_draw update;
|
||||
struct rect clip;
|
||||
os_error *error;
|
||||
struct update_box *cur;
|
||||
struct gui_window *g;
|
||||
struct redraw_context ctx = {
|
||||
.interactive = true,
|
||||
.background_images = true,
|
||||
.plot = &ro_plotters
|
||||
};
|
||||
|
||||
for (cur = pending_updates; cur != NULL; cur = cur->next) {
|
||||
g = cur->g;
|
||||
|
@ -4717,31 +4727,8 @@ void ro_gui_window_update_boxes(void)
|
|||
/* Set the current redraw gui_window to get options from */
|
||||
ro_gui_current_redraw_gui = g;
|
||||
|
||||
ro_plot_origin_x = update.box.x0 - update.xscroll;
|
||||
ro_plot_origin_y = update.box.y1 - update.yscroll;
|
||||
|
||||
while (more) {
|
||||
/* Adjust clip rect for origin. */
|
||||
ro_plot_clip_rect.x0 = update.clip.x0 - ro_plot_origin_x;
|
||||
ro_plot_clip_rect.y0 = ro_plot_origin_y - update.clip.y0;
|
||||
ro_plot_clip_rect.x1 = update.clip.x1 - ro_plot_origin_x;
|
||||
ro_plot_clip_rect.y1 = ro_plot_origin_y - update.clip.y1;
|
||||
|
||||
/* Convert OS redraw rectangle request coordinates into
|
||||
* NetSurf coordinates. NetSurf coordinates have origin
|
||||
* at top left of document and units are in px. */
|
||||
clip.x0 = (ro_plot_clip_rect.x0 ) / 2; /* left */
|
||||
clip.y0 = (ro_plot_clip_rect.y1 ) / 2; /* top */
|
||||
clip.x1 = (ro_plot_clip_rect.x1 + 1) / 2; /* right */
|
||||
clip.y1 = (ro_plot_clip_rect.y0 + 1) / 2; /* bottom */
|
||||
|
||||
if (use_buffer)
|
||||
ro_gui_buffer_open(&update);
|
||||
|
||||
browser_window_redraw(g->bw, 0, 0, &clip, &ctx);
|
||||
|
||||
if (use_buffer)
|
||||
ro_gui_buffer_close();
|
||||
ro_gui_window__redraw_rect(g, &update, use_buffer);
|
||||
|
||||
error = xwimp_get_rectangle(&update, &more);
|
||||
/* RISC OS 3.7 returns an error here if enough buffer
|
||||
|
|
Loading…
Reference in New Issue