mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 12:12:35 +03:00
[project @ 2004-08-11 16:26:13 by jmb]
Make content_redraw return a bool Printing of foreground images now uses OS_SpriteOp Printing of background images disabled Mega-paranoid SWI result checking in htmlredraw.c Rearranged GIF data structure slightly - updates to reflect this. Other stuff I've probably forgotten svn path=/import/netsurf/; revision=1208
This commit is contained in:
parent
c682f9a5ea
commit
912d09b1cb
@ -150,7 +150,7 @@ struct handler_entry {
|
||||
void (*reformat)(struct content *c, int width, int height);
|
||||
void (*destroy)(struct content *c);
|
||||
void (*stop)(struct content *c);
|
||||
void (*redraw)(struct content *c, int x, int y,
|
||||
bool (*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);
|
||||
@ -200,8 +200,8 @@ static const struct handler_entry handler_map[] = {
|
||||
0, draw_destroy, 0, draw_redraw, 0, 0, 0},
|
||||
#endif
|
||||
#ifdef WITH_PLUGIN
|
||||
{plugin_create, plugin_process_data, plugin_convert,
|
||||
plugin_reformat, plugin_destroy, 0, plugin_redraw,
|
||||
{plugin_create, 0, plugin_convert,
|
||||
0, plugin_destroy, 0, plugin_redraw,
|
||||
plugin_add_instance, plugin_remove_instance,
|
||||
plugin_reshape_instance},
|
||||
#endif
|
||||
@ -650,15 +650,16 @@ void content_quit(void)
|
||||
* Calls the redraw function for the content, if it exists.
|
||||
*/
|
||||
|
||||
void content_redraw(struct content *c, int x, int y,
|
||||
bool content_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)
|
||||
{
|
||||
assert(c != 0);
|
||||
if (handler_map[c->type].redraw)
|
||||
handler_map[c->type].redraw(c, x, y, width, height,
|
||||
return handler_map[c->type].redraw(c, x, y, width, height,
|
||||
clip_x0, clip_y0, clip_x1, clip_y1, scale);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -269,7 +269,7 @@ void content_reformat(struct content *c, int width, int height);
|
||||
void content_clean(void);
|
||||
void content_reset(struct content *c);
|
||||
void content_quit(void);
|
||||
void content_redraw(struct content *c, int x, int y,
|
||||
bool content_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);
|
||||
|
10
render/box.h
10
render/box.h
@ -107,11 +107,13 @@ struct object_params {
|
||||
/* not a parameter, but stored here for convenience */
|
||||
char* basehref;
|
||||
char* filename;
|
||||
int browser;
|
||||
int plugin;
|
||||
int browser_stream;
|
||||
int plugin_stream;
|
||||
bool repeated;
|
||||
unsigned int browser;
|
||||
unsigned int plugin;
|
||||
unsigned int browser_stream;
|
||||
unsigned int plugin_stream;
|
||||
unsigned int plugin_task;
|
||||
unsigned int consumed;
|
||||
};
|
||||
|
||||
struct plugin_params {
|
||||
|
@ -96,7 +96,7 @@ void html_remove_instance(struct content *c, struct browser_window *bw,
|
||||
struct object_params *params, void **state);
|
||||
|
||||
/* in riscos/htmlredraw.c */
|
||||
void html_redraw(struct content *c, int x, int y,
|
||||
bool html_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);
|
||||
|
@ -56,24 +56,32 @@ void draw_destroy(struct content *c)
|
||||
}
|
||||
|
||||
|
||||
void draw_redraw(struct content *c, int x, int y,
|
||||
bool draw_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)
|
||||
{
|
||||
os_trfm matrix;
|
||||
os_error *error;
|
||||
os_trfm matrix;
|
||||
|
||||
/* Scaled image. Transform units (65536*OS units) */
|
||||
matrix.entries[0][0] = ((width*65536) / (c->width*2));
|
||||
matrix.entries[0][1] = 0;
|
||||
matrix.entries[1][0] = 0;
|
||||
matrix.entries[1][1] = ((height*65536) / (c->height*2));
|
||||
/* Draw units. (x,y) = bottom left */
|
||||
matrix.entries[2][0] = x * 256 - c->data.draw.x0 * width / c->width;
|
||||
matrix.entries[2][1] = (y - height) * 256 -
|
||||
c->data.draw.y0 * height / c->height;
|
||||
/* Scaled image. Transform units (65536*OS units) */
|
||||
matrix.entries[0][0] = ((width*65536) / (c->width*2));
|
||||
matrix.entries[0][1] = 0;
|
||||
matrix.entries[1][0] = 0;
|
||||
matrix.entries[1][1] = ((height*65536) / (c->height*2));
|
||||
/* Draw units. (x,y) = bottom left */
|
||||
matrix.entries[2][0] = x * 256 - c->data.draw.x0 * width / c->width;
|
||||
matrix.entries[2][1] = (y - height) * 256 -
|
||||
c->data.draw.y0 * height / c->height;
|
||||
|
||||
xdrawfile_render(0, (drawfile_diagram*)(c->source_data),
|
||||
error = xdrawfile_render(0, (drawfile_diagram*)(c->source_data),
|
||||
(int)c->source_size, &matrix, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xdrawfile_render: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
@ -16,7 +16,7 @@ struct content_draw_data {
|
||||
|
||||
bool draw_convert(struct content *c, int width, int height);
|
||||
void draw_destroy(struct content *c);
|
||||
void draw_redraw(struct content *c, int x, int y,
|
||||
bool draw_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);
|
||||
|
71
riscos/gif.c
71
riscos/gif.c
@ -11,6 +11,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <swis.h>
|
||||
#include "oslib/colourtrans.h"
|
||||
#include "oslib/osfile.h"
|
||||
#include "oslib/osspriteop.h"
|
||||
#include "netsurf/utils/config.h"
|
||||
@ -121,7 +122,7 @@ bool nsgif_convert(struct content *c, int iwidth, int iheight) {
|
||||
}
|
||||
|
||||
|
||||
void nsgif_redraw(struct content *c, int x, int y,
|
||||
bool nsgif_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) {
|
||||
@ -129,6 +130,11 @@ void nsgif_redraw(struct content *c, int x, int y,
|
||||
int previous_frame;
|
||||
unsigned int frame, current_frame;
|
||||
unsigned int tinct_options;
|
||||
os_factors f;
|
||||
osspriteop_trans_tab *table;
|
||||
unsigned int size;
|
||||
_kernel_oserror *e;
|
||||
os_error *error;
|
||||
|
||||
/* If we have a gui_window then we work from there, if not we use the global
|
||||
settings. We default to the first image if we don't have a GUI as we are
|
||||
@ -172,12 +178,71 @@ void nsgif_redraw(struct content *c, int x, int y,
|
||||
sprites not matching the required specifications are ignored. See the Tinct
|
||||
documentation for further information.
|
||||
*/
|
||||
_swix(Tinct_PlotScaledAlpha, _IN(2) | _IN(3) | _IN(4) | _IN(5) | _IN(6) | _IN(7),
|
||||
(char *)c->data.gif.gif->frame_image,
|
||||
if (!print_active) {
|
||||
e = _swix(Tinct_PlotScaledAlpha, _INR(2,7),
|
||||
(char *)c->data.gif.gif->frame_image +
|
||||
c->data.gif.gif->frame_image->first,
|
||||
x, (int)(y - height),
|
||||
width, height,
|
||||
tinct_options);
|
||||
if (e) {
|
||||
LOG(("tinct_plotscaledalpha: 0x%x: %s", e->errnum, e->errmess));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
error = xcolourtrans_generate_table_for_sprite(
|
||||
c->data.gif.gif->frame_image,
|
||||
(osspriteop_id)((char *)
|
||||
c->data.gif.gif->frame_image +
|
||||
c->data.gif.gif->frame_image->first),
|
||||
colourtrans_CURRENT_MODE,
|
||||
colourtrans_CURRENT_PALETTE,
|
||||
0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
table = calloc(size, sizeof(char));
|
||||
|
||||
error = xcolourtrans_generate_table_for_sprite(
|
||||
c->data.gif.gif->frame_image,
|
||||
(osspriteop_id)((char *)
|
||||
c->data.gif.gif->frame_image +
|
||||
c->data.gif.gif->frame_image->first),
|
||||
colourtrans_CURRENT_MODE,
|
||||
colourtrans_CURRENT_PALETTE,
|
||||
table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess));
|
||||
free(table);
|
||||
return false;
|
||||
}
|
||||
|
||||
f.xmul = width;
|
||||
f.ymul = height;
|
||||
f.xdiv = c->width * 2;
|
||||
f.ydiv = c->height * 2;
|
||||
|
||||
error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
|
||||
c->data.gif.gif->frame_image,
|
||||
(osspriteop_id)((char *)
|
||||
c->data.gif.gif->frame_image +
|
||||
c->data.gif.gif->frame_image->first),
|
||||
x, (int)(y - height),
|
||||
osspriteop_USE_MASK | osspriteop_USE_PALETTE,
|
||||
&f, table);
|
||||
if (error) {
|
||||
LOG(("xosspriteop_put_sprite_scaled: 0x%x: %s", error->errnum, error->errmess));
|
||||
free(table);
|
||||
return false;
|
||||
}
|
||||
|
||||
free(table);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ struct content_gif_data {
|
||||
bool nsgif_create(struct content *c, const char *params[]);
|
||||
bool nsgif_convert(struct content *c, int width, int height);
|
||||
void nsgif_destroy(struct content *c);
|
||||
void nsgif_redraw(struct content *c, int x, int y,
|
||||
bool nsgif_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);
|
||||
|
@ -110,6 +110,7 @@ int gif_initialise(struct gif_animation *gif) {
|
||||
unsigned int index;
|
||||
int return_value;
|
||||
unsigned int frame;
|
||||
osspriteop_header *header;
|
||||
|
||||
/* Check for sufficient data to be a GIF
|
||||
*/
|
||||
@ -191,19 +192,25 @@ int gif_initialise(struct gif_animation *gif) {
|
||||
|
||||
/* Initialise the sprite header
|
||||
*/
|
||||
if ((gif->frame_image = (osspriteop_header *)malloc(sizeof(osspriteop_header))) == NULL) {
|
||||
if ((gif->frame_image = (osspriteop_area *)malloc(sizeof(osspriteop_area)+sizeof(osspriteop_header))) == NULL) {
|
||||
gif_finalise(gif);
|
||||
return GIF_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
gif->frame_image->size = sizeof(osspriteop_header);
|
||||
strcpy(gif->frame_image->name, "gif");
|
||||
gif->frame_image->left_bit = 0;
|
||||
gif->frame_image->right_bit = 31;
|
||||
gif->frame_image->width = 0;
|
||||
gif->frame_image->height = 0;
|
||||
gif->frame_image->image = sizeof(osspriteop_header);
|
||||
gif->frame_image->mask = sizeof(osspriteop_header);
|
||||
gif->frame_image->mode = (os_mode) 0x301680b5;
|
||||
gif->frame_image->size = sizeof(osspriteop_area) + sizeof(osspriteop_header);
|
||||
gif->frame_image->sprite_count = 1;
|
||||
gif->frame_image->first = 16;
|
||||
gif->frame_image->used = gif->frame_image->size;
|
||||
header = (osspriteop_header*)((char*)gif->frame_image +
|
||||
gif->frame_image->first);
|
||||
header->size = sizeof(osspriteop_header);
|
||||
strcpy(header->name, "gif");
|
||||
header->left_bit = 0;
|
||||
header->right_bit = 31;
|
||||
header->width = 0;
|
||||
header->height = 0;
|
||||
header->image = sizeof(osspriteop_header);
|
||||
header->mask = sizeof(osspriteop_header);
|
||||
header->mode = (os_mode) 0x301680b5;
|
||||
|
||||
/* Remember we've done this now
|
||||
*/
|
||||
@ -312,7 +319,8 @@ int gif_initialise(struct gif_animation *gif) {
|
||||
0 for success
|
||||
*/
|
||||
static int gif_initialise_sprite(struct gif_animation *gif, unsigned int width, unsigned int height) {
|
||||
struct osspriteop_header *buffer;
|
||||
struct osspriteop_area *buffer;
|
||||
struct osspriteop_header *header;
|
||||
unsigned int max_width;
|
||||
unsigned int max_height;
|
||||
unsigned int frame_bytes;
|
||||
@ -325,11 +333,12 @@ static int gif_initialise_sprite(struct gif_animation *gif, unsigned int width,
|
||||
*/
|
||||
max_width = (width > gif->width) ? width : gif->width;
|
||||
max_height = (height > gif->height) ? height : gif->height;
|
||||
frame_bytes = max_width * max_height * 4 + sizeof(osspriteop_header);
|
||||
frame_bytes = max_width * max_height * 4 +
|
||||
sizeof(osspriteop_header) + sizeof(osspriteop_area);
|
||||
|
||||
/* Allocate some more memory
|
||||
*/
|
||||
if ((buffer = (osspriteop_header *)realloc(gif->frame_image, frame_bytes)) == NULL) {
|
||||
if ((buffer = (osspriteop_area *)realloc(gif->frame_image, frame_bytes)) == NULL) {
|
||||
return GIF_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
gif->frame_image = buffer;
|
||||
@ -342,8 +351,12 @@ static int gif_initialise_sprite(struct gif_animation *gif, unsigned int width,
|
||||
/* Update our sprite image
|
||||
*/
|
||||
buffer->size = frame_bytes;
|
||||
buffer->width = max_width - 1;
|
||||
buffer->height = max_height - 1;
|
||||
buffer->used = frame_bytes;
|
||||
header = (osspriteop_header*)((char*)gif->frame_image +
|
||||
gif->frame_image->first);
|
||||
header->size = frame_bytes - sizeof(osspriteop_area);
|
||||
header->width = max_width - 1;
|
||||
header->height = max_height - 1;
|
||||
|
||||
/* Invalidate our currently decoded image
|
||||
*/
|
||||
@ -640,7 +653,7 @@ int gif_decode_frame(struct gif_animation *gif, unsigned int frame) {
|
||||
sprite and clear what we need as some frames have multiple images which would
|
||||
produce errors.
|
||||
*/
|
||||
frame_data = (unsigned int*)((char *)gif->frame_image + sizeof(osspriteop_header));
|
||||
frame_data = (unsigned int*)((char *)gif->frame_image + gif->frame_image->first + sizeof(osspriteop_header));
|
||||
if (!clear_image) {
|
||||
if ((frame == 0) || (gif->decoded_frame == 0xffffffff)) {
|
||||
memset((char*)frame_data, 0x00, gif->width * gif->height * sizeof(int));
|
||||
|
@ -47,7 +47,7 @@ typedef struct gif_frame {
|
||||
unsigned int redraw_y;
|
||||
unsigned int redraw_width;
|
||||
unsigned int redraw_height;
|
||||
|
||||
|
||||
} gif_frame;
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ typedef struct gif_animation {
|
||||
unsigned char *gif_data;
|
||||
unsigned int buffer_position;
|
||||
unsigned int buffer_size;
|
||||
|
||||
|
||||
/* Progressive decoding data
|
||||
*/
|
||||
unsigned int global_colours;
|
||||
@ -86,7 +86,7 @@ typedef struct gif_animation {
|
||||
/* Decoded frame data
|
||||
*/
|
||||
unsigned int dirty_frame; // Frame needs erasing before next
|
||||
osspriteop_header *frame_image;
|
||||
osspriteop_area *frame_image;
|
||||
} gif_animation;
|
||||
|
||||
/* Function declarations
|
||||
|
@ -35,28 +35,28 @@
|
||||
#include "netsurf/utils/utils.h"
|
||||
|
||||
|
||||
static void html_redraw_box(struct box *box,
|
||||
static bool html_redraw_box(struct box *box,
|
||||
int x, int y,
|
||||
unsigned long current_background_color,
|
||||
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
||||
float scale);
|
||||
static void html_redraw_clip(int clip_x0, int clip_y0,
|
||||
static bool html_redraw_clip(int clip_x0, int clip_y0,
|
||||
int clip_x1, int clip_y1);
|
||||
static void html_redraw_rectangle(int x0, int y0, int width, int height,
|
||||
static bool html_redraw_rectangle(int x0, int y0, int width, int height,
|
||||
os_colour colour);
|
||||
static void html_redraw_fill(int x0, int y0, int width, int height,
|
||||
static bool html_redraw_fill(int x0, int y0, int width, int height,
|
||||
os_colour colour);
|
||||
static void html_redraw_circle(int x0, int y0, int radius,
|
||||
static bool html_redraw_circle(int x0, int y0, int radius,
|
||||
os_colour colour);
|
||||
static void html_redraw_border(colour color, int width, css_border_style style,
|
||||
static bool html_redraw_border(colour color, int width, css_border_style style,
|
||||
int x0, int y0, int x1, int y1);
|
||||
static void html_redraw_checkbox(int x, int y, int width, int height,
|
||||
static bool html_redraw_checkbox(int x, int y, int width, int height,
|
||||
bool selected);
|
||||
static void html_redraw_radio(int x, int y, int width, int height,
|
||||
static bool html_redraw_radio(int x, int y, int width, int height,
|
||||
bool selected);
|
||||
static void html_redraw_file(int x, int y, int width, int height,
|
||||
static bool html_redraw_file(int x, int y, int width, int height,
|
||||
struct box *box, float scale);
|
||||
static void html_redraw_background(int x, int y, int width, int height,
|
||||
static bool html_redraw_background(int x, int y, int width, int height,
|
||||
struct box *box, float scale);
|
||||
|
||||
bool gui_redraw_debug = false;
|
||||
@ -81,17 +81,19 @@ static os_trfm trfm = { {
|
||||
* \param clip_x1 clip rectangle
|
||||
* \param clip_y1 clip rectangle
|
||||
* \param scale scale for redraw
|
||||
* \return true if successful, false otherwise
|
||||
*
|
||||
* x, y, clip_[xy][01] are in RISC OS screen absolute OS-units.
|
||||
*/
|
||||
|
||||
void html_redraw(struct content *c, int x, int y,
|
||||
bool html_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 = 0xffffff;
|
||||
struct box *box;
|
||||
os_error *error;
|
||||
|
||||
assert(c->data.html.layout != NULL);
|
||||
box = c->data.html.layout->children;
|
||||
@ -100,15 +102,23 @@ void html_redraw(struct content *c, int x, int y,
|
||||
/* clear to background colour */
|
||||
if (c->data.html.background_colour != TRANSPARENT)
|
||||
background_colour = c->data.html.background_colour;
|
||||
colourtrans_set_gcol(background_colour << 8,
|
||||
error = xcolourtrans_set_gcol(background_colour << 8,
|
||||
colourtrans_SET_BG | colourtrans_USE_ECFS,
|
||||
os_ACTION_OVERWRITE, 0);
|
||||
os_clg();
|
||||
os_ACTION_OVERWRITE, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_clg();
|
||||
if (error) {
|
||||
LOG(("xos_clg: 0x%x: %s", error->errnum, error->errmess));
|
||||
}
|
||||
|
||||
trfm.entries[0][0] = trfm.entries[1][1] = 65536 * scale;
|
||||
|
||||
ro_gui_redraw_box_depth = 0;
|
||||
html_redraw_box(box, x, y, background_colour,
|
||||
return html_redraw_box(box, x, y, background_colour,
|
||||
clip_x0, clip_y0, clip_x1, clip_y1, scale);
|
||||
}
|
||||
|
||||
@ -125,11 +135,12 @@ void html_redraw(struct content *c, int x, int y,
|
||||
* \param clip_x1 clip rectangle
|
||||
* \param clip_y1 clip rectangle
|
||||
* \param scale scale for redraw
|
||||
* \return true if successful, false otherwise
|
||||
*
|
||||
* x, y, clip_[xy][01] are in RISC OS screen absolute OS-units.
|
||||
*/
|
||||
|
||||
void html_redraw_box(struct box *box,
|
||||
bool html_redraw_box(struct box *box,
|
||||
int x, int y,
|
||||
unsigned long current_background_color,
|
||||
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
||||
@ -140,6 +151,7 @@ void html_redraw_box(struct box *box,
|
||||
int padding_left, padding_top, padding_width, padding_height;
|
||||
int x0, y0, x1, y1;
|
||||
int colour;
|
||||
os_error *error;
|
||||
|
||||
ro_gui_redraw_box_depth++;
|
||||
|
||||
@ -170,17 +182,21 @@ void html_redraw_box(struct box *box,
|
||||
/* if visibility is hidden render children only */
|
||||
if (box->style && box->style->visibility == CSS_VISIBILITY_HIDDEN) {
|
||||
for (c = box->children; c; c = c->next)
|
||||
html_redraw_box(c, x, y, current_background_color,
|
||||
x0, y0, x1, y1, scale);
|
||||
return;
|
||||
if (!html_redraw_box(c, x, y,
|
||||
current_background_color,
|
||||
x0, y0, x1, y1, scale))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (gui_redraw_debug) {
|
||||
html_redraw_rectangle(x, y, padding_width, padding_height,
|
||||
os_COLOUR_MAGENTA);
|
||||
html_redraw_rectangle(x + padding_left, y - padding_top,
|
||||
width, height, os_COLOUR_CYAN);
|
||||
html_redraw_rectangle(x - (box->border[LEFT] +
|
||||
if (!html_redraw_rectangle(x, y, padding_width,
|
||||
padding_height, os_COLOUR_MAGENTA))
|
||||
return false;
|
||||
if (html_redraw_rectangle(x + padding_left, y - padding_top,
|
||||
width, height, os_COLOUR_CYAN))
|
||||
return false;
|
||||
if (!html_redraw_rectangle(x - (box->border[LEFT] +
|
||||
box->margin[LEFT]) * 2 * scale,
|
||||
y + (box->border[TOP] + box->margin[TOP]) *
|
||||
2 * scale,
|
||||
@ -190,30 +206,33 @@ void html_redraw_box(struct box *box,
|
||||
padding_height + (box->border[TOP] +
|
||||
box->margin[TOP] + box->border[BOTTOM] +
|
||||
box->margin[BOTTOM]) * 2 * scale,
|
||||
os_COLOUR_YELLOW);
|
||||
os_COLOUR_YELLOW))
|
||||
return false;
|
||||
}
|
||||
|
||||
/* borders */
|
||||
if (box->style && box->border[TOP])
|
||||
html_redraw_border(box->style->border[TOP].color,
|
||||
if (!html_redraw_border(box->style->border[TOP].color,
|
||||
box->border[TOP] * 2 * scale,
|
||||
box->style->border[TOP].style,
|
||||
x - box->border[LEFT] * 2 * scale,
|
||||
y + box->border[TOP] * scale,
|
||||
x + padding_width + box->border[RIGHT] *
|
||||
2 * scale,
|
||||
y + box->border[TOP] * scale);
|
||||
y + box->border[TOP] * scale))
|
||||
return false;
|
||||
if (box->style && box->border[RIGHT])
|
||||
html_redraw_border(box->style->border[RIGHT].color,
|
||||
if (!html_redraw_border(box->style->border[RIGHT].color,
|
||||
box->border[RIGHT] * 2 * scale,
|
||||
box->style->border[RIGHT].style,
|
||||
x + padding_width + box->border[RIGHT] * scale,
|
||||
y + box->border[TOP] * 2 * scale,
|
||||
x + padding_width + box->border[RIGHT] * scale,
|
||||
y - padding_height - box->border[BOTTOM] *
|
||||
2 * scale);
|
||||
2 * scale))
|
||||
return false;
|
||||
if (box->style && box->border[BOTTOM])
|
||||
html_redraw_border(box->style->border[BOTTOM].color,
|
||||
if (!html_redraw_border(box->style->border[BOTTOM].color,
|
||||
box->border[BOTTOM] * 2 * scale,
|
||||
box->style->border[BOTTOM].style,
|
||||
x - box->border[LEFT] * 2 * scale,
|
||||
@ -222,21 +241,23 @@ void html_redraw_box(struct box *box,
|
||||
x + padding_width + box->border[RIGHT] *
|
||||
2 * scale,
|
||||
y - padding_height - box->border[BOTTOM] *
|
||||
scale);
|
||||
scale))
|
||||
return false;
|
||||
if (box->style && box->border[LEFT])
|
||||
html_redraw_border(box->style->border[LEFT].color,
|
||||
if (!html_redraw_border(box->style->border[LEFT].color,
|
||||
box->border[LEFT] * 2 * scale,
|
||||
box->style->border[LEFT].style,
|
||||
x - box->border[LEFT] * scale,
|
||||
y + box->border[TOP] * 2 * scale,
|
||||
x - box->border[LEFT] * scale,
|
||||
y - padding_height - box->border[BOTTOM] *
|
||||
2 * scale);
|
||||
2 * scale))
|
||||
return false;
|
||||
|
||||
/* return if the box is completely outside the clip rectangle */
|
||||
if ((ro_gui_redraw_box_depth > 2) &&
|
||||
(clip_y1 < y0 || y1 < clip_y0 || clip_x1 < x0 || x1 < clip_x0))
|
||||
return;
|
||||
return true;
|
||||
|
||||
if ((ro_gui_redraw_box_depth > 2) &&
|
||||
(box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
|
||||
@ -247,7 +268,8 @@ void html_redraw_box(struct box *box,
|
||||
if (clip_x1 < x1) x1 = clip_x1;
|
||||
if (clip_y1 < y1) y1 = clip_y1;
|
||||
/* clip to it */
|
||||
html_redraw_clip(x0, y0, x1, y1);
|
||||
if (!html_redraw_clip(x0, y0, x1, y1))
|
||||
return false;
|
||||
} else {
|
||||
/* clip box unchanged */
|
||||
x0 = clip_x0;
|
||||
@ -277,16 +299,29 @@ void html_redraw_box(struct box *box,
|
||||
/* || box->style->background_repeat !=
|
||||
CSS_BACKGROUND_REPEAT_REPEAT*/) {
|
||||
|
||||
colourtrans_set_gcol(
|
||||
error = xcolourtrans_set_gcol(
|
||||
box->style->background_color << 8,
|
||||
colourtrans_USE_ECFS,
|
||||
os_ACTION_OVERWRITE, 0);
|
||||
os_ACTION_OVERWRITE, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
os_plot(os_MOVE_TO, px0, py0);
|
||||
error = xos_plot(os_MOVE_TO, px0, py0);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (px0 < px1 && py0 < py1)
|
||||
os_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
|
||||
if (px0 < px1 && py0 < py1) {
|
||||
error = xos_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
|
||||
px1 - 1, py1 - 1);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -297,46 +332,64 @@ void html_redraw_box(struct box *box,
|
||||
if (box->background) {
|
||||
/* clip to padding box for everything but the main window */
|
||||
if (ro_gui_redraw_box_depth > 2) {
|
||||
html_redraw_clip(px0, py0, px1, py1);
|
||||
if (!html_redraw_clip(px0, py0, px1, py1))
|
||||
return false;
|
||||
} else {
|
||||
html_redraw_clip(clip_x0, clip_y0, clip_x1, clip_y1);
|
||||
if (!html_redraw_clip(clip_x0, clip_y0, clip_x1, clip_y1))
|
||||
return false;
|
||||
}
|
||||
|
||||
/* plot background image */
|
||||
html_redraw_background(x, y, width, clip_y1 - clip_y0,
|
||||
box, scale);
|
||||
if (!html_redraw_background(x, y, width, clip_y1 - clip_y0,
|
||||
box, scale))
|
||||
return false;
|
||||
|
||||
/* restore previous graphics window */
|
||||
html_redraw_clip(x0, y0, x1, y1);
|
||||
if (!html_redraw_clip(x0, y0, x1, y1))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (box->object) {
|
||||
content_redraw(box->object, x + padding_left, y - padding_top,
|
||||
width, height, x0, y0, x1, y1, scale);
|
||||
if (!content_redraw(box->object, x + padding_left, y - padding_top,
|
||||
width, height, x0, y0, x1, y1, scale))
|
||||
return false;
|
||||
|
||||
} else if (box->gadget && box->gadget->type == GADGET_CHECKBOX) {
|
||||
html_redraw_checkbox(x + padding_left, y - padding_top,
|
||||
if (!html_redraw_checkbox(x + padding_left, y - padding_top,
|
||||
width, height,
|
||||
box->gadget->selected);
|
||||
box->gadget->selected))
|
||||
return false;
|
||||
|
||||
} else if (box->gadget && box->gadget->type == GADGET_RADIO) {
|
||||
html_redraw_radio(x + padding_left, y - padding_top,
|
||||
if (!html_redraw_radio(x + padding_left, y - padding_top,
|
||||
width, height,
|
||||
box->gadget->selected);
|
||||
box->gadget->selected))
|
||||
return false;
|
||||
|
||||
} else if (box->gadget && box->gadget->type == GADGET_FILE) {
|
||||
colourtrans_set_font_colours(box->font->handle,
|
||||
error = xcolourtrans_set_font_colours(box->font->handle,
|
||||
current_background_color << 8,
|
||||
box->style->color << 8, 14, 0, 0, 0);
|
||||
html_redraw_file(x + padding_left, y - padding_top,
|
||||
width, height, box, scale);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_font_colours: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
if (!html_redraw_file(x + padding_left, y - padding_top,
|
||||
width, height, box, scale))
|
||||
return false;
|
||||
|
||||
} else if (box->text && box->font) {
|
||||
|
||||
colourtrans_set_font_colours(box->font->handle,
|
||||
error = xcolourtrans_set_font_colours(box->font->handle,
|
||||
current_background_color << 8,
|
||||
box->style->color << 8, 14, 0, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_font_colours: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
/* antialias colour for under/overline */
|
||||
colour = box->style->color;
|
||||
@ -345,38 +398,133 @@ void html_redraw_box(struct box *box,
|
||||
((current_background_color >> 8) & 0xff)) / 2) << 8)
|
||||
| ((((colour & 0xff) +
|
||||
(current_background_color & 0xff)) / 2) << 0);
|
||||
colourtrans_set_gcol((unsigned int)colour << 8, colourtrans_USE_ECFS,
|
||||
os_ACTION_OVERWRITE, 0);
|
||||
error = xcolourtrans_set_gcol((unsigned int)colour << 8, colourtrans_USE_ECFS,
|
||||
os_ACTION_OVERWRITE, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (box->style->text_decoration & CSS_TEXT_DECORATION_UNDERLINE) {
|
||||
os_plot(os_MOVE_TO, x, y - (int) (box->height * 1.8 * scale));
|
||||
os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
||||
error = xos_plot(os_MOVE_TO, x, y - (int) (box->height * 1.8 * scale));
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (box->parent->parent->style->text_decoration & CSS_TEXT_DECORATION_UNDERLINE && box->parent->parent->type == BOX_BLOCK) {
|
||||
colourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0);
|
||||
os_plot(os_MOVE_TO, x, y - (int) (box->height * 1.8 * scale));
|
||||
os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
||||
colourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0);
|
||||
error = xcolourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_MOVE_TO, x, y - (int) (box->height * 1.8 * scale));
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xcolourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (box->style->text_decoration & CSS_TEXT_DECORATION_OVERLINE) {
|
||||
os_plot(os_MOVE_TO, x, y - (int) (box->height * 0.2 * scale));
|
||||
os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
||||
error = xos_plot(os_MOVE_TO, x, y - (int) (box->height * 0.2 * scale));
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (box->parent->parent->style->text_decoration & CSS_TEXT_DECORATION_OVERLINE && box->parent->parent->type == BOX_BLOCK) {
|
||||
colourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0);
|
||||
os_plot(os_MOVE_TO, x, y - (int) (box->height * 0.2 * scale));
|
||||
os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
||||
colourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0);
|
||||
error = xcolourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_MOVE_TO, x, y - (int) (box->height * 0.2 * scale));
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xcolourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (box->style->text_decoration & CSS_TEXT_DECORATION_LINE_THROUGH) {
|
||||
os_plot(os_MOVE_TO, x, y - (int) (box->height * 1.0 * scale));
|
||||
os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
||||
error = xos_plot(os_MOVE_TO, x, y - (int) (box->height * 1.0 * scale));
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (box->parent->parent->style->text_decoration & CSS_TEXT_DECORATION_LINE_THROUGH && box->parent->parent->type == BOX_BLOCK) {
|
||||
colourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0);
|
||||
os_plot(os_MOVE_TO, x, y - (int) (box->height * 1.0 * scale));
|
||||
os_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
||||
colourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0);
|
||||
error = xcolourtrans_set_gcol((unsigned int)box->parent->parent->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_MOVE_TO, x, y - (int) (box->height * 1.0 * scale));
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_PLOT_SOLID_EX_END | os_PLOT_BY, box->width * 2 * scale, 0);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xcolourtrans_set_gcol((unsigned int)box->style->color << 8, colourtrans_USE_ECFS, os_ACTION_OVERWRITE, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (scale == 1)
|
||||
@ -392,19 +540,24 @@ void html_redraw_box(struct box *box,
|
||||
} else {
|
||||
for (c = box->children; c != 0; c = c->next)
|
||||
if (c->type != BOX_FLOAT_LEFT && c->type != BOX_FLOAT_RIGHT)
|
||||
html_redraw_box(c, x,
|
||||
if (!html_redraw_box(c, x,
|
||||
y, current_background_color,
|
||||
x0, y0, x1, y1, scale);
|
||||
x0, y0, x1, y1, scale))
|
||||
return false;
|
||||
|
||||
for (c = box->float_children; c != 0; c = c->next_float)
|
||||
html_redraw_box(c, x,
|
||||
if (!html_redraw_box(c, x,
|
||||
y, current_background_color,
|
||||
x0, y0, x1, y1, scale);
|
||||
x0, y0, x1, y1, scale))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
|
||||
box->type == BOX_TABLE_CELL || box->object)
|
||||
html_redraw_clip(clip_x0, clip_y0, clip_x1, clip_y1);
|
||||
if (!html_redraw_clip(clip_x0, clip_y0, clip_x1, clip_y1))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -412,14 +565,59 @@ void html_redraw_box(struct box *box,
|
||||
* Set the clip rectangle.
|
||||
*/
|
||||
|
||||
void html_redraw_clip(int clip_x0, int clip_y0,
|
||||
bool html_redraw_clip(int clip_x0, int clip_y0,
|
||||
int clip_x1, int clip_y1)
|
||||
{
|
||||
os_set_graphics_window();
|
||||
os_writec((char) (clip_x0 & 0xff)); os_writec((char) (clip_x0 >> 8));
|
||||
os_writec((char) (clip_y0 & 0xff)); os_writec((char) (clip_y0 >> 8));
|
||||
os_writec((char) (clip_x1 & 0xff)); os_writec((char) (clip_x1 >> 8));
|
||||
os_writec((char) (clip_y1 & 0xff)); os_writec((char) (clip_y1 >> 8));
|
||||
os_error *error;
|
||||
|
||||
error = xos_set_graphics_window();
|
||||
if (error) {
|
||||
LOG(("xos_set_graphics_window: 0x%x: %s", error->errnum,
|
||||
error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_writec((char) (clip_x0 & 0xff));
|
||||
if (error) {
|
||||
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_writec((char) (clip_x0 >> 8));
|
||||
if (error) {
|
||||
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_writec((char) (clip_y0 & 0xff));
|
||||
if (error) {
|
||||
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_writec((char) (clip_y0 >> 8));
|
||||
if (error) {
|
||||
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_writec((char) (clip_x1 & 0xff));
|
||||
if (error) {
|
||||
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_writec((char) (clip_x1 >> 8));
|
||||
if (error) {
|
||||
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_writec((char) (clip_y1 & 0xff));
|
||||
if (error) {
|
||||
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_writec((char) (clip_y1 >> 8));
|
||||
if (error) {
|
||||
LOG(("xos_writec: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -427,15 +625,44 @@ void html_redraw_clip(int clip_x0, int clip_y0,
|
||||
* Plot a dotted rectangle outline.
|
||||
*/
|
||||
|
||||
void html_redraw_rectangle(int x0, int y0, int width, int height,
|
||||
bool html_redraw_rectangle(int x0, int y0, int width, int height,
|
||||
os_colour colour)
|
||||
{
|
||||
colourtrans_set_gcol(colour, 0, os_ACTION_OVERWRITE, 0);
|
||||
os_plot(os_MOVE_TO, x0, y0);
|
||||
os_plot(os_PLOT_DOTTED | os_PLOT_BY, width, 0);
|
||||
os_plot(os_PLOT_DOTTED | os_PLOT_BY, 0, -height);
|
||||
os_plot(os_PLOT_DOTTED | os_PLOT_BY, -width, 0);
|
||||
os_plot(os_PLOT_DOTTED | os_PLOT_BY, 0, height);
|
||||
os_error *error;
|
||||
|
||||
error = xcolourtrans_set_gcol(colour, 0, os_ACTION_OVERWRITE, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_MOVE_TO, x0, y0);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_PLOT_DOTTED | os_PLOT_BY, width, 0);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_PLOT_DOTTED | os_PLOT_BY, 0, -height);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_PLOT_DOTTED | os_PLOT_BY, -width, 0);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_PLOT_DOTTED | os_PLOT_BY, 0, height);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -443,12 +670,29 @@ void html_redraw_rectangle(int x0, int y0, int width, int height,
|
||||
* Fill a rectangle of colour.
|
||||
*/
|
||||
|
||||
void html_redraw_fill(int x0, int y0, int width, int height,
|
||||
bool html_redraw_fill(int x0, int y0, int width, int height,
|
||||
os_colour colour)
|
||||
{
|
||||
colourtrans_set_gcol(colour, 0, os_ACTION_OVERWRITE, 0);
|
||||
os_plot(os_MOVE_TO, x0, y0 - height);
|
||||
os_plot(os_PLOT_RECTANGLE | os_PLOT_BY, width - 1, height - 1);
|
||||
os_error *error;
|
||||
|
||||
error = xcolourtrans_set_gcol(colour, 0, os_ACTION_OVERWRITE, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_MOVE_TO, x0, y0 - height);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_PLOT_RECTANGLE | os_PLOT_BY, width - 1, height - 1);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -456,12 +700,29 @@ void html_redraw_fill(int x0, int y0, int width, int height,
|
||||
* Fill a circle of colour.
|
||||
*/
|
||||
|
||||
void html_redraw_circle(int x0, int y0, int radius,
|
||||
bool html_redraw_circle(int x0, int y0, int radius,
|
||||
os_colour colour)
|
||||
{
|
||||
colourtrans_set_gcol(colour, 0, os_ACTION_OVERWRITE, 0);
|
||||
os_plot(os_MOVE_TO, x0, y0);
|
||||
os_plot(os_PLOT_CIRCLE | os_PLOT_BY, radius, 0);
|
||||
os_error *error;
|
||||
|
||||
error = xcolourtrans_set_gcol(colour, 0, os_ACTION_OVERWRITE, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_MOVE_TO, x0, y0);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xos_plot(os_PLOT_CIRCLE | os_PLOT_BY, radius, 0);
|
||||
if (error) {
|
||||
LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -477,7 +738,7 @@ static const int dash_pattern_dashed[] = { 0, 1, 2048 };
|
||||
* Draw a border.
|
||||
*/
|
||||
|
||||
void html_redraw_border(colour color, int width, css_border_style style,
|
||||
bool html_redraw_border(colour color, int width, css_border_style style,
|
||||
int x0, int y0, int x1, int y1)
|
||||
{
|
||||
const draw_dash_pattern *dash_pattern;
|
||||
@ -495,14 +756,20 @@ void html_redraw_border(colour color, int width, css_border_style style,
|
||||
path[4] = x1 * 256;
|
||||
path[5] = y1 * 256;
|
||||
error = xcolourtrans_set_gcol(color << 8, 0, os_ACTION_OVERWRITE, 0, 0);
|
||||
if (error)
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
error = xdraw_stroke((draw_path *) path, 0, 0, 0, width * 256,
|
||||
&line_style, dash_pattern);
|
||||
if (error)
|
||||
if (error) {
|
||||
LOG(("xdraw_stroke: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -510,19 +777,24 @@ void html_redraw_border(colour color, int width, css_border_style style,
|
||||
* Plot a checkbox.
|
||||
*/
|
||||
|
||||
void html_redraw_checkbox(int x, int y, int width, int height,
|
||||
bool html_redraw_checkbox(int x, int y, int width, int height,
|
||||
bool selected)
|
||||
{
|
||||
int z = width * 0.15;
|
||||
if (z == 0)
|
||||
z = 1;
|
||||
html_redraw_fill(x, y, width, height, os_COLOUR_BLACK);
|
||||
html_redraw_fill(x + z, y - z, width - z - z, height - z - z,
|
||||
os_COLOUR_WHITE);
|
||||
if (!html_redraw_fill(x, y, width, height, os_COLOUR_BLACK))
|
||||
return false;
|
||||
if (!html_redraw_fill(x + z, y - z, width - z - z, height - z - z,
|
||||
os_COLOUR_WHITE))
|
||||
return false;
|
||||
if (selected)
|
||||
html_redraw_fill(x + z + z, y - z - z,
|
||||
if (!html_redraw_fill(x + z + z, y - z - z,
|
||||
width - z - z - z - z, height - z - z - z - z,
|
||||
os_COLOUR_RED);
|
||||
os_COLOUR_RED))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -530,16 +802,21 @@ void html_redraw_checkbox(int x, int y, int width, int height,
|
||||
* Plot a radio icon.
|
||||
*/
|
||||
|
||||
void html_redraw_radio(int x, int y, int width, int height,
|
||||
bool html_redraw_radio(int x, int y, int width, int height,
|
||||
bool selected)
|
||||
{
|
||||
html_redraw_circle(x + width * 0.5, y - height * 0.5,
|
||||
width * 0.5 - 1, os_COLOUR_BLACK);
|
||||
html_redraw_circle(x + width * 0.5, y - height * 0.5,
|
||||
width * 0.4 - 1, os_COLOUR_WHITE);
|
||||
if (!html_redraw_circle(x + width * 0.5, y - height * 0.5,
|
||||
width * 0.5 - 1, os_COLOUR_BLACK))
|
||||
return false;
|
||||
if (!html_redraw_circle(x + width * 0.5, y - height * 0.5,
|
||||
width * 0.4 - 1, os_COLOUR_WHITE))
|
||||
return false;
|
||||
if (selected)
|
||||
html_redraw_circle(x + width * 0.5, y - height * 0.5,
|
||||
width * 0.3 - 1, os_COLOUR_RED);
|
||||
if (!html_redraw_circle(x + width * 0.5, y - height * 0.5,
|
||||
width * 0.3 - 1, os_COLOUR_RED))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -547,7 +824,7 @@ void html_redraw_radio(int x, int y, int width, int height,
|
||||
* Plot a file upload input.
|
||||
*/
|
||||
|
||||
void html_redraw_file(int x, int y, int width, int height,
|
||||
bool html_redraw_file(int x, int y, int width, int height,
|
||||
struct box *box, float scale)
|
||||
{
|
||||
int text_width;
|
||||
@ -575,9 +852,11 @@ void html_redraw_file(int x, int y, int width, int height,
|
||||
|
||||
/* xwimpspriteop_put_sprite_user_coords(sprite, x + 4, */
|
||||
/* y - height / 2 - 17, os_ACTION_OVERWRITE); */
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void html_redraw_background(int xi, int yi, int width, int height,
|
||||
bool html_redraw_background(int xi, int yi, int width, int height,
|
||||
struct box *box, float scale)
|
||||
{
|
||||
unsigned int tinct_options = 0;
|
||||
@ -588,15 +867,15 @@ void html_redraw_background(int xi, int yi, int width, int height,
|
||||
float multiplier;
|
||||
bool fixed = false;
|
||||
wimp_window_state state;
|
||||
os_error *error;
|
||||
|
||||
if (box->background == 0) return;
|
||||
if (box->background == 0) return true;
|
||||
|
||||
state.w = 0;
|
||||
|
||||
if (ro_gui_current_redraw_gui) {
|
||||
|
||||
/* read state of window we're drawing in */
|
||||
os_error *error;
|
||||
|
||||
state.w = ro_gui_current_redraw_gui->window;
|
||||
error = xwimp_get_window_state(&state);
|
||||
@ -610,11 +889,11 @@ void html_redraw_background(int xi, int yi, int width, int height,
|
||||
|
||||
/* Set the plot options */
|
||||
if (!ro_gui_current_redraw_gui->option.background_images)
|
||||
return;
|
||||
return true;
|
||||
tinct_options = (ro_gui_current_redraw_gui->option.filter_sprites?tinct_BILINEAR_FILTER:0) |
|
||||
(ro_gui_current_redraw_gui->option.dither_sprites?tinct_DITHER:0);
|
||||
} else {
|
||||
if (!option_background_images) return;
|
||||
if (!option_background_images) return true;
|
||||
tinct_options = (option_filter_sprites?tinct_BILINEAR_FILTER:0) |
|
||||
(option_dither_sprites?tinct_DITHER:0);
|
||||
}
|
||||
@ -760,7 +1039,7 @@ void html_redraw_background(int xi, int yi, int width, int height,
|
||||
#ifdef WITH_GIF
|
||||
case CONTENT_GIF:
|
||||
_swix(Tinct_PlotScaledAlpha, _IN(2) | _IN(3) | _IN(4) | _IN(5) | _IN(6) | _IN(7),
|
||||
(char*) box->background->data.gif.gif->frame_image,
|
||||
((char*) box->background->data.gif.gif->frame_image + box->background->data.gif.gif->frame_image->first),
|
||||
x, y - image_height, image_width, image_height,
|
||||
tinct_options);
|
||||
break;
|
||||
@ -769,4 +1048,6 @@ void html_redraw_background(int xi, int yi, int width, int height,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -243,12 +243,17 @@ void nsjpeg_destroy(struct content *c)
|
||||
* Redraw a CONTENT_JPEG.
|
||||
*/
|
||||
|
||||
void nsjpeg_redraw(struct content *c, int x, int y,
|
||||
bool nsjpeg_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 int tinct_options;
|
||||
unsigned int size;
|
||||
os_factors f;
|
||||
osspriteop_trans_tab *table;
|
||||
_kernel_oserror *e;
|
||||
os_error *error;
|
||||
|
||||
/* If we have a gui_window then we work from there, if not we use the global
|
||||
settings as we are drawing a thumbnail.
|
||||
@ -265,11 +270,65 @@ void nsjpeg_redraw(struct content *c, int x, int y,
|
||||
sprites not matching the required specifications are ignored. See the Tinct
|
||||
documentation for further information.
|
||||
*/
|
||||
_swix(Tinct_PlotScaled,
|
||||
_IN(2) | _IN(3) | _IN(4) | _IN(5) | _IN(6) | _IN(7),
|
||||
if (!print_active) {
|
||||
e = _swix(Tinct_PlotScaled, _INR(2,7),
|
||||
(char *) c->data.jpeg.sprite_area +
|
||||
c->data.jpeg.sprite_area->first,
|
||||
x, y - height,
|
||||
width, height,
|
||||
tinct_options);
|
||||
if (e) {
|
||||
LOG(("tinct_plotscaled: 0x%x: %s", e->errnum, e->errmess));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
error = xcolourtrans_generate_table_for_sprite(
|
||||
c->data.jpeg.sprite_area,
|
||||
(osspriteop_id)((char*)c->data.jpeg.sprite_area +
|
||||
c->data.jpeg.sprite_area->first),
|
||||
colourtrans_CURRENT_MODE,
|
||||
colourtrans_CURRENT_PALETTE,
|
||||
0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
table = calloc(size, sizeof(char));
|
||||
|
||||
error = xcolourtrans_generate_table_for_sprite(
|
||||
c->data.jpeg.sprite_area,
|
||||
(osspriteop_id)((char*)c->data.jpeg.sprite_area +
|
||||
c->data.jpeg.sprite_area->first),
|
||||
colourtrans_CURRENT_MODE,
|
||||
colourtrans_CURRENT_PALETTE,
|
||||
table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess));
|
||||
free(table);
|
||||
return false;
|
||||
}
|
||||
|
||||
f.xmul = width;
|
||||
f.ymul = height;
|
||||
f.xdiv = c->width * 2;
|
||||
f.ydiv = c->height * 2;
|
||||
|
||||
error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
|
||||
c->data.jpeg.sprite_area,
|
||||
(osspriteop_id)((char*)c->data.jpeg.sprite_area +
|
||||
c->data.jpeg.sprite_area->first),
|
||||
x, (int)(y - height),
|
||||
0, &f, table);
|
||||
if (error) {
|
||||
LOG(("xosspriteop_put_sprite_scaled: 0x%x: %s", error->errnum, error->errmess));
|
||||
free(table);
|
||||
return false;
|
||||
}
|
||||
|
||||
free(table);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ struct content_jpeg_data {
|
||||
bool nsjpeg_create(struct content *c, const char *params[]);
|
||||
bool nsjpeg_convert(struct content *c, int width, int height);
|
||||
void nsjpeg_destroy(struct content *c);
|
||||
void nsjpeg_redraw(struct content *c, int x, int y,
|
||||
bool nsjpeg_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);
|
||||
|
107
riscos/mng.c
107
riscos/mng.c
@ -11,6 +11,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <swis.h>
|
||||
#include "libmng/libmng.h"
|
||||
#include "oslib/colourtrans.h"
|
||||
#include "oslib/os.h"
|
||||
#include "oslib/osspriteop.h"
|
||||
#include "netsurf/utils/config.h"
|
||||
@ -41,6 +42,10 @@ static mng_bool nsmng_refresh(mng_handle mng, mng_uint32 x, mng_uint32 y, mng_ui
|
||||
static mng_bool nsmng_settimer(mng_handle mng, mng_uint32 msecs);
|
||||
static void nsmng_animate(void *p);
|
||||
static bool nsmng_broadcast_error(struct content *c);
|
||||
static mng_bool nsmng_trace(mng_handle mng, mng_int32 iFunNr, mng_int32 iFuncseq, mng_pchar zFuncname);
|
||||
static mng_bool nsmng_errorproc(mng_handle mng, mng_int32 code,
|
||||
mng_int8 severity, mng_chunkid chunktype, mng_uint32 chunkseq,
|
||||
mng_int32 extra1, mng_int32 extra2, mng_pchar text);
|
||||
|
||||
bool nsmng_create(struct content *c, const char *params[]) {
|
||||
|
||||
@ -98,6 +103,12 @@ bool nsmng_create(struct content *c, const char *params[]) {
|
||||
return nsmng_broadcast_error(c);
|
||||
}
|
||||
|
||||
/* register error handling function */
|
||||
if (mng_setcb_errorproc(c->data.mng.handle, nsmng_errorproc) != MNG_NOERROR) {
|
||||
LOG(("Unable to set errorproc"));
|
||||
return nsmng_broadcast_error(c);
|
||||
}
|
||||
|
||||
/* Initialise the reading
|
||||
*/
|
||||
c->data.mng.read_start = true;
|
||||
@ -127,6 +138,9 @@ mng_bool nsmng_readdata(mng_handle mng, mng_ptr buffer, mng_uint32 size, mng_uin
|
||||
*/
|
||||
*bytesread = ((c->source_size - c->data.mng.read_size) < size) ?
|
||||
(c->source_size - c->data.mng.read_size) : size;
|
||||
|
||||
LOG(("Read %d, processing %p", *bytesread, mng));
|
||||
|
||||
if ((*bytesread) > 0) {
|
||||
memcpy(buffer, c->source_data + c->data.mng.read_size, *bytesread);
|
||||
c->data.mng.read_size += *bytesread;
|
||||
@ -363,11 +377,16 @@ void nsmng_destroy(struct content *c) {
|
||||
}
|
||||
|
||||
|
||||
void nsmng_redraw(struct content *c, int x, int y,
|
||||
bool nsmng_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 int tinct_options;
|
||||
unsigned int size;
|
||||
os_factors f;
|
||||
osspriteop_trans_tab *table;
|
||||
_kernel_oserror *e;
|
||||
os_error *error;
|
||||
|
||||
/* If we have a gui_window then we work from there, if not we use the global
|
||||
settings as we are drawing a thumbnail.
|
||||
@ -384,15 +403,70 @@ void nsmng_redraw(struct content *c, int x, int y,
|
||||
sprites not matching the required specifications are ignored. See the Tinct
|
||||
documentation for further information.
|
||||
*/
|
||||
_swix(Tinct_PlotScaledAlpha, _IN(2) | _IN(3) | _IN(4) | _IN(5) | _IN(6) | _IN(7),
|
||||
if (!print_active) {
|
||||
e = _swix(Tinct_PlotScaledAlpha, _INR(2,7),
|
||||
((char *) c->data.mng.sprite_area + c->data.mng.sprite_area->first),
|
||||
x, y - height,
|
||||
width, height,
|
||||
tinct_options);
|
||||
if (e) {
|
||||
LOG(("xtince_plotscaledalpha: 0x%x: %s", e->errnum, e->errmess));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
error = xcolourtrans_generate_table_for_sprite(
|
||||
c->data.mng.sprite_area,
|
||||
(osspriteop_id)((char*)c->data.mng.sprite_area +
|
||||
c->data.mng.sprite_area->first),
|
||||
colourtrans_CURRENT_MODE,
|
||||
colourtrans_CURRENT_PALETTE,
|
||||
0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
table = calloc(size, sizeof(char));
|
||||
|
||||
error = xcolourtrans_generate_table_for_sprite(
|
||||
c->data.mng.sprite_area,
|
||||
(osspriteop_id)((char*)c->data.mng.sprite_area +
|
||||
c->data.mng.sprite_area->first),
|
||||
colourtrans_CURRENT_MODE,
|
||||
colourtrans_CURRENT_PALETTE,
|
||||
table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess));
|
||||
free(table);
|
||||
return false;
|
||||
}
|
||||
|
||||
f.xmul = width;
|
||||
f.ymul = height;
|
||||
f.xdiv = c->width * 2;
|
||||
f.ydiv = c->height * 2;
|
||||
|
||||
error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
|
||||
c->data.mng.sprite_area,
|
||||
(osspriteop_id)((char*)c->data.mng.sprite_area +
|
||||
c->data.mng.sprite_area->first),
|
||||
x, (int)(y - height),
|
||||
osspriteop_USE_MASK | osspriteop_USE_PALETTE,
|
||||
&f, table);
|
||||
if (error) {
|
||||
LOG(("xosspriteop_put_sprite_scaled: 0x%x: %s", error->errnum, error->errmess));
|
||||
free(table);
|
||||
return false;
|
||||
}
|
||||
|
||||
free(table);
|
||||
}
|
||||
/* Check if we need to restart the animation
|
||||
*/
|
||||
if (c->data.mng.waiting) nsmng_animate(c);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -432,4 +506,33 @@ bool nsmng_broadcast_error(struct content *c) {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
mng_bool nsmng_trace(mng_handle mng, mng_int32 iFunNr, mng_int32 iFuncseq, mng_pchar zFuncname)
|
||||
{
|
||||
LOG(("In %s(%d,%d), processing: %p", zFuncname, iFunNr, iFuncseq, mng));
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
mng_bool nsmng_errorproc(mng_handle mng, mng_int32 code,
|
||||
mng_int8 severity,
|
||||
mng_chunkid chunktype, mng_uint32 chunkseq,
|
||||
mng_int32 extra1, mng_int32 extra2, mng_pchar text)
|
||||
{
|
||||
struct content *c;
|
||||
char chunk[5];
|
||||
|
||||
c = (struct content *)mng_get_userdata(mng);
|
||||
|
||||
chunk[0] = (char)((chunktype >> 24) & 0xFF);
|
||||
chunk[1] = (char)((chunktype >> 16) & 0xFF);
|
||||
chunk[2] = (char)((chunktype >> 8) & 0xFF);
|
||||
chunk[3] = (char)((chunktype ) & 0xFF);
|
||||
chunk[4] = '\0';
|
||||
|
||||
LOG(("error playing '%s' chunk %s (%d):", c->url, chunk, chunkseq));
|
||||
LOG(("code %d severity %d extra1 %d extra2 %d text:'%s'", code,
|
||||
severity, extra1, extra2, text));
|
||||
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
@ -26,7 +26,7 @@ bool nsmng_create(struct content *c, const char *params[]);
|
||||
bool nsmng_process_data(struct content *c, char *data, unsigned int size);
|
||||
bool nsmng_convert(struct content *c, int width, int height);
|
||||
void nsmng_destroy(struct content *c);
|
||||
void nsmng_redraw(struct content *c, int x, int y,
|
||||
bool nsmng_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);
|
||||
|
65
riscos/png.c
65
riscos/png.c
@ -12,6 +12,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <swis.h>
|
||||
#include "libpng/png.h"
|
||||
#include "oslib/colourtrans.h"
|
||||
#include "oslib/osspriteop.h"
|
||||
#include "netsurf/utils/config.h"
|
||||
#include "netsurf/content/content.h"
|
||||
@ -266,12 +267,17 @@ void nspng_destroy(struct content *c)
|
||||
}
|
||||
|
||||
|
||||
void nspng_redraw(struct content *c, int x, int y,
|
||||
bool nspng_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 int tinct_options;
|
||||
unsigned int size;
|
||||
os_factors f;
|
||||
osspriteop_trans_tab *table;
|
||||
_kernel_oserror *e;
|
||||
os_error *error;
|
||||
|
||||
/* If we have a gui_window then we work from there, if not we use the global
|
||||
settings as we are drawing a thumbnail.
|
||||
@ -288,10 +294,65 @@ void nspng_redraw(struct content *c, int x, int y,
|
||||
sprites not matching the required specifications are ignored. See the Tinct
|
||||
documentation for further information.
|
||||
*/
|
||||
_swix(Tinct_PlotScaledAlpha, _IN(2) | _IN(3) | _IN(4) | _IN(5) | _IN(6) | _IN(7),
|
||||
if (!print_active) {
|
||||
e = _swix(Tinct_PlotScaledAlpha, _INR(2,7),
|
||||
((char *) c->data.png.sprite_area + c->data.png.sprite_area->first),
|
||||
x, y - height,
|
||||
width, height,
|
||||
tinct_options);
|
||||
if (e) {
|
||||
LOG(("xtinct_plotscaled_alpha: 0x%x: %s", e->errnum, e->errmess));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
error = xcolourtrans_generate_table_for_sprite(
|
||||
c->data.png.sprite_area,
|
||||
(osspriteop_id)((char*)c->data.png.sprite_area +
|
||||
c->data.png.sprite_area->first),
|
||||
colourtrans_CURRENT_MODE,
|
||||
colourtrans_CURRENT_PALETTE,
|
||||
0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
table = calloc(size, sizeof(char));
|
||||
|
||||
error = xcolourtrans_generate_table_for_sprite(
|
||||
c->data.png.sprite_area,
|
||||
(osspriteop_id)((char*)c->data.png.sprite_area +
|
||||
c->data.png.sprite_area->first),
|
||||
colourtrans_CURRENT_MODE,
|
||||
colourtrans_CURRENT_PALETTE,
|
||||
table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
f.xmul = width;
|
||||
f.ymul = height;
|
||||
f.xdiv = c->width * 2;
|
||||
f.ydiv = c->height * 2;
|
||||
|
||||
error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
|
||||
c->data.png.sprite_area,
|
||||
(osspriteop_id)((char*)c->data.png.sprite_area +
|
||||
c->data.png.sprite_area->first),
|
||||
x, (int)(y - height),
|
||||
osspriteop_USE_MASK | osspriteop_USE_PALETTE,
|
||||
&f, table);
|
||||
if (error) {
|
||||
LOG(("xosspriteop_put_sprite_scaled: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
free(table);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
@ -26,7 +26,7 @@ bool nspng_create(struct content *c, const char *params[]);
|
||||
bool nspng_process_data(struct content *c, char *data, unsigned int size);
|
||||
bool nspng_convert(struct content *c, int width, int height);
|
||||
void nspng_destroy(struct content *c);
|
||||
void nspng_redraw(struct content *c, int x, int y,
|
||||
bool nspng_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);
|
||||
|
@ -40,11 +40,15 @@
|
||||
|
||||
/* 1 millipoint == 1/400 OS unit = 1/800 browser units */
|
||||
|
||||
/* extern globals */
|
||||
struct gui_window *print_current_window = 0;
|
||||
bool print_active = false;
|
||||
|
||||
/* static globals */
|
||||
static bool print_in_background = false;
|
||||
static float print_scale = 1.0;
|
||||
static int print_num_copies = 1;
|
||||
static bool print_bg_images = true;
|
||||
static bool print_bg_images = false;
|
||||
static int print_max_sheets = -1;
|
||||
|
||||
/* array of fonts in document - max 255 */
|
||||
@ -97,7 +101,9 @@ void ro_gui_print_open(struct gui_window *g, int x, int y, bool sub_menu, bool k
|
||||
ro_gui_set_icon_selected_state(dialog_print, ICON_PRINT_FG_IMAGES, true);
|
||||
ro_gui_set_icon_shaded_state(dialog_print, ICON_PRINT_FG_IMAGES, true);
|
||||
|
||||
ro_gui_set_icon_selected_state(dialog_print, ICON_PRINT_BG_IMAGES, print_bg_images);
|
||||
ro_gui_set_icon_selected_state(dialog_print, ICON_PRINT_BG_IMAGES, false/*print_bg_images*/);
|
||||
ro_gui_set_icon_shaded_state(dialog_print, ICON_PRINT_BG_IMAGES, true);
|
||||
|
||||
|
||||
ro_gui_set_icon_selected_state(dialog_print, ICON_PRINT_IN_BACKGROUND, false);
|
||||
|
||||
@ -205,6 +211,9 @@ bool ro_gui_print_keypress(wimp_key *key)
|
||||
print_cleanup();
|
||||
return true;
|
||||
case wimp_KEY_RETURN:
|
||||
if (ro_gui_get_icon_shaded_state(dialog_print, ICON_PRINT_PRINT))
|
||||
return true;
|
||||
|
||||
print_in_background = ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_IN_BACKGROUND);
|
||||
print_num_copies = atoi(ro_gui_get_icon_string(dialog_print, ICON_PRINT_COPIES));
|
||||
if (ro_gui_get_icon_selected_state(dialog_print, ICON_PRINT_SHEETS))
|
||||
@ -558,6 +567,9 @@ void print_document(struct gui_window *g, const char *filename)
|
||||
LOG(("declared fonts"));
|
||||
}
|
||||
|
||||
/* print is now active */
|
||||
print_active = true;
|
||||
|
||||
do {
|
||||
os_box b = {left/400 - 2, bottom/400 - 2,
|
||||
right/400 + 2, top/400 + 2};
|
||||
@ -596,13 +608,17 @@ void print_document(struct gui_window *g, const char *filename)
|
||||
while (more) {
|
||||
LOG(("redrawing area: [(%d, %d), (%d, %d)]", b.x0, b.y0, b.x1, b.y1));
|
||||
if (c) {
|
||||
content_redraw(c, left/400,
|
||||
if (!content_redraw(c, left/400,
|
||||
top/400 + (yscroll*2),
|
||||
c->width * 2, c->height * 2,
|
||||
b.x0, b.y0,
|
||||
b.x1-1, b.y1-1,
|
||||
print_scale);
|
||||
print_scale)) {
|
||||
ro_gui_current_redraw_gui = NULL;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
e = xpdriver_get_rectangle(&b, &more, 0);
|
||||
if (e) {
|
||||
LOG(("%s", e->errmess));
|
||||
@ -614,6 +630,9 @@ void print_document(struct gui_window *g, const char *filename)
|
||||
yscroll += height;
|
||||
} while (yscroll <= c->height && --sheets != 0);
|
||||
|
||||
/* make print inactive */
|
||||
print_active = false;
|
||||
|
||||
ro_gui_current_redraw_gui = NULL;
|
||||
LOG(("finished redraw"));
|
||||
|
||||
@ -638,6 +657,7 @@ error:
|
||||
xpdriver_abort_job(fhandle);
|
||||
xosfind_close(fhandle);
|
||||
if (old_job) xpdriver_select_jobw(old_job, 0, 0);
|
||||
print_active = false;
|
||||
|
||||
/* restore document layout */
|
||||
if (c->type == CONTENT_HTML)
|
||||
@ -709,4 +729,5 @@ bool print_find_fonts(struct box *box, struct print_font **print_fonts, int *num
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -715,7 +715,7 @@ static bool add_graphic(struct content *content, struct box *box,
|
||||
break;
|
||||
#endif
|
||||
case CONTENT_GIF:
|
||||
sprite_length = content->data.gif.gif->frame_image->size;
|
||||
sprite_length = ((osspriteop_header*)((char*)content->data.gif.gif->frame_image+content->data.gif.gif->frame_image->first))->size;
|
||||
break;
|
||||
#ifdef WITH_SPRITE
|
||||
case CONTENT_SPRITE:
|
||||
@ -754,7 +754,7 @@ static bool add_graphic(struct content *content, struct box *box,
|
||||
break;
|
||||
#endif
|
||||
case CONTENT_GIF:
|
||||
memcpy((char*)ds+16, (char*)content->data.gif.gif->frame_image, (unsigned)sprite_length);
|
||||
memcpy((char*)ds+16, (char*)content->data.gif.gif->frame_image+content->data.gif.gif->frame_image->first, (unsigned)sprite_length);
|
||||
break;
|
||||
#ifdef WITH_SPRITE
|
||||
case CONTENT_SPRITE:
|
||||
|
@ -97,7 +97,7 @@ void sprite_destroy(struct content *c)
|
||||
}
|
||||
|
||||
|
||||
void sprite_redraw(struct content *c, int x, int y,
|
||||
bool sprite_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)
|
||||
@ -106,33 +106,50 @@ void sprite_redraw(struct content *c, int x, int y,
|
||||
osspriteop_area *area = (osspriteop_area*)c->data.sprite.data;
|
||||
osspriteop_trans_tab *table;
|
||||
os_factors factors;
|
||||
os_error *error;
|
||||
|
||||
xcolourtrans_generate_table_for_sprite(
|
||||
error = xcolourtrans_generate_table_for_sprite(
|
||||
area,
|
||||
(osspriteop_id)((char*)(c->data.sprite.data) +
|
||||
area->first),
|
||||
colourtrans_CURRENT_MODE, colourtrans_CURRENT_PALETTE,
|
||||
0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess));
|
||||
return false;
|
||||
}
|
||||
table = xcalloc(size, 1);
|
||||
xcolourtrans_generate_table_for_sprite(
|
||||
error = xcolourtrans_generate_table_for_sprite(
|
||||
area,
|
||||
(osspriteop_id)((char*)(c->data.sprite.data) +
|
||||
area->first),
|
||||
colourtrans_CURRENT_MODE, colourtrans_CURRENT_PALETTE,
|
||||
table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
|
||||
if (error) {
|
||||
LOG(("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess));
|
||||
free(table);
|
||||
return false;
|
||||
}
|
||||
|
||||
factors.xmul = width;
|
||||
factors.ymul = height;
|
||||
factors.xdiv = c->width * 2;
|
||||
factors.ydiv = c->height * 2;
|
||||
|
||||
xosspriteop_put_sprite_scaled(osspriteop_PTR,
|
||||
error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
|
||||
area,
|
||||
(osspriteop_id)((char*)(c->data.sprite.data) +
|
||||
area->first),
|
||||
x, (int)(y - height),
|
||||
osspriteop_USE_MASK | osspriteop_USE_PALETTE, &factors, table);
|
||||
if (error) {
|
||||
LOG(("xosspriteop_put_sprite_scaled: 0x%x: %s", error->errnum, error->errmess));
|
||||
free(table);
|
||||
return false;
|
||||
}
|
||||
|
||||
xfree(table);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
@ -21,7 +21,7 @@ bool sprite_create(struct content *c, const char *params[]);
|
||||
bool sprite_process_data(struct content *c, char *data, unsigned int size);
|
||||
bool sprite_convert(struct content *c, int width, int height);
|
||||
void sprite_destroy(struct content *c);
|
||||
void sprite_redraw(struct content *c, int x, int y,
|
||||
bool sprite_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);
|
||||
|
Loading…
Reference in New Issue
Block a user