[project @ 2004-10-17 21:16:00 by bursa]

Move to use plotters. Replace html.layout->children with html.layout.

svn path=/import/netsurf/; revision=1318
This commit is contained in:
James Bursa 2004-10-17 21:16:00 +00:00
parent ddaf4ab4d7
commit 511d66331f
7 changed files with 82 additions and 72 deletions

View File

@ -39,7 +39,7 @@ struct bitmap *bitmap_create(int width, int height)
osspriteop_area *sprite_area; osspriteop_area *sprite_area;
osspriteop_header *sprite; osspriteop_header *sprite;
if ((width == 0) || (height == 0)) if (width == 0 || height == 0)
return NULL; return NULL;
area_size = 16 + 44 + width * height * 4; area_size = 16 + 44 + width * height * 4;
@ -47,6 +47,10 @@ struct bitmap *bitmap_create(int width, int height)
if (!bitmap) if (!bitmap)
return NULL; return NULL;
bitmap->width = width;
bitmap->height = height;
bitmap->opaque = false;
/* area control block */ /* area control block */
sprite_area = &bitmap->sprite_area; sprite_area = &bitmap->sprite_area;
sprite_area->size = area_size; sprite_area->size = area_size;
@ -150,22 +154,6 @@ void bitmap_destroy(struct bitmap *bitmap)
} }
/**
* Render a bitmap.
*/
bool bitmap_redraw(struct content *c, int x, int y,
int width, int height,
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale, unsigned long background_colour)
{
return image_redraw(&(c->bitmap->sprite_area), x, y, width, height,
c->width * 2, c->height * 2, background_colour,
false, false, ((c->bitmap->opaque) ?
IMAGE_PLOT_TINCT_OPAQUE : IMAGE_PLOT_TINCT_ALPHA));
}
/** /**
* Save a bitmap in the platform's native format. * Save a bitmap in the platform's native format.
* *

View File

@ -11,6 +11,8 @@
struct osspriteop_area; struct osspriteop_area;
struct bitmap { struct bitmap {
int width;
int height;
bool opaque; bool opaque;
osspriteop_area sprite_area; osspriteop_area sprite_area;
}; };

View File

@ -23,6 +23,7 @@
#define THEMES_DIR "<NetSurf$Dir>.Themes" #define THEMES_DIR "<NetSurf$Dir>.Themes"
struct toolbar; struct toolbar;
struct plotter_table;
extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br, extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
dialog_config_prox, dialog_config_th, dialog_zoom, dialog_pageinfo, dialog_config_prox, dialog_config_th, dialog_zoom, dialog_pageinfo,
@ -250,6 +251,12 @@ void ro_gui_print_open(struct gui_window *g, int x, int y, bool sub_menu, bool k
void ro_gui_print_click(wimp_pointer *pointer); void ro_gui_print_click(wimp_pointer *pointer);
bool ro_gui_print_keypress(wimp_key *key); bool ro_gui_print_keypress(wimp_key *key);
/* in plotters.c */
extern const struct plotter_table ro_plotters;
extern int ro_plot_origin_x;
extern int ro_plot_origin_y;
void ro_plot_set_scale(float scale);
/* toolbar types */ /* toolbar types */
#define TOOLBAR_BROWSER 0 #define TOOLBAR_BROWSER 0
#define TOOLBAR_HOTLIST 1 #define TOOLBAR_HOTLIST 1

View File

@ -47,6 +47,10 @@ bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
unsigned long background_colour, unsigned long background_colour,
bool repeatx, bool repeaty,image_type type) bool repeatx, bool repeaty,image_type type)
{ {
req_width *= 2;
req_height *= 2;
width *= 2;
height *= 2;
switch (type) { switch (type) {
case IMAGE_PLOT_TINCT_ALPHA: case IMAGE_PLOT_TINCT_ALPHA:
return image_redraw_tinct(area, x, y, return image_redraw_tinct(area, x, y,

View File

@ -490,7 +490,7 @@ void print_document(struct gui_window *g, const char *filename)
LOG(("Printing page (%d)", print_max_sheets)); LOG(("Printing page (%d)", print_max_sheets));
if (c->type == CONTENT_HTML) if (c->type == CONTENT_HTML)
box = c->data.html.layout->children; box = c->data.html.layout;
/* Read Printer Driver Features */ /* Read Printer Driver Features */
e = xpdriver_info(0, 0, 0, &features, 0, 0, 0, 0); e = xpdriver_info(0, 0, 0, &features, 0, 0, 0, 0);

View File

@ -238,7 +238,7 @@ void do_search(char *string, bool from_top, bool case_sens, bool forwards)
if (c->type != CONTENT_HTML) if (c->type != CONTENT_HTML)
return; return;
box = c->data.html.layout->children; box = c->data.html.layout;
if (!box) if (!box)
return; return;

View File

@ -23,6 +23,7 @@
#include "oslib/wimpspriteop.h" #include "oslib/wimpspriteop.h"
#include "netsurf/utils/config.h" #include "netsurf/utils/config.h"
#include "netsurf/css/css.h" #include "netsurf/css/css.h"
#include "netsurf/desktop/plotters.h"
#include "netsurf/render/box.h" #include "netsurf/render/box.h"
#include "netsurf/render/form.h" #include "netsurf/render/form.h"
#include "netsurf/riscos/buffer.h" #include "netsurf/riscos/buffer.h"
@ -403,8 +404,12 @@ void ro_gui_window_redraw(struct gui_window *g, wimp_draw *redraw)
osbool more; osbool more;
bool clear_background = false; bool clear_background = false;
struct content *c = g->bw->current_content; struct content *c = g->bw->current_content;
int clip_x0, clip_y0, clip_x1, clip_y1;
os_error *error; os_error *error;
plot = ro_plotters;
ro_plot_set_scale(g->option.scale);
/* Set the current redraw gui_window to get options from /* Set the current redraw gui_window to get options from
*/ */
ro_gui_current_redraw_gui = g; ro_gui_current_redraw_gui = g;
@ -438,15 +443,15 @@ void ro_gui_window_redraw(struct gui_window *g, wimp_draw *redraw)
} }
if (c) { if (c) {
content_redraw(c, ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
redraw->box.x0 - redraw->xscroll, ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;
redraw->box.y1 - redraw->yscroll, clip_x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2;
c->width * 2, clip_y0 = (ro_plot_origin_y - redraw->clip.y1) / 2;
c->height * 2, clip_x1 = (redraw->clip.x1 - ro_plot_origin_x) / 2;
redraw->clip.x0, clip_y1 = (ro_plot_origin_y - redraw->clip.y0) / 2;
redraw->clip.y0, content_redraw(c, 0, 0,
redraw->clip.x1 - 1, c->width * 2, c->height * 2,
redraw->clip.y1 - 1, clip_x0, clip_y0, clip_x1, clip_y1,
g->option.scale, g->option.scale,
0xFFFFFF); 0xFFFFFF);
} }
@ -454,18 +459,17 @@ void ro_gui_window_redraw(struct gui_window *g, wimp_draw *redraw)
ro_gui_buffer_close(); ro_gui_buffer_close();
} }
error = xwimp_get_rectangle(redraw, &more); error = xwimp_get_rectangle(redraw, &more);
if (error) { /* RISC OS 3.7 returns an error here if enough buffer was
/* RISC OS 3.7 returns the following error is enough buffer claimed to cause a new dynamic area to be created. It
is claimed to cause a new dynamic area to be created. It doesn't actually stop anything working, so we mask it out
doesn't actually stop anything working, so we mask it out for now until a better fix is found. This appears to be a
for now until a better fix is found. bug in RISC OS. */
*/ if (error && !(ro_gui_current_redraw_gui->
if ((!ro_gui_current_redraw_gui->option.buffer_everything) || option.buffer_everything &&
(error->errnum != 0x286)) { error->errnum == error_WIMP_GET_RECT)) {
LOG(("xwimp_get_rectangle: 0x%x: %s", LOG(("xwimp_get_rectangle: 0x%x: %s",
error->errnum, error->errmess)); error->errnum, error->errmess));
warn_user("WimpError", error->errmess); warn_user("WimpError", error->errmess);
}
ro_gui_current_redraw_gui = NULL; ro_gui_current_redraw_gui = NULL;
return; return;
} }
@ -493,6 +497,7 @@ void gui_window_update_box(struct gui_window *g,
bool clear_background = false; bool clear_background = false;
bool use_buffer = g->option.buffer_everything; bool use_buffer = g->option.buffer_everything;
wimp_draw update; wimp_draw update;
int clip_x0, clip_y0, clip_x1, clip_y1;
os_error *error; os_error *error;
update.w = g->window; update.w = g->window;
@ -514,7 +519,13 @@ void gui_window_update_box(struct gui_window *g,
/* Set the current redraw gui_window to get options from /* Set the current redraw gui_window to get options from
*/ */
ro_gui_current_redraw_gui = g; ro_gui_current_redraw_gui = g;
if (data->redraw.full_redraw) use_buffer |= g->option.buffer_animations; /* if (data->redraw.full_redraw) */
use_buffer = use_buffer || g->option.buffer_animations;
plot = ro_plotters;
ro_plot_origin_x = update.box.x0 - update.xscroll;
ro_plot_origin_y = update.box.y1 - update.yscroll;
ro_plot_set_scale(g->option.scale);
/* We should clear the background, except for HTML. /* We should clear the background, except for HTML.
*/ */
@ -522,8 +533,13 @@ void gui_window_update_box(struct gui_window *g,
clear_background = true; clear_background = true;
while (more) { while (more) {
clip_x0 = (update.clip.x0 - ro_plot_origin_x) / 2;
clip_y0 = (ro_plot_origin_y - update.clip.y1) / 2;
clip_x1 = (update.clip.x1 - ro_plot_origin_x) / 2;
clip_y1 = (ro_plot_origin_y - update.clip.y0) / 2;
if (use_buffer) ro_gui_buffer_open(&update); if (use_buffer)
ro_gui_buffer_open(&update);
if (data->redraw.full_redraw) { if (data->redraw.full_redraw) {
if (clear_background) { if (clear_background) {
error = xcolourtrans_set_gcol(os_COLOUR_WHITE, error = xcolourtrans_set_gcol(os_COLOUR_WHITE,
@ -538,47 +554,40 @@ void gui_window_update_box(struct gui_window *g,
os_clg(); os_clg();
} }
content_redraw(c, content_redraw(c, 0, 0,
update.box.x0 - update.xscroll,
update.box.y1 - update.yscroll,
c->width * 2, c->height * 2, c->width * 2, c->height * 2,
update.clip.x0, update.clip.y0, clip_x0, clip_y0, clip_x1, clip_y1,
update.clip.x1 - 1, update.clip.y1 - 1,
g->option.scale, g->option.scale,
0xFFFFFF); 0xFFFFFF);
} else { } else {
assert(data->redraw.object); assert(data->redraw.object);
content_redraw(data->redraw.object, content_redraw(data->redraw.object,
update.box.x0 - update.xscroll + floorf(data->redraw.object_x *
floorf(data->redraw.object_x * 2 *
g->option.scale), g->option.scale),
update.box.y1 - update.yscroll - ceilf(data->redraw.object_y *
ceilf(data->redraw.object_y * 2 *
g->option.scale), g->option.scale),
data->redraw.object_width * 2 * data->redraw.object_width *
g->option.scale, g->option.scale,
data->redraw.object_height * 2 * data->redraw.object_height *
g->option.scale, g->option.scale,
update.clip.x0, update.clip.y0, clip_x0, clip_y0, clip_x1, clip_y1,
update.clip.x1 - 1, update.clip.y1 - 1,
g->option.scale, g->option.scale,
0xFFFFFF); 0xFFFFFF);
} }
if (use_buffer) ro_gui_buffer_close(); if (use_buffer)
ro_gui_buffer_close();
error = xwimp_get_rectangle(&update, &more); error = xwimp_get_rectangle(&update, &more);
/* RISC OS 3.7 returns an error here if enough buffer was
if (error) { claimed to cause a new dynamic area to be created. It
/* RISC OS 3.7 returns the following error is enough buffer doesn't actually stop anything working, so we mask it out
is claimed to cause a new dynamic area to be created. It for now until a better fix is found. This appears to be a
doesn't actually stop anything working, so we mask it out bug in RISC OS. */
for now until a better fix is found. if (error && !(use_buffer &&
*/ error->errnum == error_WIMP_GET_RECT)) {
if ((!use_buffer) || (error->errnum != 0x286)) { LOG(("xwimp_get_rectangle: 0x%x: %s",
LOG(("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess));
error->errnum, error->errmess)); warn_user("WimpError", error->errmess);
warn_user("WimpError", error->errmess);
}
ro_gui_current_redraw_gui = NULL; ro_gui_current_redraw_gui = NULL;
return; return;
} }
@ -1402,7 +1411,7 @@ bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar)
case wimp_KEY_F9: /* Dump content for debugging. */ case wimp_KEY_F9: /* Dump content for debugging. */
switch (content->type) { switch (content->type) {
case CONTENT_HTML: case CONTENT_HTML:
box_dump(content->data.html.layout->children, 0); box_dump(content->data.html.layout, 0);
break; break;
case CONTENT_CSS: case CONTENT_CSS:
css_dump_stylesheet(content->data.css.css); css_dump_stylesheet(content->data.css.css);
@ -1419,7 +1428,7 @@ bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar)
return true; return true;
case wimp_KEY_SHIFT + wimp_KEY_F11: /* Toggle display of box outlines. */ case wimp_KEY_SHIFT + wimp_KEY_F11: /* Toggle display of box outlines. */
gui_redraw_debug = !gui_redraw_debug; html_redraw_debug = !html_redraw_debug;
gui_window_redraw_window(g); gui_window_redraw_window(g);
return true; return true;