⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xynth.c

📁 CS架构的多平台的GUI系统
💻 C
📖 第 1 页 / 共 2 页
字号:
		if (gd == dev) {			s_list_remove(lxynth_root->gd->list, pos);			if (lxynth_root->gd->list->nb_elt > 0) {				lxynth_root->gd->active = (struct graphics_device *) s_list_get(lxynth_root->gd->list, 0);				acc = 1;			} else {				lxynth_root->gd->active = NULL;			}			break;		}		pos++;	}	unregister_bottom_half(lxynth_surface_register_update, dev);	wd = (lxynth_device_t *) dev->driver_data;	s_free(wd->title);	s_free(wd->surface->vbuf);	s_free(wd->surface);	s_free(wd);	s_free(dev);	s_thread_mutex_unlock(lxynth_root->gd->mut);	if (acc && lxynth_root->running) {		char *title;		struct rect r;		r.x1 = 0;		r.y1 = 0;		r.x2 = lxynth_root->window->surface->buf.w;		r.y2 = lxynth_root->window->surface->buf.h;		title = strdup(((lxynth_device_t *) lxynth_root->gd->active->driver_data)->title);		lxynth_set_title(lxynth_root->gd->active, title);		lxynth_root->gd->active->resize_handler(lxynth_root->gd->active);		lxynth_root->gd->active->redraw_handler(lxynth_root->gd->active, &r);		s_free(title);	}}static void lxynth_shutdown_driver (void){	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);        if (lxynth_root->running) {		lxynth_root->running = 0;		s_client_quit(lxynth_root->window);		s_thread_join(lxynth_root->tid, NULL);		kill_timer(lxynth_root->timerid);	}	while (!s_list_eol(lxynth_root->eventq->list, 0)) {		s_event_t *event = s_list_get(lxynth_root->eventq->list, 0);		s_list_remove(lxynth_root->eventq->list, 0);		s_event_uninit(event);	}	s_free(lxynth_root->eventq->list);	s_thread_mutex_destroy(lxynth_root->eventq->mut);	s_free(lxynth_root->eventq);	while (!s_list_eol(lxynth_root->gd->list, 0)) {		struct graphics_device *gd = s_list_get(lxynth_root->gd->list, 0);		lxynth_device_t *wd = (lxynth_device_t *) gd->driver_data;		s_list_remove(lxynth_root->gd->list, 0);		s_free(wd->title);		s_free(wd->surface->vbuf);		s_free(wd->surface);		s_free(wd);		s_free(gd);	}	s_free(lxynth_root->gd->list);	s_thread_mutex_destroy(lxynth_root->gd->mut);	s_free(lxynth_root->gd);	s_free(lxynth_root);}static unsigned char * lxynth_driver_param (void){	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	exit(0);}static int lxynth_get_empty_bitmap (struct bitmap *dest){	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	dest->data = (char *) s_malloc(dest->x * dest->y * lxynth_root->window->surface->bytesperpixel);	dest->skip = dest->x * lxynth_root->window->surface->bytesperpixel;	dest->flags = 0;	return 0;}static void lxynth_register_bitmap (struct bitmap *bmp){	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);}static void * lxynth_prepare_strip (struct bitmap *bmp, int top, int lines){	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	exit(0);}static void lxynth_commit_strip (struct bitmap *bmp, int top, int lines){	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	exit(0);}static void lxynth_unregister_bitmap (struct bitmap *bmp){	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	s_free(bmp->data);}#define	CLIP_PREFACE \	if ((x >= dev->clip.x2) || ((x + xs) <= dev->clip.x1)) return;\	if ((y >= dev->clip.y2) || ((y + ys) <= dev->clip.y1)) return;\	if ((x + xs) > dev->clip.x2) xs = dev->clip.x2 - x;\	if ((y + ys) > dev->clip.y2) ys = dev->clip.y2 - y;\	if ((dev->clip.x1 - x) > 0){\		xs -= (dev->clip.x1 - x);\		data += lxynth_root->window->surface->bytesperpixel * (dev->clip.x1 - x);\		x = dev->clip.x1;\	}\	if ((dev->clip.y1 - y) > 0) {\		ys -= (dev->clip.y1 - y);\		data += hndl->skip * (dev->clip.y1 - y);\		y = dev->clip.y1;\	}static void lxynth_draw_bitmap (struct graphics_device *dev, struct bitmap *hndl, int x, int y){	lxynth_device_t *wd;	int xs = hndl->x;	int ys = hndl->y;	char *data = hndl->data;	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	CLIP_PREFACE;        if (lxynth_root->running == 0) return;        s_thread_mutex_lock(lxynth_root->gd->mut);        if (lxynth_root->gd->active != dev) {		s_thread_mutex_unlock(lxynth_root->gd->mut);		return;	}	wd = (lxynth_device_t *) dev->driver_data;        s_putboxpart(wd->surface, x, y, xs, ys, hndl->x, hndl->y, data, 0, 0);	lxynth_surface_update(dev, x, y, xs, ys);	s_thread_mutex_unlock(lxynth_root->gd->mut);}static void lxynth_draw_bitmaps (struct graphics_device *dev, struct bitmap **hndls, int n, int x, int y){	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	exit(0);}static long lxynth_get_color (int rgb){	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	return s_rgbcolor(lxynth_root->window->surface, (rgb >> 0x10) & 0xFF,	                                               (rgb >> 0x08) & 0xFF,	                                               (rgb << 0x00) & 0xFF);}#define FILL_CLIP_PREFACE \	if ((left >= right) || (top >= bottom)) return;\	if ((left >= dev->clip.x2) || (right <= dev->clip.x1) || (top >= dev->clip.y2) || (bottom <= dev->clip.y1)) return;\	if (left < dev->clip.x1) left = dev->clip.x1;\	if (right > dev->clip.x2) right = dev->clip.x2;\	if (top < dev->clip.y1) top = dev->clip.y1;\	if (bottom > dev->clip.y2) bottom = dev->clip.y2;static void lxynth_fill_area (struct graphics_device *dev, int left, int top, int right, int bottom, long color){	lxynth_device_t *wd;	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	FILL_CLIP_PREFACE;        if (lxynth_root->running == 0) return;        s_thread_mutex_lock(lxynth_root->gd->mut);        if (lxynth_root->gd->active != dev) {		s_thread_mutex_unlock(lxynth_root->gd->mut);		return;	}	wd = (lxynth_device_t *) dev->driver_data;	s_fillbox(wd->surface, left, top, right - left, bottom - top, color);	lxynth_surface_update(dev, left, top, right - left, bottom - top);	s_thread_mutex_unlock(lxynth_root->gd->mut);}#define HLINE_CLIP_PREFACE \	if (left >= right) return;\	if ((y < dev->clip.y1) || (y >= dev->clip.y2) || (right <= dev->clip.x1) || (left >= dev->clip.x2)) return;\	if (left < dev->clip.x1) left = dev->clip.x1;\	if (right > dev->clip.x2) right = dev->clip.x2;static void lxynth_draw_hline (struct graphics_device *dev, int left, int y, int right, long color){	lxynth_device_t *wd;	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	HLINE_CLIP_PREFACE;        if (lxynth_root->running == 0) return;        s_thread_mutex_lock(lxynth_root->gd->mut);        if (lxynth_root->gd->active != dev) {		s_thread_mutex_unlock(lxynth_root->gd->mut);		return;	}	wd = (lxynth_device_t *) dev->driver_data;	s_hline(wd->surface, left, y, right, color);	lxynth_surface_update(dev, left, y, right - left, 1);	s_thread_mutex_unlock(lxynth_root->gd->mut);}#define VLINE_CLIP_PREFACE \	if (top >= bottom) return;\	if ((x < dev->clip.x1) || (x >= dev->clip.x2) || (top >= dev->clip.y2) || (bottom <= dev->clip.y1)) return;\	if (top < dev->clip.y1) top = dev->clip.y1;\	if (bottom > dev->clip.y2) bottom = dev->clip.y2;static void lxynth_draw_vline (struct graphics_device *dev, int x, int top, int bottom, long color){	lxynth_device_t *wd;	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	VLINE_CLIP_PREFACE;        if (lxynth_root->running == 0) return;        s_thread_mutex_lock(lxynth_root->gd->mut);        if (lxynth_root->gd->active != dev) {		s_thread_mutex_unlock(lxynth_root->gd->mut);		return;	}	wd = (lxynth_device_t *) dev->driver_data;	s_vline(wd->surface, x, top, bottom, color);	lxynth_surface_update(dev, x, top, 1, bottom - top);	s_thread_mutex_unlock(lxynth_root->gd->mut);}#define HSCROLL_CLIP_PREFACE \	if (!sc) return 0;\	if (sc > (dev->clip.x2 - dev->clip.x1) || -sc > (dev->clip.x2 - dev->clip.x1))\		return 1;static int lxynth_hscroll (struct graphics_device *dev, struct rect_set **ignore, int sc){	s_rect_t rect;	lxynth_device_t *wd;	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	HSCROLL_CLIP_PREFACE;        if (lxynth_root->running == 0) return;        s_thread_mutex_lock(lxynth_root->gd->mut);        if (lxynth_root->gd->active != dev) {		s_thread_mutex_unlock(lxynth_root->gd->mut);		return;	}	wd = (lxynth_device_t *) dev->driver_data;	ignore = NULL;	rect.x = dev->clip.x1;	rect.y = dev->clip.y1;	rect.w = dev->clip.x2 - dev->clip.x1;	rect.h = dev->clip.y2 - dev->clip.y1;        s_copybox(wd->surface, rect.x, rect.y, rect.w, rect.h, rect.x + sc, rect.y);	lxynth_surface_update(dev, rect.x, rect.y, rect.w, rect.h);	s_thread_mutex_unlock(lxynth_root->gd->mut);        return 1;}#define VSCROLL_CLIP_PREFACE \	if (!sc) return 0;\	if (sc > dev->clip.y2 - dev->clip.y1 || -sc > dev->clip.y2 - dev->clip.y1) return 1;static int lxynth_vscroll (struct graphics_device *dev, struct rect_set **ignore, int sc){	s_rect_t rect;	lxynth_device_t *wd;	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	VSCROLL_CLIP_PREFACE;        if (lxynth_root->running == 0) return;        s_thread_mutex_lock(lxynth_root->gd->mut);        if (lxynth_root->gd->active != dev) {		s_thread_mutex_unlock(lxynth_root->gd->mut);		return;	}	wd = (lxynth_device_t *) dev->driver_data;	ignore = NULL;	rect.x = dev->clip.x1;	rect.y = dev->clip.y1;	rect.w = dev->clip.x2 - dev->clip.x1;	rect.h = dev->clip.y2 - dev->clip.y1;        s_copybox(wd->surface, rect.x, rect.y, rect.w, rect.h, rect.x, rect.y + sc);	lxynth_surface_update(dev, rect.x, rect.y, rect.w, rect.h);	s_thread_mutex_unlock(lxynth_root->gd->mut);	return 1;}static void lxynth_set_clip_area (struct graphics_device *dev, struct rect *r){	lxynth_device_t *wd;	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);        s_thread_mutex_lock(lxynth_root->gd->mut);        if (lxynth_root->gd->active != dev) {		s_thread_mutex_unlock(lxynth_root->gd->mut);		return;	}	wd = (lxynth_device_t *) dev->driver_data;	memcpy(&dev->clip, r, sizeof(struct rect));	if ((dev->clip.x1 >= dev->clip.x2) ||	    (dev->clip.y2 <= dev->clip.y1) ||	    (dev->clip.y2 <= 0) ||	    (dev->clip.x2 <= 0) ||	    (dev->clip.x1 >= wd->surface->width) ||	    (dev->clip.y1 >= wd->surface->height)) {		dev->clip.x1 = dev->clip.x2 = dev->clip.y1 = dev->clip.y2 = 0;	} else {		if (dev->clip.x1 < 0) dev->clip.x1 = 0;		if (dev->clip.x2 > wd->surface->width) dev->clip.x2 = wd->surface->width;		if (dev->clip.y1 < 0) dev->clip.y1 = 0;		if (dev->clip.y2 > wd->surface->height) dev->clip.y2 = wd->surface->height;	}	s_thread_mutex_unlock(lxynth_root->gd->mut);}static int lxynth_block (struct graphics_device *dev){	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	exit(0);}static void lxynth_unblock (struct graphics_device *dev){	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	exit(0);}static void lxynth_set_title (struct graphics_device *dev, unsigned char *title){	lxynth_device_t *wd;	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	wd = (lxynth_device_t *) dev->driver_data;        s_free(wd->title);        wd->title = strdup(title);        s_thread_mutex_lock(lxynth_root->gd->mut);        if (lxynth_root->gd->active != dev) {		s_thread_mutex_unlock(lxynth_root->gd->mut);		return;	}	s_window_set_title(lxynth_root->window, title);	s_thread_mutex_unlock(lxynth_root->gd->mut);}static int lxynth_exec (unsigned char *command, int flag){	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);	exit(0);}struct graphics_driver xynth_driver = {	"xynth",	lxynth_init_driver,	lxynth_init_device,	lxynth_shutdown_device,	lxynth_shutdown_driver,	lxynth_driver_param,	lxynth_get_empty_bitmap,	lxynth_register_bitmap,	lxynth_prepare_strip,	lxynth_commit_strip,	lxynth_unregister_bitmap,	lxynth_draw_bitmap,	lxynth_draw_bitmaps,	lxynth_get_color,	lxynth_fill_area,	lxynth_draw_hline,	lxynth_draw_vline,	lxynth_hscroll,	lxynth_vscroll,	lxynth_set_clip_area,	lxynth_block,	lxynth_unblock,	lxynth_set_title,	lxynth_exec,	0,	0,	0,	0,};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -