r6628 dsilvers - in /trunk/netsurf/framebuffer: fb_bitmap.h fb_image_data.c fb_image_data.h fb_rootwindow.c
by netsurf@semichrome.net
Author: dsilvers
Date: Thu Feb 26 07:25:36 2009
New Revision: 6628
URL: http://source.netsurf-browser.org?rev=6628&view=rev
Log:
Remove fb_widget_image_[st] and begin to pave the way for pointer hotspots
Modified:
trunk/netsurf/framebuffer/fb_bitmap.h
trunk/netsurf/framebuffer/fb_image_data.c
trunk/netsurf/framebuffer/fb_image_data.h
trunk/netsurf/framebuffer/fb_rootwindow.c
Modified: trunk/netsurf/framebuffer/fb_bitmap.h
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_bitmap.h?r...
==============================================================================
--- trunk/netsurf/framebuffer/fb_bitmap.h (original)
+++ trunk/netsurf/framebuffer/fb_bitmap.h Thu Feb 26 07:25:36 2009
@@ -23,6 +23,9 @@
int width;
int height;
uint8_t *pixdata;
+ /* The following two are only used for cursors */
+ int hot_x;
+ int hot_y;
};
#endif
Modified: trunk/netsurf/framebuffer/fb_image_data.c
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_image_data...
==============================================================================
--- trunk/netsurf/framebuffer/fb_image_data.c (original)
+++ trunk/netsurf/framebuffer/fb_image_data.c Thu Feb 26 07:25:36 2009
@@ -22,8 +22,11 @@
#include "framebuffer/fb_bitmap.h"
struct bitmap pointer_image = {
- 12, 22,
- (uint8_t *)
+ .width = 12,
+ .height = 22,
+ .hot_x = 0,
+ .hot_y = 0,
+ .pixdata = (uint8_t *)
"33L\377\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\0\0\0\0\0""33L\37733L\377\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\0""33L\377\273\273\324\3773"
@@ -65,8 +68,11 @@
};
struct bitmap caret_image = {
- 7, 19,
- (uint8_t *)
+ .width = 7,
+ .height = 19,
+ .hot_x = 0,
+ .hot_y = 0,
+ .pixdata = (uint8_t *)
"33L\37733L\37733L\377\0\0\0\0""33L\37733L\37733L\37733L\377\273\273\324\377"
"\360\360\377\37733L\377\360\360\377\377\273\273\324\37733L\377\0\0\0\0""3"
"3L\377\273\273\324\377\360\360\377\377\273\273\324\37733L\377\0\0\0\0\0\0"
@@ -88,8 +94,11 @@
};
struct bitmap hand_image = {
- 16, 22,
- (uint8_t *)
+ .width = 16,
+ .height = 22,
+ .hot_x = 0,
+ .hot_y = 0,
+ .pixdata = (uint8_t *)
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""33L\37733L\377\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\0\0\0\0\0\0\0\0\0"
"\0\0\0\0""33L\377\273\273\324\377\273\273\324\37733L\377\0\0\0\0\0\0\0\0"
@@ -149,9 +158,12 @@
"\0\0\0\0",
};
-const fb_widget_image_t left_arrow = {
- 22, 25, 4,
- (uint8_t *)
+struct bitmap left_arrow = {
+ .width = 22,
+ .height = 25,
+ .hot_x = 0,
+ .hot_y = 0,
+ .pixdata = (uint8_t *)
"\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
"\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
"\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377"
@@ -249,9 +261,12 @@
"\6",
};
-const fb_widget_image_t right_arrow = {
- 22, 25, 4,
- (uint8_t *)
+struct bitmap right_arrow = {
+ .width = 22,
+ .height = 25,
+ .hot_x = 0,
+ .hot_y = 0,
+ .pixdata = (uint8_t *)
"\0\10\0""0\0\11\0\350\0\10\0\206\0\10\0\14\377\377\377\0\377\377\377\0\377"
"\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
"\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377"
@@ -349,9 +364,12 @@
"\377\377\377\0\377\377\377\0",
};
-const fb_widget_image_t reload = {
- 24, 25, 4,
- (uint8_t *)
+struct bitmap reload = {
+ .width = 24,
+ .height = 25,
+ .hot_x = 0,
+ .hot_y = 0,
+ .pixdata = (uint8_t *)
"\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
"\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\0\10\0"
"\36\0\10\0O\0\10\0H\0\10\0!\0\10\0\2\377\377\377\0\377\377\377\0\377\377"
@@ -453,9 +471,12 @@
"\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0",
};
-const fb_widget_image_t stop_image = {
- 25, 25, 4,
- (uint8_t *)
+struct bitmap stop_image = {
+ .width = 25,
+ .height = 25,
+ .hot_x = 0,
+ .hot_y = 0,
+ .pixdata = (uint8_t *)
"\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
"\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
"\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377"
Modified: trunk/netsurf/framebuffer/fb_image_data.h
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_image_data...
==============================================================================
--- trunk/netsurf/framebuffer/fb_image_data.h (original)
+++ trunk/netsurf/framebuffer/fb_image_data.h Thu Feb 26 07:25:36 2009
@@ -16,20 +16,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-struct fb_widget_image_s {
- unsigned int width;
- unsigned int height;
- unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
- unsigned char *pixel_data;
-};
+#ifndef FB_IMAGE_DATA
+#define FB_IMAGE_DATA
-typedef struct fb_widget_image_s fb_widget_image_t;
+#include "framebuffer/fb_bitmap.h"
-extern const fb_widget_image_t left_arrow;
-extern const fb_widget_image_t right_arrow;
-extern const fb_widget_image_t reload;
-extern const fb_widget_image_t stop_image;
+extern struct bitmap left_arrow;
+extern struct bitmap right_arrow;
+extern struct bitmap reload;
+extern struct bitmap stop_image;
extern struct bitmap pointer_image;
extern struct bitmap hand_image;
extern struct bitmap caret_image;
+
+#endif /* FB_IMAGE_DATA */
Modified: trunk/netsurf/framebuffer/fb_rootwindow.c
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_rootwindow...
==============================================================================
--- trunk/netsurf/framebuffer/fb_rootwindow.c (original)
+++ trunk/netsurf/framebuffer/fb_rootwindow.c Thu Feb 26 07:25:36 2009
@@ -225,7 +225,7 @@
static struct fb_widget *
fb_add_button_widget(int x,
int y,
- const fb_widget_image_t *widget_image,
+ struct bitmap *widget_image,
fb_widget_mouseclick_t click_rtn)
{
struct fb_widget *new_widget;
@@ -242,16 +242,8 @@
new_widget->click = click_rtn;
- new_widget->bitmap = bitmap_create(widget_image->width,
- widget_image->height,
- 0);
-
- memcpy(new_widget->bitmap->pixdata,
- widget_image->pixel_data,
- widget_image->width *
- widget_image->height *
- widget_image->bytes_per_pixel);
-
+ new_widget->bitmap = widget_image;
+
fb_insert_widget(new_widget);
return new_widget;
14 years, 7 months
r6627 vince - /trunk/netsurf/framebuffer/fb_font_freetype.c
by netsurf@semichrome.net
Author: vince
Date: Thu Feb 26 07:02:22 2009
New Revision: 6627
URL: http://source.netsurf-browser.org?rev=6627&view=rev
Log:
perform hoop jumps to select the correct character map for glyph index loopups
Modified:
trunk/netsurf/framebuffer/fb_font_freetype.c
Modified: trunk/netsurf/framebuffer/fb_font_freetype.c
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_font_freet...
==============================================================================
--- trunk/netsurf/framebuffer/fb_font_freetype.c (original)
+++ trunk/netsurf/framebuffer/fb_font_freetype.c Thu Feb 26 07:02:22 2009
@@ -42,6 +42,7 @@
typedef struct fb_faceid_s {
char *fontfile; /* path to font */
int index; /* index of font */
+ int cidx; /* character map index for unicode */
} fb_faceid_t;
@@ -65,12 +66,25 @@
{
FT_Error error;
fb_faceid_t *fb_face = (fb_faceid_t *)face_id;
+ int cidx;
error = FT_New_Face(library, fb_face->fontfile, fb_face->index, face);
if (error) {
LOG(("Could not find font (code %d)\n", error));
- }
-
+ } else {
+
+ error = FT_Select_Charmap(*face, FT_ENCODING_UNICODE);
+ if (error) {
+ LOG(("Could not select charmap (code %d)\n", error));
+ } else {
+ for (cidx = 0; cidx < (*face)->num_charmaps; cidx++) {
+ if ((*face)->charmap == (*face)->charmaps[cidx]) {
+ fb_face->cidx = cidx;
+ break;
+ }
+ }
+ }
+ }
LOG(("Loaded face from %s\n", fb_face->fontfile));
return error;
@@ -174,6 +188,9 @@
switch (style->font_style) {
case CSS_FONT_STYLE_ITALIC:
switch (style->font_weight) {
+ case CSS_FONT_WEIGHT_700:
+ case CSS_FONT_WEIGHT_800:
+ case CSS_FONT_WEIGHT_900:
case CSS_FONT_WEIGHT_BOLD:
srec->face_id = (FTC_FaceID)fb_face_sans_serif_italic_bold;
break;
@@ -187,6 +204,9 @@
default:
switch (style->font_weight) {
+ case CSS_FONT_WEIGHT_700:
+ case CSS_FONT_WEIGHT_800:
+ case CSS_FONT_WEIGHT_900:
case CSS_FONT_WEIGHT_BOLD:
srec->face_id = (FTC_FaceID)fb_face_sans_serif_bold;
break;
@@ -219,10 +239,13 @@
FTC_ScalerRec srec;
FT_Glyph glyph;
FT_Error error;
+ fb_faceid_t *fb_face;
fb_fill_scalar(style, &srec);
- glyph_index = FTC_CMapCache_Lookup(ft_cmap_cache, srec.face_id, 0, ucs4);
+ fb_face = (fb_faceid_t *)srec.face_id;
+
+ glyph_index = FTC_CMapCache_Lookup(ft_cmap_cache, srec.face_id, fb_face->cidx, ucs4);
error = FTC_ImageCache_LookupScaler(ft_image_cache,
&srec,
14 years, 7 months
r6626 vince - /trunk/netsurf/framebuffer/fb_font_freetype.c
by netsurf@semichrome.net
Author: vince
Date: Thu Feb 26 06:05:12 2009
New Revision: 6626
URL: http://source.netsurf-browser.org?rev=6626&view=rev
Log:
add font faces for all sans serif types (normal, italic and bold)
add font faces for monospace
add font face for serif
Modified:
trunk/netsurf/framebuffer/fb_font_freetype.c
Modified: trunk/netsurf/framebuffer/fb_font_freetype.c
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_font_freet...
==============================================================================
--- trunk/netsurf/framebuffer/fb_font_freetype.c (original)
+++ trunk/netsurf/framebuffer/fb_font_freetype.c Thu Feb 26 06:05:12 2009
@@ -46,6 +46,11 @@
static fb_faceid_t *fb_face_sans_serif; /* global default face */
+static fb_faceid_t *fb_face_sans_serif_bold; /* bold sans face */
+static fb_faceid_t *fb_face_sans_serif_italic; /* bold sans face */
+static fb_faceid_t *fb_face_sans_serif_italic_bold; /* bold sans face */
+static fb_faceid_t *fb_face_monospace; /* monospace face */
+static fb_faceid_t *fb_face_serif; /* serif face */
utf8_convert_ret utf8_to_local_encoding(const char *string,
@@ -71,12 +76,24 @@
return error;
}
+/* create new framebuffer face and cause it to be loaded to check its ok */
static fb_faceid_t *
fb_new_face(const char *fontfile)
{
fb_faceid_t *newf;
+ FT_Error error;
+ FT_Face aface;
+
newf = calloc(1, sizeof(fb_faceid_t));
newf->fontfile=strdup(fontfile);
+
+ error = FTC_Manager_LookupFace(ft_cmanager, (FTC_FaceID)newf, &aface);
+ if (error) {
+ LOG(("Could not find font face %s (code %d)\n", fontfile, error));
+ free(newf);
+ newf = fb_face_sans_serif; /* use default */
+ }
+
return newf;
}
@@ -84,7 +101,6 @@
bool fb_font_init(void)
{
FT_Error error;
- FT_Face aface;
/* freetype library initialise */
error = FT_Init_FreeType( &library );
@@ -93,8 +109,8 @@
return false;
}
- /* cache manager initialise */
- error = FTC_Manager_New(library, 0, 0, 0, ft_face_requester, NULL, &ft_cmanager);
+ /* cache manager initialise, six faces and defaults for other values */
+ error = FTC_Manager_New(library, 6, 0, 0, ft_face_requester, NULL, &ft_cmanager);
if (error) {
LOG(("Freetype could not initialise cache manager (code %d)\n", error));
FT_Done_FreeType(library);
@@ -105,16 +121,23 @@
error = FTC_ImageCache_New(ft_cmanager, &ft_image_cache);
-
+ fb_face_sans_serif = NULL;
fb_face_sans_serif = fb_new_face("/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf");
-
- error = FTC_Manager_LookupFace(ft_cmanager, (FTC_FaceID)fb_face_sans_serif, &aface);
- if (error) {
+ if (fb_face_sans_serif == NULL) {
LOG(("Could not find default font (code %d)\n", error));
FT_Done_FreeType(library);
return false;
}
+
+ fb_face_monospace = fb_new_face("/usr/share/fonts/truetype/ttf-bitstream-vera/VeraMono.ttf");
+
+ fb_face_serif = fb_new_face("/usr/share/fonts/truetype/ttf-bitstream-vera/VeraSe.ttf");
+ fb_face_sans_serif_bold = fb_new_face("/usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf");
+
+ fb_face_sans_serif_italic = fb_new_face("/usr/share/fonts/truetype/ttf-bitstream-vera/VeraIt.ttf");
+
+ fb_face_sans_serif_italic_bold = fb_new_face("/usr/share/fonts/truetype/ttf-bitstream-vera/VeraBI.ttf");
/* set the default render mode */
//ft_load_type = FT_LOAD_MONOCHROME; /* faster but less pretty */
@@ -131,7 +154,52 @@
static void fb_fill_scalar(const struct css_style *style, FTC_Scaler srec)
{
- srec->face_id = (FTC_FaceID)fb_face_sans_serif; /* should derive from style */
+ switch (style->font_family) {
+ /*
+ case CSS_FONT_FAMILY_CURSIVE:
+ break;
+ case CSS_FONT_FAMILY_FANTASY:
+ break;
+ */
+ case CSS_FONT_FAMILY_SERIF:
+ srec->face_id = (FTC_FaceID)fb_face_serif;
+ break;
+
+ case CSS_FONT_FAMILY_MONOSPACE:
+ srec->face_id = (FTC_FaceID)fb_face_monospace;
+ break;
+
+ case CSS_FONT_FAMILY_SANS_SERIF:
+ default:
+ switch (style->font_style) {
+ case CSS_FONT_STYLE_ITALIC:
+ switch (style->font_weight) {
+ case CSS_FONT_WEIGHT_BOLD:
+ srec->face_id = (FTC_FaceID)fb_face_sans_serif_italic_bold;
+ break;
+
+ case CSS_FONT_WEIGHT_NORMAL:
+ default:
+ srec->face_id = (FTC_FaceID)fb_face_sans_serif_italic;
+ break;
+ }
+ break;
+
+ default:
+ switch (style->font_weight) {
+ case CSS_FONT_WEIGHT_BOLD:
+ srec->face_id = (FTC_FaceID)fb_face_sans_serif_bold;
+ break;
+
+ case CSS_FONT_WEIGHT_NORMAL:
+ default:
+ srec->face_id = (FTC_FaceID)fb_face_sans_serif;
+ break;
+ }
+ break;
+ }
+ }
+
if (style->font_size.value.length.unit == CSS_UNIT_PX) {
srec->width = srec->height = style->font_size.value.length.value;
srec->pixel = 1;
14 years, 7 months
r6624 dsilvers - /trunk/netsurf/Makefile
by netsurf@semichrome.net
Author: dsilvers
Date: Thu Feb 26 05:08:07 2009
New Revision: 6624
URL: http://source.netsurf-browser.org?rev=6624&view=rev
Log:
Allow non-gcc-2.x builds to use -MMD -MT -MF flags to dep-as-we-compile, reducing build time quite a bit
Modified:
trunk/netsurf/Makefile
Modified: trunk/netsurf/Makefile
URL: http://source.netsurf-browser.org/trunk/netsurf/Makefile?rev=6624&r1=6623...
==============================================================================
--- trunk/netsurf/Makefile (original)
+++ trunk/netsurf/Makefile Thu Feb 26 05:08:07 2009
@@ -726,10 +726,6 @@
define dependency_generate_c
DEPFILES += $(2)
$$(DEPROOT)/$(2): $$(DEPROOT)/created $(1) css/css_enum.h css/parser.h Makefile.config
- $$(VQ)echo " DEP: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(2)
- $$(Q)$$(CC) $$(CFLAGS) -MM -MT '$$(DEPROOT)/$2 $$(OBJROOT)/$(3)' \
- -MF $$(DEPROOT)/$(2) $(1)
endef
endif
@@ -740,10 +736,6 @@
define dependency_generate_s
DEPFILES += $(2)
$$(DEPROOT)/$(2): $$(DEPROOT)/created $(1)
- $$(VQ)echo " DEP: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(2)
- $$(Q)$$(CC) $$(CFLAGS) -MM -MT '$$(DEPROOT)/$2 $$(OBJROOT)/$(3)' \
- -MF $$(DEPROOT)/$(2) $(1)
endef
@@ -751,9 +743,11 @@
# 2 = obj filename, no prefix
# 3 = dep filename, no prefix
define compile_target_c
-$$(OBJROOT)/$(2): $$(OBJROOT)/created $$(DEPROOT)/$(3)
+$$(DEPROOT)/$(3) $$(OBJROOT)/$(2): $$(OBJROOT)/created
$$(VQ)echo " COMPILE: $(1)"
- $$(Q)$$(CC) $$(CFLAGS) -o $$@ -c $(1)
+ $$(Q)$$(RM) $$(DEPROOT)/$(3)
+ $$(Q)$$(CC) $$(CFLAGS) -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
+ -MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
endef
@@ -768,9 +762,11 @@
# 2 = obj filename, no prefix
# 3 = dep filename, no prefix
define compile_target_s
-$$(OBJROOT)/$(2): $$(OBJROOT)/created
+$$(DEPROOT)/$3 $$(OBJROOT)/$(2): $$(OBJROOT)/created
$$(VQ)echo "ASSEMBLE: $(1)"
- $$(Q)$$(CC) $$(ASFLAGS) -o $$@ -c $(1)
+ $$(Q)$$(RM) $$(DEPROOT)/$(3)
+ $$(Q)$$(CC) $$(ASFLAGS) -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
+ -MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
endef
14 years, 7 months
r6622 vince - in /trunk/netsurf/framebuffer: fb_16bpp_plotters.c fb_32bpp_plotters.c fb_font.h fb_font_freetype.c
by netsurf@semichrome.net
Author: vince
Date: Thu Feb 26 04:50:00 2009
New Revision: 6622
URL: http://source.netsurf-browser.org?rev=6622&view=rev
Log:
cache freetype glyphs, massive reduction in cpu requirement
Modified:
trunk/netsurf/framebuffer/fb_16bpp_plotters.c
trunk/netsurf/framebuffer/fb_32bpp_plotters.c
trunk/netsurf/framebuffer/fb_font.h
trunk/netsurf/framebuffer/fb_font_freetype.c
Modified: trunk/netsurf/framebuffer/fb_16bpp_plotters.c
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_16bpp_plot...
==============================================================================
--- trunk/netsurf/framebuffer/fb_16bpp_plotters.c (original)
+++ trunk/netsurf/framebuffer/fb_16bpp_plotters.c Thu Feb 26 04:50:00 2009
@@ -270,37 +270,33 @@
{
uint32_t ucs4;
size_t nxtchr = 0;
- FT_UInt glyph_index;
- FT_Face face = fb_get_face(style);
- FT_Error error;
+ FT_Glyph glyph;
+ FT_BitmapGlyph bglyph;
while (nxtchr < length) {
ucs4 = utf8_to_ucs4(text + nxtchr, length - nxtchr);
nxtchr = utf8_next(text, length, nxtchr);
- glyph_index = FT_Get_Char_Index(face, ucs4);
-
- error = FT_Load_Glyph(face,
- glyph_index,
- FT_LOAD_RENDER |
- FT_LOAD_FORCE_AUTOHINT |
- ft_load_type);
- if (error)
+
+ glyph = fb_getglyph(style, ucs4);
+ if (glyph == NULL)
continue;
-
- /* now, draw to our target surface */
- if (face->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) {
- fb_16bpp_draw_ft_monobitmap( &face->glyph->bitmap,
- x + face->glyph->bitmap_left,
- y - face->glyph->bitmap_top,
- c);
- } else {
- fb_16bpp_draw_ft_bitmap( &face->glyph->bitmap,
- x + face->glyph->bitmap_left,
- y - face->glyph->bitmap_top,
- c);
- }
-
- x += face->glyph->advance.x >> 6;
+ if (glyph->format == FT_GLYPH_FORMAT_BITMAP) {
+ bglyph = (FT_BitmapGlyph)glyph;
+
+ /* now, draw to our target surface */
+ if (bglyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) {
+ fb_16bpp_draw_ft_monobitmap(&bglyph->bitmap,
+ x + bglyph->left,
+ y - bglyph->top,
+ c);
+ } else {
+ fb_16bpp_draw_ft_bitmap(&bglyph->bitmap,
+ x + bglyph->left,
+ y - bglyph->top,
+ c);
+ }
+ }
+ x += glyph->advance.x >> 16;
}
return true;
Modified: trunk/netsurf/framebuffer/fb_32bpp_plotters.c
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_32bpp_plot...
==============================================================================
--- trunk/netsurf/framebuffer/fb_32bpp_plotters.c (original)
+++ trunk/netsurf/framebuffer/fb_32bpp_plotters.c Thu Feb 26 04:50:00 2009
@@ -324,37 +324,34 @@
{
uint32_t ucs4;
size_t nxtchr = 0;
- FT_UInt glyph_index;
- FT_Face face = fb_get_face(style);
- FT_Error error;
+ FT_Glyph glyph;
+ FT_BitmapGlyph bglyph;
while (nxtchr < length) {
ucs4 = utf8_to_ucs4(text + nxtchr, length - nxtchr);
nxtchr = utf8_next(text, length, nxtchr);
- glyph_index = FT_Get_Char_Index(face, ucs4);
-
- error = FT_Load_Glyph(face,
- glyph_index,
- FT_LOAD_RENDER |
- FT_LOAD_FORCE_AUTOHINT |
- ft_load_type);
- if (error)
+
+ glyph = fb_getglyph(style, ucs4);
+ if (glyph == NULL)
continue;
- /* now, draw to our target surface */
- if (face->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) {
- fb_32bpp_draw_ft_monobitmap( &face->glyph->bitmap,
- x + face->glyph->bitmap_left,
- y - face->glyph->bitmap_top,
- c);
- } else {
- fb_32bpp_draw_ft_bitmap( &face->glyph->bitmap,
- x + face->glyph->bitmap_left,
- y - face->glyph->bitmap_top,
- c);
- }
-
- x += face->glyph->advance.x >> 6;
+ if (glyph->format == FT_GLYPH_FORMAT_BITMAP) {
+ bglyph = (FT_BitmapGlyph)glyph;
+
+ /* now, draw to our target surface */
+ if (bglyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) {
+ fb_32bpp_draw_ft_monobitmap(&bglyph->bitmap,
+ x + bglyph->left,
+ y - bglyph->top,
+ c);
+ } else {
+ fb_32bpp_draw_ft_bitmap(&bglyph->bitmap,
+ x + bglyph->left,
+ y - bglyph->top,
+ c);
+ }
+ }
+ x += glyph->advance.x >> 16;
}
return true;
Modified: trunk/netsurf/framebuffer/fb_font.h
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_font.h?rev...
==============================================================================
--- trunk/netsurf/framebuffer/fb_font.h (original)
+++ trunk/netsurf/framebuffer/fb_font.h Thu Feb 26 04:50:00 2009
@@ -26,8 +26,9 @@
#include <ft2build.h>
#include FT_FREETYPE_H
+#include <freetype/ftglyph.h>
-FT_Face fb_get_face(const struct css_style *style);
+FT_Glyph fb_getglyph(const struct css_style *style, uint32_t ucs4);
extern int ft_load_type;
Modified: trunk/netsurf/framebuffer/fb_font_freetype.c
URL: http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_font_freet...
==============================================================================
--- trunk/netsurf/framebuffer/fb_font_freetype.c (original)
+++ trunk/netsurf/framebuffer/fb_font_freetype.c Thu Feb 26 04:50:00 2009
@@ -19,6 +19,8 @@
#include <inttypes.h>
#include <assert.h>
+
+#include <freetype/ftcache.h>
#include "css/css.h"
#include "render/font.h"
@@ -30,9 +32,21 @@
#include "framebuffer/fb_font.h"
static FT_Library library;
-static FT_Face face_sans_serif;
+static FTC_Manager ft_cmanager;
+static FTC_CMapCache ft_cmap_cache ;
+static FTC_ImageCache ft_image_cache;
int ft_load_type;
+
+/* cache manager faceID data to create freetype faceid on demand */
+typedef struct fb_faceid_s {
+ char *fontfile; /* path to font */
+ int index; /* index of font */
+} fb_faceid_t;
+
+
+static fb_faceid_t *fb_face_sans_serif; /* global default face */
+
utf8_convert_ret utf8_to_local_encoding(const char *string,
size_t len,
@@ -41,33 +55,66 @@
return utf8_to_enc(string, "UTF-8", len, result);
}
+/* map cache manager handle to face id */
+static FT_Error ft_face_requester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *face )
+{
+ FT_Error error;
+ fb_faceid_t *fb_face = (fb_faceid_t *)face_id;
+
+ error = FT_New_Face(library, fb_face->fontfile, fb_face->index, face);
+ if (error) {
+ LOG(("Could not find font (code %d)\n", error));
+ }
+
+ LOG(("Loaded face from %s\n", fb_face->fontfile));
+
+ return error;
+}
+
+static fb_faceid_t *
+fb_new_face(const char *fontfile)
+{
+ fb_faceid_t *newf;
+ newf = calloc(1, sizeof(fb_faceid_t));
+ newf->fontfile=strdup(fontfile);
+ return newf;
+}
/* initialise font handling */
bool fb_font_init(void)
{
FT_Error error;
-
+ FT_Face aface;
+
+ /* freetype library initialise */
error = FT_Init_FreeType( &library );
if (error) {
LOG(("Freetype could not initialised (code %d)\n", error));
return false;
}
- error = FT_New_Face(library,
- "/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf",
- 0,
- &face_sans_serif );
+ /* cache manager initialise */
+ error = FTC_Manager_New(library, 0, 0, 0, ft_face_requester, NULL, &ft_cmanager);
+ if (error) {
+ LOG(("Freetype could not initialise cache manager (code %d)\n", error));
+ FT_Done_FreeType(library);
+ return false;
+ }
+
+ error = FTC_CMapCache_New(ft_cmanager, &ft_cmap_cache);
+
+ error = FTC_ImageCache_New(ft_cmanager, &ft_image_cache);
+
+
+ fb_face_sans_serif = fb_new_face("/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf");
+
+ error = FTC_Manager_LookupFace(ft_cmanager, (FTC_FaceID)fb_face_sans_serif, &aface);
if (error) {
LOG(("Could not find default font (code %d)\n", error));
FT_Done_FreeType(library);
return false;
}
- error = FT_Set_Pixel_Sizes(face_sans_serif, 0, 14 );
- if (error) {
- LOG(("Could not set pixel size (code %d)\n", error));
- return false;
- }
/* set the default render mode */
//ft_load_type = FT_LOAD_MONOCHROME; /* faster but less pretty */
@@ -82,34 +129,46 @@
return true;
}
-
-
-FT_Face
-fb_get_face(const struct css_style *style)
-{
- FT_Face face;
- face = face_sans_serif;
+static void fb_fill_scalar(const struct css_style *style, FTC_Scaler srec)
+{
+ srec->face_id = (FTC_FaceID)fb_face_sans_serif; /* should derive from style */
+ if (style->font_size.value.length.unit == CSS_UNIT_PX) {
+ srec->width = srec->height = style->font_size.value.length.value;
+ srec->pixel = 1;
+ } else {
+ srec->width = srec->height =
+ css_len2pt(&style->font_size.value.length, style) * 64;
+ srec->pixel = 0;
+
+ srec->x_res = srec->y_res = 72;
+ }
+
+}
+
+FT_Glyph fb_getglyph(const struct css_style *style, uint32_t ucs4)
+{
+ FT_UInt glyph_index;
+ FTC_ScalerRec srec;
+ FT_Glyph glyph;
FT_Error error;
- int size;
-
- if (style->font_size.value.length.unit == CSS_UNIT_PX) {
- size = style->font_size.value.length.value;
-
- error = FT_Set_Pixel_Sizes(face_sans_serif, 0, size );
- if (error) {
- LOG(("Could not set pixel size (code %d)\n", error));
- }
- } else {
- size = css_len2pt(&style->font_size.value.length, style);
- error = FT_Set_Char_Size( face, 0, size*64, 72, 72 );
- if (error) {
- LOG(("Could not set pixel size (code %d)\n", error));
- }
- }
-
-
- return face;
-}
+
+ fb_fill_scalar(style, &srec);
+
+ glyph_index = FTC_CMapCache_Lookup(ft_cmap_cache, srec.face_id, 0, ucs4);
+
+ error = FTC_ImageCache_LookupScaler(ft_image_cache,
+ &srec,
+ FT_LOAD_RENDER |
+ FT_LOAD_FORCE_AUTOHINT |
+ ft_load_type,
+ glyph_index,
+ &glyph,
+ NULL);
+
+ LOG(("Returning glyph %p for index %d advance %d", glyph, glyph_index,glyph->advance.x>>16));
+ return glyph;
+}
+
/**
* Measure the width of a string.
@@ -127,21 +186,18 @@
{
uint32_t ucs4;
size_t nxtchr = 0;
- FT_UInt glyph_index;
- FT_Face face = fb_get_face(style);
- FT_Error error;
+ FT_Glyph glyph;
*width = 0;
while (nxtchr < length) {
ucs4 = utf8_to_ucs4(string + nxtchr, length - nxtchr);
nxtchr = utf8_next(string, length, nxtchr);
- glyph_index = FT_Get_Char_Index(face, ucs4);
-
- error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
- if (error)
+
+ glyph = fb_getglyph(style, ucs4);
+ if (glyph == NULL)
continue;
- *width += face->glyph->advance.x >> 6;
+ *width += glyph->advance.x >> 16;
}
return true;
@@ -166,20 +222,17 @@
{
uint32_t ucs4;
size_t nxtchr = 0;
- FT_UInt glyph_index;
- FT_Face face = fb_get_face(style);
- FT_Error error;
+ FT_Glyph glyph;
*actual_x = 0;
while (nxtchr < length) {
ucs4 = utf8_to_ucs4(string + nxtchr, length - nxtchr);
- glyph_index = FT_Get_Char_Index(face, ucs4);
-
- error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
- if (error)
+
+ glyph = fb_getglyph(style, ucs4);
+ if (glyph == NULL)
continue;
- *actual_x += face->glyph->advance.x >> 6;
+ *actual_x += glyph->advance.x >> 16;
if (*actual_x > x)
break;
@@ -214,21 +267,16 @@
{
uint32_t ucs4;
size_t nxtchr = 0;
- FT_UInt glyph_index;
- FT_Face face = fb_get_face(style);
- FT_Error error;
int last_space_x = 0;
int last_space_idx = 0;
+ FT_Glyph glyph;
*actual_x = 0;
while (nxtchr < length) {
ucs4 = utf8_to_ucs4(string + nxtchr, length - nxtchr);
-
- glyph_index = FT_Get_Char_Index(face, ucs4);
-
- error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
- if (error)
+ glyph = fb_getglyph(style, ucs4);
+ if (glyph == NULL)
continue;
if (ucs4 == 0x20) {
@@ -236,7 +284,7 @@
last_space_idx = nxtchr;
}
- *actual_x += face->glyph->advance.x >> 6;
+ *actual_x += glyph->advance.x >> 16;
if (*actual_x > x) {
/* string has exceeded available width return previous
* space
14 years, 7 months
r6621 chris_y - /trunk/netsurf/amiga/plotters.c
by netsurf@semichrome.net
Author: chris_y
Date: Wed Feb 25 14:37:41 2009
New Revision: 6621
URL: http://source.netsurf-browser.org?rev=6621&view=rev
Log:
Stop images disappearing when they are half-way off the screen.
Modified:
trunk/netsurf/amiga/plotters.c
Modified: trunk/netsurf/amiga/plotters.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/plotters.c?rev=6621...
==============================================================================
--- trunk/netsurf/amiga/plotters.c (original)
+++ trunk/netsurf/amiga/plotters.c Wed Feb 25 14:37:41 2009
@@ -414,8 +414,7 @@
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y, struct content *content)
{
- ULONG xf,yf,wf,hf;
- int max_width,max_height;
+ int xf,yf;
struct BitMap *tbm = NULL;
if(!(repeat_x || repeat_y))
14 years, 7 months
r6620 chris_y - /trunk/netsurf/amiga/plotters.c
by netsurf@semichrome.net
Author: chris_y
Date: Wed Feb 25 14:09:33 2009
New Revision: 6620
URL: http://source.netsurf-browser.org?rev=6620&view=rev
Log:
Fix memory leak and make freeing bitmaps that might be cached a little safer.
Modified:
trunk/netsurf/amiga/plotters.c
Modified: trunk/netsurf/amiga/plotters.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/plotters.c?rev=6620...
==============================================================================
--- trunk/netsurf/amiga/plotters.c (original)
+++ trunk/netsurf/amiga/plotters.c Wed Feb 25 14:09:33 2009
@@ -402,6 +402,11 @@
BLITA_UseSrcAlpha,!bitmap->opaque,
TAG_DONE);
+ if(tbm != bitmap->nativebm)
+ {
+ p96FreeBitMap(tbm);
+ }
+
return true;
}
@@ -412,11 +417,6 @@
ULONG xf,yf,wf,hf;
int max_width,max_height;
struct BitMap *tbm = NULL;
-
-/*
- SetRPAttrs(currp,RPTAG_BPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg),
- TAG_DONE);
-*/
if(!(repeat_x || repeat_y))
return ami_bitmap(x, y, width, height, bitmap, bg, content);
@@ -457,7 +457,7 @@
break;
}
- if(!option_cache_bitmaps)
+ if(tbm != bitmap->nativebm)
{
p96FreeBitMap(tbm);
}
14 years, 7 months