Improve bitmap plotter API

svn path=/trunk/netsurf/; revision=8195
This commit is contained in:
Vincent Sanders 2009-06-30 13:02:23 +00:00
parent 38356d46ff
commit aa26843411
20 changed files with 297 additions and 412 deletions

View File

@ -60,22 +60,18 @@ struct bfbitmap {
struct plotter_table plot;
const struct plotter_table amiplot = {
ami_clg,
ami_rectangle,
ami_line,
ami_polygon,
ami_fill,
ami_clip,
ami_text,
ami_disc,
ami_arc,
ami_bitmap,
ami_bitmap_tile,
NULL, //ami_group_start,
NULL, //ami_group_end,
NULL, //ami_flush, // optional
ami_path,
true // option_knockout
.clg = ami_clg,
.rectangle = ami_rectangle,
.line = ami_line,
.polygon = ami_polygon,
.fill = ami_fill,
.clip = ami_clip,
.text = ami_text,
.disc = ami_disc,
.arc = ami_arc,
.bitmap = ami_bitmap_tile,
.path = ami_path,
.option_knockout = true,
};
#ifdef NS_AMIGA_CAIRO
@ -360,8 +356,7 @@ CommonFuncsPPC.lha */
return true;
}
bool ami_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content)
static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitmap)
{
struct BitMap *tbm;
@ -419,15 +414,17 @@ bool ami_bitmap(int x, int y, int width, int height,
bool ami_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content)
bitmap_flags_t flags)
{
int xf,yf,xm,ym,oy,ox;
struct BitMap *tbm = NULL;
struct Hook *bfh = NULL;
struct bfbitmap bfbm;
bool repeat_x = (flags & BITMAPF_REPEAT_X);
bool repeat_y = (flags & BITMAPF_REPEAT_Y);
if(!(repeat_x || repeat_y))
return ami_bitmap(x, y, width, height, bitmap, bg, content);
return ami_bitmap(x, y, width, height, bitmap);
tbm = ami_getcachenativebm(bitmap,width,height,currp->BitMap);

View File

@ -35,11 +35,9 @@ bool ami_text(int x, int y, const struct css_style *style,
bool ami_disc(int x, int y, int radius, colour c, bool filled);
bool ami_arc(int x, int y, int radius, int angle1, int angle2,
colour c);
bool ami_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,struct content *content);
bool ami_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y,struct content *content);
bitmap_flags_t flags);
bool ami_group_start(const char *name);
bool ami_group_end(void);
bool ami_flush(void);

View File

@ -78,10 +78,8 @@ static bool nsbeos_plot_disc(int x, int y, int radius, colour c, bool filled);
static bool nsbeos_plot_arc(int x, int y, int radius, int angle1, int angle2,
colour c);
static bool nsbeos_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content);
static bool nsbeos_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content);
bitmap_flags_t flags);
#if 0 /* GTK */
static GdkRectangle cliprect;
@ -107,7 +105,6 @@ const struct plotter_table nsbeos_plotters = {
nsbeos_plot_disc,
nsbeos_plot_arc,
nsbeos_plot_bitmap,
nsbeos_plot_bitmap_tile,
NULL,
NULL,
NULL,
@ -583,28 +580,21 @@ static bool nsbeos_plot_bbitmap(int x, int y, int width, int height,
return true;
}
bool nsbeos_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content)
{
BBitmap *b = nsbeos_bitmap_get_primary(bitmap);
return nsbeos_plot_bbitmap(x, y, width, height, b, bg);
#if 0 /* GTK */
GdkPixbuf *pixbuf = gtk_bitmap_get_primary(bitmap);
return nsbeos_plot_pixbuf(x, y, width, height, pixbuf, bg);
#endif
}
bool nsbeos_plot_bitmap_tile(int x, int y, int width, int height,
bool nsbeos_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content)
bitmap_flags_t flags)
{
int doneheight = 0, donewidth = 0;
BBitmap *primary;
BBitmap *pretiled;
bool repeat_x = (flags & BITMAPF_REPEAT_X);
bool repeat_y = (flags & BITMAPF_REPEAT_Y);
if (!(repeat_x || repeat_y)) {
/* Not repeating at all, so just pass it on */
return nsbeos_plot_bitmap(x,y,width,height,bitmap,bg,content);
/* Not repeating at all, so just plot it */
primary = nsbeos_bitmap_get_primary(bitmap);
return nsbeos_plot_bbitmap(x, y, width, height, primary, bg);
}
if (repeat_x && !repeat_y)

View File

@ -635,7 +635,7 @@ bool history_redraw_entry(struct history *history,
}
if (!plot.bitmap(entry->x + xoffset, entry->y + yoffset, WIDTH, HEIGHT,
entry->bitmap, 0xffffff, NULL))
entry->bitmap, 0xffffff, 0))
return false;
if (!plot.rectangle(entry->x - 1 + xoffset, entry->y - 1 + yoffset,
WIDTH + 1, HEIGHT + 1,

View File

@ -83,7 +83,7 @@ struct knockout_entry;
static void knockout_set_plotters(void);
static void knockout_calculate(int x0, int y0, int x1, int y1, struct knockout_box *box);
static bool knockout_plot_fill_recursive(struct knockout_box *box, colour c);
static bool knockout_plot_bitmap_tile_recursive(struct knockout_box *box,
static bool knockout_plot_bitmap_recursive(struct knockout_box *box,
struct knockout_entry *entry);
static bool knockout_plot_clg(colour c);
@ -101,10 +101,8 @@ static bool knockout_plot_disc(int x, int y, int radius, colour colour, bool fil
static bool knockout_plot_arc(int x, int y, int radius, int angle1, int angle2,
colour c);
static bool knockout_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content);
static bool knockout_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content);
bitmap_flags_t flags);
static bool knockout_plot_flush(void);
static bool knockout_plot_group_start(const char *name);
static bool knockout_plot_group_end(void);
@ -113,22 +111,21 @@ static bool knockout_plot_path(const float *p, unsigned int n, colour fill,
const struct plotter_table knockout_plotters = {
knockout_plot_clg,
knockout_plot_rectangle,
knockout_plot_line,
knockout_plot_polygon,
knockout_plot_fill,
knockout_plot_clip,
knockout_plot_text,
knockout_plot_disc,
knockout_plot_arc,
knockout_plot_bitmap,
knockout_plot_bitmap_tile,
knockout_plot_group_start,
knockout_plot_group_end,
knockout_plot_flush,
knockout_plot_path,
true
.clg = knockout_plot_clg,
.rectangle = knockout_plot_rectangle,
.line = knockout_plot_line,
.polygon = knockout_plot_polygon,
.fill = knockout_plot_fill,
.clip = knockout_plot_clip,
.text = knockout_plot_text,
.disc = knockout_plot_disc,
.arc = knockout_plot_arc,
.bitmap = knockout_plot_bitmap,
.group_start = knockout_plot_group_start,
.group_end = knockout_plot_group_end,
.flush = knockout_plot_flush,
.path = knockout_plot_path,
.option_knockout = true,
};
@ -142,8 +139,7 @@ typedef enum {
KNOCKOUT_PLOT_TEXT,
KNOCKOUT_PLOT_DISC,
KNOCKOUT_PLOT_ARC,
KNOCKOUT_PLOT_BITMAP, /* knockout */
KNOCKOUT_PLOT_BITMAP_TILE, /* knockout, knocked out */
KNOCKOUT_PLOT_BITMAP, /* knockout, knocked out */
KNOCKOUT_PLOT_GROUP_START,
KNOCKOUT_PLOT_GROUP_END,
} knockout_type;
@ -238,19 +234,8 @@ struct knockout_entry {
int height;
struct bitmap *bitmap;
colour bg;
struct content *content;
bitmap_flags_t flags;
} bitmap;
struct {
int x;
int y;
int width;
int height;
struct bitmap *bitmap;
colour bg;
bool repeat_x;
bool repeat_y;
struct content *content;
} bitmap_tile;
struct {
const char *name;
} group_start;
@ -418,40 +403,26 @@ bool knockout_plot_flush(void)
knockout_entries[i].data.arc.c);
break;
case KNOCKOUT_PLOT_BITMAP:
success &= plot.bitmap(
knockout_entries[i].data.bitmap.x,
knockout_entries[i].data.bitmap.y,
knockout_entries[i].data.bitmap.width,
knockout_entries[i].data.bitmap.height,
knockout_entries[i].data.bitmap.bitmap,
knockout_entries[i].data.bitmap.bg,
knockout_entries[i].data.bitmap.content);
break;
case KNOCKOUT_PLOT_BITMAP_TILE:
box = knockout_entries[i].box->child;
if (box) {
success &= knockout_plot_bitmap_tile_recursive(box,
success &= knockout_plot_bitmap_recursive(box,
&knockout_entries[i]);
} else if (!knockout_entries[i].box->deleted) {
success &= plot.bitmap_tile(
success &= plot.bitmap(
knockout_entries[i].data.
bitmap_tile.x,
bitmap.x,
knockout_entries[i].data.
bitmap_tile.y,
bitmap.y,
knockout_entries[i].data.
bitmap_tile.width,
bitmap.width,
knockout_entries[i].data.
bitmap_tile.height,
bitmap.height,
knockout_entries[i].data.
bitmap_tile.bitmap,
bitmap.bitmap,
knockout_entries[i].data.
bitmap_tile.bg,
bitmap.bg,
knockout_entries[i].data.
bitmap_tile.repeat_x,
knockout_entries[i].data.
bitmap_tile.repeat_y,
knockout_entries[i].data.
bitmap_tile.content);
bitmap.flags);
}
break;
case KNOCKOUT_PLOT_GROUP_START:
@ -635,7 +606,7 @@ bool knockout_plot_fill_recursive(struct knockout_box *box, colour c)
}
bool knockout_plot_bitmap_tile_recursive(struct knockout_box *box,
bool knockout_plot_bitmap_recursive(struct knockout_box *box,
struct knockout_entry *entry)
{
bool success = true;
@ -645,21 +616,19 @@ bool knockout_plot_bitmap_tile_recursive(struct knockout_box *box,
if (parent->deleted)
continue;
if (parent->child)
knockout_plot_bitmap_tile_recursive(parent->child, entry);
knockout_plot_bitmap_recursive(parent->child, entry);
else {
success &= plot.clip(parent->bbox.x0,
parent->bbox.y0,
parent->bbox.x1,
parent->bbox.y1);
success &= plot.bitmap_tile(entry->data.bitmap_tile.x,
entry->data.bitmap_tile.y,
entry->data.bitmap_tile.width,
entry->data.bitmap_tile.height,
entry->data.bitmap_tile.bitmap,
entry->data.bitmap_tile.bg,
entry->data.bitmap_tile.repeat_x,
entry->data.bitmap_tile.repeat_y,
entry->data.bitmap_tile.content);
success &= plot.bitmap(entry->data.bitmap.x,
entry->data.bitmap.y,
entry->data.bitmap.width,
entry->data.bitmap.height,
entry->data.bitmap.bitmap,
entry->data.bitmap.bg,
entry->data.bitmap.flags);
}
}
return success;
@ -852,40 +821,11 @@ bool knockout_plot_arc(int x, int y, int radius, int angle1, int angle2, colour
return true;
}
bool knockout_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content)
{
int kx0, ky0, kx1, ky1;
/* opaque bitmaps knockout, but don't get knocked out */
if (bitmap_get_opaque(bitmap)) {
/* get our bounds */
kx0 = (x > clip_x0_cur) ? x : clip_x0_cur;
ky0 = (y > clip_y0_cur) ? y : clip_y0_cur;
kx1 = (x + width < clip_x1_cur) ? x + width : clip_x1_cur;
ky1 = (y + height< clip_y1_cur) ? y + height: clip_y1_cur;
if ((kx0 > clip_x1_cur) || (kx1 < clip_x0_cur) ||
(ky0 > clip_y1_cur) || (ky1 < clip_y0_cur))
return true;
knockout_calculate(kx0, ky0, kx1, ky1, NULL);
}
knockout_entries[knockout_entry_cur].data.bitmap.x = x;
knockout_entries[knockout_entry_cur].data.bitmap.y = y;
knockout_entries[knockout_entry_cur].data.bitmap.width = width;
knockout_entries[knockout_entry_cur].data.bitmap.height = height;
knockout_entries[knockout_entry_cur].data.bitmap.bitmap = bitmap;
knockout_entries[knockout_entry_cur].data.bitmap.bg = bg;
knockout_entries[knockout_entry_cur].data.bitmap.content = content;
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_BITMAP;
if (++knockout_entry_cur >= KNOCKOUT_ENTRIES)
knockout_plot_flush();
return true;
}
bool knockout_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content)
bitmap_flags_t flags)
{
int kx0, ky0, kx1, ky1;
@ -894,7 +834,7 @@ bool knockout_plot_bitmap_tile(int x, int y, int width, int height,
ky0 = clip_y0_cur;
kx1 = clip_x1_cur;
ky1 = clip_y1_cur;
if (!repeat_x) {
if (!(flags & BITMAPF_REPEAT_X)) {
if (x > kx0)
kx0 = x;
if (x + width < kx1)
@ -902,7 +842,7 @@ bool knockout_plot_bitmap_tile(int x, int y, int width, int height,
if ((kx0 > clip_x1_cur) || (kx1 < clip_x0_cur))
return true;
}
if (!repeat_y) {
if (!(flags & BITMAPF_REPEAT_Y)) {
if (y > ky0)
ky0 = y;
if (y + height < ky1)
@ -923,16 +863,14 @@ bool knockout_plot_bitmap_tile(int x, int y, int width, int height,
knockout_boxes[knockout_box_cur].next = knockout_list;
knockout_list = &knockout_boxes[knockout_box_cur];
knockout_entries[knockout_entry_cur].box = &knockout_boxes[knockout_box_cur];
knockout_entries[knockout_entry_cur].data.bitmap_tile.x = x;
knockout_entries[knockout_entry_cur].data.bitmap_tile.y = y;
knockout_entries[knockout_entry_cur].data.bitmap_tile.width = width;
knockout_entries[knockout_entry_cur].data.bitmap_tile.height = height;
knockout_entries[knockout_entry_cur].data.bitmap_tile.bitmap = bitmap;
knockout_entries[knockout_entry_cur].data.bitmap_tile.bg = bg;
knockout_entries[knockout_entry_cur].data.bitmap_tile.repeat_x = repeat_x;
knockout_entries[knockout_entry_cur].data.bitmap_tile.repeat_y = repeat_y;
knockout_entries[knockout_entry_cur].data.bitmap_tile.content = content;
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_BITMAP_TILE;
knockout_entries[knockout_entry_cur].data.bitmap.x = x;
knockout_entries[knockout_entry_cur].data.bitmap.y = y;
knockout_entries[knockout_entry_cur].data.bitmap.width = width;
knockout_entries[knockout_entry_cur].data.bitmap.height = height;
knockout_entries[knockout_entry_cur].data.bitmap.bitmap = bitmap;
knockout_entries[knockout_entry_cur].data.bitmap.bg = bg;
knockout_entries[knockout_entry_cur].data.bitmap.flags = flags;
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_BITMAP;
if ((++knockout_entry_cur >= KNOCKOUT_ENTRIES) ||
(++knockout_box_cur >= KNOCKOUT_BOXES))
knockout_plot_flush();

View File

@ -30,6 +30,10 @@
struct bitmap;
typedef unsigned long bitmap_flags_t;
#define BITMAPF_NONE 0
#define BITMAPF_REPEAT_X 1
#define BITMAPF_REPEAT_Y 2
/** Set of target specific plotting functions.
*
@ -108,10 +112,7 @@ struct plotter_table {
bool (*arc)(int x, int y, int radius, int angle1, int angle2, colour c);
bool (*bitmap)(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
struct content *content);
bool (*bitmap_tile)(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content);
bitmap_flags_t flags);
bool (*group_start)(const char *name); /**< optional, may be NULL */
bool (*group_end)(void); /**< optional, may be NULL */
bool (*flush)(void); /**< optional, may be NULL */

View File

@ -59,15 +59,13 @@ static bool pdf_plot_text(int x, int y, const struct css_style *style,
static bool pdf_plot_disc(int x, int y, int radius, colour c, bool filled);
static bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2,
colour c);
static bool pdf_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content);
static bool pdf_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content);
bitmap_flags_t flags);
static bool pdf_plot_path(const float *p, unsigned int n, colour fill, float width,
colour c, const float transform[6]);
static HPDF_Image pdf_extract_image(struct bitmap *bitmap, struct content *content);
static HPDF_Image pdf_extract_image(struct bitmap *bitmap);
static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no,
void *user_data);
@ -126,22 +124,18 @@ static int last_clip_x0, last_clip_y0, last_clip_x1, last_clip_y1;
static const struct print_settings *settings;
static const struct plotter_table pdf_plotters = {
pdf_plot_clg,
pdf_plot_rectangle,
pdf_plot_line,
pdf_plot_polygon,
pdf_plot_fill,
pdf_plot_clip,
pdf_plot_text,
pdf_plot_disc,
pdf_plot_arc,
pdf_plot_bitmap,
pdf_plot_bitmap_tile,
NULL,
NULL,
NULL,
pdf_plot_path,
false
.clg = pdf_plot_clg,
.rectangle = pdf_plot_rectangle,
.line = pdf_plot_line,
.polygon = pdf_plot_polygon,
.fill = pdf_plot_fill,
.clip = pdf_plot_clip,
.text = pdf_plot_text,
.disc = pdf_plot_disc,
.arc = pdf_plot_arc,
.bitmap = pdf_plot_bitmap_tile,
.path = pdf_plot_path,
.option_knockout = false,
};
const struct printer pdf_printer = {
@ -346,36 +340,10 @@ bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2, colour c)
return true;
}
bool pdf_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content)
{
HPDF_Image image;
#ifdef PDF_DEBUG
LOG(("%d %d %d %d %p 0x%x %p", x, y, width, height,
bitmap, bg, content));
#endif
if (width == 0 || height == 0)
return true;
apply_clip_and_mode(false, TRANSPARENT, TRANSPARENT, 0., DashPattern_eNone);
image = pdf_extract_image(bitmap, content);
if (!image)
return false;
HPDF_Page_DrawImage(pdf_page, image,
x, page_height - y - height,
width, height);
return true;
}
bool pdf_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content)
bitmap_flags_t flags)
{
HPDF_Image image;
HPDF_REAL current_x, current_y ;
@ -390,13 +358,13 @@ bool pdf_plot_bitmap_tile(int x, int y, int width, int height,
apply_clip_and_mode(false, TRANSPARENT, TRANSPARENT, 0., DashPattern_eNone);
image = pdf_extract_image(bitmap, content);
image = pdf_extract_image(bitmap);
if (!image)
return false;
/*The position of the next tile*/
max_width = (repeat_x) ? page_width : width;
max_height = (repeat_y) ? page_height : height;
max_width = (flags & BITMAPF_REPEAT_X) ? page_width : width;
max_height = (flags & BITMAPF_REPEAT_Y) ? page_height : height;
for (current_y = 0; current_y < max_height; current_y += height)
for (current_x = 0; current_x < max_width; current_x += width)
@ -408,9 +376,12 @@ bool pdf_plot_bitmap_tile(int x, int y, int width, int height,
return true;
}
HPDF_Image pdf_extract_image(struct bitmap *bitmap, struct content *content)
HPDF_Image pdf_extract_image(struct bitmap *bitmap)
{
HPDF_Image image = NULL;
struct content *content = NULL;
/* TODO - get content from bitmap pointer */
if (content) {
/*Not sure if I don't have to check if downloading has been

View File

@ -132,30 +132,18 @@ static bool framebuffer_plot_text(int x, int y, const struct css_style *style,
}
#endif
static bool framebuffer_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
struct content *content)
{
nsfb_bbox_t loc;
loc.x0 = x;
loc.y0 = y;
loc.x1 = loc.x0 + width;
loc.y1 = loc.y0 + height;
return nsfb_plot_bitmap(nsfb, &loc, (nsfb_colour_t *)bitmap->pixdata, bitmap->width, bitmap->height, bitmap->width, !bitmap->opaque);
}
static bool
framebuffer_plot_bitmap_tile(int x, int y,
framebuffer_plot_bitmap(int x, int y,
int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y,
struct content *content)
bitmap_flags_t flags)
{
int xf,yf;
nsfb_bbox_t loc;
nsfb_bbox_t clipbox;
bool repeat_x = (flags & BITMAPF_REPEAT_X);
bool repeat_y = (flags & BITMAPF_REPEAT_Y);
nsfb_plot_get_clip(nsfb, &clipbox);
@ -165,12 +153,17 @@ framebuffer_plot_bitmap_tile(int x, int y,
* four directions from the initial tile).
*/
LOG(("x %d, y %d, width %d, height %d, bitmap %p, repx %d repy %d content %p", x,y,width,height,bitmap,repeat_x, repeat_y, content));
if (!(repeat_x || repeat_y)) {
/* Not repeating at all, so just pass it on */
LOG(("Not repeating"));
return framebuffer_plot_bitmap(x, y, width, height, bitmap, bg,content);
/* Not repeating at all, so just plot it */
loc.x0 = x;
loc.y0 = y;
loc.x1 = loc.x0 + width;
loc.y1 = loc.y0 + height;
return nsfb_plot_bitmap(nsfb, &loc,
(nsfb_colour_t *)bitmap->pixdata,
bitmap->width, bitmap->height,
bitmap->width, !bitmap->opaque);
}
/* get left most tile position */
@ -179,13 +172,22 @@ framebuffer_plot_bitmap_tile(int x, int y,
/* get top most tile position */
if (repeat_y)
for (; y > clipbox.y0; y -= height)
;
for (; y > clipbox.y0; y -= height);
/* tile down and across to extents */
for (xf = x; xf < clipbox.x1; xf += width) {
for (yf = y; yf < clipbox.y1; yf += height) {
framebuffer_plot_bitmap(xf, yf, width, height, bitmap, bg, content);
loc.x0 = xf;
loc.y0 = yf;
loc.x1 = loc.x0 + width;
loc.y1 = loc.y0 + height;
nsfb_plot_bitmap(nsfb, &loc,
(nsfb_colour_t *)bitmap->pixdata,
bitmap->width, bitmap->height,
bitmap->width, !bitmap->opaque);
if (!repeat_y)
break;
}
@ -225,7 +227,6 @@ struct plotter_table plot = {
.disc = nsfb_lplot_disc,
.arc = nsfb_lplot_arc,
.bitmap = framebuffer_plot_bitmap,
.bitmap_tile = framebuffer_plot_bitmap_tile,
.flush = framebuffer_plot_flush,
.path = framebuffer_plot_path,
.option_knockout = true,

View File

@ -66,10 +66,8 @@ static bool nsgtk_plot_disc(int x, int y, int radius, colour c, bool filled);
static bool nsgtk_plot_arc(int x, int y, int radius, int angle1, int angle2,
colour c);
static bool nsgtk_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content);
static bool nsgtk_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content);
bitmap_flags_t flags);
static void nsgtk_set_solid(void); /**< Set for drawing solid lines */
static void nsgtk_set_dotted(void); /**< Set for drawing dotted lines */
static void nsgtk_set_dashed(void); /**< Set for drawing dashed lines */
@ -80,22 +78,18 @@ static float nsgtk_plot_scale = 1.0;
struct plotter_table plot;
const struct plotter_table nsgtk_plotters = {
nsgtk_plot_clg,
nsgtk_plot_rectangle,
nsgtk_plot_line,
nsgtk_plot_polygon,
nsgtk_plot_fill,
nsgtk_plot_clip,
nsgtk_plot_text,
nsgtk_plot_disc,
nsgtk_plot_arc,
nsgtk_plot_bitmap,
nsgtk_plot_bitmap_tile,
NULL,
NULL,
NULL,
nsgtk_plot_path,
true
.clg = nsgtk_plot_clg,
.rectangle = nsgtk_plot_rectangle,
.line = nsgtk_plot_line,
.polygon = nsgtk_plot_polygon,
.fill = nsgtk_plot_fill,
.clip = nsgtk_plot_clip,
.text = nsgtk_plot_text,
.disc = nsgtk_plot_disc,
.arc = nsgtk_plot_arc,
.bitmap = nsgtk_plot_bitmap,
.path = nsgtk_plot_path,
.option_knockout = true
};
@ -283,23 +277,20 @@ static bool nsgtk_plot_pixbuf(int x, int y, int width, int height,
}
bool nsgtk_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content)
{
GdkPixbuf *pixbuf = gtk_bitmap_get_primary(bitmap);
return nsgtk_plot_pixbuf(x, y, width, height, pixbuf, bg);
}
bool nsgtk_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content)
bitmap_flags_t flags)
{
int doneheight = 0, donewidth = 0;
GdkPixbuf *primary;
GdkPixbuf *pretiled = NULL;
bool repeat_x = (flags & BITMAPF_REPEAT_X);
bool repeat_y = (flags & BITMAPF_REPEAT_Y);
if (!(repeat_x || repeat_y)) {
/* Not repeating at all, so just pass it on */
return nsgtk_plot_bitmap(x,y,width,height,bitmap,bg,content);
/* Not repeating at all, so just pass it on */
primary = gtk_bitmap_get_primary(bitmap);
return nsgtk_plot_pixbuf(x, y, width, height, primary, bg);
}
if (repeat_x && !repeat_y)

View File

@ -63,10 +63,8 @@ static bool nsgtk_print_plot_disc(int x, int y, int radius, colour c,
static bool nsgtk_print_plot_arc(int x, int y, int radius, int angle1,
int angle2, colour c);
static bool nsgtk_print_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content);
static bool nsgtk_print_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content);
bitmap_flags_t flags);
static void nsgtk_print_set_solid(void); /**< Set for drawing solid lines */
static void nsgtk_print_set_dotted(void); /**< Set for drawing dotted lines */
@ -91,22 +89,18 @@ struct content *content_to_print;
static GdkRectangle cliprect;
static const struct plotter_table nsgtk_print_plotters = {
nsgtk_print_plot_clg,
nsgtk_print_plot_rectangle,
nsgtk_print_plot_line,
nsgtk_print_plot_polygon,
nsgtk_print_plot_fill,
nsgtk_print_plot_clip,
nsgtk_print_plot_text,
nsgtk_print_plot_disc,
nsgtk_print_plot_arc,
nsgtk_print_plot_bitmap,
nsgtk_print_plot_bitmap_tile,
NULL,
NULL,
NULL,
nsgtk_print_plot_path,
false
.clg = nsgtk_print_plot_clg,
.rectangle = nsgtk_print_plot_rectangle,
.line = nsgtk_print_plot_line,
.polygon = nsgtk_print_plot_polygon,
.fill = nsgtk_print_plot_fill,
.clip = nsgtk_print_plot_clip,
.text = nsgtk_print_plot_text,
.disc = nsgtk_print_plot_disc,
.arc = nsgtk_print_plot_arc,
.bitmap = nsgtk_print_plot_bitmap,
.path = nsgtk_print_plot_path,
.option_knockout = false,
};
static const struct printer gtk_printer = {
@ -324,26 +318,22 @@ static bool nsgtk_print_plot_pixbuf(int x, int y, int width, int height,
return true;
}
bool nsgtk_print_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content)
{
GdkPixbuf *pixbuf = gtk_bitmap_get_primary(bitmap);
return nsgtk_print_plot_pixbuf(x, y, width, height, pixbuf, bg);
}
bool nsgtk_print_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content)
bitmap_flags_t flags)
{
int doneheight = 0, donewidth = 0;
GdkPixbuf *primary;
GdkPixbuf *pretiled = NULL;
bool repeat_x = (flags & BITMAPF_REPEAT_X);
bool repeat_y = (flags & BITMAPF_REPEAT_Y);
if (!(repeat_x || repeat_y)) {
/* Not repeating at all, so just pass it on */
return nsgtk_print_plot_bitmap(x, y, width, height,
bitmap, bg, content);
primary = gtk_bitmap_get_primary(bitmap);
return nsgtk_print_plot_pixbuf(x, y, width, height, primary, bg);
}
if (repeat_x && !repeat_y)

View File

@ -123,7 +123,7 @@ bool nsbmp_redraw(struct content *c, int x, int y,
return false;
c->bitmap = c->data.bmp.bmp->bitmap;
return plot.bitmap(x, y, width, height, c->bitmap,
background_colour, c);
background_colour, BITMAPF_NONE);
}
@ -133,13 +133,21 @@ bool nsbmp_redraw_tiled(struct content *c, int x, int y,
float scale, colour background_colour,
bool repeat_x, bool repeat_y)
{
bitmap_flags_t flags = BITMAPF_NONE;
if (!c->data.bmp.bmp->decoded)
if (bmp_decode(c->data.bmp.bmp) != BMP_OK)
if (bmp_decode(c->data.bmp.bmp) != BMP_OK)
return false;
c->bitmap = c->data.bmp.bmp->bitmap;
return plot.bitmap_tile(x, y, width, height, c->bitmap,
background_colour, repeat_x, repeat_y, c);
if (repeat_x)
flags |= BITMAPF_REPEAT_X;
if (repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(x, y, width, height, c->bitmap,
background_colour, flags);
}

View File

@ -160,7 +160,7 @@ bool nsgif_redraw(struct content *c, int x, int y,
return false;
c->bitmap = c->data.gif.gif->frame_image;
return plot.bitmap(x, y, width, height, c->bitmap,
background_colour, c);
background_colour, BITMAPF_NONE);
}
@ -170,12 +170,20 @@ bool nsgif_redraw_tiled(struct content *c, int x, int y,
float scale, colour background_colour,
bool repeat_x, bool repeat_y)
{
bitmap_flags_t flags = BITMAPF_NONE;
if (c->data.gif.current_frame != c->data.gif.gif->decoded_frame)
if (nsgif_get_frame(c) != GIF_OK)
return false;
c->bitmap = c->data.gif.gif->frame_image;
return plot.bitmap_tile(x, y, width, height, c->bitmap,
background_colour, repeat_x, repeat_y, c);
if (repeat_x)
flags |= BITMAPF_REPEAT_X;
if (repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(x, y, width, height, c->bitmap, background_colour, flags);
}

View File

@ -111,7 +111,7 @@ bool nsico_redraw(struct content *c, int x, int y,
return false;
c->bitmap = bmp->bitmap;
return plot.bitmap(x, y, width, height, c->bitmap,
background_colour, c);
background_colour, BITMAPF_NONE);
}
@ -122,12 +122,20 @@ bool nsico_redraw_tiled(struct content *c, int x, int y,
bool repeat_x, bool repeat_y)
{
struct bmp_image *bmp = ico_find(c->data.ico.ico, width, height);
bitmap_flags_t flags = BITMAPF_NONE;
if (!bmp->decoded)
if (bmp_decode(bmp) != BMP_OK)
if (bmp_decode(bmp) != BMP_OK)
return false;
c->bitmap = bmp->bitmap;
return plot.bitmap_tile(x, y, width, height, c->bitmap,
background_colour, repeat_x, repeat_y, c);
if (repeat_x)
flags |= BITMAPF_REPEAT_X;
if (repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(x, y, width, height, c->bitmap, background_colour, flags);
}

View File

@ -242,7 +242,7 @@ bool nsjpeg_redraw(struct content *c, int x, int y,
float scale, colour background_colour)
{
return plot.bitmap(x, y, width, height,
c->bitmap, background_colour, c);
c->bitmap, background_colour, BITMAPF_NONE);
}
@ -256,9 +256,16 @@ bool nsjpeg_redraw_tiled(struct content *c, int x, int y,
float scale, colour background_colour,
bool repeat_x, bool repeat_y)
{
return plot.bitmap_tile(x, y, width, height,
bitmap_flags_t flags = BITMAPF_NONE;
if (repeat_x)
flags |= BITMAPF_REPEAT_X;
if (repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(x, y, width, height,
c->bitmap, background_colour,
repeat_x, repeat_y, c);
flags);
}

View File

@ -542,7 +542,7 @@ bool nsmng_redraw(struct content *c, int x, int y,
}
ret = plot.bitmap(x, y, width, height,
c->bitmap, background_colour, c);
c->bitmap, background_colour, BITMAPF_NONE);
/* Check if we need to restart the animation
*/
@ -560,6 +560,7 @@ bool nsmng_redraw_tiled(struct content *c, int x, int y,
bool repeat_x, bool repeat_y)
{
bool ret;
bitmap_flags_t flags = BITMAPF_NONE;
/* mark image as having been requested to display */
c->data.mng.displayed = true;
@ -569,9 +570,14 @@ bool nsmng_redraw_tiled(struct content *c, int x, int y,
c->data.mng.opaque_test_pending = false;
}
ret = plot.bitmap_tile(x, y, width, height,
if (repeat_x)
flags |= BITMAPF_REPEAT_X;
if (repeat_y)
flags |= BITMAPF_REPEAT_Y;
ret = plot.bitmap(x, y, width, height,
c->bitmap, background_colour,
repeat_x, repeat_y, c);
flags);
/* Check if we need to restart the animation
*/

View File

@ -270,12 +270,11 @@ bool nspng_redraw(struct content *c, int x, int y,
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale, colour background_colour)
{
if (c->bitmap != NULL) {
return plot.bitmap(x, y, width, height, c->bitmap,
background_colour, c);
}
if (c->bitmap == NULL)
return true;
return true;
return plot.bitmap(x, y, width, height, c->bitmap,
background_colour, BITMAPF_NONE);
}
bool nspng_redraw_tiled(struct content *c, int x, int y, int width, int height,
@ -283,12 +282,18 @@ bool nspng_redraw_tiled(struct content *c, int x, int y, int width, int height,
float scale, colour background_colour,
bool repeat_x, bool repeat_y)
{
if (c->bitmap != NULL) {
return plot.bitmap_tile(x, y, width, height, c->bitmap,
background_colour, repeat_x, repeat_y, c);
}
bitmap_flags_t flags = 0;
return true;
if (c->bitmap == NULL)
return true;
if (repeat_x)
flags |= BITMAPF_REPEAT_X;
if (repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(x, y, width, height, c->bitmap,
background_colour, flags);
}
#endif

View File

@ -183,7 +183,7 @@ bool rsvg_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, colour background_colour)
{
plot.bitmap(x, y, width, height, c->bitmap, background_colour, c);
plot.bitmap(x, y, width, height, c->bitmap, background_colour, BITMAPF_NONE);
return true;
}

View File

@ -53,31 +53,25 @@ static bool ro_plot_disc(int x, int y, int radius, colour colour, bool filled);
static bool ro_plot_arc(int x, int y, int radius, int angle1, int angle2,
colour c);
static bool ro_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content);
static bool ro_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content);
bitmap_flags_t flags);
struct plotter_table plot;
const struct plotter_table ro_plotters = {
ro_plot_clg,
ro_plot_rectangle,
ro_plot_line,
ro_plot_polygon,
ro_plot_fill,
ro_plot_clip,
ro_plot_text,
ro_plot_disc,
ro_plot_arc,
ro_plot_bitmap,
ro_plot_bitmap_tile,
NULL,
NULL,
NULL,
ro_plot_path,
true
.clg = ro_plot_clg,
.rectangle = ro_plot_rectangle,
.line = ro_plot_line,
.polygon = ro_plot_polygon,
.fill = ro_plot_fill,
.clip = ro_plot_clip,
.text = ro_plot_text,
.disc = ro_plot_disc,
.arc = ro_plot_arc,
.bitmap = ro_plot_bitmap,
.path = ro_plot_path,
.option_knockout = true,
};
int ro_plot_origin_x = 0;
@ -498,10 +492,15 @@ bool ro_plot_arc(int x, int y, int radius, int angle1, int angle2, colour c)
return true;
}
bool ro_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content)
struct bitmap *bitmap, colour bg,
bitmap_flags_t flags)
{
const uint8_t *buffer;
bool repeat_x = (flags & BITMAPF_REPEAT_X);
bool repeat_y = (flags & BITMAPF_REPEAT_Y);
buffer = bitmap_get_buffer(bitmap);
if (!buffer) {
@ -509,6 +508,7 @@ bool ro_plot_bitmap(int x, int y, int width, int height,
return false;
}
if (!(repeat_x || repeat_y)) {
return image_redraw(bitmap->sprite_area,
ro_plot_origin_x + x * 2,
ro_plot_origin_y - y * 2,
@ -519,20 +519,7 @@ bool ro_plot_bitmap(int x, int y, int width, int height,
false, false, false,
bitmap_get_opaque(bitmap) ? IMAGE_PLOT_TINCT_OPAQUE :
IMAGE_PLOT_TINCT_ALPHA);
}
bool ro_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content)
{
const uint8_t *buffer;
buffer = bitmap_get_buffer(bitmap);
if (!buffer) {
LOG(("bitmap_get_buffer failed"));
return false;
}
}
return image_redraw(bitmap->sprite_area,
ro_plot_origin_x + x * 2,

View File

@ -114,10 +114,7 @@ static bool print_fonts_plot_arc(int x, int y, int radius, int angle1, int angle
colour c);
static bool print_fonts_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
struct content *content);
static bool print_fonts_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content);
bitmap_flags_t flags);
static bool print_fonts_plot_path(const float *p, unsigned int n, colour fill, float width,
colour c, const float transform[6]);
static void print_fonts_callback(void *context,
@ -129,22 +126,18 @@ static void print_fonts_callback(void *context,
/** Plotter for print_declare_fonts(). All the functions do nothing except for
* print_fonts_plot_text, which records the fonts used. */
static const struct plotter_table print_fonts_plotters = {
print_fonts_plot_clg,
print_fonts_plot_rectangle,
print_fonts_plot_line,
print_fonts_plot_polygon,
print_fonts_plot_fill,
print_fonts_plot_clip,
print_fonts_plot_text,
print_fonts_plot_disc,
print_fonts_plot_arc,
print_fonts_plot_bitmap,
print_fonts_plot_bitmap_tile,
NULL,
NULL,
NULL,
print_fonts_plot_path,
false
.clg = print_fonts_plot_clg,
.rectangle = print_fonts_plot_rectangle,
.line = print_fonts_plot_line,
.polygon = print_fonts_plot_polygon,
.fill = print_fonts_plot_fill,
.clip = print_fonts_plot_clip,
.text = print_fonts_plot_text,
.disc = print_fonts_plot_disc,
.arc = print_fonts_plot_arc,
.bitmap = print_fonts_plot_bitmap,
.path = print_fonts_plot_path,
.option_knockout = false,
};
@ -838,32 +831,31 @@ bool print_fonts_plot_fill(int x0, int y0, int x1, int y1, colour c)
{
return true;
}
bool print_fonts_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1)
{
return true;
}
bool print_fonts_plot_disc(int x, int y, int radius, colour colour,
bool filled)
{
return true;
}
bool print_fonts_plot_arc(int x, int y, int radius, int angle1, int angle2,
colour c)
{
return true;
}
bool print_fonts_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content)
{
return true;
}
bool print_fonts_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content)
struct bitmap *bitmap, colour bg, bitmap_flags_t flags)
{
return true;
}
bool print_fonts_plot_path(const float *p, unsigned int n, colour fill, float width,
colour c, const float transform[6])
{

View File

@ -56,32 +56,27 @@ static bool ro_save_draw_disc(int x, int y, int radius, colour colour,
static bool ro_save_draw_arc(int x, int y, int radius, int angle1, int angle2,
colour c);
static bool ro_save_draw_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content);
static bool ro_save_draw_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content);
struct bitmap *bitmap, colour bg, bitmap_flags_t flags);
static bool ro_save_draw_group_start(const char *name);
static bool ro_save_draw_group_end(void);
static bool ro_save_draw_error(pencil_code code);
static const struct plotter_table ro_save_draw_plotters = {
ro_save_draw_clg,
ro_save_draw_rectangle,
ro_save_draw_line,
ro_save_draw_polygon,
ro_save_draw_fill,
ro_save_draw_clip,
ro_save_draw_text,
ro_save_draw_disc,
ro_save_draw_arc,
ro_save_draw_bitmap,
ro_save_draw_bitmap_tile,
ro_save_draw_group_start,
ro_save_draw_group_end,
NULL,
ro_save_draw_path,
false
.clg = ro_save_draw_clg,
.rectangle = ro_save_draw_rectangle,
.line = ro_save_draw_line,
.polygon = ro_save_draw_polygon,
.fill = ro_save_draw_fill,
.clip = ro_save_draw_clip,
.text = ro_save_draw_text,
.disc = ro_save_draw_disc,
.arc = ro_save_draw_arc,
.bitmap = ro_save_draw_bitmap,
.group_start = ro_save_draw_group_start,
.group_end = ro_save_draw_group_end,
.path = ro_save_draw_path,
.option_knockout = false,
};
static struct pencil_diagram *ro_save_draw_diagram;
@ -378,7 +373,7 @@ bool ro_save_draw_arc(int x, int y, int radius, int angle1, int angle2,
}
bool ro_save_draw_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg, struct content *content)
struct bitmap *bitmap, colour bg, bitmap_flags_t flags)
{
pencil_code code;
const uint8_t *buffer;
@ -400,14 +395,6 @@ bool ro_save_draw_bitmap(int x, int y, int width, int height,
}
bool ro_save_draw_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content)
{
return true;
}
bool ro_save_draw_group_start(const char *name)
{
pencil_code code;