PageRenderTime 21ms CodeModel.GetById 10ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/project/jni/sdl_blitpool/include/SDL_blitpool.h

https://github.com/aichunyu/FFPlayer
C Header | 258 lines | 84 code | 99 blank | 75 comment | 0 complexity | dfd7d9323cda082388ee3986a4c081e0 MD5 | raw file
  1/*
  2//
  3//	Blit operation pool for the SDL.
  4//	Copyright (C) 2005 Strangebug (S.Miura) [strangebug art hotmail.co.jp]
  5//
  6//
  7//	This library is free software; you can redistribute it and/or
  8//	modify it under the terms of the GNU Lesser General Public
  9//	License as published by the Free Software Foundation; either
 10//	version 2.1 of the License, or (at your option) any later version.
 11//	
 12//	This library is distributed in the hope that it will be useful,
 13//	but WITHOUT ANY WARRANTY; without even the implied warranty of
 14//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 15//	Lesser General Public License for more details.
 16//	
 17//	You should have received a copy of the GNU Lesser General Public
 18//	License along with this library; if not, write to the Free Software
 19//	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 20//
 21//
 22//	SDL_BlitPool.c	: 25/Feb/2005	: created
 23//
 24*/
 25
 26
 27#ifndef INCLUDED_SDL_BLITPOOL_H
 28#define INCLUDED_SDL_BLITPOOL_H
 29
 30
 31
 32#include "SDL.h"
 33#include "begin_code.h"
 34
 35
 36#ifdef __cplusplus
 37extern "C" {
 38#endif
 39
 40
 41
 42
 43#ifndef Optional
 44# define Optional
 45#endif
 46
 47
 48
 49
 50typedef enum {
 51	
 52	/*	BlitType	*/
 53	BLIT_TYPE_SURFACE	= 1 << 0,
 54	BLIT_TYPE_COLORFILL	= 1 << 1,
 55	BLIT_TYPE_EMPTY		= 1 << 2,
 56	
 57	#define BLIT_TYPE_MASK	(BLIT_TYPE_SURFACE | BLIT_TYPE_COLORFILL | BLIT_TYPE_EMPTY)
 58	
 59	
 60	/*	BlitTransparency	*/
 61	BLIT_ALPHA_TRANSPARENT	= 1 << 3,			/*	Surface have transparency pixel	*/
 62	BLIT_ALPHA_OPAQUE		= 1 << 4,			/*	Surface not have transparency pixel	*/
 63	
 64	#define BLIT_ALPHA_MASK	(BLIT_ALPHA_TRANSPARENT | BLIT_ALPHA_OPAQUE)
 65	
 66	
 67	/*	BlitExecOption	*/
 68	BLIT_EXEC_OPTIMIZE		= 1 << 7,			/*	do optimize	*/
 69	BLIT_EXEC_NO_OPTIMIZE	= 1 << 8,			/*	do not optimize	*/
 70	
 71	#define BLIT_EXEC_MASK	(BLIT_EXEC_OPTIMIZE | BLIT_EXEC_NO_OPTIMIZE)
 72	
 73	
 74	BLIT_FLAG_TERM	= 1 << 9		/*	terminater	*/
 75	
 76} BlitEntryFlag;
 77
 78
 79
 80
 81typedef enum {
 82	BLIT_OPT_REMOVEOVERLAP	= 1 << 0,		/*	remove overlap area	*/
 83	BLIT_OPT_REMOVEOUTSIDE	= 1 << 1,		/*	remove outside of destination surface	*/
 84	
 85	BLIT_OPT_ALL = BLIT_OPT_REMOVEOVERLAP | BLIT_OPT_REMOVEOUTSIDE
 86	
 87} BlitOptimizeFlag;
 88
 89
 90
 91typedef struct BlitPool_tag BlitPool;			/*	Pool object	*/
 92
 93
 94typedef void *(*allocator_func)(unsigned long nbyte);
 95typedef void (*releaser_func)(void *p);
 96
 97
 98
 99typedef struct {
100	/*
101	// Box: (x0, y0) - (x1, y1)
102	*/
103	
104	Sint16 x0, y0, x1, y1;
105	
106} BlitPool_BoundingBox;
107
108
109
110
111
112/*
113//	Create/Delete a BlitPool object.
114*/
115extern BlitPool *BlitPool_CreatePool(Optional SDL_Surface *destsurf);
116
117extern void BlitPool_DeletePool(BlitPool *pool);
118
119extern void BlitPool_SetAllocator(BlitPool *pool, allocator_func allocator, releaser_func releaser);
120
121
122
123
124/*
125//	Release all of entries.
126*/
127extern void BlitPool_ReleaseEntry(BlitPool *pool);
128
129
130
131
132/*
133//	Blit/Fill operation post.
134*/
135extern int BlitPool_Post(
136	BlitPool *pool,
137	BlitEntryFlag flag,
138	SDL_Surface *src,
139	Optional SDL_Rect *srcrect,
140	Optional SDL_Rect *destrect,
141	Uint32 color
142);
143
144#define BlitPool_PostSurface(pool, src, srcrect, destrect, flag)	\
145	BlitPool_Post(pool, BLIT_TYPE_SURFACE | (flag), src, srcrect, destrect, 0)
146
147#define BlitPool_PostFill(pool, destrect, color, flag)	\
148	BlitPool_Post(pool, BLIT_TYPE_COLORFILL | (flag), NULL, NULL, destrect, color)
149
150
151
152
153/*
154//	Commit pool.
155//	src_pool don't release.
156//	offset use only (x, y).
157*/
158extern void BlitPool_PostPool(
159	BlitPool *dest_pool,
160	BlitPool *src_pool,
161	Optional SDL_Rect *offset
162);
163
164
165
166
167/*
168//	Post separated surface/fill by area_description_str.
169//
170//	area_description_str like: "pos=(45, 12):O:(0,0)-(12,12):(45,23)-(62, 24):pos=(0,0):col=(255,255,255,255):(12,98)-(1,65)"
171//	pos=(x,y) : destination position. default=(0,0).
172//	(x0,y0)-(x1,y1) : source surface rectangle.
173//	O/T : T=Transparens(default), O=Opaque.
174//	col=(r, g, b, a) : colorfill mode. it's format be surf->format.
175//
176//	* Don't forget delimiter ':'.
177*/
178extern int BlitPool_PostByDescription(
179	BlitPool *pool,
180	Optional SDL_Surface *surf,
181	unsigned char *area_description_str
182);
183
184
185
186
187/*
188//	Optimize the operations and execute blit.
189*/
190extern void BlitPool_Optimize(BlitPool *pool, BlitOptimizeFlag flag);
191
192extern void BlitPool_Execute(BlitPool *pool);
193
194
195
196
197/*
198//	For update.
199//	example: {
200//		int numrect;
201//		SDL_Rect rectbuf[10];
202//		
203//		while ((numrect = BlitPool_GetUpdateRects(pool, rectbuf, sizeof(rectbuf)/sizeof(rectbuf[0]))) > 0) {
204//			SDL_UpdateRects(screen, numrect, rectbuf);
205//		}
206//	}
207*/
208extern int BlitPool_GetRectCount(BlitPool *pool);
209
210extern void *BlitPool_GetUpdateRectsObj(BlitPool *pool);
211
212extern int BlitPool_GetUpdateRects(BlitPool *pool, SDL_Rect *rectbuf, int size, void **update_rects_obj);
213
214
215
216
217
218/*
219//	Get update area.
220*/
221extern Uint32 BlitPool_GetArea(BlitPool *pool);
222
223
224
225
226/*
227//	Utilities.
228*/
229
230extern int BlitPoolUtil_GetOverlapCode(
231	Uint8 *out_code,					/*	Must not NULL	*/
232	BlitPool_BoundingBox *f,
233	BlitPool_BoundingBox *b
234);
235
236extern void BlitPoolUtil_CalcOverlapArea(
237	BlitPool_BoundingBox *out_overlap_box,		/*	Must not NULL	*/
238	Uint8 code,
239	BlitPool_BoundingBox *f,
240	BlitPool_BoundingBox *b
241);
242
243extern void BlitPoolUtil_RectToBBox(SDL_Rect *src, BlitPool_BoundingBox *dest);
244
245extern void BlitPoolUtil_BBoxToRect(BlitPool_BoundingBox *src, SDL_Rect *dest);
246
247
248
249
250#ifdef __cplusplus
251}		/*	for extern "c" {	*/
252#endif
253
254
255#include "close_code.h"
256
257
258#endif	/*	INCLUDED_SDL_BLITPOOL_H	*/