2009-06-28 22:32:47 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
|
|
|
|
*
|
|
|
|
* Framebuffer interface
|
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <libnsfb.h>
|
|
|
|
#include <libnsfb_plot.h>
|
|
|
|
#include <libnsfb_event.h>
|
|
|
|
#include <libnsfb_cursor.h>
|
|
|
|
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "desktop/browser.h"
|
2011-11-21 12:45:08 +04:00
|
|
|
#include "image/bitmap.h"
|
2009-06-28 22:32:47 +04:00
|
|
|
|
|
|
|
#include "framebuffer/gui.h"
|
|
|
|
#include "framebuffer/fbtk.h"
|
|
|
|
#include "framebuffer/framebuffer.h"
|
|
|
|
#include "framebuffer/font.h"
|
|
|
|
|
|
|
|
/* netsurf framebuffer library handle */
|
|
|
|
static nsfb_t *nsfb;
|
|
|
|
|
|
|
|
|
2009-07-14 14:03:58 +04:00
|
|
|
static bool
|
|
|
|
framebuffer_plot_disc(int x, int y, int radius, const plot_style_t *style)
|
|
|
|
{
|
|
|
|
nsfb_bbox_t ellipse;
|
|
|
|
ellipse.x0 = x - radius;
|
|
|
|
ellipse.y0 = y - radius;
|
|
|
|
ellipse.x1 = x + radius;
|
|
|
|
ellipse.y1 = y + radius;
|
|
|
|
|
|
|
|
if (style->fill_type != PLOT_OP_TYPE_NONE) {
|
|
|
|
nsfb_plot_ellipse_fill(nsfb, &ellipse, style->fill_colour);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
|
|
|
|
nsfb_plot_ellipse(nsfb, &ellipse, style->stroke_colour);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
framebuffer_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style)
|
|
|
|
{
|
|
|
|
return nsfb_plot_arc(nsfb, x, y, radius, angle1, angle2, style->fill_colour);
|
|
|
|
}
|
|
|
|
|
2010-07-07 22:08:17 +04:00
|
|
|
static bool
|
|
|
|
framebuffer_plot_polygon(const int *p, unsigned int n, const plot_style_t *style)
|
2009-07-14 14:03:58 +04:00
|
|
|
{
|
|
|
|
return nsfb_plot_polygon(nsfb, p, n, style->fill_colour);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-21 14:59:53 +04:00
|
|
|
#ifdef FB_USE_FREETYPE
|
2010-07-07 22:08:17 +04:00
|
|
|
static bool
|
|
|
|
framebuffer_plot_text(int x, int y, const char *text, size_t length,
|
2009-07-21 14:59:53 +04:00
|
|
|
const plot_font_style_t *fstyle)
|
2009-06-28 22:32:47 +04:00
|
|
|
{
|
|
|
|
uint32_t ucs4;
|
|
|
|
size_t nxtchr = 0;
|
|
|
|
FT_Glyph glyph;
|
|
|
|
FT_BitmapGlyph bglyph;
|
|
|
|
nsfb_bbox_t loc;
|
|
|
|
|
|
|
|
while (nxtchr < length) {
|
|
|
|
ucs4 = utf8_to_ucs4(text + nxtchr, length - nxtchr);
|
|
|
|
nxtchr = utf8_next(text, length, nxtchr);
|
|
|
|
|
2009-07-21 14:59:53 +04:00
|
|
|
glyph = fb_getglyph(fstyle, ucs4);
|
2009-06-28 22:32:47 +04:00
|
|
|
if (glyph == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (glyph->format == FT_GLYPH_FORMAT_BITMAP) {
|
|
|
|
bglyph = (FT_BitmapGlyph)glyph;
|
|
|
|
|
|
|
|
loc.x0 = x + bglyph->left;
|
|
|
|
loc.y0 = y - bglyph->top;
|
|
|
|
loc.x1 = loc.x0 + bglyph->bitmap.width;
|
|
|
|
loc.y1 = loc.y0 + bglyph->bitmap.rows;
|
|
|
|
|
|
|
|
/* now, draw to our target surface */
|
|
|
|
if (bglyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) {
|
|
|
|
nsfb_plot_glyph1(nsfb,
|
|
|
|
&loc,
|
|
|
|
bglyph->bitmap.buffer,
|
|
|
|
bglyph->bitmap.pitch,
|
2009-07-21 14:59:53 +04:00
|
|
|
fstyle->foreground);
|
2009-06-28 22:32:47 +04:00
|
|
|
} else {
|
|
|
|
nsfb_plot_glyph8(nsfb,
|
|
|
|
&loc,
|
|
|
|
bglyph->bitmap.buffer,
|
|
|
|
bglyph->bitmap.pitch,
|
2009-07-21 14:59:53 +04:00
|
|
|
fstyle->foreground);
|
2009-06-28 22:32:47 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
x += glyph->advance.x >> 16;
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
#else
|
2009-07-21 14:59:53 +04:00
|
|
|
static bool framebuffer_plot_text(int x, int y, const char *text, size_t length,
|
|
|
|
const plot_font_style_t *fstyle)
|
2009-06-28 22:32:47 +04:00
|
|
|
{
|
2014-05-07 00:31:05 +04:00
|
|
|
enum fb_font_style style = fb_get_font_style(fstyle);
|
2014-08-01 12:50:31 +04:00
|
|
|
int size = fb_get_font_size(fstyle);
|
2014-05-07 00:31:05 +04:00
|
|
|
const uint8_t *chrp;
|
|
|
|
size_t nxtchr = 0;
|
2009-06-28 22:32:47 +04:00
|
|
|
nsfb_bbox_t loc;
|
2014-05-07 00:31:05 +04:00
|
|
|
uint32_t ucs4;
|
2014-08-01 12:50:31 +04:00
|
|
|
int p = FB_FONT_PITCH * size;
|
|
|
|
int w = FB_FONT_WIDTH * size;
|
|
|
|
int h = FB_FONT_HEIGHT * size;
|
2009-06-28 22:32:47 +04:00
|
|
|
|
2014-08-01 12:50:31 +04:00
|
|
|
y -= ((h * 3) / 4);
|
2014-05-07 00:31:05 +04:00
|
|
|
/* the coord is the bottom-left of the pixels offset by 1 to make
|
|
|
|
* it work since fb coords are the top-left of pixels */
|
|
|
|
y += 1;
|
2009-06-28 22:32:47 +04:00
|
|
|
|
2014-05-07 00:31:05 +04:00
|
|
|
while (nxtchr < length) {
|
|
|
|
ucs4 = utf8_to_ucs4(text + nxtchr, length - nxtchr);
|
|
|
|
nxtchr = utf8_next(text, length, nxtchr);
|
2009-06-28 22:32:47 +04:00
|
|
|
|
2014-06-18 16:12:08 +04:00
|
|
|
if (!codepoint_displayable(ucs4))
|
|
|
|
continue;
|
|
|
|
|
2009-06-28 22:32:47 +04:00
|
|
|
loc.x0 = x;
|
|
|
|
loc.y0 = y;
|
2014-08-01 12:50:31 +04:00
|
|
|
loc.x1 = loc.x0 + w;
|
|
|
|
loc.y1 = loc.y0 + h;
|
2009-06-28 22:32:47 +04:00
|
|
|
|
2014-08-01 12:50:31 +04:00
|
|
|
chrp = fb_get_glyph(ucs4, style, size);
|
|
|
|
nsfb_plot_glyph1(nsfb, &loc, chrp, p, fstyle->foreground);
|
2009-06-28 22:32:47 +04:00
|
|
|
|
2014-08-01 12:50:31 +04:00
|
|
|
x += w;
|
2009-06-28 22:32:47 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static bool
|
2009-06-30 17:02:23 +04:00
|
|
|
framebuffer_plot_bitmap(int x, int y,
|
2009-06-28 22:32:47 +04:00
|
|
|
int width, int height,
|
|
|
|
struct bitmap *bitmap, colour bg,
|
2009-06-30 17:02:23 +04:00
|
|
|
bitmap_flags_t flags)
|
2009-06-28 22:32:47 +04:00
|
|
|
{
|
2009-06-30 17:02:23 +04:00
|
|
|
nsfb_bbox_t loc;
|
2009-06-28 22:32:47 +04:00
|
|
|
nsfb_bbox_t clipbox;
|
2009-06-30 17:02:23 +04:00
|
|
|
bool repeat_x = (flags & BITMAPF_REPEAT_X);
|
|
|
|
bool repeat_y = (flags & BITMAPF_REPEAT_Y);
|
2011-11-21 12:45:08 +04:00
|
|
|
int bmwidth;
|
|
|
|
int bmheight;
|
2013-10-29 03:05:48 +04:00
|
|
|
int bmstride;
|
|
|
|
enum nsfb_format_e bmformat;
|
2011-11-21 12:45:08 +04:00
|
|
|
unsigned char *bmptr;
|
|
|
|
nsfb_t *bm = (nsfb_t *)bitmap;
|
2009-06-28 22:32:47 +04:00
|
|
|
|
|
|
|
/* x and y define coordinate of top left of of the initial explicitly
|
|
|
|
* placed tile. The width and height are the image scaling and the
|
|
|
|
* bounding box defines the extent of the repeat (which may go in all
|
|
|
|
* four directions from the initial tile).
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!(repeat_x || repeat_y)) {
|
2009-06-30 17:02:23 +04:00
|
|
|
/* Not repeating at all, so just plot it */
|
|
|
|
loc.x0 = x;
|
|
|
|
loc.y0 = y;
|
|
|
|
loc.x1 = loc.x0 + width;
|
|
|
|
loc.y1 = loc.y0 + height;
|
|
|
|
|
2011-11-21 12:45:08 +04:00
|
|
|
return nsfb_plot_copy(bm, NULL, nsfb, &loc);
|
2009-06-28 22:32:47 +04:00
|
|
|
}
|
|
|
|
|
2011-11-21 12:45:08 +04:00
|
|
|
nsfb_plot_get_clip(nsfb, &clipbox);
|
2013-10-29 03:05:48 +04:00
|
|
|
nsfb_get_geometry(bm, &bmwidth, &bmheight, &bmformat);
|
|
|
|
nsfb_get_buffer(bm, &bmptr, &bmstride);
|
2011-11-21 12:45:08 +04:00
|
|
|
|
2010-07-07 22:12:07 +04:00
|
|
|
/* Optimise tiled plots of 1x1 bitmaps by replacing with a flat fill
|
|
|
|
* of the area. Can only be done when image is fully opaque. */
|
2011-11-21 12:45:08 +04:00
|
|
|
if ((bmwidth == 1) && (bmheight == 1)) {
|
|
|
|
if ((*(nsfb_colour_t *)bmptr & 0xff000000) != 0) {
|
2010-07-07 22:12:07 +04:00
|
|
|
return nsfb_plot_rectangle_fill(nsfb, &clipbox,
|
2011-11-21 12:45:08 +04:00
|
|
|
*(nsfb_colour_t *)bmptr);
|
2010-07-07 22:12:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-09 00:38:48 +04:00
|
|
|
/* Optimise tiled plots of bitmaps scaled to 1x1 by replacing with
|
|
|
|
* a flat fill of the area. Can only be done when image is fully
|
|
|
|
* opaque. */
|
|
|
|
if ((width == 1) && (height == 1)) {
|
2011-11-21 12:45:08 +04:00
|
|
|
if (bitmap_get_opaque(bm)) {
|
2010-07-09 00:38:48 +04:00
|
|
|
/** TODO: Currently using top left pixel. Maybe centre
|
|
|
|
* pixel or average value would be better. */
|
|
|
|
return nsfb_plot_rectangle_fill(nsfb, &clipbox,
|
2011-11-21 12:45:08 +04:00
|
|
|
*(nsfb_colour_t *)bmptr);
|
2010-07-09 00:38:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-28 22:32:47 +04:00
|
|
|
/* get left most tile position */
|
|
|
|
if (repeat_x)
|
|
|
|
for (; x > clipbox.x0; x -= width);
|
|
|
|
|
|
|
|
/* get top most tile position */
|
|
|
|
if (repeat_y)
|
2009-06-30 17:02:23 +04:00
|
|
|
for (; y > clipbox.y0; y -= height);
|
2009-06-28 22:32:47 +04:00
|
|
|
|
2013-10-29 03:05:48 +04:00
|
|
|
/* set up top left tile location */
|
|
|
|
loc.x0 = x;
|
|
|
|
loc.y0 = y;
|
|
|
|
loc.x1 = loc.x0 + width;
|
|
|
|
loc.y1 = loc.y0 + height;
|
2009-06-30 17:02:23 +04:00
|
|
|
|
2013-10-29 03:05:48 +04:00
|
|
|
/* plot tiling across and down to extents */
|
|
|
|
nsfb_plot_bitmap_tiles(nsfb, &loc,
|
|
|
|
repeat_x ? ((clipbox.x1 - x) + width - 1) / width : 1,
|
|
|
|
repeat_y ? ((clipbox.y1 - y) + height - 1) / height : 1,
|
|
|
|
(nsfb_colour_t *)bmptr, bmwidth, bmheight,
|
|
|
|
bmstride * 8 / 32, bmformat == NSFB_FMT_ABGR8888);
|
2011-11-21 12:45:08 +04:00
|
|
|
|
2009-06-28 22:32:47 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-07-06 00:10:17 +04:00
|
|
|
static bool
|
2009-07-09 02:04:40 +04:00
|
|
|
framebuffer_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
|
2009-07-06 00:10:17 +04:00
|
|
|
{
|
2009-07-09 02:04:40 +04:00
|
|
|
nsfb_bbox_t rect;
|
|
|
|
bool dotted = false;
|
|
|
|
bool dashed = false;
|
2009-07-06 00:10:17 +04:00
|
|
|
|
2009-07-09 02:04:40 +04:00
|
|
|
rect.x0 = x0;
|
|
|
|
rect.y0 = y0;
|
|
|
|
rect.x1 = x1;
|
|
|
|
rect.y1 = y1;
|
2009-07-06 00:10:17 +04:00
|
|
|
|
2009-07-09 02:04:40 +04:00
|
|
|
if (style->fill_type != PLOT_OP_TYPE_NONE) {
|
|
|
|
nsfb_plot_rectangle_fill(nsfb, &rect, style->fill_colour);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
|
|
|
|
if (style->stroke_type == PLOT_OP_TYPE_DOT)
|
|
|
|
dotted = true;
|
|
|
|
|
|
|
|
if (style->stroke_type == PLOT_OP_TYPE_DASH)
|
|
|
|
dashed = true;
|
|
|
|
|
|
|
|
nsfb_plot_rectangle(nsfb, &rect, style->stroke_width, style->stroke_colour, dotted, dashed);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2009-07-06 00:10:17 +04:00
|
|
|
}
|
2009-06-28 22:32:47 +04:00
|
|
|
|
2009-07-10 22:36:49 +04:00
|
|
|
static bool
|
|
|
|
framebuffer_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
|
|
|
|
{
|
|
|
|
nsfb_bbox_t rect;
|
2010-01-09 03:12:23 +03:00
|
|
|
nsfb_plot_pen_t pen;
|
2009-07-10 22:36:49 +04:00
|
|
|
|
|
|
|
rect.x0 = x0;
|
|
|
|
rect.y0 = y0;
|
|
|
|
rect.x1 = x1;
|
|
|
|
rect.y1 = y1;
|
|
|
|
|
|
|
|
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
|
|
|
|
|
2010-01-09 03:12:23 +03:00
|
|
|
if (style->stroke_type == PLOT_OP_TYPE_DOT) {
|
|
|
|
pen.stroke_type = NFSB_PLOT_OPTYPE_PATTERN;
|
|
|
|
pen.stroke_pattern = 0xAAAAAAAA;
|
|
|
|
} else if (style->stroke_type == PLOT_OP_TYPE_DASH) {
|
|
|
|
pen.stroke_type = NFSB_PLOT_OPTYPE_PATTERN;
|
|
|
|
pen.stroke_pattern = 0xF0F0F0F0;
|
|
|
|
} else {
|
|
|
|
pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID;
|
|
|
|
}
|
2009-07-10 22:36:49 +04:00
|
|
|
|
2010-01-09 03:12:23 +03:00
|
|
|
pen.stroke_colour = style->stroke_colour;
|
|
|
|
pen.stroke_width = style->stroke_width;
|
|
|
|
nsfb_plot_line(nsfb, &rect, &pen);
|
2009-07-10 22:36:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-28 22:32:47 +04:00
|
|
|
|
|
|
|
static bool
|
|
|
|
framebuffer_plot_path(const float *p,
|
|
|
|
unsigned int n,
|
|
|
|
colour fill,
|
|
|
|
float width,
|
|
|
|
colour c,
|
|
|
|
const float transform[6])
|
|
|
|
{
|
|
|
|
LOG(("path unimplemented"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-09 03:12:23 +03:00
|
|
|
static bool
|
2011-02-15 01:05:39 +03:00
|
|
|
framebuffer_plot_clip(const struct rect *clip)
|
2010-01-09 03:12:23 +03:00
|
|
|
{
|
2011-02-15 01:05:39 +03:00
|
|
|
nsfb_bbox_t nsfb_clip;
|
|
|
|
nsfb_clip.x0 = clip->x0;
|
|
|
|
nsfb_clip.y0 = clip->y0;
|
|
|
|
nsfb_clip.x1 = clip->x1;
|
|
|
|
nsfb_clip.y1 = clip->y1;
|
2010-01-09 03:12:23 +03:00
|
|
|
|
2011-02-15 01:05:39 +03:00
|
|
|
return nsfb_plot_set_clip(nsfb, &nsfb_clip);
|
2010-01-09 03:12:23 +03:00
|
|
|
}
|
|
|
|
|
2011-06-30 19:48:07 +04:00
|
|
|
const struct plotter_table fb_plotters = {
|
2010-01-09 03:12:23 +03:00
|
|
|
.clip = framebuffer_plot_clip,
|
2009-07-14 14:03:58 +04:00
|
|
|
.arc = framebuffer_plot_arc,
|
|
|
|
.disc = framebuffer_plot_disc,
|
|
|
|
.line = framebuffer_plot_line,
|
|
|
|
.rectangle = framebuffer_plot_rectangle,
|
|
|
|
.polygon = framebuffer_plot_polygon,
|
2009-06-28 22:32:47 +04:00
|
|
|
.path = framebuffer_plot_path,
|
2009-07-14 14:03:58 +04:00
|
|
|
.bitmap = framebuffer_plot_bitmap,
|
|
|
|
.text = framebuffer_plot_text,
|
2009-06-28 22:32:47 +04:00
|
|
|
.option_knockout = true,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-07-27 01:12:55 +04:00
|
|
|
static bool framebuffer_format_from_bpp(int bpp, enum nsfb_format_e *fmt)
|
|
|
|
{
|
|
|
|
switch (bpp) {
|
|
|
|
case 32:
|
|
|
|
*fmt = NSFB_FMT_XRGB8888;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 24:
|
|
|
|
*fmt = NSFB_FMT_RGB888;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 16:
|
|
|
|
*fmt = NSFB_FMT_RGB565;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
*fmt = NSFB_FMT_I8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
*fmt = NSFB_FMT_I4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
*fmt = NSFB_FMT_I1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
LOG(("Bad bits per pixel (%d)\n", bpp));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-28 22:32:47 +04:00
|
|
|
|
|
|
|
nsfb_t *
|
2010-01-20 20:07:26 +03:00
|
|
|
framebuffer_initialise(const char *fename, int width, int height, int bpp)
|
2009-06-28 22:32:47 +04:00
|
|
|
{
|
2011-11-21 12:45:08 +04:00
|
|
|
enum nsfb_type_e fbtype;
|
|
|
|
enum nsfb_format_e fbfmt;
|
|
|
|
|
|
|
|
/* bpp is a proxy for the framebuffer format */
|
2014-07-27 01:12:55 +04:00
|
|
|
if (framebuffer_format_from_bpp(bpp, &fbfmt) == false) {
|
|
|
|
return NULL;
|
2011-11-21 12:45:08 +04:00
|
|
|
}
|
2009-06-28 22:32:47 +04:00
|
|
|
|
2011-11-21 12:45:08 +04:00
|
|
|
fbtype = nsfb_type_from_name(fename);
|
|
|
|
if (fbtype == NSFB_SURFACE_NONE) {
|
|
|
|
LOG(("The %s surface is not available from libnsfb\n", fename));
|
2009-06-28 22:32:47 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-11-21 12:45:08 +04:00
|
|
|
nsfb = nsfb_new(fbtype);
|
2009-06-28 22:32:47 +04:00
|
|
|
if (nsfb == NULL) {
|
2011-11-21 12:45:08 +04:00
|
|
|
LOG(("Unable to create %s fb surface\n", fename));
|
2009-06-28 22:32:47 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-11-21 12:45:08 +04:00
|
|
|
if (nsfb_set_geometry(nsfb, width, height, fbfmt) == -1) {
|
|
|
|
LOG(("Unable to set surface geometry\n"));
|
|
|
|
nsfb_free(nsfb);
|
2009-06-28 22:32:47 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsfb_cursor_init(nsfb);
|
|
|
|
|
2011-11-21 12:45:08 +04:00
|
|
|
if (nsfb_init(nsfb) == -1) {
|
|
|
|
LOG(("Unable to initialise nsfb surface\n"));
|
|
|
|
nsfb_free(nsfb);
|
2009-06-28 22:32:47 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsfb;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-27 01:12:55 +04:00
|
|
|
bool
|
|
|
|
framebuffer_resize(nsfb_t *nsfb, int width, int height, int bpp)
|
|
|
|
{
|
|
|
|
enum nsfb_format_e fbfmt;
|
|
|
|
|
|
|
|
/* bpp is a proxy for the framebuffer format */
|
|
|
|
if (framebuffer_format_from_bpp(bpp, &fbfmt) == false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsfb_set_geometry(nsfb, width, height, fbfmt) == -1) {
|
|
|
|
LOG(("Unable to change surface geometry\n"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-06-28 22:32:47 +04:00
|
|
|
void
|
|
|
|
framebuffer_finalise(void)
|
|
|
|
{
|
2011-11-21 12:45:08 +04:00
|
|
|
nsfb_free(nsfb);
|
2009-06-28 22:32:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-11-21 12:45:08 +04:00
|
|
|
framebuffer_set_cursor(struct fbtk_bitmap *bm)
|
2009-06-28 22:32:47 +04:00
|
|
|
{
|
2012-08-01 15:52:46 +04:00
|
|
|
return nsfb_cursor_set(nsfb, (nsfb_colour_t *)bm->pixdata, bm->width, bm->height, bm->width, bm->hot_x, bm->hot_y);
|
2009-06-28 22:32:47 +04:00
|
|
|
}
|
2011-11-21 12:45:08 +04:00
|
|
|
|
|
|
|
nsfb_t *framebuffer_set_surface(nsfb_t *new_nsfb)
|
|
|
|
{
|
|
|
|
nsfb_t *old_nsfb;
|
|
|
|
old_nsfb = nsfb;
|
|
|
|
nsfb = new_nsfb;
|
|
|
|
return old_nsfb;
|
|
|
|
}
|