[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>
This commit is contained in:
Fumitoshi UKAI
2003-07-07 15:48:16 +00:00
parent 3c45cb485a
commit 0bbf6748bb
9 changed files with 165 additions and 49 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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>
@@ -60,6 +60,15 @@ w3mfb_close(w3mimg_op * self)
fb_close();
}
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)
{
@@ -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;