r13889 mono - /trunk/netsurf/atari/plot/font_freetype.c
by netsurf@semichrome.net
Author: mono
Date: Tue Apr 24 15:51:52 2012
New Revision: 13889
URL: http://source.netsurf-browser.org?rev=13889&view=rev
Log:
Fix typo ( fontbitmap was never destroyed within dtor )
Modified:
trunk/netsurf/atari/plot/font_freetype.c
Modified: trunk/netsurf/atari/plot/font_freetype.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/plot/font_freetype....
==============================================================================
--- trunk/netsurf/atari/plot/font_freetype.c (original)
+++ trunk/netsurf/atari/plot/font_freetype.c Tue Apr 24 15:51:52 2012
@@ -577,9 +577,10 @@
static int dtor( FONT_PLOTTER self )
{
ft_font_finalise();
- if( fontbmp == NULL )
- bitmap_destroy( fontbmp );
-
+ if( fontbmp != NULL ) {
+ bitmap_destroy( fontbmp );
+ fontbmp = NULL;
+ }
if( tmp.fd_addr != NULL ){
free( tmp.fd_addr );
}
11 years, 1 month
r13888 mono - /trunk/netsurf/atari/plot/font_freetype.c
by netsurf@semichrome.net
Author: mono
Date: Tue Apr 24 15:47:38 2012
New Revision: 13888
URL: http://source.netsurf-browser.org?rev=13888&view=rev
Log:
Small font plotter speedup by reducing function calls in a draw glyph loop.
Modified:
trunk/netsurf/atari/plot/font_freetype.c
Modified: trunk/netsurf/atari/plot/font_freetype.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/plot/font_freetype....
==============================================================================
--- trunk/netsurf/atari/plot/font_freetype.c (original)
+++ trunk/netsurf/atari/plot/font_freetype.c Tue Apr 24 15:47:38 2012
@@ -41,10 +41,6 @@
int cidx; /* character map index for unicode */
} ftc_faceid_t;
-static struct bitmap * fontbmp;
-
-static ftc_faceid_t *font_faces[FONT_FACE_COUNT];
-
static int dtor( FONT_PLOTTER self );
static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle,
const char * str, size_t length, int * width );
@@ -57,14 +53,19 @@
static int text( FONT_PLOTTER self, int x, int y, const char *text,
size_t length, const plot_font_style_t *fstyle );
-static void draw_glyph8(FONT_PLOTTER self, GRECT * loc, uint8_t * pixdata,
- int pitch, uint32_t colour);
-static void draw_glyph1(FONT_PLOTTER self, GRECT * loc, uint8_t * pixdata,
- int pitch, uint32_t colour);
-
+static void draw_glyph8(FONT_PLOTTER self, GRECT *clip, GRECT * loc,
+ uint8_t * pixdata, int pitch, uint32_t colour);
+static void draw_glyph1(FONT_PLOTTER self, GRECT * clip, GRECT * loc,
+ uint8_t * pixdata, int pitch, uint32_t colour);
+
+static ftc_faceid_t *font_faces[FONT_FACE_COUNT];
static MFDB tmp;
static int tmp_mfdb_size;
static bool init = false;
+static struct bitmap * fontbmp;
+static size_t fontbmp_stride;
+static int fontbmp_allocated_height;
+static int fontbmp_allocated_width;
@@ -370,51 +371,39 @@
}
-static void draw_glyph8(FONT_PLOTTER self, GRECT * loc, uint8_t * pixdata, int pitch, uint32_t colour)
-{
- GRECT clip;
+static void draw_glyph8(FONT_PLOTTER self, GRECT * clip, GRECT * loc, uint8_t * pixdata, int pitch, uint32_t colour)
+{
uint32_t * linebuf;
uint32_t fontpix;
- size_t bmpstride;
int xloop,yloop,xoff,yoff;
int x,y,w,h;
- struct rect clipping;
x = loc->g_x;
y = loc->g_y;
w = loc->g_w;
h = loc->g_h;
-
- self->plotter->get_clip( self->plotter, &clipping );
-
- clip.g_x = clipping.x0;
- clip.g_y = clipping.y0;
- clip.g_w = (clipping.x1 - clipping.x0)+1;
- clip.g_h = (clipping.y1 - clipping.y0)+1;
-
- if( !rc_intersect( &clip, loc ) ){
+
+ if( !rc_intersect( clip, loc ) ){
return;
}
- assert( loc->g_w > 0 );
- assert( loc->g_h > 0 );
xoff = loc->g_x - x;
yoff = loc->g_y - y;
-
- if (h > loc->g_h)
- h = loc->g_h;
-
- if (w > loc->g_w)
- w = loc->g_w;
- fontbmp = bitmap_realloc( w, h,
- fontbmp->bpp, w * fontbmp->bpp,
- BITMAP_GROW, fontbmp );
- assert( fontbmp );
- assert( fontbmp->pixdata );
- bmpstride = bitmap_get_rowstride(fontbmp);
- for( yloop = 0; yloop < h; yloop++) {
- linebuf = (uint32_t *)(fontbmp->pixdata + (bmpstride * yloop));
- for(xloop = 0; xloop < w; xloop++){
+
+ assert( loc->g_h <= h );
+ assert( loc->g_w <= w );
+
+ h = loc->g_h;
+ w = loc->g_w;
+
+ assert( h <= fontbmp_allocated_height );
+ assert( w <= fontbmp_allocated_width );
+
+ fontbmp->height = h;
+ fontbmp->width = w;
+ for( yloop = 0; yloop < MIN(fontbmp_allocated_height, h); yloop++) {
+ linebuf = (uint32_t *)(fontbmp->pixdata + (fontbmp_stride * yloop));
+ for(xloop = 0; xloop < MIN(fontbmp_allocated_width, w); xloop++){
fontpix = (uint32_t)(pixdata[(( yoff + yloop ) * pitch) + xloop + xoff]);
linebuf[xloop] = (uint32_t)(colour | fontpix);
}
@@ -422,33 +411,22 @@
self->plotter->bitmap( self->plotter, fontbmp, loc->g_x, loc->g_y, 0, BITMAPF_MONOGLYPH);
}
-static void draw_glyph1(FONT_PLOTTER self, GRECT * loc, uint8_t * pixdata, int pitch, uint32_t colour)
+static void draw_glyph1(FONT_PLOTTER self, GRECT * clip, GRECT * loc, uint8_t * pixdata, int pitch, uint32_t colour)
{
- GRECT clip;
int xloop,yloop,xoff,yoff;
int x,y,w,h;
uint8_t bitm;
const uint8_t *fntd;
- struct rect clipping;
x = loc->g_x;
y = loc->g_y;
w = loc->g_w;
h = loc->g_h;
-
- self->plotter->get_clip( self->plotter, &clipping );
-
- clip.g_x = clipping.x0;
- clip.g_y = clipping.y0;
- clip.g_w = (clipping.x1 - clipping.x0)+1;
- clip.g_h = (clipping.y1 - clipping.y0)+1;
-
- if( !rc_intersect( &clip, loc ) ){
+
+ if( !rc_intersect( clip, loc ) ){
return;
}
- assert( loc->g_w > 0 );
- assert( loc->g_h > 0 );
xoff = loc->g_x - x;
yoff = loc->g_y - y;
@@ -486,22 +464,15 @@
#ifdef WITH_8BPP_SUPPORT
if( app.nplanes > 8 ){
#endif
- unsigned short out[4];
- rgb_to_vdi1000( (unsigned char*)&colour, (unsigned short*)&out );
- vs_color( self->plotter->vdi_handle, OFFSET_CUSTOM_COLOR, (unsigned short*)&out[0] );
self->plotter->plot_mfdb( self->plotter, loc, &tmp, OFFSET_CUSTOM_COLOR, PLOT_FLAG_TRANS );
#ifdef WITH_8BPP_SUPPORT
} else {
- unsigned char c = RGB_TO_VDI(colour);
- self->plotter->plot_mfdb( self->plotter, loc, &tmp, c, PLOT_FLAG_TRANS );
+ self->plotter->plot_mfdb( self->plotter, loc, &tmp, colour, PLOT_FLAG_TRANS );
}
#endif
}
-
-
-
static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t length,
const plot_font_style_t *fstyle )
{
@@ -509,12 +480,39 @@
size_t nxtchr = 0;
FT_Glyph glyph;
FT_BitmapGlyph bglyph;
- GRECT loc;
- uint32_t c = fstyle->foreground ;
+ GRECT loc, clip;
+ uint32_t c = fstyle->foreground ;
+ struct rect clipping;
/* in -> BGR */
/* out -> ARGB */
- if( !(self->flags & FONTPLOT_FLAG_MONOGLYPH) )
+ if( !(self->flags & FONTPLOT_FLAG_MONOGLYPH) ){
c = ABGR_TO_RGB(c);
+ } else {
+#ifdef WITH_8BPP_SUPPORT
+ if( app.nplanes > 8 ){
+#endif
+ unsigned short out[4];
+ rgb_to_vdi1000( (unsigned char*)&c, (unsigned short*)&out );
+ vs_color( self->plotter->vdi_handle, OFFSET_CUSTOM_COLOR, (unsigned short*)&out[0] );
+#ifdef WITH_8BPP_SUPPORT
+ } else {
+ c = RGB_TO_VDI(c);
+ }
+#endif
+ }
+
+ self->plotter->get_clip( self->plotter, &clipping );
+ clip.g_x = clipping.x0;
+ clip.g_y = clipping.y0;
+ clip.g_w = (clipping.x1 - clipping.x0)+1;
+ clip.g_h = (clipping.y1 - clipping.y0)+1;
+
+ fontbmp = bitmap_realloc( clip.g_w, clip.g_h,
+ 4, clip.g_w << 2,
+ BITMAP_GROW, fontbmp );
+ fontbmp_stride = bitmap_get_rowstride(fontbmp);
+ fontbmp_allocated_height = clip.g_h;
+ fontbmp_allocated_width = clip.g_w;
while (nxtchr < length) {
ucs4 = utf8_to_ucs4(text + nxtchr, length - nxtchr);
@@ -534,7 +532,7 @@
if( loc.g_w > 0) {
self->draw_glyph( self,
- &loc,
+ &clip, &loc,
bglyph->bitmap.buffer,
bglyph->bitmap.pitch,
c
@@ -542,7 +540,6 @@
}
}
x += glyph->advance.x >> 16;
-
}
return( 0 );
}
11 years, 1 month
r13887 mono - /trunk/netsurf/atari/toolbar.c
by netsurf@semichrome.net
Author: mono
Date: Tue Apr 24 15:32:53 2012
New Revision: 13887
URL: http://source.netsurf-browser.org?rev=13887&view=rev
Log:
Implemented "paste clipboard" for toolbar URL textbox.
Modified:
trunk/netsurf/atari/toolbar.c
Modified: trunk/netsurf/atari/toolbar.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/toolbar.c?rev=13887...
==============================================================================
--- trunk/netsurf/atari/toolbar.c (original)
+++ trunk/netsurf/atari/toolbar.c Tue Apr 24 15:32:53 2012
@@ -36,7 +36,8 @@
#include "desktop/mouse.h"
#include "desktop/plot_style.h"
#include "desktop/plotters.h"
-#include "desktop/tree.h"
+#include "desktop/tree.h"
+#include "utils/utf8.h"
#include "atari/clipboard.h"
#include "atari/gui.h"
#include "atari/toolbar.h"
@@ -169,7 +170,7 @@
static void __CDECL button_redraw( COMPONENT *c, long buff[8], void * data )
{
- OBJECT *tree;
+ OBJECT *tree=NULL;
LGRECT work,clip;
GRECT todo,crect;
struct s_tb_button *bt = (struct s_tb_button*)data;
@@ -177,8 +178,8 @@
struct s_toolbar * tb = gw->root->toolbar;
short pxy[4];
- int bmpx, bmpy, bmpw, bmph;
- struct bitmap * icon;
+ int bmpx=0, bmpy=0, bmpw=0, bmph = 0;
+ struct bitmap * icon = NULL;
bool draw_bitmap = false;
mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
@@ -877,6 +878,25 @@
free( text );
}
}
+ else if( ik == KEY_PASTE ){
+ char * clip = scrap_txt_read( &app );
+ if( clip != NULL ){
+ int clip_length = strlen( clip );
+ if ( clip_length > 0 ) {
+ char *utf8;
+ utf8_convert_ret res;
+ /* Clipboard is in local encoding so
+ * convert to UTF8 */
+ res = utf8_from_local_encoding( clip, clip_length, &utf8 );
+ if ( res == UTF8_CONVERT_OK ) {
+ tb_url_set( gw, utf8 );
+ free(utf8);
+ ret = true;
+ }
+ free( clip );
+ }
+ }
+ }
else if( ik == KEY_ESCAPE ) {
textarea_keypress( tb->url.textarea, KEY_SELECT_ALL );
textarea_keypress( tb->url.textarea, KEY_DELETE_LEFT );
11 years, 1 month
r13886 mono - in /trunk/netsurf/atari/plot: font_freetype.c plotter_vdi.c
by netsurf@semichrome.net
Author: mono
Date: Thu Apr 19 17:44:49 2012
New Revision: 13886
URL: http://source.netsurf-browser.org?rev=13886&view=rev
Log:
Optimized bitmap blitting: cache native (converted) bitmaps.
This required an change to the convert and blit routines - for opaque images, they convert the whole image. Transparent images are still converted on demand and still only the clipped area is converted. This is incomplete - native buffers should be stored in the well known bitmap buffer, but currently the bitmap struct holds a second buffer which contains converted data.
Modified:
trunk/netsurf/atari/plot/font_freetype.c
trunk/netsurf/atari/plot/plotter_vdi.c
Modified: trunk/netsurf/atari/plot/font_freetype.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/plot/font_freetype....
==============================================================================
--- trunk/netsurf/atari/plot/font_freetype.c (original)
+++ trunk/netsurf/atari/plot/font_freetype.c Thu Apr 19 17:44:49 2012
@@ -419,7 +419,7 @@
linebuf[xloop] = (uint32_t)(colour | fontpix);
}
}
- self->plotter->bitmap( self->plotter, fontbmp, loc->g_x, loc->g_y, 0, 0);
+ self->plotter->bitmap( self->plotter, fontbmp, loc->g_x, loc->g_y, 0, BITMAPF_MONOGLYPH);
}
static void draw_glyph1(FONT_PLOTTER self, GRECT * loc, uint8_t * pixdata, int pitch, uint32_t colour)
Modified: trunk/netsurf/atari/plot/plotter_vdi.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/plot/plotter_vdi.c?...
==============================================================================
--- trunk/netsurf/atari/plot/plotter_vdi.c (original)
+++ trunk/netsurf/atari/plot/plotter_vdi.c Thu Apr 19 17:44:49 2012
@@ -87,6 +87,7 @@
static HermesHandle hermes_res_h;
static short prev_vdi_clip[4];
+static struct bitmap snapshot;
#ifdef WITH_8BPP_SUPPORT
static unsigned short sys_pal[256][3]; /*RGB*/
@@ -151,11 +152,10 @@
*/
static inline void plotter_get_visible_grect( GEM_PLOTTER self, GRECT * out )
{
- /*todo: !!! */
- out->g_x = VIEW( self ).clipping.x0;
- out->g_y = VIEW( self ).clipping.y0;
- out->g_w = VIEW( self ).clipping.x1 - VIEW( self ).clipping.x0;
- out->g_h = VIEW( self ).clipping.y1 - VIEW( self ).clipping.y0;
+ out->g_x = VIEW( self ).vis_x;
+ out->g_y = VIEW( self ).vis_y;
+ out->g_w = VIEW( self ).vis_w;
+ out->g_h = VIEW( self ).vis_h;
}
@@ -163,9 +163,10 @@
1. calculate visible area of framebuffer in coords relative to framebuffer position
result:
- this function should calc offsets into x,y coords of the framebuffer which
- can be drawn. If the framebuffer coords do not fall within the screen region,
- all values of visible region are set to zero.
+ this function should calculates an rectangle relative to the plot origin and
+ size.
+ If the ploter coords do not fall within the screen region,
+ all values of the region are set to zero.
*/
static inline void update_visible_rect( GEM_PLOTTER p )
{
@@ -408,8 +409,10 @@
free( VIEW(self).mem );
#ifdef WITH_8BPP_SUPPORT
- for( i=OFFSET_WEB_PAL; i<OFFSET_CUST_PAL+16; i++){
- vs_color( self->vdi_handle, i, &sys_pal[i][0] );
+ if( DUMMY_PRIV(self)->vfmt.indexed ){
+ for( i=OFFSET_WEB_PAL; i<OFFSET_CUST_PAL+16; i++){
+ vs_color( self->vdi_handle, i, &sys_pal[i][0] );
+ }
}
#endif
@@ -910,12 +913,25 @@
/*
This will create an snapshot of the screen in netsurf ABGR format
*/
+
static struct bitmap * snapshot_create(GEM_PLOTTER self, int x, int y, int w, int h)
{
int err;
MFDB * native;
+ uint32_t start = clock();
+
+ // FIXME: This can be optimized a lot.
+ // 1. do not copy the snapshot to the bitmap buffer
+ // when the format of screen and bitmap equals.
+ // just point the bitmap to the native mfdb.
+ // 2. if we have eddi 1.1, we could optimize that further
+ // make snapshot_create_native_mfdb just returning a pointer
+ // to the screen.
native = snapshot_create_native_mfdb( self, x, y, w, h );
+
+ if( DUMMY_PRIV(self)->vfmt.bits == 32 )
+ goto no_copy;
/* allocate buffer for result bitmap: */
if( DUMMY_PRIV(self)->buf_scr_compat == NULL ) {
@@ -948,6 +964,24 @@
);
assert( err != 0 );
return( (struct bitmap * )DUMMY_PRIV(self)->buf_scr_compat );
+
+no_copy:
+
+ snapshot.width = w;
+ snapshot.height = h;
+ snapshot.pixdata = native->fd_addr;
+ snapshot.native = *native;
+ snapshot.rowstride = MFDB_STRIDE( w )*4;
+
+ uint32_t row, col;
+ for( row = 0; row<h; row++ ){
+ // fd_w matches stride!
+ uint32_t *rowptr = ((uint32_t*)native->fd_addr + ((row*native->fd_w)));
+ for( col=0; col<w; col++){
+ *(rowptr+col) = (*(rowptr+col)<<8);
+ }
+ }
+ return( &snapshot );
}
static void snapshot_suspend(GEM_PLOTTER self )
@@ -974,34 +1008,36 @@
}
}
- if( bitmap_buffer_size( DUMMY_PRIV(self)->buf_scr_compat ) > CONV_KEEP_LIMIT ) {
- int w = 0;
- int h = 1;
- w = (CONV_KEEP_LIMIT / DUMMY_PRIV(self)->buf_scr_compat->bpp);
- assert( CONV_KEEP_LIMIT == w*DUMMY_PRIV(self)->buf_scr_compat->bpp );
- DUMMY_PRIV(self)->buf_scr_compat = bitmap_realloc( w, h,
- DUMMY_PRIV(self)->buf_scr_compat->bpp,
- CONV_KEEP_LIMIT, BITMAP_SHRINK, DUMMY_PRIV(self)->buf_scr_compat
- );
+ if( DUMMY_PRIV(self)->buf_scr_compat != NULL ) {
+ size_t bs = bitmap_buffer_size( DUMMY_PRIV(self)->buf_scr_compat );
+ if( bs > CONV_KEEP_LIMIT ) {
+ int w = 0;
+ int h = 1;
+ w = (CONV_KEEP_LIMIT / DUMMY_PRIV(self)->buf_scr_compat->bpp);
+ assert( CONV_KEEP_LIMIT == w*DUMMY_PRIV(self)->buf_scr_compat->bpp );
+ DUMMY_PRIV(self)->buf_scr_compat = bitmap_realloc( w, h,
+ DUMMY_PRIV(self)->buf_scr_compat->bpp,
+ CONV_KEEP_LIMIT, BITMAP_SHRINK, DUMMY_PRIV(self)->buf_scr_compat
+ );
+ }
}
}
static void snapshot_destroy( GEM_PLOTTER self )
{
- if( DUMMY_PRIV(self)->buf_scr.fd_addr ) {
- free( DUMMY_PRIV(self)->buf_scr.fd_addr );
- DUMMY_PRIV(self)->buf_scr.fd_addr = NULL;
- }
-
- if( DUMMY_PRIV(self)->buf_std.fd_addr ) {
- free( DUMMY_PRIV(self)->buf_std.fd_addr );
- DUMMY_PRIV(self)->buf_std.fd_addr = NULL;
- }
-
- if( DUMMY_PRIV(self)->buf_scr_compat ) {
+
+ free( DUMMY_PRIV(self)->buf_scr.fd_addr );
+ if( DUMMY_PRIV(self)->buf_scr_compat != NULL ) {
bitmap_destroy( DUMMY_PRIV(self)->buf_scr_compat );
- DUMMY_PRIV(self)->buf_scr_compat = NULL;
- }
+ }
+
+ DUMMY_PRIV(self)->buf_scr.fd_addr = NULL;
+ DUMMY_PRIV(self)->buf_scr_compat = NULL;
+
+#ifdef WITH_8BPP_SUPPORT
+ free( DUMMY_PRIV(self)->buf_std.fd_addr );
+ DUMMY_PRIV(self)->buf_std.fd_addr = NULL;
+#endif
}
@@ -1082,94 +1118,129 @@
return( ret );
}
-static int bitmap_convert_8( GEM_PLOTTER self,
- struct bitmap * img,
- int x,
- int y,
- GRECT * clip,
- uint32_t bg,
- uint32_t flags,
- MFDB *out )
-{
-
- int dststride; /* stride of dest. image */
- int dstsize; /* size of dest. in byte */
- int err;
- int bw;
+static int bitmap_convert_8( GEM_PLOTTER self, struct bitmap * img, int x,
+ int y, GRECT * clip, uint32_t bg, uint32_t flags,
+ MFDB *out )
+{
+ MFDB native;
+ MFDB stdform;
+ int dststride; /* stride of dest. image */
+ int dstsize; /* size of dest. in byte */
+ int err;
+ int bw, bh;
+ int process_w, process_h;
struct bitmap * scrbuf = NULL;
- struct bitmap * bm;
- bool transp = ( ( (img->opaque == false) || ( (flags & BITMAPF_MONOGLYPH) != 0) )
- && ((self->flags & PLOT_FLAG_TRANS) != 0) );
+ struct bitmap * source;
+ bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
+ bool opaque = bitmap_get_opaque( img );
+
+ if( opaque == false ){
+ if( ( (self->flags & PLOT_FLAG_TRANS) == 0)
+ &&
+ ((flags & (BITMAPF_MONOGLYPH|BITMAPF_BUFFER_NATIVE))==0) ){
+ opaque = true;
+ }
+ }
assert( clip->g_h > 0 );
assert( clip->g_w > 0 );
- bm = img;
- bw = bitmap_get_width( img );
-
- dststride = MFDB_STRIDE( clip->g_w );
- dstsize = ( ((dststride >> 3) * clip->g_h) * self->bpp_virt );
+ process_w = bw = bitmap_get_width( img );
+ process_h = bh = bitmap_get_height( img );
+
+ // The converted bitmap can be saved for subsequent blits, when
+ // the bitmap is fully opaque
+
+ if( (opaque == true) || (flags & BITMAPF_BUFFER_NATIVE ) ){
+ if( img->converted == true ){
+ *out = img->native;
+ return( 0 );
+ }
+ if( ( flags & BITMAPF_MONOGLYPH ) == 0 ){
+ cache = true;
+ }
+ }
+ if( ( flags & BITMAPF_MONOGLYPH ) != 0 ){
+ assert(cache == false);
+ }
/* (re)allocate buffer for out image: */
/* altough the buffer is named "buf_packed" on 8bit systems */
/* it's not... */
- if( dstsize > DUMMY_PRIV(self)->size_buf_packed) {
- int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
- if( DUMMY_PRIV(self)->buf_packed == NULL )
- DUMMY_PRIV(self)->buf_packed =(void*)malloc( blocks * CONV_BLOCK_SIZE );
- else
- DUMMY_PRIV(self)->buf_packed =(void*)realloc(
- DUMMY_PRIV(self)->buf_packed,
- blocks * CONV_BLOCK_SIZE
- );
- assert( DUMMY_PRIV(self)->buf_packed );
- if( DUMMY_PRIV(self)->buf_packed == NULL ) {
+ if( cache == false ){
+ // the size of the output will match the size of the clipping:
+ dststride = MFDB_STRIDE( clip->g_w );
+ dstsize = ( ((dststride >> 3) * clip->g_h) * self->bpp_virt );
+ if( dstsize > DUMMY_PRIV(self)->size_buf_packed) {
+ int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
+ if( DUMMY_PRIV(self)->buf_packed == NULL )
+ DUMMY_PRIV(self)->buf_packed =(void*)malloc( blocks * CONV_BLOCK_SIZE );
+ else
+ DUMMY_PRIV(self)->buf_packed =(void*)realloc(
+ DUMMY_PRIV(self)->buf_packed,
+ blocks * CONV_BLOCK_SIZE
+ );
+ assert( DUMMY_PRIV(self)->buf_packed );
+ if( DUMMY_PRIV(self)->buf_packed == NULL ) {
+ return( 0-ERR_NO_MEM );
+ }
+ DUMMY_PRIV(self)->size_buf_packed = blocks * CONV_BLOCK_SIZE;
+ }
+ native.fd_addr = DUMMY_PRIV(self)->buf_packed;
+ }
+ else {
+ // the output image will be completly saved, so size of the output
+ // image will match the input image size.
+ dststride = MFDB_STRIDE( bw );
+ dstsize = ( ((dststride >> 3) * bh) * self->bpp_virt );
+ assert( out->fd_addr == NULL );
+ native.fd_addr = (void*)malloc( dstsize );
+ if( native.fd_addr == NULL ){
+ if( scrbuf != NULL )
+ bitmap_destroy( scrbuf );
return( 0-ERR_NO_MEM );
}
- DUMMY_PRIV(self)->size_buf_packed = blocks * CONV_BLOCK_SIZE;
}
/*
on 8 bit systems we must convert the TC (ABGR) image
to vdi standard format. ( only tested for 256 colors )
- and then convert it to native format
+ and then convert it to native format with v_trnfm()
*/
-
// realloc mem for stdform
- MFDB stdform;
- if( transp ){
- if( ((self->flags & PLOT_FLAG_TRANS) != 0) || ( (flags & BITMAPF_MONOGLYPH) != 0) ) {
- // point image to snapshot buffer, otherwise allocate mem
- MFDB * bg = snapshot_create_std_mfdb( self, x+clip->g_x,y+clip->g_y, clip->g_w, clip->g_h );
- stdform.fd_addr = bg->fd_addr;
- } else {
- if( dstsize > DUMMY_PRIV(self)->size_buf_planar) {
- int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
- if( DUMMY_PRIV(self)->buf_planar == NULL )
- DUMMY_PRIV(self)->buf_planar =(void*)malloc( blocks * CONV_BLOCK_SIZE );
- else
- DUMMY_PRIV(self)->buf_planar =(void*)realloc(
- DUMMY_PRIV(self)->buf_planar,
- blocks * CONV_BLOCK_SIZE
- );
- assert( DUMMY_PRIV(self)->buf_planar );
- if( DUMMY_PRIV(self)->buf_planar == NULL ) {
- return( 0-ERR_NO_MEM );
- }
- DUMMY_PRIV(self)->size_buf_planar = blocks * CONV_BLOCK_SIZE;
+ if( opaque == false ){
+ // point image to snapshot buffer, otherwise allocate mem
+ MFDB * bg = snapshot_create_std_mfdb( self, x, y, clip->g_w,
+ clip->g_h );
+ stdform.fd_addr = bg->fd_addr;
+ bh = clip->g_h;
+ } else {
+ if( dstsize > DUMMY_PRIV(self)->size_buf_planar) {
+ int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
+ if( DUMMY_PRIV(self)->buf_planar == NULL )
+ DUMMY_PRIV(self)->buf_planar =(void*)malloc( blocks * CONV_BLOCK_SIZE );
+ else
+ DUMMY_PRIV(self)->buf_planar =(void*)realloc(
+ DUMMY_PRIV(self)->buf_planar,
+ blocks * CONV_BLOCK_SIZE
+ );
+ assert( DUMMY_PRIV(self)->buf_planar );
+ if( DUMMY_PRIV(self)->buf_planar == NULL ) {
+ return( 0-ERR_NO_MEM );
}
- stdform.fd_addr = DUMMY_PRIV(self)->buf_planar;
- }
+ DUMMY_PRIV(self)->size_buf_planar = blocks * CONV_BLOCK_SIZE;
+ }
+ stdform.fd_addr = DUMMY_PRIV(self)->buf_planar;
}
stdform.fd_w = dststride;
- stdform.fd_h = clip->g_h;
+ stdform.fd_h = bh;
stdform.fd_wdwidth = dststride >> 4;
stdform.fd_stand = 1;
stdform.fd_nplanes = (short)self->bpp_virt;
stdform.fd_r1 = stdform.fd_r2 = stdform.fd_r3 = 0;
- int img_stride = bitmap_get_rowstride(bm);
+ int img_stride = bitmap_get_rowstride(img);
uint32_t prev_pixel = 0x12345678;
unsigned long col = 0;
unsigned char val = 0;
@@ -1177,25 +1248,17 @@
uint32_t pixel;
int wdplanesize = stdform.fd_wdwidth*stdform.fd_h;
-
- // apply transparency.
- if( transp ){
+ if( opaque == false ){
+ // apply transparency and convert to vdi std format
unsigned long bgcol = 0;
unsigned char prev_col = 0;
-
-
for( y=0; y<clip->g_h; y++ ){
-
- row = (uint32_t *)(bm->pixdata + (img_stride * (y+clip->g_y)));
-
+ row = (uint32_t *)(img->pixdata + (img_stride * (y+clip->g_y)));
for( x=0; x<clip->g_w; x++ ){
-
pixel = row[x+clip->g_x];
-
if( (pixel&0xFF) == 0 ){
continue;
}
-
if( (pixel&0xFF) < 0xF0 ){
col = get_stdpx( &stdform, wdplanesize,x,y );
if( (col != prev_col) || (y == 0) )
@@ -1211,7 +1274,7 @@
| ((pixel&0xFF0000)>>16) );
val = RGB_TO_VDI( col );
}
- set_stdpx( &stdform, wdplanesize, x,y, val );
+ set_stdpx( &stdform, wdplanesize, x, y, val );
} else {
if( pixel != prev_pixel ){
/* convert pixel value to vdi color index: */
@@ -1222,18 +1285,19 @@
val = RGB_TO_VDI( col );
prev_pixel = pixel;
}
- set_stdpx( &stdform, wdplanesize, x,y, val );
+ set_stdpx( &stdform, wdplanesize, x, y, val );
}
}
}
+ // adjust output position:
+ clip->g_x = 0;
+ clip->g_y = 0;
} else {
- for( y=0; y<clip->g_h; y++ ){
-
- row = (uint32_t *)(bm->pixdata + (img_stride * (y+clip->g_y)));
-
- for( x=0; x<clip->g_w; x++ ){
-
- pixel = row[x+clip->g_x];
+ // convert the whole image data to vdi std format.
+ for( y=0; y < bh; y++ ){
+ row = (uint32_t *)(img->pixdata + (img_stride * y));
+ for( x=0; x < bw; x++ ){
+ pixel = row[x];
if( pixel != prev_pixel ){
/* convert pixel value to vdi color index: */
pixel = pixel >> 8;
@@ -1243,22 +1307,24 @@
val = RGB_TO_VDI( col );
prev_pixel = pixel;
}
- set_stdpx( &stdform, wdplanesize, x,y, val );
+ set_stdpx( &stdform, wdplanesize, x, y, val );
}
}
}
// convert into native format:
- MFDB native;
- native.fd_addr = DUMMY_PRIV(self)->buf_packed;
- native.fd_w = dststride;
- native.fd_h = clip->g_h;
- native.fd_wdwidth = dststride >> 4;
+ native.fd_w = stdform.fd_w;
+ native.fd_h = stdform.fd_h;
+ native.fd_wdwidth = stdform.fd_wdwidth;
native.fd_stand = 0;
native.fd_nplanes = (short)self->bpp_virt;
native.fd_r1 = native.fd_r2 = native.fd_r3 = 0;
vr_trnfm( self->vdi_handle, &stdform, &native );
*out = native;
+ if( cache == true ){
+ img->native = native;
+ img->converted = true;
+ }
return(0);
}
@@ -1266,81 +1332,122 @@
/*
*
-* Convert bitmap to the virutal (chunked) framebuffer format
-*
+* Convert bitmap to the native screen format
+* self: the plotter instance
+* img: the bitmap
+* x: coordinate where the bitmap REGION (described in clip)
+* shall be drawn (screen coords)
+* y: coordinate where the bitmap REGION (described in clip)
+* shall be drawn (screen coords)
+* clip: which area of the bitmap shall be drawn
+* bg: background color
+* flags: blit flags
+* out: the result MFDB
*/
-static int bitmap_convert( GEM_PLOTTER self,
- struct bitmap * img,
- int x,
- int y,
- GRECT * clip,
- uint32_t bg,
- uint32_t flags,
- MFDB *out )
+static int bitmap_convert( GEM_PLOTTER self, struct bitmap * img, int x, int y,
+ GRECT * clip, uint32_t bg, uint32_t flags, MFDB *out )
{
int dststride; /* stride of dest. image */
int dstsize; /* size of dest. in byte */
int err;
- int bw, bh;
- struct bitmap * scrbuf = NULL;
- struct bitmap * bm;
- bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
+ int bw, bh;
+ struct bitmap * scrbuf = NULL;
+ struct bitmap * source;
+ bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
+ bool opaque = bitmap_get_opaque( img );
+
+ if( opaque == false ){
+ if( ( (self->flags & PLOT_FLAG_TRANS) == 0)
+ &&
+ ((flags & (BITMAPF_MONOGLYPH|BITMAPF_BUFFER_NATIVE))==0) ){
+ opaque = true;
+ }
+ }
+
assert( clip->g_h > 0 );
assert( clip->g_w > 0 );
- bm = img;
bw = bitmap_get_width( img );
- bh = bitmap_get_height( img );
-
- if( cache ){
- assert( clip->g_w >= bw && clip->g_h >= bh );
- if( img->native.fd_addr != NULL ){
+ bh = bitmap_get_height( img );
+
+ // The converted bitmap can be saved for subsequent blits, WHEN:
+ // A.) the bitmap is fully opaque OR
+ // B.) the bitmap is completly inside the window
+ // the latter one is important for alpha blits,
+ // because we must get the window background to apply transparency
+ // If the image is not completly within the window,
+ // we can't get the whole background for the image.
+ // this only works if the image isn't used at several different places.
+ // In fact in case of alpha bitmap caching it is only used for the
+ // toolbar buttons right now.
+
+ if( (opaque == true) || (flags & BITMAPF_BUFFER_NATIVE ) ){
+ if( img->converted == true ){
*out = img->native;
return( 0 );
}
- }
-
+ if( ( flags & BITMAPF_MONOGLYPH ) == 0 ){
+ cache = true;
+ }
+ }
+
/* rem. if eddi xy is installed, we could directly access the screen! */
/* apply transparency to the image: */
- if( ( img->opaque == false )
- && ( (self->flags & PLOT_FLAG_TRANS) != 0)
- && (
- (vdi_sysinfo.vdiformat == VDI_FORMAT_PACK )
- ||
- ( (flags & BITMAPF_MONOGLYPH) != 0)
- ) ) {
- uint32_t * imgpixel;
- uint32_t * screenpixel;
+ if( ( opaque == false ) ) {
+ uint32_t * imgrow;
+ uint32_t * screenrow;
int img_x, img_y; /* points into old bitmap */
int screen_x, screen_y; /* pointers into new bitmap */
- /* copy the screen to an temp buffer: */
+
+ /* copy the screen to an temp buffer: */
scrbuf = snapshot_create(self, x, y, clip->g_w, clip->g_h );
if( scrbuf != NULL ) {
- /* copy blended pixels the new buffer (which contains screen content): */
- int img_stride = bitmap_get_rowstride(bm);
+ // copy blended pixels to the new buffer (which contains screen content):
+ int img_stride = bitmap_get_rowstride(img);
int screen_stride = bitmap_get_rowstride(scrbuf);
for( img_y = clip->g_y, screen_y = 0; screen_y < clip->g_h; screen_y++, img_y++) {
- imgpixel = (uint32_t *)(bm->pixdata + (img_stride * img_y));
- screenpixel = (uint32_t *)(scrbuf->pixdata + (screen_stride * screen_y));
- for( img_x = clip->g_x, screen_x = 0; screen_x < clip->g_w; screen_x++, img_x++ ) {
- if( (imgpixel[img_x] & 0xFF) == 0xFF ) {
- screenpixel[screen_x] = imgpixel[img_x];
- } else {
- if( (imgpixel[img_x] & 0x0FF) != 0 ) {
- screenpixel[screen_x] = ablend( imgpixel[img_x], screenpixel[screen_x]);
- }
- }
+ imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
+ screenrow = (uint32_t *)(scrbuf->pixdata + (screen_stride * screen_y));
+ for( img_x = clip->g_x, screen_x = 0; screen_x < clip->g_w; screen_x++, img_x++ ) {
+
+ // when the pixel isn't fully opaque,...:
+ if( (imgrow[img_x] & 0x0FF) != 0 ){
+ screenrow[screen_x] = ablend( imgrow[img_x], screenrow[screen_x]);
+ }
+
+ // FIXME, maybe this loop would be faster??:
+ // ---
+ //if( (imgrow[img_x] & 0x0FF) != 0xFF ){
+ // imgrow[screen_x] = ablend( imgrow[img_x], screenrow[screen_x]);
+ //}
+
+ // or maybe even this???
+ // ---
+ //if( (imgrow[img_x] & 0x0FF) == 0xFF ){
+ // screenrow[screen_x] = imgrow[img_x];
+ //} else if( (imgrow[img_x] & 0x0FF) != 0x00 ) {
+ // screenrow[screen_x] = ablend( imgrow[img_x], screenrow[screen_x]);
+ //}
}
- }
- clip->g_x = 0;
- clip->g_y = 0;
- bm = scrbuf;
+ }
+ assert( clip->g_w <= bw );
+ assert( clip->g_h <= bh );
+ /* adjust size which gets converted: */
+ bw = clip->g_w;
+ bh = clip->g_h;
+ /* adjust output position: */
+ clip->g_x = 0;
+ clip->g_y = 0;
+ /* set the source of conversion: */
+ source = scrbuf;
}
- }
- /* (re)allocate buffer for framebuffer image: */
- dststride = MFDB_STRIDE( clip->g_w );
- dstsize = ( ((dststride >> 3) * clip->g_h) * self->bpp_virt);
+ } else {
+ source = img;
+ }
+ /* (re)allocate buffer for converted image: */
+ dststride = MFDB_STRIDE( bw );
+ dstsize = ( ((dststride >> 3) * bh) * self->bpp_virt );
if( cache == false ){
if( dstsize > DUMMY_PRIV(self)->size_buf_packed) {
int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
@@ -1371,7 +1478,7 @@
}
out->fd_w = dststride;
- out->fd_h = clip->g_h;
+ out->fd_h = bh;
out->fd_wdwidth = dststride >> 4;
out->fd_stand = 0;
out->fd_nplanes = (short)self->bpp_virt;
@@ -1382,23 +1489,29 @@
&DUMMY_PRIV(self)->nsfmt,
&DUMMY_PRIV(self)->vfmt
);
- assert( err != 0 );
+ assert( err != 0 );
+
+ // FIXME: here we can use the same optimization which is used for
+ // the snapshot creation.
+
/* convert image to virtual format: */
err = Hermes_ConverterCopy( hermes_cnv_h,
- bm->pixdata,
- clip->g_x, /* x src coord of top left in pixel coords */
- clip->g_y, /* y src coord of top left in pixel coords */
- clip->g_w, clip->g_h,
- bm->rowstride, /* stride as bytes */
+ source->pixdata,
+ 0, /* x src coord of top left in pixel coords */
+ 0, /* y src coord of top left in pixel coords */
+ bw, bh,
+ source->rowstride, /* stride as bytes */
out->fd_addr,
- 0, /* x dst coord of top left in pixel coords */
- 0, /* y dst coord of top left in pixel coords */
- clip->g_w, clip->g_h,
- (dststride >> 3) * self->bpp_virt /* stride as bytes */
- );
+ 0, /* x dst coord of top left in pixel coords */
+ 0, /* y dst coord of top left in pixel coords */
+ bw, bh,
+ (dststride >> 3) * self->bpp_virt /* stride as bytes */
+ );
assert( err != 0 );
+
if( cache == true ){
img->native = *out;
+ img->converted = true;
}
return( 0 );
@@ -1421,7 +1534,8 @@
MFDB src_mf;
MFDB scrmf;
short pxy[8];
- GRECT off, clip, loc, vis;
+ GRECT off, clip, vis;
+ int screen_x, screen_y;
src_mf.fd_addr = NULL;
scrmf.fd_addr = NULL;
@@ -1430,44 +1544,54 @@
off.g_y = y;
off.g_h = bmp->height;
off.g_w = bmp->width;
-
+
+ // clip plotter clip rectangle:
clip.g_x = VIEW( self ).clipping.x0;
clip.g_y = VIEW( self ).clipping.y0;
clip.g_w = VIEW( self ).clipping.x1 - VIEW( self ).clipping.x0;
clip.g_h = VIEW( self ).clipping.y1 - VIEW( self ).clipping.y0;
if( !rc_intersect( &clip, &off) ) {
- return( true );
- }
-
+ return( 1 );
+ }
+
+ // clip the visible rectangle of the plot area
+ // this is the area of the plotter which falls into
+ // screen region:
plotter_get_visible_grect( self, &vis );
if( !rc_intersect( &vis, &off) ) {
- return( true );
- }
-
- loc = off;
- off.g_x = MAX(0, off.g_x - x);
- off.g_y = MAX(0, off.g_y - y);
- loc.g_x = MAX(0, loc.g_x);
- loc.g_y = MAX(0, loc.g_y);
-
- pxy[0] = 0;
- pxy[1] = 0;
- pxy[2] = off.g_w-1;
- pxy[3] = off.g_h-1;
- pxy[4] = VIEW(self).x + loc.g_x;
- pxy[5] = VIEW(self).y + loc.g_y;
- pxy[6] = VIEW(self).x + loc.g_x + off.g_w-1;
- pxy[7] = VIEW(self).y + loc.g_y + off.g_h-1;
- /* Convert the Bitmap to native screen format - ready for output*/
- /* This includes blending transparent pixels */
-
- if( self->bitmap_convert( self, bmp, pxy[4], pxy[5], &off, bg, flags, &src_mf) != 0 ) {
- return( true );
- }
+ return( 1 );
+ }
+
+ screen_x = VIEW(self).x + off.g_x;
+ screen_y = VIEW(self).y + off.g_y;
+
+ // convert the clipping relative to bitmap:
+ off.g_x = off.g_x - x;
+ off.g_y = off.g_y - y;
+ assert( (off.g_x >= 0) && (off.g_y >= 0) );
+
+ /* Convert the Bitmap to native screen format - ready for output. */
+ /* This includes blending transparent pixels: */
+ if( self->bitmap_convert( self, bmp, screen_x, screen_y, &off, bg, flags, &src_mf) != 0 ) {
+ return( 1 );
+ }
+
+ // setup the src region:
+ pxy[0] = off.g_x;
+ pxy[1] = off.g_y;
+ pxy[2] = off.g_x + off.g_w-1;
+ pxy[3] = off.g_y + off.g_h-1;
+
+ // setup the target region:
+ pxy[4] = screen_x;
+ pxy[5] = screen_y;
+ pxy[6] = screen_x + off.g_w-1;
+ pxy[7] = screen_y + off.g_h-1;
+
vro_cpyfm( self->vdi_handle, S_ONLY, (short*)&pxy, &src_mf, &scrmf);
convert_bitmap_done( self );
- return( true );
+ return( 1 );
}
static int plot_mfdb (GEM_PLOTTER self, GRECT * loc, MFDB * insrc, unsigned char fgcolor, uint32_t flags)
11 years, 1 month
r13885 mmu_man - in /branches/mmu_man/netsurf-gopher-support-v3/content: fetchers/curl.c gopher.c
by netsurf@semichrome.net
Author: mmu_man
Date: Thu Apr 19 13:04:19 2012
New Revision: 13885
URL: http://source.netsurf-browser.org?rev=13885&view=rev
Log:
Spice up error handling for non-directory types.
We try to match the beginning of an error line that includes the selector.
Also avoid checking the mime type too early, since a second content-type header, as in case of error, is discarded.
Modified:
branches/mmu_man/netsurf-gopher-support-v3/content/fetchers/curl.c
branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c
Modified: branches/mmu_man/netsurf-gopher-support-v3/content/fetchers/curl.c
URL: http://source.netsurf-browser.org/branches/mmu_man/netsurf-gopher-support...
==============================================================================
--- branches/mmu_man/netsurf-gopher-support-v3/content/fetchers/curl.c (original)
+++ branches/mmu_man/netsurf-gopher-support-v3/content/fetchers/curl.c Thu Apr 19 13:04:19 2012
@@ -484,8 +484,6 @@
LOG(("fetch %p, gopher error for '%s'", f, nsurl_access(url)));
}
- gopher_probe_mime(f->gopher, NULL, 0);
-
return f;
}
Modified: branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c
URL: http://source.netsurf-browser.org/branches/mmu_man/netsurf-gopher-support...
==============================================================================
--- branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c (original)
+++ branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c Thu Apr 19 13:04:19 2012
@@ -43,6 +43,7 @@
#include <math.h>
#include <sys/param.h>
+#include <libwapcaplet/libwapcaplet.h>
#include "content/content_protected.h"
#include "content/fetch.h"
#include "content/gopher.h"
@@ -248,22 +249,59 @@
/* delay until we get data */
return 0;
- if (gopher_need_generate(s->type)) {
- /* We didn't receive anything yet, check for error.
- * type '3' items report an error
- */
- /*LOG(("data[0] == 0x%02x '%c'", data[0], data[0]));*/
- if (data[0] == GOPHER_TYPE_ERROR) {
+ /* We didn't receive anything yet, check for error.
+ * type '3' items report an error
+ */
+ /*LOG(("data[0] == 0x%02x '%c'", data[0], data[0]));*/
+ if (data[0] == GOPHER_TYPE_ERROR) {
+ lwc_string *path;
+ size_t i = 1;
+
+ if (gopher_need_generate(s->type)) {
/* TODO: try to guess better from the string ?
* like "3 '/bcd' doesn't exist!"
* XXX: it might not always be a 404
*/
return 404;
- } else {
+ }
+ /* Check more carefully for possible error vs valid data.
+ * Usually we get something like:
+ * 3 '/foo' does not exist error.host 1
+ */
+ if (i >= size)
return 200;
- }
- } else
- return 200; /* TODO: handle other types better */
+ if (data[i] == ' ')
+ i++;
+ if (i >= size)
+ return 200;
+ if (data[i++] != '\'')
+ return 200;
+ path = nsurl_get_component(s->url, NSURL_PATH);
+ if (path == NULL)
+ return 200;
+ if (lwc_string_length(path) < 2 ||
+ (size - i) < lwc_string_length(path) ||
+ strncmp(&data[i], lwc_string_data(path) + 2,
+ lwc_string_length(path) - 2)) {
+ lwc_string_unref(path);
+ return 200;
+ }
+ i += lwc_string_length(path) - 2;
+ lwc_string_unref(path);
+ if (i >= size)
+ return 200;
+ if (data[i++] != '\'')
+ return 200;
+ /* XXX: check even more? */
+
+ s->type = GOPHER_TYPE_DIRECTORY;
+ /* force the Content-type */
+ gopher_probe_mime(s, NULL, 0);
+
+ return 404;
+ }
+
+ return 200;
}
/**
11 years, 1 month
r13884 mmu_man - /branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c
by netsurf@semichrome.net
Author: mmu_man
Date: Thu Apr 19 10:08:26 2012
New Revision: 13884
URL: http://source.netsurf-browser.org?rev=13884&view=rev
Log:
Add case for movie item types. Someday we'll support this.
Modified:
branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c
Modified: branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c
URL: http://source.netsurf-browser.org/branches/mmu_man/netsurf-gopher-support...
==============================================================================
--- branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c (original)
+++ branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c Thu Apr 19 10:08:26 2012
@@ -733,8 +733,21 @@
type, fields[FIELD_SELECTOR], nice_text);
break;
case GOPHER_TYPE_MOVIE:
- /* TODO */
- /* FALLTHROUGH */
+ error = snprintf(buffer, buffer_length,
+ "<a href=\"gopher://%s%s%s/%c%s\">"
+ "<span class=\"video\">%s</span></a>"
+ "<video src=\"gopher://%s%s%s/%c%s\" controls=\"controls\">"
+ "<span>[player]</span></video>"
+ "<br/>"HTML_LF,
+ fields[FIELD_HOST],
+ alt_port ? ":" : "",
+ alt_port ? fields[FIELD_PORT] : "",
+ type, fields[FIELD_SELECTOR], nice_text,
+ fields[FIELD_HOST],
+ alt_port ? ":" : "",
+ alt_port ? fields[FIELD_PORT] : "",
+ type, fields[FIELD_SELECTOR]);
+ break;
default:
/* yet to be tested items, please report when you see them! */
LOG(("warning: unknown gopher item type 0x%02x '%c'", type, type));
11 years, 1 month
r13883 mmu_man - /branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c
by netsurf@semichrome.net
Author: mmu_man
Date: Thu Apr 19 09:50:51 2012
New Revision: 13883
URL: http://source.netsurf-browser.org?rev=13883&view=rev
Log:
Cleanup.
Remove call to fetch_filetype() and just let the mime sniffer handle unknown types on its own. Works well enough and avoids relying on file extensions.
Modified:
branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c
Modified: branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c
URL: http://source.netsurf-browser.org/branches/mmu_man/netsurf-gopher-support...
==============================================================================
--- branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c (original)
+++ branches/mmu_man/netsurf-gopher-support-v3/content/gopher.c Thu Apr 19 09:50:51 2012
@@ -32,7 +32,7 @@
* gopher://sdf.org/1/users/ long page
* gopher://jgw.mdns.org/1/ search items
* gopher://jgw.mdns.org/1/MISC/ 's' item (sound)
- * gopher://gopher.floodgap.com/1/gopher empty+broken link - fixed 2012/04/08
+ * gopher://gopher.floodgap.com/1/gopher broken link - fixed 2012/04/08
* gopher://sdf.org/1/maps/m missing lines - fixed 2012/04/08
*/
@@ -280,11 +280,7 @@
mime = gopher_type_to_mime(s->type);
- /* TODO: use the newer mime sniffer API,
- * fetch_filetype() is wrongly assuming unknown files to be HTML.
- */
- if (mime == NULL)
- mime = fetch_filetype(nsurl_access(s->url));
+ /* leave other types unknown and let the mime sniffer handle them */
if (mime) {
LOG(("gopher %p mime is '%s'", s, mime));
@@ -298,6 +294,8 @@
return true;
}
+
+ LOG(("gopher %p unknown mime (type '%c')", s, s->type));
return false;
}
@@ -433,7 +431,6 @@
int error = snprintf(buffer, buffer_length,
"<html>\n"
"<head>\n"
- /*"<!-- base href=\"%s\" -->\n"*//* XXX: needs the content url */
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
"<link rel=\"stylesheet\" title=\"Standard\" "
"type=\"text/css\" href=\"resource:internal.css\">\n"
11 years, 1 month
r13882 chris_y - in /trunk/netsurf/amiga: font.c launch.c options.h
by netsurf@semichrome.net
Author: chris_y
Date: Wed Apr 18 14:44:09 2012
New Revision: 13882
URL: http://source.netsurf-browser.org?rev=13882&view=rev
Log:
Re-jig URL launch as would never have fallen back to using openurl.library.
Add it as an option instead.
Modified:
trunk/netsurf/amiga/font.c
trunk/netsurf/amiga/launch.c
trunk/netsurf/amiga/options.h
Modified: trunk/netsurf/amiga/font.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/font.c?rev=13882&r1...
==============================================================================
--- trunk/netsurf/amiga/font.c (original)
+++ trunk/netsurf/amiga/font.c Wed Apr 18 14:44:09 2012
@@ -584,7 +584,7 @@
TAG_END) == 0)
{
gwnode = GetHead((struct MinList *)gwlist);
- char1w = gwnode->gwe_Width;
+ if(gwnode) char1w = gwnode->gwe_Width;
kern = 0;
Modified: trunk/netsurf/amiga/launch.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/launch.c?rev=13882&...
==============================================================================
--- trunk/netsurf/amiga/launch.c (original)
+++ trunk/netsurf/amiga/launch.c Wed Apr 18 14:44:09 2012
@@ -29,10 +29,12 @@
#include <proto/dos.h>
#include <proto/utility.h>
#include <proto/openurl.h>
-#include <utils/url.h>
-struct Library *OpenURLBase;
-struct OpenURLIFace *IOpenURL;
+#include "desktop/options.h"
+#include "utils/url.h"
+
+struct Library *OpenURLBase = NULL;
+struct OpenURLIFace *IOpenURL = NULL;
struct MinList ami_unsupportedprotocols;
@@ -106,9 +108,9 @@
{
struct ami_protocol *ami_p;
- if(OpenURLBase = OpenLibrary("openurl.library",0))
- {
- IOpenURL = (struct OpenURLIFace *)GetInterface(OpenURLBase,"main",1,NULL);
+ if(nsoption_bool(use_openurl_lib)) {
+ if(OpenURLBase = OpenLibrary("openurl.library",0))
+ IOpenURL = (struct OpenURLIFace *)GetInterface(OpenURLBase,"main",1,NULL);
}
NewMinList(&ami_unsupportedprotocols);
@@ -131,18 +133,17 @@
if(ami_openurl_check_list(&ami_unsupportedprotocols, url) == FALSE)
{
- launchurl = ASPrintf("URL:%s",url);
-
- if(launchurl)
+ if(IOpenURL)
{
- fptr = Open(launchurl,MODE_OLDFILE);
- if(fptr) Close(fptr);
- else ami_openurl_add_protocol(url);
+ URL_OpenA((STRPTR)url,NULL);
+ } else {
+ if(launchurl = ASPrintf("URL:%s",url)) {
+ fptr = Open(launchurl,MODE_OLDFILE);
+ if(fptr) Close(fptr);
+ else ami_openurl_add_protocol(url);
+ FreeVec(launchurl);
+ }
}
- else if(IOpenURL)
- URL_OpenA((STRPTR)url,NULL);
-
- FreeVec(launchurl);
}
SetProcWindow(procwin);
Modified: trunk/netsurf/amiga/options.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/options.h?rev=13882...
==============================================================================
--- trunk/netsurf/amiga/options.h (original)
+++ trunk/netsurf/amiga/options.h Wed Apr 18 14:44:09 2012
@@ -29,12 +29,14 @@
char *use_pubscreen; \
char *modeid; \
int screen_compositing; \
+ int amiga_ydpi; \
int cache_bitmaps; \
char *theme; \
bool utf8_clipboard; \
bool context_menu; \
bool truecolour_mouse_pointers; \
bool use_os_pointers; \
+ bool use_openurl_lib; \
bool new_tab_active; \
bool new_tab_last; \
bool kiosk_mode; \
@@ -68,7 +70,6 @@
int cookies_window_ysize; \
int cairo_renderer; \
bool direct_render; \
- int amiga_ydpi; \
int redraw_tile_size_x; \
int redraw_tile_size_y; \
int monitor_aspect_x; \
@@ -83,12 +84,14 @@
.use_pubscreen = NULL, \
.modeid = NULL, \
.screen_compositing = -1, \
+ .amiga_ydpi = 72, \
.cache_bitmaps = 0, \
.theme = NULL, \
.utf8_clipboard = false, \
.context_menu = true, \
.truecolour_mouse_pointers = false, \
.use_os_pointers = true, \
+ .use_openurl_lib = false, \
.new_tab_active = false, \
.new_tab_last = false, \
.kiosk_mode = false, \
@@ -122,7 +125,6 @@
.cookies_window_ysize = 0, \
.cairo_renderer = 1, \
.direct_render = false, \
- .amiga_ydpi = 72, \
.redraw_tile_size_x = 400, \
.redraw_tile_size_y = 150, \
.monitor_aspect_x = 0, \
@@ -136,12 +138,14 @@
{ "use_pubscreen", OPTION_STRING, &nsoptions.use_pubscreen}, \
{ "screen_modeid", OPTION_STRING, &nsoptions.modeid}, \
{ "screen_compositing", OPTION_INTEGER, &nsoptions.screen_compositing}, \
+{ "screen_ydpi", OPTION_INTEGER, &nsoptions.amiga_ydpi}, \
{ "cache_bitmaps", OPTION_INTEGER, &nsoptions.cache_bitmaps}, \
{ "theme", OPTION_STRING, &nsoptions.theme}, \
{ "clipboard_write_utf8", OPTION_BOOL, &nsoptions.utf8_clipboard}, \
{ "context_menu", OPTION_BOOL, &nsoptions.context_menu}, \
{ "truecolour_mouse_pointers", OPTION_BOOL, &nsoptions.truecolour_mouse_pointers}, \
{ "os_mouse_pointers", OPTION_BOOL, &nsoptions.use_os_pointers}, \
+{ "use_openurl_lib", OPTION_BOOL, &nsoptions.use_openurl_lib}, \
{ "new_tab_is_active", OPTION_BOOL, &nsoptions.new_tab_active}, \
{ "new_tab_last", OPTION_BOOL, &nsoptions.new_tab_last}, \
{ "kiosk_mode", OPTION_BOOL, &nsoptions.kiosk_mode}, \
@@ -175,7 +179,6 @@
{ "cookies_window_ysize", OPTION_INTEGER, &nsoptions.cookies_window_ysize}, \
{ "cairo_renderer", OPTION_INTEGER, &nsoptions.cairo_renderer}, \
{ "direct_render", OPTION_BOOL, &nsoptions.direct_render}, \
-{ "amiga_ydpi", OPTION_INTEGER, &nsoptions.amiga_ydpi}, \
{ "redraw_tile_size_x", OPTION_INTEGER, &nsoptions.redraw_tile_size_x}, \
{ "redraw_tile_size_y", OPTION_INTEGER, &nsoptions.redraw_tile_size_y}, \
{ "monitor_aspect_x", OPTION_INTEGER, &nsoptions.monitor_aspect_x}, \
11 years, 1 month
r13881 chris_y - in /trunk/netsurf/amiga: gui.c misc.c
by netsurf@semichrome.net
Author: chris_y
Date: Wed Apr 18 13:54:15 2012
New Revision: 13881
URL: http://source.netsurf-browser.org?rev=13881&view=rev
Log:
Replace strncpy with strlcpy, as strncpy is not guaranteed to be
NULL-terminated. (thx Colin Wenzel)
Modified:
trunk/netsurf/amiga/gui.c
trunk/netsurf/amiga/misc.c
Modified: trunk/netsurf/amiga/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=13881&r1=...
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Wed Apr 18 13:54:15 2012
@@ -867,13 +867,13 @@
ami_gui_splash_close(splash_window);
- strncpy(script, nsoption_charp(arexx_dir), 1024);
+ strlcpy(script, nsoption_charp(arexx_dir), 1024);
AddPart(script, nsoption_charp(arexx_startup), 1024);
ami_arexx_execute(script);
netsurf_main_loop();
- strncpy(script, nsoption_charp(arexx_dir), 1024);
+ strlcpy(script, nsoption_charp(arexx_dir), 1024);
AddPart(script, nsoption_charp(arexx_shutdown), 1024);
ami_arexx_execute(script);
Modified: trunk/netsurf/amiga/misc.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/misc.c?rev=13881&r1...
==============================================================================
--- trunk/netsurf/amiga/misc.c (original)
+++ trunk/netsurf/amiga/misc.c Wed Apr 18 13:54:15 2012
@@ -115,7 +115,7 @@
DevNameFromLock(lock, newpath, sizeof newpath, DN_FULLPATH);
UnLock(lock);
}
- else strncpy(newpath, path, sizeof newpath);
+ else strlcpy(newpath, path, sizeof newpath);
r = malloc(strlen(newpath) + SLEN("file:///") + 1);
11 years, 1 month