diff options
author | Vincent Sanders <vince@netsurf-browser.org> | 2011-11-21 08:44:10 +0000 |
---|---|---|
committer | Vincent Sanders <vince@netsurf-browser.org> | 2011-11-21 08:44:10 +0000 |
commit | 2dd32c7adb7116f1ad9ab2632d9fcf57a31e9fa2 (patch) | |
tree | 3528ebeb39ee0aadaf7faf0259b583b26172ed5c /src/plot/api.c | |
parent | 81ad700162a2fa639a69c1c6e3969ed8f7b3f63b (diff) | |
download | libnsfb-2dd32c7adb7116f1ad9ab2632d9fcf57a31e9fa2.tar.gz libnsfb-2dd32c7adb7116f1ad9ab2632d9fcf57a31e9fa2.tar.bz2 |
Improve API to allow for RAM surfaces instead of direct blitting
Improve and update tests
Fix RAM surface
Fix VNC surface
svn path=/trunk/libnsfb/; revision=13158
Diffstat (limited to 'src/plot/api.c')
-rw-r--r-- | src/plot/api.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/plot/api.c b/src/plot/api.c index f5c16f3..77559cb 100644 --- a/src/plot/api.c +++ b/src/plot/api.c @@ -126,9 +126,41 @@ bool nsfb_plot_ellipse_fill(nsfb_t *nsfb, nsfb_bbox_t *ellipse, nsfb_colour_t c) return nsfb->plotter_fns->ellipse_fill(nsfb, ellipse, c); } -bool nsfb_plot_copy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox) +/* copy an area of surface from one location to another. + * + * @warning This implementation is woefully incomplete! + */ +bool +nsfb_plot_copy(nsfb_t *srcfb, + nsfb_bbox_t *srcbox, + nsfb_t *dstfb, + nsfb_bbox_t *dstbox) { - return nsfb->plotter_fns->copy(nsfb, srcbox, dstbox); + bool trans = false; + nsfb_colour_t srccol; + + if (srcfb == dstfb) { + return dstfb->plotter_fns->copy(srcfb, srcbox, dstbox); + } + + if (srcfb->format == NSFB_FMT_ABGR8888) { + trans = true; + } + + if ((srcfb->width == 1) && (srcfb->height == 1)) { + srccol = *(nsfb_colour_t *)(srcfb->ptr); + + /* check for completely transparent */ + if ((srccol & 0xff000000) == 0) + return true; + + /* completely opaque pixels can be replaced with fill */ + if ((srccol & 0xff000000) == 0xff) + return dstfb->plotter_fns->fill(dstfb, dstbox, srccol); + } + + return dstfb->plotter_fns->bitmap(dstfb, dstbox, (const nsfb_colour_t *)srcfb->ptr, srcfb->width, srcfb->height, (srcfb->linelen * 8) / srcfb->bpp, trans); + } bool nsfb_plot_bitmap(nsfb_t *nsfb, const nsfb_bbox_t *loc, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride, bool alpha) @@ -172,3 +204,10 @@ bool nsfb_plot_path(nsfb_t *nsfb, int pathc, nsfb_plot_pathop_t *pathop, nsfb_pl { return nsfb->plotter_fns->path(nsfb, pathc, pathop, pen); } + +/* + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * End: + */ |