diff options
| author | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-07-07 15:48:16 +0000 | 
|---|---|---|
| committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-07-07 15:48:16 +0000 | 
| commit | 0bbf6748bb7cd8cf187fcb7a8261c1dcddd03df5 (patch) | |
| tree | 7361b0c822440318261d7ead736a2f8911f36ff0 | |
| parent | [w3m-dev 03927] deflate (diff) | |
| download | w3m-0bbf6748bb7cd8cf187fcb7a8261c1dcddd03df5.tar.gz w3m-0bbf6748bb7cd8cf187fcb7a8261c1dcddd03df5.zip | |
[w3m-dev 03929] clear image
* image.c (syncImage): added
	(drawImage): rewrite using syncImage()
	(clearImage): use clear image command (6)
* w3mimgdisplay.c: change protocol
	2 => terminate drawing
	6 => clear image
	(main): '2' calls TermImage()
		'6' calls ClearImage()
		TermImage() when exit
	(TermImage): renamed from ClearImage
	(ClearImage): rewritten to call w_op->clear()
* w3mimg.h/w3mimg.h (w3mimg_op): add clear()
* w3mimg/fb/fb.c (fb_clear): added
* w3mimg/fb/fb.h (fb_clear): added
* w3mimg/fb/fb_img.c (fb_image_clear): added
* w3mimg/fb/fb_w3mimg.c (w3mfb_clear): added
	(w3mimg_fbopen): initialize wop->clear
* w3mimg/x11/x11_w3mimg.c (x11_clear): added
	(w3mimg_x11open): initialize wop->clear
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
| -rw-r--r-- | ChangeLog | 25 | ||||
| -rw-r--r-- | image.c | 76 | ||||
| -rw-r--r-- | w3mimg/fb/fb.c | 26 | ||||
| -rw-r--r-- | w3mimg/fb/fb.h | 3 | ||||
| -rw-r--r-- | w3mimg/fb/fb_img.c | 8 | ||||
| -rw-r--r-- | w3mimg/fb/fb_w3mimg.c | 12 | ||||
| -rw-r--r-- | w3mimg/w3mimg.h | 3 | ||||
| -rw-r--r-- | w3mimg/x11/x11_w3mimg.c | 16 | ||||
| -rw-r--r-- | w3mimgdisplay.c | 45 | 
9 files changed, 165 insertions, 49 deletions
| @@ -1,5 +1,28 @@  2003-07-08  Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> +	* [w3m-dev 03929] clear image +	* image.c (syncImage): added +		(drawImage): rewrite using syncImage() +		(clearImage): use clear image command (6) +	* w3mimgdisplay.c: change protocol +		2 => terminate drawing +		6 => clear image +		(main): '2' calls TermImage() +			'6' calls ClearImage() +			TermImage() when exit +		(TermImage): renamed from ClearImage +		(ClearImage): rewritten to call w_op->clear() +	* w3mimg.h/w3mimg.h (w3mimg_op): add clear() +	* w3mimg/fb/fb.c (fb_clear): added +	* w3mimg/fb/fb.h (fb_clear): added +	* w3mimg/fb/fb_img.c (fb_image_clear): added +	* w3mimg/fb/fb_w3mimg.c (w3mfb_clear): added +		(w3mimg_fbopen): initialize wop->clear +	* w3mimg/x11/x11_w3mimg.c (x11_clear): added +		(w3mimg_x11open): initialize wop->clear + +2003-07-08  Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> +  	* [w3m-dev 03927] deflate  	* file.c (compression_decoder): .deflate for application/x-deflate's  				extension @@ -7869,4 +7892,4 @@ a	* [w3m-dev 03276] compile error on EWS4800  	* release-0-2-1  	* import w3m-0.2.1 -$Id: ChangeLog,v 1.844 2003/07/07 15:39:43 ukai Exp $ +$Id: ChangeLog,v 1.845 2003/07/07 15:48:16 ukai Exp $ @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.34 2003/02/24 16:27:36 ukai Exp $ */ +/* $Id: image.c,v 1.35 2003/07/07 15:48:16 ukai Exp $ */  #include "fm.h"  #include <sys/types.h> @@ -149,6 +149,24 @@ addImage(ImageCache * cache, int x, int y, int sx, int sy, int w, int h)      n_terminal_image++;  } +static void +syncImage(void) +{ +    fputs("3;\n", Imgdisplay_wf);	/* XSync() */ +    fputs("4;\n", Imgdisplay_wf);	/* put '\n' */ +    while (fflush(Imgdisplay_wf) != 0) { +	if (ferror(Imgdisplay_wf)) +	    goto err; +    } +    if (!fgetc(Imgdisplay_rf)) +	goto err; +    return; +  err: +    closeImgdisplay(); +    image_index += MAX_IMAGE; +    n_terminal_image = 0; +} +  void  drawImage()  { @@ -169,10 +187,6 @@ drawImage()  	    if (!openImgdisplay())  		return;  	} -	if (!draw) { -	    fputs("3;\n", Imgdisplay_wf);	/* XSync() */ -	    draw = TRUE; -	}  	if (i->cache->index > 0) {  	    i->cache->index *= -1;  	    fputs("0;", Imgdisplay_wf);	/* DrawImage() */ @@ -187,49 +201,39 @@ drawImage()  	fputs(buf, Imgdisplay_wf);  	fputs(i->cache->file, Imgdisplay_wf);  	fputs("\n", Imgdisplay_wf); -	fputs("4;\n", Imgdisplay_wf);	/* put '\n' */ -	while (fflush(Imgdisplay_wf) != 0) { -	    if (ferror(Imgdisplay_wf)) -		goto err; -	} -	if (!fgetc(Imgdisplay_rf)) -	    goto err; +	draw = TRUE;      }      if (!draw)  	return; -    fputs("3;\n", Imgdisplay_wf);	/* XSync() */ -    fputs("4;\n", Imgdisplay_wf);	/* put '\n' */ -    while (fflush(Imgdisplay_wf) != 0) { -	if (ferror(Imgdisplay_wf)) -	    goto err; -    } -    if (!fgetc(Imgdisplay_rf)) -	goto err; -    /* -     * touch_line(); -     * touch_column(CurColumn); -     * #ifdef JP_CHARSET -     * if (CurColumn > 0 && -     * CHMODE(ScreenImage[CurLine]->lineprop[CurColumn]) == C_WCHAR2) -     * touch_column(CurColumn - 1); -     * else if (CurColumn < COLS - 1 && -     * CHMODE(ScreenImage[CurLine]->lineprop[CurColumn]) == C_WCHAR1) -     * touch_column(CurColumn + 1); -     * #endif -     */ +    syncImage();      touch_cursor();      refresh(); -    return; -  err: -    closeImgdisplay(); -    image_index += MAX_IMAGE;  }  void  clearImage()  { +    static char buf[64]; +    int j; +    TerminalImage *i; +      if (!activeImage)  	return; +    if (!n_terminal_image) +	return; +    if (!Imgdisplay_wf) { +	n_terminal_image = 0; +	return; +    } +    for (j = 0; j < n_terminal_image; j++) { +	i = &terminal_image[j]; +	if (!(i->cache->loaded & IMG_FLAG_LOADED && +	    i->width > 0 && i->height > 0)) +	    continue; +	sprintf(buf, "6;%d;%d;%d;%d\n", i->x, i->y, i->width, i->height); +	fputs(buf, Imgdisplay_wf); +    } +    syncImage();      n_terminal_image = 0;  } diff --git a/w3mimg/fb/fb.c b/w3mimg/fb/fb.c index c936784..954525a 100644 --- a/w3mimg/fb/fb.c +++ b/w3mimg/fb/fb.c @@ -1,4 +1,4 @@ -/* $Id: fb.c,v 1.9 2002/10/31 09:36:22 ukai Exp $ */ +/* $Id: fb.c,v 1.10 2003/07/07 15:48:17 ukai Exp $ */  /**************************************************************************                  fb.c 0.3 Copyright (C) 2002, hito   **************************************************************************/ @@ -365,6 +365,30 @@ fb_height(void)      return vscinfo.yres;  } +int +fb_clear(int x, int y, int w, int h, int r, int g, int b) +{ +    unsigned long bg; +    int i, offset_fb; + +    if (is_open != TRUE || x > fb_width() || y > fb_height()) +	return 1; +    if (x + w > fb_width()) +	w = fb_width() - x; +    if (y + h > fb_height()) +	h = fb_height() - y; + +    offset_fb = fscinfo.line_length * y + pixel_size * x; +    bg = ((r >> (CHAR_BIT - vscinfo.red.length)) << vscinfo.red.offset) + +	 ((g >> (CHAR_BIT - vscinfo.green.length)) << vscinfo.green.offset) + +	 ((b >> (CHAR_BIT - vscinfo.blue.length)) << vscinfo.blue.offset); +    for (i = 0; i < h; i++) { +	memcpy(buf + offset_fb, bg, pixel_size * w); +	offset_fb += fscinfo.line_length; +    } +    return 0; +} +  /********* static functions **************/  static      int diff --git a/w3mimg/fb/fb.h b/w3mimg/fb/fb.h index bec281d..1138bb0 100644 --- a/w3mimg/fb/fb.h +++ b/w3mimg/fb/fb.h @@ -1,4 +1,4 @@ -/* $Id: fb.h,v 1.6 2002/10/10 16:16:03 ukai Exp $ */ +/* $Id: fb.h,v 1.7 2003/07/07 15:48:17 ukai Exp $ */  #ifndef fb_header  #define fb_header  #include <linux/fb.h> @@ -29,5 +29,6 @@ int fb_open(void);  void fb_close(void);  int fb_width(void);  int fb_height(void); +int fb_clear(int x, int y, int w, int h, int r, int g, int b);  #endif diff --git a/w3mimg/fb/fb_img.c b/w3mimg/fb/fb_img.c index aad3847..3547a00 100644 --- a/w3mimg/fb/fb_img.c +++ b/w3mimg/fb/fb_img.c @@ -1,4 +1,4 @@ -/* $Id: fb_img.c,v 1.5 2002/10/10 16:16:04 ukai Exp $ */ +/* $Id: fb_img.c,v 1.6 2003/07/07 15:48:17 ukai Exp $ */  #include <stdio.h>  #include <stdlib.h>  #include <sys/types.h> @@ -24,3 +24,9 @@ fb_image_set_bg(int r, int g, int b)      bg_g = g;      bg_b = b;  } + +int +fb_image_clear(int x, int y, int w, int h) +{ +    return fb_clear(x, y, w, h, bg_r, bg_g, bg_b); +} diff --git a/w3mimg/fb/fb_w3mimg.c b/w3mimg/fb/fb_w3mimg.c index 5c8fe4c..94674ed 100644 --- a/w3mimg/fb/fb_w3mimg.c +++ b/w3mimg/fb/fb_w3mimg.c @@ -1,4 +1,4 @@ -/* $Id: fb_w3mimg.c,v 1.11 2003/04/03 16:35:48 ukai Exp $ */ +/* $Id: fb_w3mimg.c,v 1.12 2003/07/07 15:48:17 ukai Exp $ */  #include <stdio.h>  #include <stdlib.h>  #include <ctype.h> @@ -61,6 +61,15 @@ w3mfb_close(w3mimg_op * self)  }  static int +w3mfb_clear(w3mimg_op * self, int x, int y, int w, int h) +{ +    if (self == NULL) +	return 0; +    fb_image_clear(x, y, w, h); +    return 1; +} + +static int  w3mfb_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h)  {      FB_IMAGE **im; @@ -179,6 +188,7 @@ w3mimg_fbopen()      wop->set_background = w3mfb_set_background;      wop->sync = w3mfb_sync;      wop->close = w3mfb_close; +    wop->clear = w3mfb_clear;      wop->load_image = w3mfb_load_image;      wop->show_image = w3mfb_show_image; diff --git a/w3mimg/w3mimg.h b/w3mimg/w3mimg.h index 0e7bc26..03158db 100644 --- a/w3mimg/w3mimg.h +++ b/w3mimg/w3mimg.h @@ -1,4 +1,4 @@ -/* $Id: w3mimg.h,v 1.6 2003/03/24 15:45:58 ukai Exp $ */ +/* $Id: w3mimg.h,v 1.7 2003/07/07 15:48:17 ukai Exp $ */  #include "config.h"  #ifdef USE_W3MIMG_FB @@ -32,6 +32,7 @@ typedef struct _w3mimg_op {      void (*free_image) (struct _w3mimg_op * self, W3MImage * img);      int (*get_image_size) (struct _w3mimg_op * self, W3MImage * img,  			   char *fname, int *w, int *h); +    int (*clear) (struct _w3mimg_op * self, int x, int y, int w, int h);  } w3mimg_op;  #ifdef USE_W3MIMG_X11 diff --git a/w3mimg/x11/x11_w3mimg.c b/w3mimg/x11/x11_w3mimg.c index b2e529f..88be7b1 100644 --- a/w3mimg/x11/x11_w3mimg.c +++ b/w3mimg/x11/x11_w3mimg.c @@ -1,4 +1,4 @@ -/* $Id: x11_w3mimg.c,v 1.22 2003/06/13 15:04:00 ukai Exp $ */ +/* $Id: x11_w3mimg.c,v 1.23 2003/07/07 15:48:17 ukai Exp $ */  #include <stdio.h>  #include <stdlib.h>  #include <ctype.h> @@ -123,6 +123,19 @@ x11_finish(w3mimg_op * self)  }  static int +x11_clear(w3mimg_op * self, int x, int y, int w, int h) +{ +    struct x11_info *xi; +    if (self == NULL) +	return 0; +    xi = (struct x11_info *)self->priv; +    if (xi == NULL) +	return 0; +    XClearArea(xi->display, xi->window, x, y, w, h, FALSE); +    return 1; +} + +static int  x11_active(w3mimg_op * self)  {      struct x11_info *xi; @@ -688,6 +701,7 @@ w3mimg_x11open()      wop->set_background = x11_set_background;      wop->sync = x11_sync;      wop->close = x11_close; +    wop->clear = x11_clear;      wop->load_image = x11_load_image;      wop->show_image = x11_show_image; diff --git a/w3mimgdisplay.c b/w3mimgdisplay.c index 4534246..6ec24cc 100644 --- a/w3mimgdisplay.c +++ b/w3mimgdisplay.c @@ -1,4 +1,4 @@ -/* $Id: w3mimgdisplay.c,v 1.13 2003/03/24 15:45:57 ukai Exp $ */ +/* $Id: w3mimgdisplay.c,v 1.14 2003/07/07 15:48:16 ukai Exp $ */  #include <stdio.h>  #include <stdlib.h>  #include <ctype.h> @@ -21,7 +21,8 @@ static int maxImage = 0, maxAnim = 100;  static void GetOption(int argc, char **argv);  static void DrawImage(char *buf, int redraw); -static void ClearImage(void); +static void TermImage(void); +static void ClearImage(char *buf);  int  main(int argc, char **argv) @@ -100,15 +101,18 @@ main(int argc, char **argv)  	 * op	args  	 *  0;  params		draw image  	 *  1;  params		redraw image -	 *  2;  -none-		clear image +	 *  2;  -none-		terminate drawing  	 *  3;  -none-		sync drawing  	 *  4;  -none-		nop, sync communication  	 *			response '\n'  	 *  5;  path		get size of image,  	 *			response "<width> <height>\n" +	 *  6;  params(6)	clear image  	 *  	 * params  	 *	<n>;<x>;<y>;<w>;<h>;<sx>;<sy>;<sw>;<sh>;<path> +	 * params(6) +	 *	<x>;<y>;<w>;<h>  	 *     	 */  	switch (buf[0]) { @@ -119,7 +123,7 @@ main(int argc, char **argv)  	    DrawImage(&buf[2], 1);  	    break;  	case '2': -	    ClearImage(); +	    TermImage();  	    break;  	case '3':  	    w_op->sync(w_op); @@ -144,9 +148,12 @@ main(int argc, char **argv)  		fflush(stdout);  	    }  	    break; +	case '6': +	    ClearImage(&buf[2]); +	    break;  	}      } -    ClearImage(); +    TermImage();      w_op->close(w_op);      exit(0);  } @@ -278,7 +285,7 @@ DrawImage(char *buf, int redraw)  }  void -ClearImage(void) +TermImage(void)  {      w_op->finish(w_op);      if (imageBuf) { @@ -291,3 +298,29 @@ ClearImage(void)      }      maxImage = 0;  } + +void +ClearImage(char *buf) +{ +    char *p = buf; +    int x = 0, y = 0, w = 0, h = 0; + +    if (!p) +	return; +    for (; isdigit(*p); p++) +	x = 10 * x + (*p - '0'); +    if (*(p++) != ';') +	return; +    for (; isdigit(*p); p++) +	y = 10 * y + (*p - '0'); +    if (*(p++) != ';') +	return; +    for (; isdigit(*p); p++) +	w = 10 * w + (*p - '0'); +    if (*(p++) != ';') +	return; +    for (; isdigit(*p); p++) +	h = 10 * h + (*p - '0'); + +    w_op->clear(w_op, x, y, w, h); +} | 
