forked from rhaberkorn/ffmpeg-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ag_sdl_aux.c
47 lines (40 loc) · 930 Bytes
/
ag_sdl_aux.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <agar/core.h>
#include <agar/gui.h>
#include <agar/gui/cursors.h>
#include <agar/gui/sdl.h>
#include <SDL/SDL.h>
#include <SDL/SDL_ffmpeg.h>
AG_Surface *
AG_SDL_ShadowSurface(SDL_Surface *ss)
{
AG_PixelFormat *pf;
AG_Surface *ds;
if ((pf = AG_SDL_GetPixelFormat(ss)) == NULL) {
return (NULL);
}
if (pf->palette != NULL) {
AG_SetError("Indexed formats not supported");
AG_PixelFormatFree(pf);
return (NULL);
}
if ((ds = AG_SurfaceNew(AG_SURFACE_PACKED, 0, 0, pf, 0))
== NULL) {
goto out;
}
if (ss->flags & SDL_SRCCOLORKEY) { ds->flags |= AG_SRCCOLORKEY; }
if (ss->flags & SDL_SRCALPHA) { ds->flags |= AG_SRCALPHA; }
ds->pixels = ss->pixels;
ds->w = ss->w;
ds->h = ss->h;
ds->pitch = ds->w * pf->BytesPerPixel;
ds->clipRect = AG_RECT(0,0,ds->w,ds->h);
out:
AG_PixelFormatFree(pf);
return (ds);
}
void
AG_SDL_ShadowSurfaceFree(AG_Surface *s)
{
s->pixels = NULL;
AG_SurfaceFree(s);
}