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

📄 sdl_gemvideo.c

📁 linux下面的一个开源的多媒体中间件
💻 C
📖 第 1 页 / 共 3 页
字号:
				source, destination,				x2-x1, rects[i].h,				SDL_FALSE,				surface->pitch, destpitch			);		}	}	if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) {		MFDB mfdb_src;		short blitcoords[8];		mfdb_src.fd_addr=surface->pixels;		mfdb_src.fd_w=surf_width;		mfdb_src.fd_h=surface->h;		mfdb_src.fd_wdwidth= (surface->pitch/VDI_pixelsize) >> 4;		mfdb_src.fd_nplanes=surface->format->BitsPerPixel;		mfdb_src.fd_stand=			mfdb_src.fd_r1=			mfdb_src.fd_r2=			mfdb_src.fd_r3= 0;		if (GEM_bufops & B2S_VROCPYFM_2TOS) {			mfdb_src.fd_addr=GEM_buffer2;		}		for ( i=0; i<numrects; ++i ) {			blitcoords[0] = blitcoords[4] = rects[i].x;			blitcoords[1] = blitcoords[5] = rects[i].y;			blitcoords[2] = blitcoords[6] = rects[i].x + rects[i].w - 1;			blitcoords[3] = blitcoords[7] = rects[i].y + rects[i].h - 1;			vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);		}	}}static void GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect *rects){	short pxy[4], wind_pxy[4];	int i;	if (wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) {		return;	}	for ( i=0; i<numrects; ++i ) {		pxy[0] = wind_pxy[0] + rects[i].x;		pxy[1] = wind_pxy[1] + rects[i].y;		pxy[2] = rects[i].w;		pxy[3] = rects[i].h;		GEM_wind_redraw(this, GEM_handle, pxy);	}}static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect *rects){	SDL_Surface *surface;	if (GEM_lock_redraw) {		return;	}	surface = this->screen;	if (surface->flags & SDL_FULLSCREEN) {		GEM_UpdateRectsFullscreen(this, numrects, rects);	} else {		GEM_UpdateRectsWindowed(this, numrects, rects);	}}static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface){	int surf_width;	/* Need to be a multiple of 16 pixels */	surf_width=surface->w;	if ((surf_width & 15) != 0) {		surf_width = (surf_width | 15) + 1;	}	if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) {		void *destscr;		int destpitch;		if (GEM_bufops & B2S_C2P_1TOS) {			destscr = VDI_screen;			destpitch = VDI_pitch;		} else {			destscr = GEM_buffer2;			destpitch = surface->pitch;		}		SDL_Atari_C2pConvert(			surface->pixels, destscr,			surf_width, surface->h,			SDL_FALSE,			surface->pitch, destpitch		);	}	if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) {		MFDB mfdb_src;		short blitcoords[8];		mfdb_src.fd_w=surf_width;		mfdb_src.fd_h=surface->h;		mfdb_src.fd_wdwidth=mfdb_src.fd_w >> 4;		mfdb_src.fd_nplanes=surface->format->BitsPerPixel;		mfdb_src.fd_stand=			mfdb_src.fd_r1=			mfdb_src.fd_r2=			mfdb_src.fd_r3= 0;		if (GEM_bufops & B2S_VROCPYFM_1TOS) {			mfdb_src.fd_addr=surface->pixels;		} else {			mfdb_src.fd_addr=GEM_buffer2;		}		blitcoords[0] = blitcoords[4] = 0;		blitcoords[1] = blitcoords[5] = 0;		blitcoords[2] = blitcoords[6] = surface->w - 1;		blitcoords[3] = blitcoords[7] = surface->h - 1;		vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);	}	return(0);}static int GEM_FlipHWSurfaceWindowed(_THIS, SDL_Surface *surface){	short	pxy[8];	/* Update the whole window */	wind_get(GEM_handle, WF_WORKXYWH, &pxy[0], &pxy[1], &pxy[2], &pxy[3]);	GEM_wind_redraw(this, GEM_handle, pxy);	return(0);}static int GEM_FlipHWSurface(_THIS, SDL_Surface *surface){	if (GEM_lock_redraw) {		return(0);	}	if (surface->flags & SDL_FULLSCREEN) {		return GEM_FlipHWSurfaceFullscreen(this, surface);	} else {		return GEM_FlipHWSurfaceWindowed(this, surface);	}}static int GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors){	int i;	SDL_Surface *surface;#ifdef DEBUG_VIDEO_GEM	printf("sdl:video:gem: setcolors()\n");#endif	/* Do not change palette in True Colour */	surface = this->screen;	if (surface->format->BitsPerPixel > 8) {		return 1;	}	for(i = 0; i < ncolors; i++)	{		int		r, g, b;		short	rgb[3];		r = colors[i].r;		g = colors[i].g;		b = colors[i].b;		rgb[0] = VDI_curpalette[i][0] = (1000 * r) / 255;		rgb[1] = VDI_curpalette[i][1] =(1000 * g) / 255;		rgb[2] = VDI_curpalette[i][2] =(1000 * b) / 255;		vs_color(VDI_handle, vdi_index[firstcolor+i], rgb);	}	return(1);}#if 0static int GEM_ToggleFullScreen(_THIS, int on){	if (on) {		GEM_LockScreen(this);	} else {		GEM_UnlockScreen(this);	}	return(1);}#endif/* Note:  If we are terminated, this could be called in the middle of   another SDL video routine -- notably UpdateRects.*/void GEM_VideoQuit(_THIS){	SDL_AtariXbios_RestoreVectors();	if (GEM_usedevmouse) {		SDL_AtariDevMouse_Close();	}	GEM_FreeBuffers(this);#if SDL_VIDEO_OPENGL	if (gl_active) {		SDL_AtariGL_Quit(this, SDL_TRUE);	}#endif	/* Destroy window */	if (GEM_handle>=0) {		wind_close(GEM_handle);		wind_delete(GEM_handle);		GEM_handle=-1;	}	GEM_UnlockScreen(this);	if (GEM_menubar) {		Mfree(GEM_menubar);		GEM_menubar=NULL;	}	appl_exit();	GEM_SetNewPalette(this, VDI_oldpalette);	/* Close VDI workstation */	if (VDI_handle) {		v_clsvwk(VDI_handle);	}	/* Free mode list */	if (SDL_modelist[0]) {		SDL_free(SDL_modelist[0]);		SDL_modelist[0]=NULL;	}	this->screen->pixels = NULL;	}void GEM_wind_redraw(_THIS, int winhandle, short *inside){	short todo[4];	/* Tell AES we are going to update */	wind_update(BEG_UPDATE);	v_hide_c(VDI_handle);	/* Browse the rectangle list to redraw */	if (wind_get(winhandle, WF_FIRSTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])!=0) {		while (todo[2] && todo[3]) {			if (rc_intersect((GRECT *)inside,(GRECT *)todo)) {				todo[2] += todo[0]-1;				todo[3] += todo[1]-1;				refresh_window(this, winhandle, todo);			}			if (wind_get(winhandle, WF_NEXTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])==0) {				break;			}		}	}	/* Update finished */	wind_update(END_UPDATE);	v_show_c(VDI_handle,1);}static void refresh_window(_THIS, int winhandle, short *rect){	MFDB mfdb_src;	short pxy[8],wind_pxy[8];	SDL_Surface *surface;	int iconified;	/* Is window iconified ? */	iconified = 0;/*	if (GEM_wfeatures & (1<<WF_ICONIFY))*/ {		if (wind_get(winhandle, WF_ICONIFY, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])!=0) {			iconified = wind_pxy[0];		}	}	if (wind_get(winhandle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) {		return;	}	if (iconified && GEM_icon) {		short icon_rect[4], dst_rect[4];		short iconx,icony;				surface = GEM_icon;		GEM_ClearRect(this, rect);		/* Calculate centered icon(x,y,w,h) relative to window */		iconx = (wind_pxy[2]-surface->w)>>1;		icony = (wind_pxy[3]-surface->h)>>1;		icon_rect[0] = iconx;		icon_rect[1] = icony;		icon_rect[2] = surface->w;		icon_rect[3] = surface->h;		/* Calculate redraw rectangle(x,y,w,h) relative to window */		dst_rect[0] = rect[0]-wind_pxy[0];		dst_rect[1] = rect[1]-wind_pxy[1];		dst_rect[2] = rect[2]-rect[0]+1;		dst_rect[3] = rect[3]-rect[1]+1;		/* Does the icon rectangle must be redrawn ? */		if (!rc_intersect((GRECT *)icon_rect, (GRECT *)dst_rect)) {			return;		}#if DEBUG_VIDEO_GEM		printf("sdl:video:gem:  clip(0,0,%d,%d) to (%d,%d,%d,%d)\n",			surface->w-1,surface->h-1, dst_rect[0],dst_rect[1],dst_rect[2],dst_rect[3]);		printf("sdl:video:gem:  icon(%d,%d,%d,%d)\n",			icon_rect[0], icon_rect[1], icon_rect[2], icon_rect[3]);		printf("sdl:video:gem: refresh_window(): draw icon\n");#endif		/* Calculate icon(x1,y1,x2,y2) relative to screen */		icon_rect[0] += wind_pxy[0];		icon_rect[1] += wind_pxy[1];		icon_rect[2] += icon_rect[0]-1;		icon_rect[3] += icon_rect[1]-1;		/* Calculate intersection rectangle to redraw */		pxy[4]=pxy[0]=MAX(icon_rect[0],rect[0]);		pxy[5]=pxy[1]=MAX(icon_rect[1],rect[1]); 		pxy[6]=pxy[2]=MIN(icon_rect[2],rect[2]);	 	pxy[7]=pxy[3]=MIN(icon_rect[3],rect[3]);		/* Calculate icon source image pos relative to window */		pxy[0] -= wind_pxy[0]+iconx;		pxy[1] -= wind_pxy[1]+icony;		pxy[2] -= wind_pxy[0]+iconx;		pxy[3] -= wind_pxy[1]+icony;	} else {		surface = this->screen;#if DEBUG_VIDEO_GEM		printf("sdl:video:gem: refresh_window(): draw frame buffer\n");#endif		/* Redraw all window content */		pxy[0] = rect[0]-wind_pxy[0];		pxy[1] = rect[1]-wind_pxy[1];	 	pxy[2] = rect[2]-wind_pxy[0];   	 	pxy[3] = rect[3]-wind_pxy[1];  		pxy[4] = rect[0];		pxy[5] = rect[1];		pxy[6] = rect[2];  		pxy[7] = rect[3];	}	if (GEM_bufops & B2S_C2P_1TO2) {		void *src, *dest;		int x1,x2;		x1 = (rect[0]-wind_pxy[0]) & ~15;		x2 = rect[2]-wind_pxy[0];		if (x2 & 15) {			x2 = (x2 | 15) +1;		}		src = surface->pixels;		src += surface->pitch * (rect[1]-wind_pxy[1]);		src += x1;		dest = GEM_buffer2;		dest += surface->pitch * (rect[1]-wind_pxy[1]);		dest += x1;		SDL_Atari_C2pConvert(			src, dest,			x2-x1, rect[3]-rect[1]+1,			SDL_FALSE,			surface->pitch, surface->pitch		);	}	mfdb_src.fd_addr=surface->pixels;	{		int width;		/* Need to be a multiple of 16 pixels */		width=surface->w;		if ((width & 15) != 0) {			width = (width | 15) + 1;		}		mfdb_src.fd_w=width;	}	mfdb_src.fd_h=surface->h;  	mfdb_src.fd_nplanes=surface->format->BitsPerPixel;	mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4;	mfdb_src.fd_stand=		mfdb_src.fd_r1=  		mfdb_src.fd_r2=	  	mfdb_src.fd_r3= 0;	if (GEM_bufops & B2S_VROCPYFM_2TOS) {		mfdb_src.fd_addr=GEM_buffer2;	}#if DEBUG_VIDEO_GEM	printf("sdl:video:gem: redraw %dx%d: (%d,%d,%d,%d) to (%d,%d,%d,%d)\n",		surface->w, surface->h,		pxy[0],pxy[1],pxy[2],pxy[3],		pxy[4],pxy[5],pxy[6],pxy[7]	);#endif	vro_cpyfm( VDI_handle, S_ONLY, pxy, &mfdb_src, &VDI_dst_mfdb);}#if SDL_VIDEO_OPENGLstatic void GEM_GL_SwapBuffers(_THIS){	SDL_AtariGL_SwapBuffers(this);	GEM_FlipHWSurface(this, this->screen);}#endif

⌨️ 快捷键说明

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