27#include <libnsfb_plot.h>
28#include <libnsfb_event.h>
29#include <libnsfb_cursor.h>
59 nsfb_bbox_t nsfb_clip;
60 nsfb_clip.x0 =
clip->x0;
61 nsfb_clip.y0 =
clip->y0;
62 nsfb_clip.x1 =
clip->x1;
63 nsfb_clip.y1 =
clip->y1;
65 if (!nsfb_plot_set_clip(
nsfb, &nsfb_clip)) {
91 int x,
int y,
int radius,
int angle1,
int angle2)
93 if (!nsfb_plot_arc(
nsfb, x, y, radius, angle1, angle2, style->
fill_colour)) {
115 int x,
int y,
int radius)
118 ellipse.x0 = x - radius;
119 ellipse.y0 = y - radius;
120 ellipse.x1 = x + radius;
121 ellipse.y1 = y + radius;
161 pen.stroke_type = NFSB_PLOT_OPTYPE_PATTERN;
162 pen.stroke_pattern = 0xAAAAAAAA;
164 pen.stroke_type = NFSB_PLOT_OPTYPE_PATTERN;
165 pen.stroke_pattern = 0xF0F0F0F0;
167 pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID;
195 const struct rect *nsrect)
272 const float transform[6])
274 NSLOG(netsurf, INFO,
"path unimplemented");
319 enum nsfb_format_e bmformat;
320 unsigned char *bmptr;
321 nsfb_t *bm = (nsfb_t *)
bitmap;
329 if (!(repeat_x || repeat_y)) {
333 loc.x1 = loc.x0 +
width;
336 if (!nsfb_plot_copy(bm, NULL,
nsfb, &loc)) {
342 nsfb_plot_get_clip(
nsfb, &clipbox);
343 nsfb_get_geometry(bm, &bmwidth, &bmheight, &bmformat);
344 nsfb_get_buffer(bm, &bmptr, &bmstride);
348 if ((bmwidth == 1) && (bmheight == 1)) {
349 if ((*(nsfb_colour_t *)bmptr & 0xff000000) != 0) {
350 if (!nsfb_plot_rectangle_fill(
nsfb, &clipbox,
351 *(nsfb_colour_t *)bmptr)) {
365 if (!nsfb_plot_rectangle_fill(
nsfb, &clipbox,
366 *(nsfb_colour_t *)bmptr)) {
375 for (; x > clipbox.x0; x -=
width);
380 for (; y > clipbox.y0; y -=
height);
386 loc.x1 = loc.x0 +
width;
390 nsfb_plot_bitmap_tiles(
nsfb, &loc,
391 repeat_x ? ((clipbox.x1 - x) +
width - 1) /
width : 1,
392 repeat_y ? ((clipbox.y1 - y) +
height - 1) /
height : 1,
393 (nsfb_colour_t *)bmptr, bmwidth, bmheight,
394 bmstride * 8 / 32, bmformat == NSFB_FMT_ABGR8888);
400#ifdef FB_USE_FREETYPE
423 FT_BitmapGlyph bglyph;
426 while (nxtchr < length) {
434 if (glyph->format == FT_GLYPH_FORMAT_BITMAP) {
435 bglyph = (FT_BitmapGlyph)glyph;
437 loc.x0 = x + bglyph->left;
438 loc.y0 = y - bglyph->top;
439 loc.x1 = loc.x0 + bglyph->bitmap.width;
440 loc.y1 = loc.y0 + bglyph->bitmap.rows;
443 if (bglyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) {
444 nsfb_plot_glyph1(
nsfb,
446 bglyph->bitmap.buffer,
447 bglyph->bitmap.pitch,
450 nsfb_plot_glyph8(
nsfb,
452 bglyph->bitmap.buffer,
453 bglyph->bitmap.pitch,
457 x += glyph->advance.x >> 16;
500 while (nxtchr < length) {
535 .option_knockout =
true,
543 *fmt = NSFB_FMT_XRGB8888;
547 *fmt = NSFB_FMT_RGB888;
551 *fmt = NSFB_FMT_RGB565;
567 NSLOG(netsurf, INFO,
"Bad bits per pixel (%d)\n", bpp);
579 enum nsfb_type_e fbtype;
580 enum nsfb_format_e fbfmt;
587 fbtype = nsfb_type_from_name(
fename);
588 if (fbtype == NSFB_SURFACE_NONE) {
590 "The %s surface is not available from libnsfb\n",
fename);
594 nsfb = nsfb_new(fbtype);
596 NSLOG(netsurf, INFO,
"Unable to create %s fb surface\n",
fename);
601 NSLOG(netsurf, INFO,
"Unable to set surface geometry\n");
606 nsfb_cursor_init(
nsfb);
608 if (nsfb_init(
nsfb) == -1) {
609 NSLOG(netsurf, INFO,
"Unable to initialise nsfb surface\n");
621 enum nsfb_format_e fbfmt;
629 NSLOG(netsurf, INFO,
"Unable to change surface geometry\n");
Browser window creation and manipulation interface.
nserror
Enumeration of error codes.
@ NSERROR_INVALID
Invalid data.
FT_Glyph fb_getglyph(const plot_font_style_t *fstyle, uint32_t ucs4)
const uint8_t * fb_get_glyph(uint32_t ucs4, enum fb_font_style style, int scale)
int fb_get_font_size(const plot_font_style_t *fstyle)
enum fb_font_style fb_get_font_style(const plot_font_style_t *fstyle)
#define codepoint_displayable(u)
static const char * fename
static nserror framebuffer_plot_path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
nsfb_t * framebuffer_initialise(const char *fename, int width, int height, int bpp)
bool framebuffer_resize(nsfb_t *nsfb, int width, int height, int bpp)
static bool framebuffer_format_from_bpp(int bpp, enum nsfb_format_e *fmt)
static nserror framebuffer_plot_line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
const struct plotter_table fb_plotters
framebuffer plot operation table
static nserror framebuffer_plot_bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
nsfb_t * framebuffer_set_surface(nsfb_t *new_nsfb)
Set framebuffer surface to render into.
static nserror framebuffer_plot_polygon(const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
Plot a polygon.
static nserror framebuffer_plot_text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
static nserror framebuffer_plot_arc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius, int angle1, int angle2)
Plots an arc.
static nserror framebuffer_plot_clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
static nserror framebuffer_plot_rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *nsrect)
Plots a rectangle.
void framebuffer_finalise(void)
bool framebuffer_set_cursor(struct fbtk_bitmap *bm)
static nserror framebuffer_plot_disc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
Plots a circle.
bool framebuffer_bitmap_get_opaque(void *bitmap)
Gets weather a bitmap should be plotted opaque.
Generic bitmap handling interface.
Target independent plotting interface.
unsigned long bitmap_flags_t
#define NSLOG(catname, level, logmsg, args...)
#define plot_style_fixed_to_int(v)
@ PLOT_OP_TYPE_NONE
No operation.
@ PLOT_OP_TYPE_DASH
Dashed plot.
@ PLOT_OP_TYPE_DOT
Dotted plot.
Interface to utility string handling.
RISC OS wimp toolkit bitmap.
framebuffer toolkit bitmaps
colour foreground
Colour of text.
Plot style for stroke/fill plotters.
colour fill_colour
Colour of fill.
plot_style_fixed stroke_width
Width of stroke, in pixels.
plot_operation_type_t fill_type
Fill plot type.
colour stroke_colour
Colour of stroke.
plot_operation_type_t stroke_type
Stroke plot type.
Plotter operations table.
nserror(* clip)(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
uint32_t colour
Colour type: XBGR.
struct rect rect
Rectangle coordinates.
uint32_t utf8_to_ucs4(const char *s_in, size_t l)
Convert a UTF-8 multibyte sequence into a single UCS4 character.
size_t utf8_next(const char *s, size_t l, size_t o)
Find next legal UTF-8 char in string.
UTF-8 manipulation functions (interface).
Interface to a number of general purpose functionality.
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.