Merged revisions 5309-5406,5409-5422 via svnmerge from

svn://svn.netsurf-browser.org/branches/vince/netsurf-fb

........
  r5309 | vince | 2008-09-13 10:59:10 +0100 (Sat, 13 Sep 2008) | 2 lines
  
  first stab at framebuffer frontend
........
  r5313 | vince | 2008-09-14 15:08:52 +0100 (Sun, 14 Sep 2008) | 2 lines
  
  add line plotters
........
  r5314 | vince | 2008-09-14 15:28:12 +0100 (Sun, 14 Sep 2008) | 2 lines
  
  add rectangle plot to 16bpp plotters
........
  r5315 | vince | 2008-09-14 19:58:57 +0100 (Sun, 14 Sep 2008) | 2 lines
  
  improve 16bpp image plot
........
  r5316 | vince | 2008-09-15 00:35:32 +0100 (Mon, 15 Sep 2008) | 2 lines
  
  abstract the os specific framebuffer init
........
  r5317 | vince | 2008-09-15 11:18:51 +0100 (Mon, 15 Sep 2008) | 2 lines
  
  first cut of linux frontend
........
  r5318 | vince | 2008-09-15 12:01:00 +0100 (Mon, 15 Sep 2008) | 2 lines
  
  remove junk includes
........
  r5319 | vince | 2008-09-15 12:09:02 +0100 (Mon, 15 Sep 2008) | 2 lines
  
  make plotters OS agnostic again
........
  r5322 | vince | 2008-09-15 15:55:01 +0100 (Mon, 15 Sep 2008) | 2 lines
  
  Linux frontend operates
........
  r5323 | vince | 2008-09-15 16:32:47 +0100 (Mon, 15 Sep 2008) | 2 lines
  
  abstract out OS specific input
........
  r5326 | vince | 2008-09-15 19:21:01 +0100 (Mon, 15 Sep 2008) | 2 lines
  
  Improve linux mode setting
........
  r5329 | vince | 2008-09-15 21:13:33 +0100 (Mon, 15 Sep 2008) | 2 lines
  
  improve text clipping
........
  r5339 | vince | 2008-09-16 00:07:57 +0100 (Tue, 16 Sep 2008) | 2 lines
  
  possibly fix text clipping issue
........
  r5342 | vince | 2008-09-16 00:39:36 +0100 (Tue, 16 Sep 2008) | 2 lines
  
  consolidate polygon plotters
........
  r5344 | dsilvers | 2008-09-16 10:21:06 +0100 (Tue, 16 Sep 2008) | 1 line
  
  Fix up the framebuffer target makefile a bit more, add some config options for it
........
  r5345 | dsilvers | 2008-09-16 10:22:19 +0100 (Tue, 16 Sep 2008) | 1 line
  
  Ensure the appropriate frontend is selected when building framebuffer
........
  r5346 | dsilvers | 2008-09-16 10:27:16 +0100 (Tue, 16 Sep 2008) | 1 line
  
  Update build system to support targetting separate framebuffer frontends in different build trees, update executable to be nsfb-blah
........
  r5350 | vince | 2008-09-16 17:15:04 +0100 (Tue, 16 Sep 2008) | 1 line
  
  Add -g to provide symbols for framebuffer link
........
  r5351 | vince | 2008-09-16 17:17:09 +0100 (Tue, 16 Sep 2008) | 1 line
  
  framebuffer scheduler now works, plotters tweaked, gui tracks window redraw requirements better, keypresses not duplicated under linux fb
........
  r5352 | dsilvers | 2008-09-16 17:38:53 +0100 (Tue, 16 Sep 2008) | 1 line
  
  Ensure we only allow one fetcher at a time
........
  r5361 | vince | 2008-09-17 11:48:44 +0100 (Wed, 17 Sep 2008) | 2 lines
  
  initial cursor support
........
  r5362 | vince | 2008-09-17 13:56:47 +0100 (Wed, 17 Sep 2008) | 2 lines
  
  add mouse handling
........
  r5363 | vince | 2008-09-17 14:14:44 +0100 (Wed, 17 Sep 2008) | 2 lines
  
  add framebuffer resources
........
  r5364 | vince | 2008-09-17 17:12:21 +0100 (Wed, 17 Sep 2008) | 2 lines
  
  add reasonable pointer
........
  r5366 | vince | 2008-09-17 17:17:25 +0100 (Wed, 17 Sep 2008) | 2 lines
  
  fix pointer alpha
........
  r5370 | vince | 2008-09-18 13:43:53 +0100 (Thu, 18 Sep 2008) | 2 lines
  
  warning squash and cleanup ready for trunk merge
........
  r5375 | vince | 2008-09-19 14:58:43 +0100 (Fri, 19 Sep 2008) | 2 lines
  
  Working mouse navigation
........
  r5377 | vince | 2008-09-20 14:06:22 +0100 (Sat, 20 Sep 2008) | 2 lines
  
  Improve scrolling
........
  r5378 | vince | 2008-09-20 14:46:46 +0100 (Sat, 20 Sep 2008) | 2 lines
  
  fix redraw issues with scrolling
........
  r5380 | vince | 2008-09-20 17:08:43 +0100 (Sat, 20 Sep 2008) | 3 lines
  
  Alter panning to use its own flag so it doesnt cause invalid redraw 
  operations 
........
  r5381 | vince | 2008-09-20 21:52:45 +0100 (Sat, 20 Sep 2008) | 2 lines
  
  add dummy framebuffer
........
  r5383 | vince | 2008-09-21 00:00:15 +0100 (Sun, 21 Sep 2008) | 2 lines
  
  fix segfault when cursor is off teh bottom of teh screen
........
  r5384 | vince | 2008-09-21 00:06:08 +0100 (Sun, 21 Sep 2008) | 2 lines
  
  fix off by one in pointer fix
........
  r5385 | vince | 2008-09-21 00:25:09 +0100 (Sun, 21 Sep 2008) | 2 lines
  
  when fixing bloody silly off by one errors remember to fix *both* references
........
  r5387 | vince | 2008-09-21 00:38:13 +0100 (Sun, 21 Sep 2008) | 2 lines
  
  last try at stopping the pointer segfault
........
  r5388 | vince | 2008-09-21 16:24:18 +0100 (Sun, 21 Sep 2008) | 2 lines
  
  improve vertical text clipping
........
  r5392 | vince | 2008-09-21 23:11:51 +0100 (Sun, 21 Sep 2008) | 2 lines
  
  Improve text plotters
........
  r5393 | vince | 2008-09-21 23:34:38 +0100 (Sun, 21 Sep 2008) | 2 lines
  
  fix 32bpp line plotting
........
  r5394 | vince | 2008-09-22 00:00:03 +0100 (Mon, 22 Sep 2008) | 2 lines
  
  Fix off by one error in line plotting clipping
........
  r5397 | vince | 2008-09-22 13:46:22 +0100 (Mon, 22 Sep 2008) | 2 lines
  
  Fix bitmap tileing
........
  r5398 | vince | 2008-09-22 17:46:02 +0100 (Mon, 22 Sep 2008) | 2 lines
  
  enable knockout renderer
........
  r5399 | vince | 2008-09-22 18:43:48 +0100 (Mon, 22 Sep 2008) | 2 lines
  
  ensure clipping region lies within window, caused by knockout renderer
........
  r5400 | vince | 2008-09-22 19:20:25 +0100 (Mon, 22 Sep 2008) | 2 lines
  
  update cursor to one swiped from X windows
........
  r5405 | vince | 2008-09-23 09:09:05 +0100 (Tue, 23 Sep 2008) | 2 lines
  
  fix vertical scroll limit
........
  r5412 | dsilvers | 2008-09-23 10:53:14 +0100 (Tue, 23 Sep 2008) | 1 line
  
  Revert noisy fetcher patch
........
  r5413 | dsilvers | 2008-09-23 10:58:00 +0100 (Tue, 23 Sep 2008) | 1 line
  
  Add header guards
........
  r5414 | dsilvers | 2008-09-23 11:31:31 +0100 (Tue, 23 Sep 2008) | 1 line
  
  Tidy the region clipping slightly
........
  r5416 | dsilvers | 2008-09-23 12:05:00 +0100 (Tue, 23 Sep 2008) | 1 line
  
  Rationalise how the framebuffer frontend finds resources and options
........
  r5418 | dsilvers | 2008-09-23 13:59:00 +0100 (Tue, 23 Sep 2008) | 1 line
  
  Ensure options are overridden after load, and squash an fb_gui.c warning
........
  r5419 | dsilvers | 2008-09-23 14:20:07 +0100 (Tue, 23 Sep 2008) | 1 line
  
  Support fb_mode and fb_device options
........
  r5420 | dsilvers | 2008-09-23 14:21:48 +0100 (Tue, 23 Sep 2008) | 1 line
  
  Support option_fb_device in the able frontend
........
  r5421 | dsilvers | 2008-09-23 14:25:17 +0100 (Tue, 23 Sep 2008) | 1 line
  
  Ensure target_blank is disabled
........
  r5422 | dsilvers | 2008-09-23 14:39:00 +0100 (Tue, 23 Sep 2008) | 1 line
  
  Rework linux fb frontend to support scanning and opening all event devices for input
........

svn path=/trunk/netsurf/; revision=5423
This commit is contained in:
Daniel Silverstone 2008-09-23 14:00:40 +00:00
parent 9de2adbdf1
commit 3f5d902edd
43 changed files with 9427 additions and 5 deletions

View File

@ -94,7 +94,9 @@ ifneq ($(TARGET),riscos)
ifneq ($(TARGET),beos)
ifneq ($(TARGET),debug)
ifneq ($(TARGET),amiga)
$(error Unknown TARGET "$(TARGET)", should either be "riscos", "gtk", "beos", "amiga" or "debug")
ifneq ($(TARGET),framebuffer)
$(error Unknown TARGET "$(TARGET)", should either be "riscos", "gtk", "beos", "amiga", "debug" or "framebuffer")
endif
endif
endif
endif
@ -156,7 +158,7 @@ else
endif
endif
OBJROOT := build-$(HOST)-$(TARGET)$(SUBTARGET)
OBJROOT = build-$(HOST)-$(TARGET)$(SUBTARGET)
# ----------------------------------------------------------------------------
# General flag setup
@ -439,6 +441,71 @@ ifeq ($(TARGET),amiga)
LDFLAGS += -lxml2 -lcurl -lm -lsocket -lpthread -lregex -lauto -lraauto -lssl -lcrypto -lamisslauto -mcrt=newlib
endif
# ----------------------------------------------------------------------------
# Framebuffer target setup
# ----------------------------------------------------------------------------
ifeq ($(TARGET),framebuffer)
$(eval $(call feature_enabled,MNG,-DWITH_MNG,-lmng,PNG support))
# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
NETSURF_FEATURE_RSVG_CFLAGS := -DWITH_RSVG
NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE
NETSURF_FEATURE_HUBBUB_CFLAGS := -DWITH_HUBBUB
NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
CFLAGS += '-DNETSURF_FB_RESPATH="$(NETSURF_FB_RESPATH_$(NETSURF_FB_FRONTEND))"'
CFLAGS += '-DNETSURF_FB_HOMEPATH="$(NETSURF_FB_HOMEPATH_$(NETSURF_FB_FRONTEND))"'
CFLAGS += -Dnsfb
ifeq ($(NETSURF_FB_FRONTEND),linux)
$(eval $(call pkg_config_find_and_add,RSVG,librsvg-2.0,SVG rendering))
$(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,RISC OS sprite rendering))
$(eval $(call pkg_config_find_and_add,HUBBUB,libhubbub,Hubbub HTML parser))
$(eval $(call pkg_config_find_and_add,BMP,libnsbmp,NetSurf BMP decoder))
$(eval $(call pkg_config_find_and_add,GIF,libnsgif,NetSurf GIF decoder))
CFLAGS += -std=c99 -g -I. -Dsmall $(WARNFLAGS) \
$(shell xml2-config --cflags) \
-D_BSD_SOURCE \
-D_XOPEN_SOURCE=600 \
-D_POSIX_C_SOURCE=200112L
LDFLAGS += -lxml2 -lz -ljpeg -lcurl -lm
LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl openssl)
SUBTARGET := -linux
endif
ifeq ($(NETSURF_FB_FRONTEND),able)
$(eval $(call feature_enabled,GIF,-DWITH_GIF,-lnsgif,NetSurf GIF decoder))
CC=arm-able-gcc
CFLAGS += -std=c99 -I. -I/usr/lib/able/include -Dsmall $(WARNFLAGS)
LDFLAGS += -lxml2 -lz -ljpeg -lcurl -lm
SUBTARGET := -able
endif
ifeq ($(NETSURF_FB_FRONTEND),dummy)
$(eval $(call pkg_config_find_and_add,RSVG,librsvg-2.0,SVG rendering))
$(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,RISC OS sprite rendering))
$(eval $(call pkg_config_find_and_add,HUBBUB,libhubbub,Hubbub HTML parser))
$(eval $(call pkg_config_find_and_add,BMP,libnsbmp,NetSurf BMP decoder))
$(eval $(call pkg_config_find_and_add,GIF,libnsgif,NetSurf GIF decoder))
CFLAGS += -std=c99 -g -I. $(WARNFLAGS) \
$(shell xml2-config --cflags) \
-D_BSD_SOURCE \
-D_XOPEN_SOURCE=600 \
-D_POSIX_C_SOURCE=200112L
LDFLAGS += -lxml2 -lz -ljpeg -lcurl -lm
LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl openssl)
SUBTARGET := -dummy
endif
endif
# ----------------------------------------------------------------------------
# Debug target setup
# ----------------------------------------------------------------------------

View File

@ -182,6 +182,33 @@ ifeq ($(TARGET),debug)
endif
# ----------------------------------------------------------------------------
# Framebuffer-target-specific options
# ----------------------------------------------------------------------------
ifeq ($(TARGET),framebuffer)
# Optimisation levels
CFLAGS += -O2 -Wuninitialized
# Framebuffer frontend.
# Valid values are: linux, able
NETSURF_FB_FRONTEND := linux
# Use libharu to enable PDF export and GTK printing support.
# Valid options: YES, NO
NETSURF_USE_HARU_PDF := NO
# Framebuffer frontends may have differing root paths for resources
# As such, these specify the resource path and config path.
NETSURF_FB_RESPATH_linux := /usr/share/netsurf/
NETSURF_FB_RESPATH_able := (tftpboot)/
NETSURF_FB_RESPATH_dummy := ./
NETSURF_FB_HOMEPATH_linux := ~/.netsurf/
NETSURF_FB_HOMEPATH_able := (tftpboot)/
NETSURF_FB_HOMEPATH_dummy := ./
endif
# Include any local overrides
-include Makefile.config.override

View File

@ -91,6 +91,26 @@ S_AMIGA := compat.c gui.c tree.c history.c hotlist.c schedule.c \
plotters.c object.c menu.c save_pdf.c
S_AMIGA := $(addprefix amiga/,$(S_AMIGA))
# S_FRAMEBUFFER are sources purely for the framebuffer build
S_FRAMEBUFFER := fb_gui.c tree.c history.c hotlist.c fb_schedule.c \
thumbnail.c misc.c fb_bitmap.c fb_font.c font_8x16.c \
fb_filetype.c login.c fb_cursor.c fb_plotters.c \
fb_8bpp_plotters.c fb_16bpp_plotters.c fb_32bpp_plotters.c \
fb_findfile.c
# fb_1bpp_plotters.c
ifeq ($(NETSURF_FB_FRONTEND),linux)
S_FRAMEBUFFER += fb_frontend_linuxfb.c
endif
ifeq ($(NETSURF_FB_FRONTEND),able)
S_FRAMEBUFFER += fb_frontend_ablefb.c
endif
ifeq ($(NETSURF_FB_FRONTEND),dummy)
S_FRAMEBUFFER += fb_frontend_dummy.c
endif
S_FRAMEBUFFER := $(addprefix framebuffer/,$(S_FRAMEBUFFER))
# Some extra rules for building the scanner etc.
css/css_enum.c css/css_enum.h: css/css_enums css/makeenum
$(VQ)echo "MAKEENUM: css"
@ -163,6 +183,11 @@ SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_AMIGA) $(S_PDF)
EXETARGET := NetSurf
endif
ifeq ($(TARGET),framebuffer)
SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_FRAMEBUFFER)
EXETARGET := nsfb$(SUBTARGET)
endif
ifeq ($(SOURCES),)
$(error Unable to build NetSurf, could not determine set of sources to build)
endif

View File

@ -31,6 +31,7 @@
#include <sys/types.h>
#include <regex.h>
#include <time.h>
#include <unistd.h>
#include <curl/curl.h> /* for curl_getdate() */
#include "utils/config.h"
#include "content/content.h"

View File

@ -35,12 +35,13 @@
#ifndef _NETSURF_CSS_CSS_H_
#define _NETSURF_CSS_CSS_H_
#include <stdint.h>
#include <stdbool.h>
#include <libxml/HTMLparser.h>
#include "css/css_enum.h"
typedef unsigned long colour; /* 0xbbggrr */
typedef uint32_t colour; /* 0xbbggrr */
#define TRANSPARENT 0x1000000
#define CSS_COLOR_INHERIT 0x2000000
#define CSS_COLOR_NONE 0x3000000

View File

@ -49,6 +49,8 @@
#include "beos/options.h"
#elif defined(nsamiga)
#include "amiga/options.h"
#elif defined(nsfb)
#include "framebuffer/fb_options.h"
#else
#define EXTRA_OPTION_DEFINE
#define EXTRA_OPTION_TABLE

View File

@ -0,0 +1,418 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
#include "utils/log.h"
#include "utils/utf8.h"
#include "desktop/plotters.h"
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_bitmap.h"
#include "framebuffer/fb_font.h"
static inline uint16_t *
fb_16bpp_get_xy_loc(int x, int y)
{
return (void *)(framebuffer->ptr +
(y * framebuffer->linelen) +
(x << 1));
}
#define SIGN(x) ((x<0) ? -1 : ((x>0) ? 1 : 0))
static bool fb_16bpp_line(int x0, int y0, int x1, int y1, int width,
colour c, bool dotted, bool dashed)
{
int w;
uint16_t ent;
uint16_t *pvideo;
int x, y, i;
int dx, dy, sdy;
int dxabs, dyabs;
/*LOG(("%d, %d, %d, %d, %d, 0x%lx, %d, %d",
x0,y0,x1,y1,width,c,dotted,dashed));*/
if (y1 > fb_plot_ctx.y1)
return true;
if (y0 < fb_plot_ctx.y0)
return true;
ent = ((c & 0xF8) << 8) |
((c & 0xFC00 ) >> 5) |
((c & 0xF80000) >> 19);
if (y0 == y1) {
/* horizontal line special cased */
fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1);
/*LOG(("horiz: %d, %d, %d, %d, %d, 0x%lx, %d, %d",
x0,y0,x1,y1,width,c,dotted,dashed));*/
pvideo = fb_16bpp_get_xy_loc(x0, y0);
w = x1 - x0;
while (w-- > 0) {
*(pvideo + w) = ent;
}
return true;
} else {
/* standard bresenham line */
if (!fb_plotters_clip_line_ctx(&x0, &y0, &x1, &y1))
return true; /* line outside clipping */
//LOG(("%d, %d, %d, %d", x0,y0,x1,y1));
/* the horizontal distance of the line */
dx = x1 - x0;
dxabs = abs (dx);
/* the vertical distance of the line */
dy = y1 - y0;
dyabs = abs (dy);
sdy = dx ? SIGN(dy) * SIGN(dx) : SIGN(dy);
if (dx >= 0)
pvideo = fb_16bpp_get_xy_loc(x0, y0);
else
pvideo = fb_16bpp_get_xy_loc(x1, y1);
x = dyabs >> 1;
y = dxabs >> 1;
if (dxabs >= dyabs) {
/* the line is more horizontal than vertical */
for (i = 0; i <= dxabs; i++) {
*pvideo = ent;
pvideo++;
y += dyabs;
if (y >= dxabs) {
y -= dxabs;
pvideo += sdy * (framebuffer->linelen>>1);
}
}
} else {
/* the line is more vertical than horizontal */
for (i = 0; i <= dyabs; i++) {
*pvideo = ent;
pvideo += sdy * (framebuffer->linelen >> 1);
x += dxabs;
if (x >= dyabs) {
x -= dyabs;
pvideo++;
}
}
}
}
return true;
}
static bool fb_16bpp_rectangle(int x0, int y0, int width, int height,
int line_width, colour c, bool dotted, bool dashed)
{
fb_16bpp_line(x0, y0, x0 + width, y0, line_width, c, dotted, dashed);
fb_16bpp_line(x0, y0 + height, x0 + width, y0 + height, line_width, c, dotted, dashed);
fb_16bpp_line(x0, y0, x0, y0 + height, line_width, c, dotted, dashed);
fb_16bpp_line(x0 + width, y0, x0 + width, y0 + height, line_width, c, dotted, dashed);
return true;
}
static bool fb_16bpp_polygon(int *p, unsigned int n, colour fill)
{
return fb_plotters_polygon(p, n, fill, fb_16bpp_line);
}
static bool fb_16bpp_fill(int x0, int y0, int x1, int y1, colour c)
{
int w;
int y;
uint16_t ent;
uint16_t *pvideo;
if (!fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1))
return true; /* fill lies outside current clipping region */
ent = ((c & 0xF8) << 8) |
((c & 0xFC00 ) >> 5) |
((c & 0xF80000) >> 19);
pvideo = fb_16bpp_get_xy_loc(x0, y0);
for (y = y0; y < y1; y++) {
w = x1 - x0;
while (w-- > 0) {
*(pvideo + w) = ent;
}
pvideo += (framebuffer->linelen >> 1);
}
return true;
}
static bool fb_16bpp_clg(colour c)
{
/* LOG(("c %lx", c)); */
fb_16bpp_fill(fb_plot_ctx.x0,
fb_plot_ctx.y0,
fb_plot_ctx.x1,
fb_plot_ctx.y1,
c);
return true;
}
static bool fb_16bpp_text(int x, int y, const struct css_style *style,
const char *text, size_t length, colour bg, colour c)
{
const struct fb_font_desc* fb_font = fb_get_font(style);
const uint32_t *font_data;
int xloop, yloop;
uint32_t row;
size_t chr;
uint16_t *pvideo;
uint16_t fgcol;
uint16_t bgcol;
char *buffer = NULL;
int x0,y0,x1,y1;
int xoff, yoff; /* x and y offset into image */
int height = fb_font->height;
/* aquire thge text in local font encoding */
utf8_to_font_encoding(fb_font, text, length, &buffer);
if (!buffer)
return true;
length = strlen(buffer);
/* y is given to the fonts baseline we need it to the fonts top */
y-=((fb_font->height * 75)/100);
y+=1; /* 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
*/
/* The part of the text displayed is cropped to the current context. */
x0 = x;
y0 = y;
x1 = x + (fb_font->width * length);
y1 = y + fb_font->height;
if (!fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1))
return true; /* text lies outside current clipping region */
/* find width and height to plot */
if (height > (y1 - y0))
height = (y1 - y0);
xoff = x0 - x;
yoff = y0 - y;
fgcol = ((c & 0xF8) << 8) |
((c & 0xFC00 ) >> 5) |
((c & 0xF80000) >> 19);
bgcol = ((bg & 0xF8) << 8) |
((bg & 0xFC00 ) >> 5) |
((bg & 0xF80000) >> 19);
/*LOG(("x %d, y %d, style %p, txt %.*s , len %d, bg 0x%lx, fg 0x%lx",
x,y,style,length,text,length,bg,c));*/
for (chr = 0; chr < length; chr++, x += fb_font->width) {
if ((x + fb_font->width) > x1)
break;
if (x < x0)
continue;
pvideo = fb_16bpp_get_xy_loc(x, y0);
/* move our font-data to the correct position */
font_data = fb_font->data + (buffer[chr] * fb_font->height);
for (yloop = 0; yloop < height; yloop++) {
row = font_data[yoff + yloop];
for (xloop = fb_font->width; xloop > 0 ; xloop--) {
if ((row & 1) != 0)
*(pvideo + xloop) = fgcol;
row = row >> 1;
}
pvideo += (framebuffer->linelen >> 1);
}
}
free(buffer);
return true;
}
static bool fb_16bpp_disc(int x, int y, int radius, colour c, bool filled)
{
LOG(("x %d, y %d, r %d, c 0x%lx, fill %d",
x, y, radius, c, filled));
return true;
}
static bool fb_16bpp_arc(int x, int y, int radius, int angle1, int angle2,
colour c)
{
LOG(("x %d, y %d, r %d, a1 %d, a2 %d, c 0x%lx",
x, y, radius, angle1, angle2, c));
return true;
}
static inline colour fb_16bpp_to_colour(uint16_t pixel)
{
return ((pixel & 0x1F) << 19) |
((pixel & 0x7E0) << 5) |
((pixel & 0xF800) >> 8);
}
static bool fb_16bpp_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
struct content *content)
{
uint16_t *pvideo;
colour *pixel = (colour *)bitmap->pixdata;
colour abpixel; /* alphablended pixel */
int xloop, yloop;
int x0,y0,x1,y1;
int xoff, yoff; /* x and y offset into image */
/* LOG(("x %d, y %d, width %d, height %d, bitmap %p, content %p",
x,y,width,height,bitmap,content));*/
/* TODO here we should scale the image from bitmap->width to width, for
* now simply crop.
*/
if (width > bitmap->width)
width = bitmap->width;
if (height > bitmap->height)
height = bitmap->height;
/* The part of the scaled image actually displayed is cropped to the
* current context.
*/
x0 = x;
y0 = y;
x1 = x + width;
y1 = y + height;
if (!fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1))
return true;
if (height > (y1 - y0))
height = (y1 - y0);
if (width > (x1 - x0))
width = (x1 - x0);
xoff = x0 - x;
yoff = y0 - y;
/* plot the image */
pvideo = fb_16bpp_get_xy_loc(x0, y0);
for (yloop = 0; yloop < height; yloop++) {
for (xloop = 0; xloop < width; xloop++) {
abpixel = pixel[((yoff + yloop) * bitmap->width) + xloop + xoff];
if ((abpixel & 0xFF000000) != 0) {
if ((abpixel & 0xFF000000) != 0xFF) {
abpixel = fb_plotters_ablend(abpixel,
fb_16bpp_to_colour(*(pvideo + xloop)));
}
*(pvideo + xloop) =
((abpixel & 0xF8) << 8) |
((abpixel & 0xFC00 ) >> 5) |
((abpixel & 0xF80000) >> 19);
}
}
pvideo += (framebuffer->linelen >> 1);
}
return true;
}
static bool fb_16bpp_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 fb_plotters_bitmap_tile(x, y, width, height,
bitmap, bg, repeat_x, repeat_y,
content, fb_16bpp_bitmap);
}
static bool fb_16bpp_flush(void)
{
LOG(("optional"));
return true;
}
static bool fb_16bpp_path(float *p, unsigned int n, colour fill, float width,
colour c, float *transform)
{
LOG(("%f, %d, 0x%lx, %f, 0x%lx, %f",
*p, n, fill, width, c, *transform));
return true;
}
const struct plotter_table framebuffer_16bpp_plot = {
.clg = fb_16bpp_clg,
.rectangle = fb_16bpp_rectangle,
.line = fb_16bpp_line,
.polygon = fb_16bpp_polygon,
.fill = fb_16bpp_fill,
.clip = fb_clip,
.text = fb_16bpp_text,
.disc = fb_16bpp_disc,
.arc = fb_16bpp_arc,
.bitmap = fb_16bpp_bitmap,
.bitmap_tile = fb_16bpp_bitmap_tile,
.flush = fb_16bpp_flush,
.path = fb_16bpp_path,
.option_knockout = true,
};
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

View File

@ -0,0 +1,266 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
#include "utils/log.h"
#include "utils/utf8.h"
#include "desktop/plotters.h"
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_bitmap.h"
#include "framebuffer/fb_font.h"
extern struct fb_info_s *fbinfo;
static bool fb_1bpp_rectangle(int x0, int y0, int width, int height,
int line_width, colour c, bool dotted, bool dashed)
{
LOG(("%s(%d, %d, %d, %d, %d, 0x%lx, %d, %d)\n", __func__,
x0,y0,width,height,line_width,c,dotted,dashed));
return true;
}
static bool fb_1bpp_line(int x0, int y0, int x1, int y1, int width,
colour c, bool dotted, bool dashed)
{
LOG(("%s(%d, %d, %d, %d, %d, 0x%lx, %d, %d)\n", __func__,
x0,y0,x1,y1,width,c,dotted,dashed));
return true;
}
static bool fb_1bpp_polygon(int *p, unsigned int n, colour fill)
{
LOG(("%s(%p, %d, 0x%lx)\n", __func__, p,n,fill));
return true;
}
static bool fb_1bpp_fill(int x0, int y0, int x1, int y1, colour c)
{
int x;
int y;
int pent;
LOG(("%s(%d, %d, %d, %d, 0x%lx)\n", __func__,
x0,y0,x1,y1,c));
if (c != 0)
pent = 0xff;
else
pent = 0;
fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1);
x = x1 - x0;
for (y = y0; y < y1; y++) {
memset(fb_plotters_get_xy_loc(x0, y, fbinfo), pent, x);
}
return true;
}
static bool fb_1bpp_clg(colour c)
{
LOG(("%s(%lx)\n", __func__, c));
fb_1bpp_fill(fb_plot_ctx.x0,
fb_plot_ctx.y0,
fb_plot_ctx.x1,
fb_plot_ctx.y1,
c);
return true;
}
static bool fb_1bpp_text(int x, int y, const struct css_style *style,
const char *text, size_t length, colour bg, colour c)
{
const struct fb_font_desc* fb_font = fb_get_font(style);
u8_t *video_char_start;
const u8_t *font_data;
int yloop;
unsigned char row;
int chr;
LOG(("%s(%d, %d, %p, %.*s , %d, 0x%lx, 0x%lx)\n", __func__,
x,y,style,length,text,length,bg,c));
for (chr=0; chr < length; chr++) {
video_char_start = fb_plotters_get_xy_loc(x + (chr * (fb_font->width)), y, fbinfo);
/* move our font-data to the correct position */
font_data = fb_font->data + (text[chr] * fb_font->height);
for (yloop = 0; yloop < fb_font->height; yloop++) {
row = font_data[yloop];
*video_char_start = row;
video_char_start += fbinfo->line_len;
}
}
return true;
/* copied from css/css.h - need to open the correct font here
* font properties *
css_font_family font_family;
struct {
css_font_size_type size;
union {
struct css_length length;
float absolute;
float percent;
} value;
} font_size;
css_font_style font_style;
css_font_variant font_variant;
css_font_weight font_weight;
*/
return true;
}
static bool fb_1bpp_disc(int x, int y, int radius, colour c, bool filled)
{
LOG(("%s(%d, %d, %d, 0x%lx, %d)\n", __func__,
x, y, radius, c, filled));
return true;
}
static bool fb_1bpp_arc(int x, int y, int radius, int angle1, int angle2,
colour c)
{
LOG(("x %d, y %d, radius %d, angle1 %d, angle2 %d, c 0x%lx",
x, y, radius, angle1, angle2, c));
return true;
}
static inline colour ablend(colour pixel)
{
return pixel;
}
static bool fb_1bpp_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
struct content *content)
{
u8_t *video_char_start;
colour *pixel = (colour *)bitmap->pixdata;
colour abpixel; /* alphablended pixel */
int xloop,yloop;
video_char_start = fb_plotters_get_xy_loc(x, y, fbinfo);
for (yloop = 0; yloop < height; yloop++) {
for (xloop = 0; xloop < width; xloop++) {
abpixel = pixel[(yloop * bitmap->width) + xloop];
if ((abpixel & 0xFF000000) != 0) {
if ((abpixel & 0xFF000000) != 0xFF)
abpixel = ablend(abpixel);
if (abpixel == 0)
video_char_start[xloop] |= (1 << (xloop % 8));
else
video_char_start[xloop] &= ~(1 << (xloop % 8));
}
}
video_char_start += fbinfo->line_len;
}
return true;
}
static bool fb_1bpp_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y,
struct content *content)
{
unsigned long xf,yf,wf,hf;
if (!(repeat_x || repeat_y)) {
/* Not repeating at all, so just pass it on */
return fb_1bpp_bitmap(x,y,width,height,bitmap,bg,content);
}
for (xf = 0; xf < width; xf += bitmap->width) {
for(yf = 0;yf < height; yf += bitmap->height) {
if(width > xf+bitmap->width)
{
wf = width-(xf+bitmap->width);
}
else
{
wf=bitmap->width;
}
if(height > yf+bitmap->height)
{
hf = height-(yf+bitmap->height);
}
else
{
hf=bitmap->height;
}
fb_1bpp_bitmap(x+xf, y+yf, wf, hf, bitmap, bg, content);
}
}
return true;
}
static bool fb_1bpp_flush(void)
{
LOG(("%s()\n", __func__));
return true;
}
static bool fb_1bpp_path(float *p, unsigned int n, colour fill, float width,
colour c, float *transform)
{
LOG(("%s(%f, %d, 0x%lx, %f, 0x%lx, %f)\n", __func__,
*p, n, fill, width, c, *transform));
return true;
}
const struct plotter_table framebuffer_1bpp_plot = {
.clg = fb_1bpp_clg,
.rectangle = fb_1bpp_rectangle,
.line = fb_1bpp_line,
.polygon = fb_1bpp_polygon,
.fill = fb_1bpp_fill,
.clip = fb_clip,
.text = fb_1bpp_text,
.disc = fb_1bpp_disc,
.arc = fb_1bpp_arc,
.bitmap = fb_1bpp_bitmap,
.bitmap_tile = fb_1bpp_bitmap_tile,
.flush = fb_1bpp_flush,
.path = fb_1bpp_path
};
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

View File

@ -0,0 +1,398 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
#include "utils/log.h"
#include "utils/utf8.h"
#include "desktop/plotters.h"
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_bitmap.h"
#include "framebuffer/fb_font.h"
static inline uint32_t *
fb_32bpp_get_xy_loc(int x, int y)
{
return (uint32_t *)(framebuffer->ptr +
(y * framebuffer->linelen) +
(x << 2));
}
#define SIGN(x) ((x<0) ? -1 : ((x>0) ? 1 : 0))
static bool fb_32bpp_line(int x0, int y0, int x1, int y1, int width,
colour c, bool dotted, bool dashed)
{
int w;
uint32_t ent;
uint32_t *pvideo;
int x, y, i;
int dx, dy, sdy;
int dxabs, dyabs;
if (y1 > fb_plot_ctx.y1)
return true;
if (y0 < fb_plot_ctx.y0)
return true;
ent = ((c & 0xff0000) >> 16) | (c & 0xff00) | ((c & 0xff) << 16);
if (y0 == y1) {
/* horizontal line special cased */
fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1);
pvideo = fb_32bpp_get_xy_loc(x0, y0);
w = x1 - x0;
while (w-- > 0) {
*(pvideo + w) = ent;
}
return true;
} else {
/* standard bresenham line */
if (!fb_plotters_clip_line_ctx(&x0, &y0, &x1, &y1))
return true; /* line outside clipping */
/* the horizontal distance of the line */
dx = x1 - x0;
dxabs = abs (dx);
/* the vertical distance of the line */
dy = y1 - y0;
dyabs = abs (dy);
sdy = dx ? SIGN(dy) * SIGN(dx) : SIGN(dy);
if (dx >= 0)
pvideo = fb_32bpp_get_xy_loc(x0, y0);
else
pvideo = fb_32bpp_get_xy_loc(x1, y1);
x = dyabs >> 1;
y = dxabs >> 1;
if (dxabs >= dyabs) {
/* the line is more horizontal than vertical */
for (i = 0; i <= dxabs; i++) {
*pvideo = ent;
pvideo++;
y += dyabs;
if (y >= dxabs) {
y -= dxabs;
pvideo += sdy * (framebuffer->linelen>>2);
}
}
} else {
/* the line is more vertical than horizontal */
for (i = 0; i <= dyabs; i++) {
*pvideo = ent;
pvideo += sdy * (framebuffer->linelen >> 2);
x += dxabs;
if (x >= dyabs) {
x -= dyabs;
pvideo++;
}
}
}
}
return true;
}
static bool fb_32bpp_rectangle(int x0, int y0, int width, int height,
int line_width, colour c, bool dotted, bool dashed)
{
fb_32bpp_line(x0, y0, x0 + width, y0, line_width, c, dotted, dashed);
fb_32bpp_line(x0, y0 + height, x0 + width, y0 + height, line_width, c, dotted, dashed);
fb_32bpp_line(x0, y0, x0, y0 + height, line_width, c, dotted, dashed);
fb_32bpp_line(x0 + width, y0, x0 + width, y0 + height, line_width, c, dotted, dashed);
return true;
}
static bool fb_32bpp_polygon(int *p, unsigned int n, colour fill)
{
return fb_plotters_polygon(p, n, fill, fb_32bpp_line);
}
static bool fb_32bpp_fill(int x0, int y0, int x1, int y1, colour c)
{
int w;
int y;
uint32_t *pvid;
uint32_t ent;
if (!fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1))
return true; /* fill lies outside current clipping region */
ent = ((c & 0xff0000) >> 16) | (c & 0xff00) | ((c & 0xff) << 16);
pvid = fb_32bpp_get_xy_loc(x0, y0);
for (y = y0; y < y1; y++) {
w = x1 - x0;
while (w-- > 0) {
*(pvid + w) = ent;
}
pvid += (framebuffer->linelen >> 2);
}
return true;
}
static bool fb_32bpp_clg(colour c)
{
fb_32bpp_fill(fb_plot_ctx.x0,
fb_plot_ctx.y0,
fb_plot_ctx.x1,
fb_plot_ctx.y1,
c);
return true;
}
static bool fb_32bpp_text(int x, int y, const struct css_style *style,
const char *text, size_t length, colour bg, colour c)
{
const struct fb_font_desc* fb_font = fb_get_font(style);
const uint32_t *font_data;
uint32_t row;
int xloop, yloop;
size_t chr;
uint32_t *pvideo;
uint32_t fgcol;
char *buffer = NULL;
int x0,y0,x1,y1;
int xoff, yoff; /* x and y offset into image */
int height = fb_font->height;
/* aquire thge text in local font encoding */
utf8_to_font_encoding(fb_font, text, length, &buffer);
if (!buffer)
return true;
length = strlen(buffer);
/* y is given to the fonts baseline we need it to the fonts top */
y-=((fb_font->height * 75)/100);
y+=1; /* 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
*/
/* The part of the text displayed is cropped to the current context. */
x0 = x;
y0 = y;
x1 = x + (fb_font->width * length);
y1 = y + fb_font->height;
if (!fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1))
return true; /* text lies outside current clipping region */
/* find width and height to plot */
if (height > (y1 - y0))
height = (y1 - y0);
xoff = x0 - x;
yoff = y0 - y;
fgcol = ((c & 0xff0000) >> 16) | (c & 0xff00) | ((c & 0xff) << 16);
/*LOG(("x %d, y %d, style %p, txt %.*s , len %d, bg 0x%lx, fg 0x%lx",
x,y,style,length,text,length,bg,c));*/
for (chr = 0; chr < length; chr++, x += fb_font->width) {
if ((x + fb_font->width) > x1)
break;
if (x < x0)
continue;
pvideo = fb_32bpp_get_xy_loc(x, y0);
/* move our font-data to the correct position */
font_data = fb_font->data + (buffer[chr] * fb_font->height);
for (yloop = 0; yloop < height; yloop++) {
row = font_data[yoff + yloop];
for (xloop = fb_font->width; xloop > 0 ; xloop--) {
if ((row & 1) != 0)
*(pvideo + xloop) = fgcol;
row = row >> 1;
}
pvideo += (framebuffer->linelen >> 2);
}
}
free(buffer);
return true;
}
static bool fb_32bpp_disc(int x, int y, int radius, colour c, bool filled)
{
printf("disc\n");
return true;
}
static bool fb_32bpp_arc(int x, int y, int radius, int angle1, int angle2,
colour c)
{
printf("arc\n");
return true;
}
static inline colour ablend(colour pixel)
{
return pixel;
}
static inline colour fb_32bpp_to_colour(uint32_t pixel)
{
return ((pixel & 0xFF) << 16) |
((pixel & 0xFF00)) |
((pixel & 0xFF0000) >> 16);
}
static bool fb_32bpp_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
struct content *content)
{
uint32_t *pvideo;
colour *pixel = (colour *)bitmap->pixdata;
colour abpixel; /* alphablended pixel */
int xloop, yloop;
int x0,y0,x1,y1;
int xoff, yoff; /* x and y offset into image */
/* LOG(("x %d, y %d, width %d, height %d, bitmap %p, content %p",
x,y,width,height,bitmap,content));*/
/* TODO here we should scale the image from bitmap->width to width, for
* now simply crop.
*/
if (width > bitmap->width)
width = bitmap->width;
if (height > bitmap->height)
height = bitmap->height;
/* The part of the scaled image actually displayed is cropped to the
* current context.
*/
x0 = x;
y0 = y;
x1 = x + width;
y1 = y + height;
if (!fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1))
return true;
if (height > (y1 - y0))
height = (y1 - y0);
if (width > (x1 - x0))
width = (x1 - x0);
xoff = x0 - x;
yoff = y0 - y;
/* plot the image */
pvideo = fb_32bpp_get_xy_loc(x0, y0);
for (yloop = 0; yloop < height; yloop++) {
for (xloop = 0; xloop < width; xloop++) {
abpixel = pixel[((yoff + yloop) * bitmap->width) + xloop + xoff];
if ((abpixel & 0xFF000000) != 0) {
if ((abpixel & 0xFF000000) != 0xFF) {
abpixel = fb_plotters_ablend(abpixel,
fb_32bpp_to_colour(*(pvideo + xloop)));
}
*(pvideo + xloop) = ((abpixel & 0xFF) << 16) |
((abpixel & 0xFF00)) |
((abpixel & 0xFF0000) >> 16);
}
}
pvideo += (framebuffer->linelen >> 2);
}
return true;
}
static bool fb_32bpp_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 fb_plotters_bitmap_tile(x, y, width, height,
bitmap, bg, repeat_x, repeat_y,
content, fb_32bpp_bitmap);
}
static bool fb_32bpp_flush(void)
{
printf("flush\n");
return true;
}
static bool fb_32bpp_path(float *p, unsigned int n, colour fill, float width,
colour c, float *transform)
{
printf("path\n");
return true;
}
const struct plotter_table framebuffer_32bpp_plot = {
.clg = fb_32bpp_clg,
.rectangle = fb_32bpp_rectangle,
.line = fb_32bpp_line,
.polygon = fb_32bpp_polygon,
.fill = fb_32bpp_fill,
.clip = fb_clip,
.text = fb_32bpp_text,
.disc = fb_32bpp_disc,
.arc = fb_32bpp_arc,
.bitmap = fb_32bpp_bitmap,
.bitmap_tile = fb_32bpp_bitmap_tile,
.flush = fb_32bpp_flush,
.path = fb_32bpp_path,
.option_knockout = true,
};
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

View File

@ -0,0 +1,300 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
#include "utils/log.h"
#include "utils/utf8.h"
#include "desktop/plotters.h"
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_bitmap.h"
#include "framebuffer/fb_font.h"
static inline uint8_t *
fb_8bpp_get_xy_loc(int x, int y)
{
return (uint8_t *)(framebuffer->ptr +
(y * framebuffer->linelen) +
(x));
}
static bool fb_8bpp_rectangle(int x0, int y0, int width, int height,
int line_width, colour c, bool dotted, bool dashed)
{
LOG(("%s(%d, %d, %d, %d, %d, 0x%lx, %d, %d)\n", __func__,
x0,y0,width,height,line_width,c,dotted,dashed));
return true;
}
static bool fb_8bpp_line(int x0, int y0, int x1, int y1, int width,
colour c, bool dotted, bool dashed)
{
LOG(("%s(%d, %d, %d, %d, %d, 0x%lx, %d, %d)\n", __func__,
x0,y0,x1,y1,width,c,dotted,dashed));
return true;
}
static bool fb_8bpp_polygon(int *p, unsigned int n, colour fill)
{
/*LOG(("%p, %d, 0x%lx", p,n,fill));*/
return fb_plotters_polygon(p, n, fill, fb_8bpp_line);
}
static int
find_closest_palette_entry(colour c)
{
colour palent;
int col;
int dr, dg, db; /* delta red, green blue values */
int cur_distance;
int best_distance = INT_MAX;
int best_col = 0;
for (col = 0; col < 256; col++) {
palent = framebuffer->palette[col];
dr = (c & 0xFF) - (palent & 0xFF);
dg = ((c >> 8) & 0xFF) - ((palent >> 8) & 0xFF);
db = ((c >> 16) & 0xFF) - ((palent >> 16) & 0xFF);
cur_distance = ((dr * dr) + (dg * dg) + (db *db));
if (cur_distance < best_distance) {
best_distance = cur_distance;
best_col = col;
}
}
return best_col;
}
static colour calc_colour(uint8_t c)
{
return framebuffer->palette[c];
}
static bool fb_8bpp_fill(int x0, int y0, int x1, int y1, colour c)
{
int y;
uint8_t ent;
uint8_t *pvideo;
if (!fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1))
return true; /* fill lies outside current clipping region */
pvideo = fb_8bpp_get_xy_loc(x0, y0);
ent = find_closest_palette_entry(c);
for (y = y0; y < y1; y++) {
memset(pvideo, ent, x1 - x0);
pvideo += framebuffer->linelen;
}
return true;
}
static bool fb_8bpp_clg(colour c)
{
LOG(("%s(%lx)\n", __func__, c));
fb_8bpp_fill(fb_plot_ctx.x0,
fb_plot_ctx.y0,
fb_plot_ctx.x1,
fb_plot_ctx.y1,
c);
return true;
}
static bool fb_8bpp_text(int x, int y, const struct css_style *style,
const char *text, size_t length, colour bg, colour c)
{
const struct fb_font_desc* fb_font = fb_get_font(style);
const uint32_t *font_data;
uint32_t row;
int xloop, yloop;
size_t chr;
uint8_t *pvideo;
uint8_t fgcol;
char *buffer = NULL;
int x0,y0,x1,y1;
int xoff, yoff; /* x and y offset into image */
int height = fb_font->height;
/* aquire thge text in local font encoding */
utf8_to_font_encoding(fb_font, text, length, &buffer);
if (!buffer)
return true;
length = strlen(buffer);
/* y is given to the fonts baseline we need it to the fonts top */
y-=((fb_font->height * 75)/100);
y+=1; /* 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
*/
/* The part of the text displayed is cropped to the current context. */
x0 = x;
y0 = y;
x1 = x + (fb_font->width * length);
y1 = y + fb_font->height;
if (!fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1))
return true; /* text lies outside current clipping region */
/* find width and height to plot */
if (height > (y1 - y0))
height = (y1 - y0);
xoff = x0 - x;
yoff = y0 - y;
fgcol = find_closest_palette_entry(c);
/*LOG(("x %d, y %d, style %p, txt %.*s , len %d, bg 0x%lx, fg 0x%lx",
x,y,style,length,text,length,bg,c));*/
for (chr = 0; chr < length; chr++, x += fb_font->width) {
if ((x + fb_font->width) > x1)
break;
if (x < x0)
continue;
pvideo = fb_8bpp_get_xy_loc(x, y0);
/* move our font-data to the correct position */
font_data = fb_font->data + (buffer[chr] * fb_font->height);
for (yloop = 0; yloop < height; yloop++) {
row = font_data[yoff + yloop];
for (xloop = fb_font->width; xloop > 0 ; xloop--) {
if ((row & 1) != 0)
*(pvideo + xloop) = fgcol;
row = row >> 1;
}
pvideo += framebuffer->linelen;
}
}
free(buffer);
return true;
}
static bool fb_8bpp_disc(int x, int y, int radius, colour c, bool filled)
{
LOG(("x %d, y %d, rad %d, c 0x%lx, fill %d", x, y, radius, c, filled));
return true;
}
static bool fb_8bpp_arc(int x, int y, int radius, int angle1, int angle2,
colour c)
{
LOG(("x %d, y %d, radius %d, angle1 %d, angle2 %d, c 0x%lx",
x, y, radius, angle1, angle2, c));
return true;
}
static bool fb_8bpp_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
struct content *content)
{
uint8_t *pvideo;
colour *pixel = (colour *)bitmap->pixdata;
colour abpixel; /* alphablended pixel */
int xloop,yloop;
pvideo = fb_8bpp_get_xy_loc(x, y);
for (yloop = 0; yloop < height; yloop++) {
for (xloop = 0; xloop < width; xloop++) {
abpixel = pixel[(yloop * bitmap->width) + xloop];
if ((abpixel & 0xFF000000) != 0) {
if ((abpixel & 0xFF000000) != 0xFF)
abpixel = fb_plotters_ablend(abpixel, calc_colour(pvideo[xloop]));
pvideo[xloop] = find_closest_palette_entry(abpixel);
}
}
pvideo += framebuffer->linelen;
}
return true;
}
static bool fb_8bpp_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 fb_plotters_bitmap_tile(x, y, width, height,
bitmap, bg, repeat_x, repeat_y,
content, fb_8bpp_bitmap);
}
static bool fb_8bpp_flush(void)
{
LOG(("%s()\n", __func__));
return true;
}
static bool fb_8bpp_path(float *p, unsigned int n, colour fill, float width,
colour c, float *transform)
{
LOG(("%s(%f, %d, 0x%lx, %f, 0x%lx, %f)\n", __func__,
*p, n, fill, width, c, *transform));
return true;
}
const struct plotter_table framebuffer_8bpp_plot = {
.clg = fb_8bpp_clg,
.rectangle = fb_8bpp_rectangle,
.line = fb_8bpp_line,
.polygon = fb_8bpp_polygon,
.fill = fb_8bpp_fill,
.clip = fb_clip,
.text = fb_8bpp_text,
.disc = fb_8bpp_disc,
.arc = fb_8bpp_arc,
.bitmap = fb_8bpp_bitmap,
.bitmap_tile = fb_8bpp_bitmap_tile,
.flush = fb_8bpp_flush,
.path = fb_8bpp_path,
.option_knockout = true,
};
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

242
framebuffer/fb_bitmap.c Normal file
View File

@ -0,0 +1,242 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <inttypes.h>
#include <sys/types.h>
#include "assert.h"
#include "image/bitmap.h"
#include "framebuffer/fb_bitmap.h"
#include "utils/log.h"
/**
* Create a bitmap.
*
* \param width width of image in pixels
* \param height width of image in pixels
* \param state a flag word indicating the initial state
* \return an opaque struct bitmap, or NULL on memory exhaustion
*/
void *bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *bitmap;
LOG(("width %d, height %d, state %u",width,height,state));
bitmap = calloc(1 , sizeof(struct bitmap));
if (bitmap) {
bitmap->pixdata = calloc(4, width * height);
if (bitmap->pixdata != NULL) {
bitmap->width = width;
bitmap->height = height;
} else {
free(bitmap);
bitmap=NULL;
}
}
LOG(("bitmap %p", bitmap));
return bitmap;
}
/**
* Return a pointer to the pixel data in a bitmap.
*
* \param bitmap a bitmap, as returned by bitmap_create()
* \return pointer to the pixel buffer
*
* The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
* of rows. The width of a row in bytes is given by bitmap_get_rowstride().
*/
unsigned char *bitmap_get_buffer(void *bitmap)
{
struct bitmap *bm = bitmap;
if (bitmap == NULL) {
LOG(("NULL bitmap!"));
return NULL;
}
return bm->pixdata;
}
/**
* Find the width of a pixel row in bytes.
*
* \param bitmap a bitmap, as returned by bitmap_create()
* \return width of a pixel row in the bitmap
*/
size_t bitmap_get_rowstride(void *bitmap)
{
struct bitmap *bm = bitmap;
if (bitmap == NULL) {
LOG(("NULL bitmap!"));
return 0;
}
return (bm->width) * 4;
}
/**
* Free a bitmap.
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
void bitmap_destroy(void *bitmap)
{
struct bitmap *bm = bitmap;
if (bitmap == NULL) {
LOG(("NULL bitmap!"));
return;
}
free(bm->pixdata);
free(bm);
}
/**
* Save a bitmap in the platform's native format.
*
* \param bitmap a bitmap, as returned by bitmap_create()
* \param path pathname for file
* \return true on success, false on error and error reported
*/
bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
return true;
}
/**
* The bitmap image has changed, so flush any persistant cache.
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
void bitmap_modified(void *bitmap) {
}
/**
* The bitmap image can be suspended.
*
* \param bitmap a bitmap, as returned by bitmap_create()
* \param private_word a private word to be returned later
* \param suspend the function to be called upon suspension
* \param resume the function to be called when resuming
*/
void bitmap_set_suspendable(void *bitmap, void *private_word,
void (*invalidate)(void *bitmap, void *private_word)) {
}
/**
* Sets whether a bitmap should be plotted opaque
*
* \param bitmap a bitmap, as returned by bitmap_create()
* \param opaque whether the bitmap should be plotted opaque
*/
void bitmap_set_opaque(void *bitmap, bool opaque)
{
if (bitmap == NULL) {
LOG(("NULL bitmap!"));
return;
}
/* todo: set bitmap as opaque */
}
/**
* Tests whether a bitmap has an opaque alpha channel
*
* \param bitmap a bitmap, as returned by bitmap_create()
* \return whether the bitmap is opaque
*/
bool bitmap_test_opaque(void *bitmap)
{
if (bitmap == NULL) {
LOG(("NULL bitmap!"));
return false;
}
/* todo: test if bitmap as opaque */
return false;
}
/**
* Gets whether a bitmap should be plotted opaque
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
bool bitmap_get_opaque(void *bitmap)
{
if (bitmap == NULL) {
LOG(("NULL bitmap!"));
return false;
}
/* todo: get whether bitmap is opaque */
return false;
}
int bitmap_get_width(void *bitmap)
{
struct bitmap *bm = bitmap;
if (bitmap == NULL) {
LOG(("NULL bitmap!"));
return 0;
}
return(bm->width);
}
int bitmap_get_height(void *bitmap)
{
struct bitmap *bm = bitmap;
if (bitmap == NULL) {
LOG(("NULL bitmap!"));
return 0;
}
return(bm->height);
}
size_t bitmap_get_bpp(void *bitmap)
{
return 4;
}
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

28
framebuffer/fb_bitmap.h Normal file
View File

@ -0,0 +1,28 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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/>.
*/
#ifndef FRAMEBUFFER_BITMAP_H
#define FRAMEBUFFER_BITMAP_H
struct bitmap {
int width;
int height;
uint8_t *pixdata;
};
#endif

241
framebuffer/fb_cursor.c Normal file
View File

@ -0,0 +1,241 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <sys/types.h>
#include <stdint.h>
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
#include "utils/log.h"
#include "utils/utf8.h"
#include "desktop/plotters.h"
#include "desktop/browser.h"
#include "image/bitmap.h"
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_bitmap.h"
#include "framebuffer/fb_cursor.h"
struct fb_cursor_s {
int x;
int y;
int width; /**< width */
int height; /**< height */
bool plotted;
struct bitmap *bitmap; /* pointer bitmap */
uint8_t *savedata; /* save under area */
};
static const struct {
unsigned int width;
unsigned int height;
unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
unsigned char pixel_data[11 * 15 * 4 + 1];
} pointer_image = {
11, 15, 4,
"\0\0\0'\0\0\0""8\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0`\230\230\230\275\3\3\3D\0\0\0\1\0\0\0\4\0\0\0\1\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0`\377\377\377\277\230\230\230"
"\275\2\2\2N\0\0\0\37\0\0\0\23\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0`\377\377\377\277\377\377\377\277\224\224\224\302\2\2\2`\0\0\0$\0\0\0\24"
"\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0`\377\377\377\277\377\377\377\277\370"
"\370\370\304\220\220\220\307\2\2\2`\0\0\0$\0\0\0\24\0\0\0\2\0\0\0\0\0\0\0"
"\0\0\0\0`\377\377\377\277\377\377\377\277\370\370\370\304\362\362\362\311"
"\220\220\220\307\2\2\2`\0\0\0$\0\0\0\24\0\0\0\2\0\0\0\0\0\0\0`\377\377\377"
"\277\377\377\377\277\370\370\370\304\362\362\362\311\361\361\361\311]]]\307"
"\0\0\0;\0\0\0$\0\0\0\24\0\0\0\2\0\0\0`\377\377\377\277\377\377\377\277\370"
"\370\370\304\304\304\304\311222\245\0\0\0Z\0\0\0'\0\0\0&\0\0\0$\0\0\0\24"
"\0\0\0`\334\334\334\277sss\273\277\277\277\304\340\340\340\311\16\16\16~"
"\0\0\0&\0\0\0&\0\0\0&\0\0\0&\0\0\0#\0\0\0-\5\5\5T\0\0\0\21]]]\261\362\362"
"\362\311ccc\276\0\0\0,\0\0\0&\0\0\0&\0\0\0#\0\0\0\26\0\0\0\0\0\0\0\0\0\0"
"\0\0\11\11\11h\333\333\333\311\306\306\306\311\0\0\0g\0\0\0&\0\0\0&\0\0\0"
"\31\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\36ooo\304\212\212\212\305\15\15"
"\15q\0\0\0&\0\0\0&\0\0\0!\0\0\0\6\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0""8"
"\0\0\0\35\0\0\0\25\0\0\0&\0\0\0&\0\0\0%\0\0\0\21\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10\0\0\0#\0\0\0&\0\0\0%\0\0\0\24\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\24\0\0\0\34\0\0\0\22"
"\0\0\0\4",
};
static void fb_cursor_save(framebuffer_t *fb)
{
uint8_t *savebuf;
int savelen;
uint8_t *pvid;
int yloop;
int height = fb->cursor->height;
if ((fb->height - fb->cursor->y) < height)
height = fb->height - fb->cursor->y;
if (height == 0) {
if (fb->cursor->savedata != NULL)
free(fb->cursor->savedata);
fb->cursor->savedata = NULL;
return;
}
savelen = ((fb->cursor->width * fb->bpp) / 8);
savebuf = malloc(savelen * height);
if (savebuf == NULL)
return;
if (fb->cursor->savedata != NULL)
free(fb->cursor->savedata);
fb->cursor->savedata = savebuf;
pvid = fb->ptr +
(fb->cursor->y * fb->linelen) +
((fb->cursor->x * fb->bpp) / 8);
for (yloop=0; yloop < height; yloop++) {
memcpy(savebuf, pvid, savelen);
savebuf += savelen;
pvid += fb->linelen;
}
}
static void fb_cursor_clear(framebuffer_t *fb)
{
uint8_t *savebuf;
int savelen;
uint8_t *pvid;
int yloop;
int height = fb->cursor->height;
if ((fb->height - fb->cursor->y) < height)
height = fb->height - fb->cursor->y ;
if (height == 0)
return;
if (fb->cursor->plotted == false)
return;
fb->cursor->plotted = false;
savebuf = fb->cursor->savedata;
if (savebuf == NULL)
return;
savelen = ((fb->cursor->width * fb->bpp) / 8);
pvid = fb->ptr +
(fb->cursor->y * fb->linelen) +
((fb->cursor->x * fb->bpp) / 8);
for (yloop=0; yloop < height; yloop++) {
memcpy(pvid, savebuf, savelen);
savebuf += savelen;
pvid += fb->linelen;
}
}
void
fb_cursor_move(framebuffer_t *fb, int x, int y)
{
fb_cursor_clear(fb);
fb->cursor->x += x;
fb->cursor->y += y;
if (fb->cursor->x < 0)
fb->cursor->x = 0;
if (fb->cursor->y < 0)
fb->cursor->y = 0;
if (fb->cursor->x > fb->width)
fb->cursor->x = fb->width;
if (fb->cursor->y > fb->height)
fb->cursor->y = fb->height;
}
void
fb_cursor_plot(framebuffer_t *fb)
{
bbox_t saved_plot_ctx;
if (fb->cursor->plotted)
return;
saved_plot_ctx = fb_plot_ctx;
fb_plot_ctx.x0 = 0;
fb_plot_ctx.y0 = 0;
fb_plot_ctx.x1 = fb->width;
fb_plot_ctx.y1 = fb->height;
fb_cursor_save(fb);
plot.bitmap(fb->cursor->x, fb->cursor->y,
fb->cursor->width, fb->cursor->height,
fb->cursor->bitmap, 0, NULL);
fb->cursor->plotted = true;
fb_plot_ctx = saved_plot_ctx;
}
fb_cursor_t *
fb_cursor_init(framebuffer_t *fb)
{
fb_cursor_t *cursor;
cursor = calloc(1, sizeof(fb_cursor_t));
cursor->x = fb->width / 2;
cursor->y = fb->height / 2;
cursor->width = pointer_image.width;
cursor->height = pointer_image.height;
cursor->bitmap = bitmap_create(cursor->width, cursor->height, 0);
memcpy(cursor->bitmap->pixdata,
pointer_image.pixel_data,
pointer_image.width *
pointer_image.height *
pointer_image.bytes_per_pixel);
cursor->plotted = false;
return cursor;
}
void
fb_cursor_click(framebuffer_t *fb,
struct gui_window *g,
browser_mouse_state st)
{
browser_window_mouse_click(g->bw,
st,
fb->cursor->x,
fb->cursor->y + g->scrolly);
}
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

30
framebuffer/fb_cursor.h Normal file
View File

@ -0,0 +1,30 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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/>.
*/
#ifndef FRAMEBUFFER_FB_CURSOR
#define FRAMEBUFFER_FB_CURSOR
void fb_cursor_move(struct framebuffer_s *fb, int x, int y);
void fb_cursor_plot(struct framebuffer_s *fb);
fb_cursor_t *fb_cursor_init(struct framebuffer_s *fb);
void fb_cursor_click(framebuffer_t *fb, struct gui_window *g, browser_mouse_state st);
#endif

55
framebuffer/fb_filetype.c Normal file
View File

@ -0,0 +1,55 @@
/*
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
*
* 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 <stdlib.h>
#include <string.h>
#include "content/fetch.h"
#include "utils/log.h"
#include "utils/utils.h"
/**
* filetype -- determine the MIME type of a local file
*/
const char *fetch_filetype(const char *unix_path)
{
int l;
LOG(("unix path %s", unix_path));
l = strlen(unix_path);
if (2 < l && strcasecmp(unix_path + l - 3, "css") == 0)
return "text/css";
if (2 < l && strcasecmp(unix_path + l - 3, "jpg") == 0)
return "image/jpeg";
if (3 < l && strcasecmp(unix_path + l - 4, "jpeg") == 0)
return "image/jpeg";
if (2 < l && strcasecmp(unix_path + l - 3, "gif") == 0)
return "image/gif";
if (2 < l && strcasecmp(unix_path + l - 3, "png") == 0)
return "image/png";
if (2 < l && strcasecmp(unix_path + l - 3, "jng") == 0)
return "image/jng";
if (2 < l && strcasecmp(unix_path + l - 3, "svg") == 0)
return "image/svg";
return "text/html";
}
char *fetch_mimetype(const char *ro_path)
{
return strdup("text/plain");
}

85
framebuffer/fb_findfile.c Normal file
View File

@ -0,0 +1,85 @@
/*
* Copyright 2008 Daniel Silverstone <dsilvers@netsurf-browser.org>
*
* 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 <limits.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fb_findfile.h"
static bool
fb_findfile_exists(char *buffer, const char *base, const char *filename)
{
if (base == NULL)
return false;
if (*base == '~') {
snprintf(buffer, PATH_MAX, "%s/%s/%s",
getenv("HOME") ? getenv("HOME") : "",
base + 1, filename);
} else {
snprintf(buffer, PATH_MAX, "%s/%s", base, filename);
}
return (access(buffer, R_OK) == 0);
}
char *
fb_findfile(const char *filename)
{
static char buffer[PATH_MAX];
/* Search sequence is:
* home/filename
* res-env/filename
* resources/filename
*/
if (fb_findfile_exists(buffer, NETSURF_FB_HOMEPATH, filename))
return buffer;
if (fb_findfile_exists(buffer, getenv("NETSURF_RES"), filename))
return buffer;
if (fb_findfile_exists(buffer, NETSURF_FB_RESPATH, filename))
return buffer;
return NULL;
}
char *
fb_findfile_asurl(const char *filename)
{
static char buffer[PATH_MAX];
char *f = fb_findfile(filename);
if (f == NULL)
return NULL;
snprintf(buffer, PATH_MAX, "file://%s", f);
return strdup(buffer);
}
/*
* Local Variables:
* c-basic-offset: 8
* End:
*/

25
framebuffer/fb_findfile.h Normal file
View File

@ -0,0 +1,25 @@
/*
* Copyright 2008 Daniel Silverstone <dsilvers@netsurf-browser.org>
*
* 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/>.
*/
#ifndef NETSURF_FB_FINDFILE_H
#define NETSURF_FB_FINDFILE_H
extern char *fb_findfile(const char *filename);
extern char *fb_findfile_asurl(const char *filename);
#endif /* NETSURF_FB_FINDFILE_H */

134
framebuffer/fb_font.c Normal file
View File

@ -0,0 +1,134 @@
/*
* Copyright 2005 James Bursa <bursa@users.sourceforge.net>
* 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <inttypes.h>
#include <assert.h>
#include "css/css.h"
#include "render/font.h"
#include "desktop/options.h"
#include "utils/utf8.h"
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_font.h"
const struct fb_font_desc*
fb_get_font(const struct css_style *style)
{
return &font_vga_8x16;
}
utf8_convert_ret utf8_to_font_encoding(const struct fb_font_desc* font,
const char *string,
size_t len,
char **result)
{
return utf8_to_enc(string, font->encoding, len, result);
}
utf8_convert_ret utf8_to_local_encoding(const char *string,
size_t len,
char **result)
{
return utf8_to_enc(string, "CP437", len, result);
}
static bool nsfont_width(const struct css_style *style,
const char *string, size_t length,
int *width)
{
const struct fb_font_desc* fb_font = fb_get_font(style);
*width = fb_font->width * length;
return true;
}
/**
* Find the position in a string where an x coordinate falls.
*
* \param style css_style for this text, with style->font_size.size ==
* CSS_FONT_SIZE_LENGTH
* \param string UTF-8 string to measure
* \param length length of string
* \param x x coordinate to search for
* \param char_offset updated to offset in string of actual_x, [0..length]
* \param actual_x updated to x coordinate of character closest to x
* \return true on success, false on error and error reported
*/
static bool nsfont_position_in_string(const struct css_style *style,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x)
{
const struct fb_font_desc* fb_font = fb_get_font(style);
*char_offset = x / fb_font->width;
*actual_x = *char_offset * fb_font->width;
return true;
}
/**
* Find where to split a string to make it fit a width.
*
* \param style css_style for this text, with style->font_size.size ==
* CSS_FONT_SIZE_LENGTH
* \param string UTF-8 string to measure
* \param length length of string
* \param x width available
* \param char_offset updated to offset in string of actual_x, [0..length]
* \param actual_x updated to x coordinate of character closest to x
* \return true on success, false on error and error reported
*
* On exit, [char_offset == 0 ||
* string[char_offset] == ' ' ||
* char_offset == length]
*/
static bool nsfont_split(const struct css_style *style,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x)
{
const struct fb_font_desc* fb_font = fb_get_font(style);
*char_offset = x / fb_font->width;
if (*char_offset > length) {
*char_offset = length;
} else {
while (*char_offset > 0) {
if (string[*char_offset] == ' ')
break;
(*char_offset)--;
}
}
*actual_x = *char_offset * fb_font->width;
return true;
}
const struct font_functions nsfont = {
nsfont_width,
nsfont_position_in_string,
nsfont_split
};
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

39
framebuffer/fb_font.h Normal file
View File

@ -0,0 +1,39 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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/>.
*/
#ifndef NETSURF_FB_FONT_H
#define NETSURF_FB_FONT_H
struct fb_font_desc {
const char *name;
int width, height;
const char *encoding;
const uint32_t *data;
};
extern const struct fb_font_desc font_vga_8x16;
extern const struct fb_font_desc* fb_get_font(const struct css_style *style);
extern utf8_convert_ret utf8_to_font_encoding(const struct fb_font_desc* font,
const char *string,
size_t len,
char **result);
#endif /* NETSURF_FB_FONT_H */

27
framebuffer/fb_frontend.h Normal file
View File

@ -0,0 +1,27 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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/>.
*/
#ifndef NETSURF_FB_FRONTEND_H
#define NETSURF_FB_FRONTEND_H
extern framebuffer_t *fb_os_init(int argc, char** argv);
extern void fb_os_quit(framebuffer_t *fb);
extern void fb_os_input(struct gui_window *g);
extern void fb_os_option_override(void);
#endif /* NETSURF_FB_FRONTEND_H */

View File

@ -0,0 +1,142 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <string.h>
#include <able/fb.h>
#include "css/css.h"
#include "desktop/options.h"
#include "desktop/gui.h"
#include "desktop/options.h"
#include "utils/messages.h"
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_frontend.h"
#include "utils/log.h"
int devfd;
static const char *fbdevname = "(fb0)";
framebuffer_t *fb_os_init(int argc, char** argv)
{
framebuffer_t *newfb;
struct fb_info_s *fbinfo;
argb_t palent;
int ploop;
int res;
/* open display device */
devfd = open(option_fb_device ? option_fb_device : fbdevname, O_RDWR);
if (devfd < 0) {
LOG(("Error opening output device %s", fbdevname));
return NULL;
}
LOG(("Opened %s fd is %d",fbdevname, devfd));
res = ioctl(devfd, IOCTL_FB_GETINFO, &fbinfo);
if (res < 0) {
LOG(("Output device error"));
close(devfd);
return NULL;
}
LOG(("Framebuffer device name %s bpp %d\n",
fbinfo->name,
fbinfo->screeninfo->bits_per_pixel));
newfb = calloc(1, sizeof(framebuffer_t));
newfb->width = fbinfo->screeninfo->xres;
newfb->height = fbinfo->screeninfo->yres;
newfb->ptr = fbinfo->video_start + fbinfo->video_scroll;
newfb->linelen = fbinfo->line_len;
newfb->bpp = fbinfo->screeninfo->bits_per_pixel;
if (newfb->bpp <= 8) {
for(ploop=0; ploop<256; ploop++) {
palent = fbinfo->cur_palette[ploop];
newfb->palette[ploop] = 0xFF000000 |
palent.b << 16 |
palent.g << 8 |
palent.r ;
}
}
/* set stdin to nonblocking */
fcntl(0, F_SETFL, O_NONBLOCK);
return newfb;
}
void fb_os_quit(framebuffer_t *fb)
{
}
void fb_os_input(struct gui_window *g)
{
ssize_t amt;
char key;
amt = read(0, &key, 1);
if (amt > 0) {
if (key == 'j') {
g->scrolly +=100;
gui_window_redraw_window(g);
}
if (key == 'k') {
g->scrolly -=100;
if (g->scrolly < 0)
g->scrolly = 0;
gui_window_redraw_window(g);
}
if (key == 'q') {
browser_window_destroy(g->bw);
}
if (key == 'd') {
list_schedule();
}
}
}
void
fb_os_option_override(void)
{
/* override some options */
option_max_cached_fetch_handles = 1;
option_max_fetchers = option_max_fetchers_per_host = 1;
}
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

View File

@ -0,0 +1,79 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <string.h>
#include "css/css.h"
#include "desktop/options.h"
#include "desktop/gui.h"
#include "desktop/options.h"
#include "utils/messages.h"
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_frontend.h"
#include "utils/log.h"
#define FILE_PFX "/home/vince/netsurf/netsurf-fb/framebuffer/res/"
framebuffer_t *fb_os_init(int argc, char** argv)
{
framebuffer_t *newfb;
newfb = calloc(1, sizeof(framebuffer_t));
newfb->width = 800;
newfb->height = 600;
newfb->bpp = 16;
newfb->ptr = malloc((newfb->width * newfb->height * newfb->bpp) / 8);
newfb->linelen = (newfb->width * newfb->bpp) / 8;
/* load browser messages */
messages_load(FILE_PFX "messages");
/* load browser options */
options_read(FILE_PFX "Options");
default_stylesheet_url = strdup("file://" FILE_PFX "default.css");
return newfb;
}
void fb_os_quit(framebuffer_t *fb)
{
free(fb->ptr);
}
void fb_os_input(struct gui_window *g)
{
}
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

View File

@ -0,0 +1,681 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <signal.h>
#include <sys/types.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <errno.h>
#include <setjmp.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <dirent.h>
#include <fnmatch.h>
#include <linux/kd.h>
#include <linux/vt.h>
#include <linux/fb.h>
#include <linux/input.h>
#include "css/css.h"
#include "desktop/browser.h"
#include "desktop/gui.h"
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_schedule.h"
#include "framebuffer/fb_cursor.h"
#include "framebuffer/fb_frontend.h"
#include "framebuffer/fb_options.h"
#include "utils/log.h"
#include "utils/messages.h"
#define FB_ACTIVE 0
#define FB_REL_REQ 1
#define FB_INACTIVE 2
#define FB_ACQ_REQ 3
struct fb_fix_screeninfo fb_fix;
struct fb_var_screeninfo fb_var;
unsigned char *fb_mem;
int fb_mem_offset = 0;
int fb_switch_state = FB_ACTIVE;
static int fb,tty;
static int orig_vt_no = 0;
static struct vt_mode vt_mode;
static int kd_mode;
static struct vt_mode vt_omode;
static struct termios term;
static struct fb_var_screeninfo fb_ovar;
static unsigned short ored[256], ogreen[256], oblue[256], otransp[256];
static struct fb_cmap ocmap = { 0, 256, ored, ogreen, oblue, otransp };
typedef struct _input_dev {
struct _input_dev *next;
int fd;
} fb_input_dev;
static fb_input_dev *inputdevs = 0;
/* -------------------------------------------------------------------- */
/* devices */
struct DEVS {
const char *fb0;
const char *fbnr;
const char *ttynr;
};
struct DEVS devs_default = {
.fb0 = "/dev/fb0",
.fbnr = "/dev/fb%d",
.ttynr = "/dev/tty%d",
};
struct DEVS devs_devfs = {
.fb0 = "/dev/fb/0",
.fbnr = "/dev/fb/%d",
.ttynr = "/dev/vc/%d",
};
struct DEVS *devices;
static void dev_init(void)
{
struct stat dummy;
if (NULL != devices)
return;
if (0 == stat("/dev/.devfsd",&dummy))
devices = &devs_devfs;
else
devices = &devs_default;
}
static char *
fconcat(const char *base, const char *leaf)
{
static char buffer[PATH_MAX];
snprintf(buffer, PATH_MAX, "%s/%s", base, leaf);
return buffer;
}
/* Input device opening */
static void
fb_open_input_devices(void)
{
DIR *dir;
fb_input_dev *d;
struct dirent *de;
const char *basepath = option_fb_input_devpath ? option_fb_input_devpath : "/dev/input";
dir = opendir(basepath);
if (dir == NULL)
return;
while ((de = readdir(dir)) != NULL) {
if (fnmatch(option_fb_input_glob ? option_fb_input_glob : "event*",
de->d_name, 0) == 0) {
char *cc = fconcat(basepath, de->d_name);
int fd = open(cc, O_RDONLY | O_NONBLOCK);
if (fd >= 0) {
d = calloc(1, sizeof(fb_input_dev));
d->next = inputdevs;
inputdevs = d;
d->fd = fd;
}
}
}
closedir(dir);
}
/* -------------------------------------------------------------------- */
/* console switching */
static void
fb_switch_signal(int signal)
{
if (signal == SIGUSR1) {
/* release */
fb_switch_state = FB_REL_REQ;
}
if (signal == SIGUSR2) {
/* acquisition */
fb_switch_state = FB_ACQ_REQ;
}
}
static int
fb_switch_init(void)
{
struct sigaction act,old;
memset(&act,0,sizeof(act));
act.sa_handler = fb_switch_signal;
sigemptyset(&act.sa_mask);
sigaction(SIGUSR1,&act,&old);
sigaction(SIGUSR2,&act,&old);
if (-1 == ioctl(tty,VT_GETMODE, &vt_mode)) {
perror("ioctl VT_GETMODE");
exit(1);
}
vt_mode.mode = VT_PROCESS;
vt_mode.waitv = 0;
vt_mode.relsig = SIGUSR1;
vt_mode.acqsig = SIGUSR2;
if (-1 == ioctl(tty,VT_SETMODE, &vt_mode)) {
perror("ioctl VT_SETMODE");
exit(1);
}
return 0;
}
/* -------------------------------------------------------------------- */
/* initialisation & cleanup */
static void
fb_memset (void *addr, int c, size_t len)
{
#if 1 /* defined(__powerpc__) */
unsigned int i, *p;
i = (c & 0xff) << 8;
i |= i << 16;
len >>= 2;
for (p = addr; len--; p++)
*p = i;
#else
memset(addr, c, len);
#endif
}
static int
fb_setmode(const char *name, int bpp)
{
FILE *fp;
char line[80],label[32],value[16];
int geometry=0, timings=0;
/* load current values */
if (ioctl(fb,FBIOGET_VSCREENINFO,&fb_var) == -1) {
perror("ioctl FBIOGET_VSCREENINFO");
exit(1);
}
if (name == NULL)
return -1;
if ((fp = fopen("/etc/fb.modes","r")) == NULL)
return -1;
while (NULL != fgets(line,79,fp)) {
if (1 == sscanf(line, "mode \"%31[^\"]\"",label) &&
0 == strcmp(label,name)) {
/* fill in new values */
fb_var.sync = 0;
fb_var.vmode = 0;
while (NULL != fgets(line,79,fp) &&
NULL == strstr(line,"endmode")) {
if (5 == sscanf(line," geometry %d %d %d %d %d",
&fb_var.xres,&fb_var.yres,
&fb_var.xres_virtual,&fb_var.yres_virtual,
&fb_var.bits_per_pixel))
geometry = 1;
if (7 == sscanf(line," timings %d %d %d %d %d %d %d",
&fb_var.pixclock,
&fb_var.left_margin, &fb_var.right_margin,
&fb_var.upper_margin, &fb_var.lower_margin,
&fb_var.hsync_len, &fb_var.vsync_len))
timings = 1;
if (1 == sscanf(line, " hsync %15s",value) &&
0 == strcasecmp(value,"high"))
fb_var.sync |= FB_SYNC_HOR_HIGH_ACT;
if (1 == sscanf(line, " vsync %15s",value) &&
0 == strcasecmp(value,"high"))
fb_var.sync |= FB_SYNC_VERT_HIGH_ACT;
if (1 == sscanf(line, " csync %15s",value) &&
0 == strcasecmp(value,"high"))
fb_var.sync |= FB_SYNC_COMP_HIGH_ACT;
if (1 == sscanf(line, " extsync %15s",value) &&
0 == strcasecmp(value,"true"))
fb_var.sync |= FB_SYNC_EXT;
if (1 == sscanf(line, " laced %15s",value) &&
0 == strcasecmp(value,"true"))
fb_var.vmode |= FB_VMODE_INTERLACED;
if (1 == sscanf(line, " double %15s",value) &&
0 == strcasecmp(value,"true"))
fb_var.vmode |= FB_VMODE_DOUBLE;
}
/* ok ? */
if (!geometry || !timings)
return -1;
if (bpp != 0)
fb_var.bits_per_pixel = bpp;
/* set */
fb_var.xoffset = 0;
fb_var.yoffset = 0;
if (-1 == ioctl(fb,FBIOPUT_VSCREENINFO,&fb_var))
perror("ioctl FBIOPUT_VSCREENINFO");
/* look what we have now ... */
if (-1 == ioctl(fb,FBIOGET_VSCREENINFO,&fb_var)) {
perror("ioctl FBIOGET_VSCREENINFO");
exit(1);
}
return 0;
}
}
return -1;
}
static void
fb_setvt(int vtno)
{
struct vt_stat vts;
char vtname[12];
if (vtno < 0) {
if (-1 == ioctl(tty,VT_OPENQRY, &vtno) || vtno == -1) {
perror("ioctl VT_OPENQRY");
exit(1);
}
}
vtno &= 0xff;
sprintf(vtname, devices->ttynr, vtno);
chown(vtname, getuid(), getgid());
if (-1 == access(vtname, R_OK | W_OK)) {
fprintf(stderr,"access %s: %s\n",vtname,strerror(errno));
exit(1);
}
/* switch (fork()) {
case 0:
break;
case -1:
perror("fork");
exit(1);
default:
exit(0);
}
close(tty);
close(0);
close(1);
close(2);
setsid();
open(vtname,O_RDWR);
dup(0);
dup(0);
*/
tty = open(vtname,O_RDWR);
if (-1 == ioctl(tty,VT_GETSTATE, &vts)) {
perror("ioctl VT_GETSTATE");
exit(1);
}
orig_vt_no = vts.v_active;
if (-1 == ioctl(tty,VT_ACTIVATE, vtno)) {
perror("ioctl VT_ACTIVATE");
exit(1);
}
if (-1 == ioctl(tty,VT_WAITACTIVE, vtno)) {
perror("ioctl VT_WAITACTIVE");
exit(1);
}
}
/* Hmm. radeonfb needs this. matroxfb doesn't. */
static int
fb_activate_current(int tty)
{
struct vt_stat vts;
if (-1 == ioctl(tty,VT_GETSTATE, &vts)) {
perror("ioctl VT_GETSTATE");
return -1;
}
if (-1 == ioctl(tty,VT_ACTIVATE, vts.v_active)) {
perror("ioctl VT_ACTIVATE");
return -1;
}
if (-1 == ioctl(tty,VT_WAITACTIVE, vts.v_active)) {
perror("ioctl VT_WAITACTIVE");
return -1;
}
return 0;
}
static void
fb_cleanup(void)
{
/* restore console */
if (-1 == ioctl(fb,FBIOPUT_VSCREENINFO,&fb_ovar))
perror("ioctl FBIOPUT_VSCREENINFO");
if (-1 == ioctl(fb,FBIOGET_FSCREENINFO,&fb_fix))
perror("ioctl FBIOGET_FSCREENINFO");
if (fb_ovar.bits_per_pixel == 8 ||
fb_fix.visual == FB_VISUAL_DIRECTCOLOR) {
if (-1 == ioctl(fb,FBIOPUTCMAP,&ocmap))
perror("ioctl FBIOPUTCMAP");
}
close(fb);
if (-1 == ioctl(tty,KDSETMODE, kd_mode))
perror("ioctl KDSETMODE");
if (-1 == ioctl(tty,VT_SETMODE, &vt_omode))
perror("ioctl VT_SETMODE");
if (orig_vt_no && -1 == ioctl(tty, VT_ACTIVATE, orig_vt_no))
perror("ioctl VT_ACTIVATE");
if (orig_vt_no && -1 == ioctl(tty, VT_WAITACTIVE, orig_vt_no))
perror("ioctl VT_WAITACTIVE");
tcsetattr(tty, TCSANOW, &term);
close(tty);
}
static int
fb_init(const char *device, const char *mode, int bpp, int vt)
{
char fbdev[16];
struct vt_stat vts;
long pm = ~(sysconf(_SC_PAGESIZE) - 1);
dev_init();
tty = 0;
if (vt != 0)
fb_setvt(vt);
if (-1 == ioctl(tty,VT_GETSTATE, &vts)) {
fprintf(stderr,"ioctl VT_GETSTATE: %s (not a linux console?)\n",
strerror(errno));
exit(1);
}
if (device == NULL) {
device = getenv("FRAMEBUFFER");
if (device == NULL) {
struct fb_con2fbmap c2m;
if (-1 == (fb = open(devices->fb0,O_RDWR /* O_WRONLY */,0))) {
fprintf(stderr,"open %s: %s\n",devices->fb0,strerror(errno));
exit(1);
}
c2m.console = vts.v_active;
if (-1 == ioctl(fb, FBIOGET_CON2FBMAP, &c2m)) {
perror("ioctl FBIOGET_CON2FBMAP");
exit(1);
}
close(fb);
fprintf(stderr,"map: vt%02d => fb%d\n",
c2m.console,c2m.framebuffer);
sprintf(fbdev,devices->fbnr,c2m.framebuffer);
device = fbdev;
}
}
/* get current settings (which we have to restore) */
if (-1 == (fb = open(device,O_RDWR /* O_WRONLY */))) {
fprintf(stderr,"open %s: %s\n",device,strerror(errno));
exit(1);
}
if (-1 == ioctl(fb,FBIOGET_VSCREENINFO,&fb_ovar)) {
perror("ioctl FBIOGET_VSCREENINFO");
exit(1);
}
if (-1 == ioctl(fb,FBIOGET_FSCREENINFO,&fb_fix)) {
perror("ioctl FBIOGET_FSCREENINFO");
exit(1);
}
if (fb_ovar.bits_per_pixel == 8 ||
fb_fix.visual == FB_VISUAL_DIRECTCOLOR) {
if (-1 == ioctl(fb,FBIOGETCMAP,&ocmap)) {
perror("ioctl FBIOGETCMAP");
exit(1);
}
}
if (-1 == ioctl(tty,KDGETMODE, &kd_mode)) {
perror("ioctl KDGETMODE");
exit(1);
}
if (-1 == ioctl(tty,VT_GETMODE, &vt_omode)) {
perror("ioctl VT_GETMODE");
exit(1);
}
tcgetattr(tty, &term);
/* switch mode */
fb_setmode(mode, bpp);
/* checks & initialisation */
if (-1 == ioctl(fb,FBIOGET_FSCREENINFO,&fb_fix)) {
perror("ioctl FBIOGET_FSCREENINFO");
exit(1);
}
if (fb_fix.type != FB_TYPE_PACKED_PIXELS) {
fprintf(stderr,"can handle only packed pixel frame buffers\n");
goto err;
}
fb_mem_offset = (unsigned long)(fb_fix.smem_start) & (~pm);
fb_mem = mmap(NULL,fb_fix.smem_len+fb_mem_offset,
PROT_READ|PROT_WRITE,MAP_SHARED,fb,0);
if (-1L == (long)fb_mem) {
perror("mmap");
goto err;
}
/* move viewport to upper left corner */
if (fb_var.xoffset != 0 || fb_var.yoffset != 0) {
fb_var.xoffset = 0;
fb_var.yoffset = 0;
if (-1 == ioctl(fb,FBIOPAN_DISPLAY,&fb_var)) {
perror("ioctl FBIOPAN_DISPLAY");
goto err;
}
}
if (-1 == ioctl(tty,KDSETMODE, KD_GRAPHICS)) {
perror("ioctl KDSETMODE");
goto err;
}
fb_activate_current(tty);
/* cls */
fb_memset(fb_mem + fb_mem_offset, 0, fb_fix.smem_len);
return fb;
err:
fb_cleanup();
exit(1);
}
/* -------------------------------------------------------------------- */
/* handle fatal errors */
static jmp_buf fb_fatal_cleanup;
static void
fb_catch_exit_signal(int signal)
{
siglongjmp(fb_fatal_cleanup,signal);
}
static void
fb_catch_exit_signals(void)
{
struct sigaction act,old;
int termsig;
memset(&act,0,sizeof(act));
act.sa_handler = fb_catch_exit_signal;
sigemptyset(&act.sa_mask);
sigaction(SIGINT, &act,&old);
sigaction(SIGQUIT,&act,&old);
sigaction(SIGTERM,&act,&old);
sigaction(SIGABRT,&act,&old);
sigaction(SIGTSTP,&act,&old);
sigaction(SIGBUS, &act,&old);
sigaction(SIGILL, &act,&old);
sigaction(SIGSEGV,&act,&old);
if (0 == (termsig = sigsetjmp(fb_fatal_cleanup,0)))
return;
/* cleanup */
fb_cleanup();
fprintf(stderr,"Oops: %s\n",sys_siglist[termsig]);
exit(42);
}
framebuffer_t *fb_os_init(int argc, char** argv)
{
framebuffer_t *newfb;
int ploop;
fb_init(option_fb_device, option_fb_mode ? option_fb_mode : "800x600-70", 16, 1);
fb_switch_init();
fb_catch_exit_signals();
newfb = calloc(1, sizeof(framebuffer_t));
newfb->width = fb_var.xres;
newfb->height = fb_var.yres;
newfb->ptr = fb_mem;
newfb->linelen = fb_fix.line_length;
newfb->bpp = fb_var.bits_per_pixel;
if (newfb->bpp <= 8) {
for(ploop=0; ploop < 256; ploop++) {
newfb->palette[ploop] = 0xFF000000 |
ocmap.blue[ploop] << 16 |
ocmap.green[ploop] << 8 |
ocmap.red[ploop] ;
}
}
fb_open_input_devices();
return newfb;
}
void fb_os_quit(framebuffer_t *fb)
{
fb_cleanup();
}
void fb_os_input(struct gui_window *g)
{
ssize_t amt;
struct input_event event;
fb_input_dev *d;
for (d = inputdevs; d != NULL; d = d->next) {
amt = read(d->fd, &event, sizeof(struct input_event));
if (amt > 0) {
if (event.type == EV_KEY) {
if (event.value == 0)
return;
switch (event.code) {
case KEY_J:
fb_window_scroll(g, 0, 100);
break;
case KEY_K:
fb_window_scroll(g, 0, -100);
break;
case KEY_Q:
browser_window_destroy(g->bw);
break;
case KEY_D:
list_schedule();
break;
case KEY_UP:
fb_cursor_move(framebuffer, 0, -1);
break;
case KEY_DOWN:
fb_cursor_move(framebuffer, 0, 1);
break;
case KEY_LEFT:
fb_cursor_move(framebuffer, -1, 0);
break;
case KEY_RIGHT:
fb_cursor_move(framebuffer, 1, 0);
break;
case BTN_LEFT:
fb_cursor_click(framebuffer,
g,
BROWSER_MOUSE_CLICK_1);
break;
}
} else if (event.type == EV_REL) {
switch (event.code) {
case 0:
fb_cursor_move(framebuffer,
event.value,
0);
break;
case 1:
fb_cursor_move(framebuffer,
0,
event.value);
break;
case 8:
fb_window_scroll(g, 0, event.value * -100);
break;
}
}
}
}
}
void
fb_os_option_override(void)
{
}
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

554
framebuffer/fb_gui.c Normal file
View File

@ -0,0 +1,554 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "desktop/gui.h"
#include "desktop/plotters.h"
#include "desktop/netsurf.h"
#include "desktop/options.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "framebuffer/fb_bitmap.h"
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_frontend.h"
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_schedule.h"
#include "framebuffer/fb_cursor.h"
#include "framebuffer/fb_findfile.h"
#include "content/urldb.h"
#include "desktop/history_core.h"
#include "content/fetch.h"
char *default_stylesheet_url;
char *adblock_stylesheet_url;
struct gui_window *input_window = NULL;
struct gui_window *search_current_window;
struct gui_window *window_list = NULL;
bool redraws_pending = false;
framebuffer_t *framebuffer;
static void fb_queue_redraw(struct gui_window *g, int x0, int y0, int x1, int y1);
static void fb_pan(struct gui_window *g)
{
struct content *c;
if (!g)
return;
c = g->bw->current_content;
if (!c) return;
if (c->locked) return;
LOG(("panning %d, %d from %d, %d in content %d,%d",g->panx, g->pany,g->scrollx,g->scrolly,c->width, c->height));
/* dont pan off the top */
if ((g->scrolly + g->pany) < 0)
g->pany = -g->scrolly;
/* do not pan off the bottom of the content */
if ((g->scrolly + g->pany) > (c->height - g->height))
g->pany = (c->height - g->height) - g->scrolly;
LOG(("panning %d, %d",g->panx, g->pany));
/* pump up the volume. dance, dance! lets do it */
if (g->pany < 0) {
/* we cannot pan more than a window height at a time */
if (g->pany < -g->height)
g->pany = -g->height;
LOG(("panning up %d", g->pany));
fb_plotters_move_block(g->x, g->y,
g->width, g->height + g->pany,
g->x, g->y - g->pany);
g->scrolly += g->pany;
fb_queue_redraw(g, g->x, g->y,
g->x + g->width, g->y - g->pany);
}
if (g->pany > 0) {
/* we cannot pan more than a window height at a time */
if (g->pany > g->height)
g->pany = g->height;
LOG(("panning down %d", g->pany));
fb_plotters_move_block(g->x, g->y + g->pany, g->width, g->height - g->pany, g->x, g->y);
g->scrolly += g->pany;
fb_queue_redraw(g, g->x, g->y + g->height - g->pany,
g->x + g->width, g->y + g->height);
}
g->pan_required = false;
g->panx = 0;
g->pany = 0;
}
static void fb_redraw(struct gui_window *g)
{
struct content *c;
if (!g)
return;
c = g->bw->current_content;
if (!c) return;
if (c->locked) return;
content_redraw(c, 0, -g->scrolly, g->width, g->height,
g->redraw_box.x0, g->redraw_box.y0, g->redraw_box.x1, g->redraw_box.y1,
g->bw->scale, 0xFFFFFF);
g->redraw_required = false;
g->redraw_box.y0 = g->redraw_box.x0 = INT_MAX;
g->redraw_box.y1 = g->redraw_box.x1 = -(INT_MAX);
g->panx = 0;
g->pany = 0;
redraws_pending = false;
}
void gui_init(int argc, char** argv)
{
LOG(("argc %d, argv %p", argc, argv));
/* load browser messages */
messages_load(fb_findfile("messages"));
/* load browser options */
options_read(fb_findfile("Options"));
default_stylesheet_url = fb_findfile_asurl("default.css");
framebuffer = fb_os_init(argc, argv);
fb_os_option_override();
option_target_blank = false;
switch (framebuffer->bpp) {
/* case 1:
plot = framebuffer_1bpp_plot;
break;
*/
case 8:
plot = framebuffer_8bpp_plot;
break;
case 16:
plot = framebuffer_16bpp_plot;
break;
case 32:
plot = framebuffer_32bpp_plot;
break;
default:
LOG(("Unsupported bit depth (%d)", framebuffer->bpp));
exit(1);
}
framebuffer->cursor = fb_cursor_init(framebuffer);
}
void gui_init2(int argc, char** argv)
{
struct browser_window *bw;
const char *addr = NETSURF_HOMEPAGE;
LOG(("%s(%d, %p)", __func__, argc, argv));
if (option_homepage_url != NULL && option_homepage_url[0] != '\0')
addr = option_homepage_url;
if (argc > 1) addr = argv[1];
LOG(("%s: calling browser_window_create", __func__));
bw = browser_window_create(addr, 0, 0, true, false);
}
void gui_multitask(void)
{
// LOG(("gui_multitask"));
}
void gui_poll(bool active)
{
// LOG(("enter fetch_poll"));
if (active)
fetch_poll();
//LOG(("enter schedule run"));
schedule_run();
fb_os_input(input_window);
if (redraws_pending == true) {
struct gui_window *g;
fb_cursor_move(framebuffer, 0,0);
redraws_pending = false;
for (g = window_list; g != NULL; g = g->next) {
if (g->pan_required == true) {
fb_pan(g);
}
if (g->redraw_required == true) {
fb_redraw(g);
}
}
}
fb_cursor_plot(framebuffer);
}
void gui_quit(void)
{
LOG(("gui_quit"));
fb_os_quit(framebuffer);
}
struct gui_window *gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone,
bool new_tab)
{
struct gui_window *g, *p;
LOG(("bw %p, clone %p", bw, clone));
g = calloc(1, sizeof(struct gui_window));
if (g == NULL)
return NULL;
g->x = 0;
g->y = 0;
g->width = framebuffer->width;
g->height = framebuffer->height;
g->bw = bw;
if (window_list == NULL) {
window_list = input_window = g;
} else {
for(p = window_list; p->next != NULL; p = p->next);
p->next = g;
g->prev = p;
}
return g;
}
void gui_window_destroy(struct gui_window *g)
{
LOG(("g %p", g));
if (g->prev == NULL) {
window_list = input_window = g->next;
} else {
g->prev->next = g->next;
}
if (g->next != NULL)
g->next->prev = g->prev;
free(g);
if (window_list == NULL)
netsurf_quit = true;
}
void gui_window_set_title(struct gui_window *g, const char *title)
{
LOG(("%s(%p, %s)", __func__, g, title));
}
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
static void fb_queue_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)
{
if (!g) return;
LOG(("%p, %d, %d, %d, %d", g, x0 , y0, x1, y1));
g->redraw_box.x0 = MIN(g->redraw_box.x0, x0);
g->redraw_box.y0 = MIN(g->redraw_box.y0, y0);
g->redraw_box.x1 = MAX(g->redraw_box.x1, x1);
g->redraw_box.y1 = MAX(g->redraw_box.y1, y1);
redraws_pending = true;
g->redraw_required = true;
}
static void fb_queue_pan(struct gui_window *g, int x, int y)
{
if (!g) return;
LOG(("%p, x %d, y %d", g, x , y));
g->panx +=x;
g->pany +=y;
redraws_pending = true;
g->pan_required = true;
}
void fb_window_scroll(struct gui_window *g, int x, int y)
{
fb_queue_pan(g, x, y);
}
void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)
{
if (!g) return;
fb_queue_redraw(g, x0, y0, x1, y1);
}
void gui_window_redraw_window(struct gui_window *g)
{
if (!g) return;
fb_queue_redraw(g, 0, 0, g->width, g->height);
}
void gui_window_update_box(struct gui_window *g,
const union content_msg_data *data)
{
struct content *c;
if (!g) return;
c = g->bw->current_content;
if (c == NULL) return;
gui_window_redraw(g, data->redraw.x, data->redraw.y, data->redraw.x + data->redraw.width, data->redraw.y + data->redraw.height);
}
bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
LOG(("g %p, sx %d, sy%d", g, *sx, *sy));
*sx=0;
*sy=g->scrolly;
return true;
}
void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
LOG(("%s:(%p, %d, %d)", __func__, g, sx, sy));
g->scrolly = sy;
}
void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
int x1, int y1)
{
LOG(("%s:(%p, %d, %d, %d, %d)", __func__, g, x0, y0, x1, y1));
}
void gui_window_position_frame(struct gui_window *g, int x0, int y0,
int x1, int y1)
{
LOG(("%p, %d, %d, %d, %d", g, x0, y0, x1, y1));
}
void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
bool scaled)
{
LOG(("%p, %d, %d, %d", g, *width, *height, scaled));
*width = g->width;
*height = g->height;
}
void gui_window_update_extent(struct gui_window *g)
{
LOG(("g %p", g));
}
void gui_window_set_status(struct gui_window *g, const char *text)
{
LOG(("g %p, text %s", g, text));
}
void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
}
void gui_window_hide_pointer(struct gui_window *g)
{
}
void gui_window_set_url(struct gui_window *g, const char *url)
{
}
void gui_window_start_throbber(struct gui_window *g)
{
}
void gui_window_stop_throbber(struct gui_window *g)
{
}
void gui_window_place_caret(struct gui_window *g, int x, int y, int height)
{
}
void gui_window_remove_caret(struct gui_window *g)
{
}
void gui_window_new_content(struct gui_window *g)
{
}
bool gui_window_scroll_start(struct gui_window *g)
{
return true;
}
bool gui_window_box_scroll_start(struct gui_window *g,
int x0, int y0, int x1, int y1)
{
return true;
}
bool gui_window_frame_resize_start(struct gui_window *g)
{
printf("resize frame\n");
return true;
}
void gui_window_save_as_link(struct gui_window *g, struct content *c)
{
}
void gui_window_set_scale(struct gui_window *g, float scale)
{
printf("set scale\n");
}
struct gui_download_window *gui_download_window_create(const char *url,
const char *mime_type, struct fetch *fetch,
unsigned int total_size, struct gui_window *gui)
{
return NULL;
}
void gui_download_window_data(struct gui_download_window *dw, const char *data,
unsigned int size)
{
}
void gui_download_window_error(struct gui_download_window *dw,
const char *error_msg)
{
}
void gui_download_window_done(struct gui_download_window *dw)
{
}
void gui_drag_save_object(gui_save_type type, struct content *c,
struct gui_window *g)
{
}
void gui_drag_save_selection(struct selection *s, struct gui_window *g)
{
}
void gui_start_selection(struct gui_window *g)
{
}
void gui_paste_from_clipboard(struct gui_window *g, int x, int y)
{
}
bool gui_empty_clipboard(void)
{
return false;
}
bool gui_add_to_clipboard(const char *text, size_t length, bool space)
{
return false;
}
bool gui_commit_clipboard(void)
{
return false;
}
bool gui_copy_to_clipboard(struct selection *s)
{
return false;
}
void gui_create_form_select_menu(struct browser_window *bw,
struct form_control *control)
{
}
void gui_launch_url(const char *url)
{
}
bool gui_search_term_highlighted(struct gui_window *g,
unsigned start_offset, unsigned end_offset,
unsigned *start_idx, unsigned *end_idx)
{
return false;
}
#ifdef WITH_SSL
void gui_cert_verify(struct browser_window *bw, struct content *c,
const struct ssl_cert_info *certs, unsigned long num)
{
}
#endif
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

77
framebuffer/fb_gui.h Normal file
View File

@ -0,0 +1,77 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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/>.
*/
#ifndef NETSURF_FB_GUI_H
#define NETSURF_FB_GUI_H
typedef struct fb_cursor_s fb_cursor_t;
/* bounding box */
typedef struct bbox_s {
int x0;
int y0;
int x1;
int y1;
} bbox_t;
typedef struct framebuffer_s {
int width;
int height;
uint8_t *ptr; /**< Base of video memory. */
int linelen; /**< length of a video line. */
int bpp;
colour palette[256]; /* palette for index modes */
fb_cursor_t *cursor;
} framebuffer_t;
struct gui_window {
struct gui_window *next, *prev; /**< List of windows */
struct browser_window *bw; /**< The browser window connected to this gui window */
int x;
int y;
int width; /**< Window width */
int height; /**< window height */
int scrollx, scrolly; /**< scroll offsets. */
/* Pending window redraw state. */
bool redraw_required; /**< flag indicating the foreground loop
* needs to redraw the window.
*/
bbox_t redraw_box; /**< Area requiring redraw. */
bool pan_required; /**< flag indicating the foreground loop
* needs to pan the window.
*/
int panx, pany; /**< Panning required. */
};
extern framebuffer_t *framebuffer;
extern struct gui_window *window_list;
/* scroll a window */
void fb_window_scroll(struct gui_window *g, int x, int y);
#endif /* NETSURF_FB_GUI_H */
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

41
framebuffer/fb_options.h Normal file
View File

@ -0,0 +1,41 @@
/*
* Copyright 2008 Daniel Silverstone <dsilvers@netsurf-browser.org>
*
* 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/>.
*/
#ifndef _NETSURF_FRAMEBUFFER_OPTIONS_H_
#define _NETSURF_FRAMEBUFFER_OPTIONS_H_
#include "desktop/options.h"
extern char *option_fb_mode;
extern char *option_fb_device;
extern char *option_fb_input_devpath;
extern char *option_fb_input_glob;
#define EXTRA_OPTION_DEFINE \
char *option_fb_mode = 0; \
char *option_fb_device = 0; \
char *option_fb_input_devpath = 0; \
char *option_fb_input_glob = 0;
#define EXTRA_OPTION_TABLE \
{ "fb_mode", OPTION_STRING, &option_fb_mode }, \
{ "fb_device", OPTION_STRING, &option_fb_device }, \
{ "fb_input_devpath", OPTION_STRING, &option_fb_input_devpath }, \
{ "fb_input_glob", OPTION_STRING, &option_fb_input_glob },
#endif

297
framebuffer/fb_plotters.c Normal file
View File

@ -0,0 +1,297 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
#include "utils/log.h"
#include "utils/utf8.h"
#include "desktop/plotters.h"
#include "framebuffer/fb_gui.h"
#include "framebuffer/fb_plotters.h"
#include "framebuffer/fb_bitmap.h"
#include "framebuffer/fb_font.h"
/* Currently selected ploting routines. */
struct plotter_table plot;
/* Current plotting context */
bbox_t fb_plot_ctx;
enum {
POINT_LEFTOF_REGION = 1,
POINT_RIGHTOF_REGION = 2,
POINT_ABOVE_REGION = 4,
POINT_BELOW_REGION = 8,
};
#define REGION(x,y,cx1,cx2,cy1,cy2) ( ( (y) > (cy2) ? POINT_BELOW_REGION : 0) | \
( (y) < (cy1) ? POINT_ABOVE_REGION : 0) | \
( (x) > (cx2) ? POINT_RIGHTOF_REGION : 0) | \
( (x) < (cx1) ? POINT_LEFTOF_REGION : 0) )
#define SWAP(a, b) do { int t; t=(a); (a)=(b); (b)=t; } while(0)
/* clip a rectangle to another rectangle */
bool fb_plotters_clip_rect(const bbox_t *clip,
int *x0, int *y0, int *x1, int *y1)
{
char region1;
char region2;
if (*x1 < *x0) SWAP(*x0, *x1);
if (*y1 < *y0) SWAP(*y0, *y1);
region1 = REGION(*x0, *y0, clip->x0, clip->x1, clip->y0, clip->y1);
region2 = REGION(*x1, *y1, clip->x0, clip->x1, clip->y0, clip->y1);
/* area lies entirely outside the clipping rectangle */
if ((region1 | region2) && (region1 & region2))
return false;
if (*x0 < clip->x0)
*x0 = clip->x0;
if (*x0 > clip->x1)
*x0 = clip->x1;
if (*x1 < clip->x0)
*x1 = clip->x0;
if (*x1 > clip->x1)
*x1 = clip->x1;
if (*y0 < clip->y0)
*y0 = clip->y0;
if (*y0 > clip->y1)
*y0 = clip->y1;
if (*y1 < clip->y0)
*y1 = clip->y0;
if (*y1 > clip->y1)
*y1 = clip->y1;
return true;
}
bool fb_plotters_clip_rect_ctx(int *x0, int *y0, int *x1, int *y1)
{
return fb_plotters_clip_rect(&fb_plot_ctx, x0, y0, x1, y1);
}
/** Clip a line to a bounding box.
*/
bool fb_plotters_clip_line(const bbox_t *clip,
int *x0, int *y0, int *x1, int *y1)
{
char region1;
char region2;
region1 = REGION(*x0, *y0, clip->x0, clip->x1 - 1, clip->y0, clip->y1 - 1);
region2 = REGION(*x1, *y1, clip->x0, clip->x1 - 1, clip->y0, clip->y1 - 1);
while (region1 | region2) {
if (region1 & region2) {
/* line lies entirely outside the clipping rectangle */
return false;
}
if (region1) {
/* first point */
if (region1 & POINT_BELOW_REGION) {
/* divide line at bottom */
*x0 = (*x0 + (*x1 - *x0) *
(clip->y1 - 1 - *y0) / (*y1-*y0));
*y0 = clip->y1 - 1;
} else if (region1 & POINT_ABOVE_REGION) {
/* divide line at top */
*x0 = (*x0 + (*x1 - *x0) *
(clip->y0 - *y0) / (*y1-*y0));
*y0 = clip->y0;
} else if (region1 & POINT_RIGHTOF_REGION) {
/* divide line at right */
*y0 = (*y0 + (*y1 - *y0) *
(clip->x1 - 1 - *x0) / (*x1-*x0));
*x0 = clip->x1 - 1;
} else if (region1 & POINT_LEFTOF_REGION) {
/* divide line at right */
*y0 = (*y0 + (*y1 - *y0) *
(clip->x0 - *x0) / (*x1-*x0));
*x0 = clip->x0;
}
region1 = REGION(*x0, *y0,
clip->x0, clip->x1 - 1, clip->y0, clip->y1 - 1);
} else {
/* second point */
if (region2 & POINT_BELOW_REGION) {
/* divide line at bottom*/
*x1 = (*x0 + (*x1 - *x0) *
(clip->y1 - 1 - *y0) / (*y1-*y0));
*y1 = clip->y1 - 1;
} else if (region2 & POINT_ABOVE_REGION) {
/* divide line at top*/
*x1 = (*x0 + (*x1 - *x0) *
(clip->y0 - *y0) / (*y1-*y0));
*y1 = clip->y0;
} else if (region2 & POINT_RIGHTOF_REGION) {
/* divide line at right*/
*y1 = (*y0 + (*y1 - *y0) *
(clip->x1 - 1 - *x0) / (*x1 - *x0));
*x1 = clip->x1 - 1;
} else if (region2 & POINT_LEFTOF_REGION) {
/* divide line at right*/
*y1 = (*y0 + (*y1 - *y0) *
(clip->x0 - *x0) / (*x1 - *x0));
*x1 = clip->x0;
}
region2 = REGION(*x1, *y1,
clip->x0, clip->x1 - 1, clip->y0, clip->y1 - 1);
}
}
return true;
}
bool fb_plotters_clip_line_ctx(int *x0, int *y0, int *x1, int *y1)
{
return fb_plotters_clip_line(&fb_plot_ctx, x0, y0, x1, y1);
}
/* generic setting of clipping rectangle */
bool fb_clip(int x0, int y0, int x1, int y1)
{
bbox_t clip;
struct gui_window *g;
g = window_list;
/* LOG(("x0 %d, y0 %d, x1 %d, y1 %d", x0, y0, x1, y1)); */
if (x1 < x0) SWAP(x0, x1);
if (y1 < y0) SWAP(y0, y1);
clip.x0 = g->x;
clip.y0 = g->y;
clip.x1 = g->x + g->width;
clip.y1 = g->x + g->height;
if (fb_plotters_clip_rect(&clip, &x0, &y0, &x1, &y1)) {
/* new clipping region is inside the root window */
fb_plot_ctx.x0 = x0;
fb_plot_ctx.y0 = y0;
fb_plot_ctx.x1 = x1;
fb_plot_ctx.y1 = y1;
}
return true;
}
colour fb_plotters_ablend(colour pixel, colour scrpixel)
{
int opacity = (pixel >> 24) & 0xFF;
int r,g,b;
r = (((pixel & 0xFF) * opacity) >> 8) +
(((scrpixel & 0xFF) * (0xFF - opacity)) >> 8);
g = ((((pixel & 0xFF00) >> 8) * opacity) >> 8) +
((((scrpixel & 0xFF00) >> 8) * (0xFF - opacity)) >> 8);
b = ((((pixel & 0xFF0000) >> 16) * opacity) >> 8) +
((((scrpixel & 0xFF0000) >> 16) * (0xFF - opacity)) >> 8);
return r | (g << 8) | (b << 16);
}
bool
fb_plotters_polygon(int *p, unsigned int n, colour fill,bool (linefn)(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed))
{
unsigned int pnt;
int *cur = p;
for (pnt = 1; pnt < n; pnt++) {
cur = p + (pnt << 1);
linefn(cur[-2], cur[-1], cur[0], cur[1], 1, fill, false, false);
}
linefn(cur[0], cur[1], p[0], p[1], 1, fill, false, false);
return true;
}
bool fb_plotters_bitmap_tile(int x, int y,
int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y,
struct content *content,
bool (bitmapfn)(int x, int y,
int width, int height,
struct bitmap *bitmap,
colour bg,
struct content *content))
{
int xf,yf;
/* x and y define top left hand corner of tile start, the width height
* are the mage scaling and the bounding box defines teh extent of the
* repeat
*/
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 bitmapfn(x, y, width, height, bitmap, bg,content);
}
for (xf = x; xf < fb_plot_ctx.x1; xf += width) {
for (yf = y; yf < fb_plot_ctx.y1; yf += height) {
bitmapfn(xf, yf, width, height, bitmap, bg, content);
if (!repeat_y)
break;
}
if (!repeat_x)
break;
}
return true;
}
bool fb_plotters_move_block(int srcx, int srcy, int width, int height, int dstx, int dsty)
{
LOG(("from (%d,%d) w %d h %d to (%d,%d)",srcx,srcy,width,height,dstx,dsty));
uint8_t *srcptr = (framebuffer->ptr +
(srcy * framebuffer->linelen) +
(srcx));
uint8_t *dstptr = (framebuffer->ptr +
(dsty * framebuffer->linelen) +
(dstx));
memmove(dstptr, srcptr, (width * height * framebuffer->bpp) / 8);
return true;
}
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

58
framebuffer/fb_plotters.h Normal file
View File

@ -0,0 +1,58 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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/>.
*/
#ifndef FRAMEBUFFER_PLOTTERS_H
#define FRAMEBUFFER_PLOTTERS_H
extern const struct plotter_table framebuffer_1bpp_plot;
extern const struct plotter_table framebuffer_8bpp_plot;
extern const struct plotter_table framebuffer_16bpp_plot;
extern const struct plotter_table framebuffer_32bpp_plot;
/* plotting context */
extern bbox_t fb_plot_ctx;
/* plotter support functions */
bool fb_plotters_clip_rect_ctx(int *x0, int *y0, int *x1, int *y1);
bool fb_plotters_clip_rect(const bbox_t *clip, int *x0, int *y0, int *x1, int *y1);
bool fb_plotters_clip_line_ctx(int *x0, int *y0, int *x1, int *y1);
bool fb_plotters_clip_line(const bbox_t *clip, int *x0, int *y0, int *x1, int *y1);
bool fb_plotters_polygon(int *p, unsigned int n, colour fill, bool (linefn)(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed));
bool fb_plotters_bitmap_tile(int x, int y,
int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y,
struct content *content,
bool (bitmapfn)(int x, int y,
int width, int height,
struct bitmap *bitmap,
colour bg,
struct content *content));
colour fb_plotters_ablend(colour pixel, colour scrpixel);
bool fb_plotters_move_block(int srcx, int srcy, int width, int height, int dstx, int dsty);
/* generic plotter entry points */
bool fb_clip(int x0, int y0, int x1, int y1);
#endif

196
framebuffer/fb_schedule.c Normal file
View File

@ -0,0 +1,196 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <sys/time.h>
#include <time.h>
#include "desktop/browser.h"
#include "framebuffer/fb_schedule.h"
#include "utils/log.h"
/* linked list of scheduled callbacks */
static struct nscallback *schedule_list = NULL;
/**
* scheduled callback.
*/
struct nscallback
{
struct nscallback *next;
struct timeval tv;
void (*callback)(void *p);
void *p;
};
/**
* Schedule a callback.
*
* \param tival interval before the callback should be made / cs
* \param callback callback function
* \param p user parameter, passed to callback function
*
* The callback function will be called as soon as possible after t cs have
* passed.
*/
void schedule(int cs_ival, void (*callback)(void *p), void *p)
{
struct nscallback *nscb;
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = cs_ival * 10000;
LOG(("adding callback %p, %p at %d cs", callback, p, cs_ival));
nscb = calloc(1, sizeof(struct nscallback));
gettimeofday(&nscb->tv, NULL);
timeradd(&nscb->tv, &tv, &nscb->tv);
nscb->callback = callback;
nscb->p = p;
/* add to list front */
nscb->next = schedule_list;
schedule_list = nscb;
}
/**
* Unschedule a callback.
*
* \param callback callback function
* \param p user parameter, passed to callback function
*
* All scheduled callbacks matching both callback and p are removed.
*/
void schedule_remove(void (*callback)(void *p), void *p)
{
struct nscallback *cur_nscb;
struct nscallback *prev_nscb;
struct nscallback *unlnk_nscb;
if (schedule_list == NULL)
return;
LOG(("removing %p, %p", callback, p));
cur_nscb = schedule_list;
prev_nscb = NULL;
while (cur_nscb != NULL) {
if ((cur_nscb->callback == callback) &&
(cur_nscb->p == p)) {
/* item to remove */
LOG(("removing %p(%p)",
cur_nscb->callback, cur_nscb->p));
/* remove callback */
unlnk_nscb = cur_nscb;
cur_nscb = unlnk_nscb->next;
if (prev_nscb == NULL) {
schedule_list = cur_nscb;
} else {
prev_nscb->next = cur_nscb;
}
free (unlnk_nscb);
} else {
/* move to next element */
prev_nscb = cur_nscb;
cur_nscb = prev_nscb->next;
}
}
}
/**
* Process events up to current time.
*/
void schedule_run(void)
{
struct timeval tv;
struct nscallback *cur_nscb;
struct nscallback *prev_nscb;
struct nscallback *unlnk_nscb;
if (schedule_list == NULL)
return;
cur_nscb = schedule_list;
prev_nscb = NULL;
gettimeofday(&tv, NULL);
while (cur_nscb != NULL) {
if (timercmp(&tv, &cur_nscb->tv, >)) {
/* scheduled time */
/* remove callback */
unlnk_nscb = cur_nscb;
cur_nscb = unlnk_nscb->next;
if (prev_nscb == NULL) {
schedule_list = cur_nscb;
} else {
prev_nscb->next = cur_nscb;
}
LOG(("calling %p with %p",
unlnk_nscb->callback, unlnk_nscb->p));
/* call callback */
unlnk_nscb->callback(unlnk_nscb->p);
free (unlnk_nscb);
} else {
/* move to next element */
prev_nscb = cur_nscb;
cur_nscb = prev_nscb->next;
}
}
}
void list_schedule(void)
{
struct timeval tv;
struct nscallback *cur_nscb;
gettimeofday(&tv, NULL);
LOG(("schedule list at %ld:%ld", tv.tv_sec, tv.tv_usec));
cur_nscb = schedule_list;
while (cur_nscb != NULL) {
LOG(("Schedule %p at %ld:%ld",
cur_nscb, cur_nscb->tv.tv_sec, cur_nscb->tv.tv_usec));
cur_nscb = cur_nscb->next;
}
}
/*
* Local Variables:
* c-basic-offset:8
* End:
*/

24
framebuffer/fb_schedule.h Normal file
View File

@ -0,0 +1,24 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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/>.
*/
#ifndef FRAMEBUFFER_SCHEDULE_H
#define FRAMEBUFFER_SCHEDULE_H
void list_schedule(void);
#endif

4645
framebuffer/font_8x16.c Normal file

File diff suppressed because it is too large Load Diff

33
framebuffer/history.c Normal file
View File

@ -0,0 +1,33 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 "desktop/browser.h"
void global_history_add(const char *url)
{
}
void global_history_add_recent(const char *url)
{
}
char **global_history_get_recent(int *count)
{
return NULL;
}

23
framebuffer/hotlist.c Normal file
View File

@ -0,0 +1,23 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 "desktop/browser.h"
void hotlist_visited(struct content *content)
{
}

24
framebuffer/login.c Normal file
View File

@ -0,0 +1,24 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 "desktop/401login.h"
void gui_401login_open(struct browser_window *bw, struct content *c,
const char *realm)
{
}

46
framebuffer/misc.c Normal file
View File

@ -0,0 +1,46 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "desktop/cookies.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/url.h"
void warn_user(const char *warning, const char *detail)
{
}
void die(const char *error)
{
exit(1);
}
bool cookies_update(const char *domain, const struct cookie_data *data)
{
return true;
}
char *url_to_path(const char *url)
{
return strdup(url + 5);
}

1
framebuffer/res/default.css Symbolic link
View File

@ -0,0 +1 @@
../../!NetSurf/Resources/CSS,f79

1
framebuffer/res/messages Symbolic link
View File

@ -0,0 +1 @@
../../!NetSurf/Resources/en/Messages

BIN
framebuffer/res/pointer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

25
framebuffer/thumbnail.c Normal file
View File

@ -0,0 +1,25 @@
/*
* Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* 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 "desktop/browser.h"
bool thumbnail_create(struct content *content, struct bitmap *bitmap,
const char *url)
{
return false;
}

62
framebuffer/tree.c Normal file
View File

@ -0,0 +1,62 @@
/*
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
*
* 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 "desktop/tree.h"
void tree_initialise_redraw(struct tree *tree)
{
}
void tree_redraw_area(struct tree *tree, int x, int y, int width, int height)
{
}
void tree_draw_line(int x, int y, int width, int height)
{
}
void tree_draw_node_element(struct tree *tree, struct node_element *element)
{
}
void tree_draw_node_expansion(struct tree *tree, struct node *node)
{
}
void tree_recalculate_node_element(struct node_element *element)
{
}
void tree_update_URL_node(struct node *node, const char *url,
const struct url_data *data)
{
}
void tree_resized(struct tree *tree)
{
}
void tree_set_node_sprite_folder(struct node *node)
{
}
void tree_set_node_sprite(struct node *node, const char *sprite,
const char *expanded)
{
}

View File

@ -20,6 +20,7 @@
* Content for directory listings (implementation).
*/
#include <sys/types.h>
#include <dirent.h>
#include <stdbool.h>
#include <string.h>

View File

@ -22,13 +22,13 @@
* A maximum of 2^24 files can be allocated at any point in time.
*/
#include <sys/types.h>
#include <dirent.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "utils/filename.h"

View File

@ -22,14 +22,15 @@
* URL parsing and joining (implementation).
*/
#include <sys/types.h>
#include <assert.h>
#include <ctype.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/types.h>
#include <regex.h>
#include <unistd.h>
#include "curl/curl.h"
#include "utils/log.h"
#include "utils/url.h"