Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5131 | clevermous | 1 | /* |
2 | SDL - Simple DirectMedia Layer |
||
3 | Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga |
||
4 | |||
5 | This library is free software; you can redistribute it and/or |
||
6 | modify it under the terms of the GNU Library General Public |
||
7 | License as published by the Free Software Foundation; either |
||
8 | version 2 of the License, or (at your option) any later version. |
||
9 | |||
10 | This library is distributed in the hope that it will be useful, |
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
13 | Library General Public License for more details. |
||
14 | |||
15 | You should have received a copy of the GNU Library General Public |
||
16 | License along with this library; if not, write to the Free |
||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
18 | |||
19 | Sam Lantinga |
||
20 | slouken@devolution.com |
||
21 | */ |
||
22 | |||
23 | |||
24 | /* This is the implementation of the YUV video surface support */ |
||
25 | |||
26 | #include |
||
27 | #include |
||
28 | |||
29 | #include "SDL_getenv.h" |
||
30 | #include "SDL_video.h" |
||
31 | #include "SDL_sysvideo.h" |
||
32 | #include "SDL_yuvfuncs.h" |
||
33 | #include "SDL_yuv_sw_c.h" |
||
34 | |||
35 | |||
36 | SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format, |
||
37 | SDL_Surface *display) |
||
38 | { |
||
39 | SDL_VideoDevice *video = current_video; |
||
40 | SDL_VideoDevice *this = current_video; |
||
41 | const char *yuv_hwaccel; |
||
42 | SDL_Overlay *overlay; |
||
43 | |||
44 | overlay = NULL; |
||
45 | |||
46 | /* Display directly on video surface, if possible */ |
||
47 | if ( getenv("SDL_VIDEO_YUV_DIRECT") ) { |
||
48 | if ( (display == SDL_PublicSurface) && |
||
49 | ((SDL_VideoSurface->format->BytesPerPixel == 2) || |
||
50 | (SDL_VideoSurface->format->BytesPerPixel == 4)) ) { |
||
51 | display = SDL_VideoSurface; |
||
52 | } |
||
53 | } |
||
54 | yuv_hwaccel = getenv("SDL_VIDEO_YUV_HWACCEL"); |
||
55 | if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) && |
||
56 | (!yuv_hwaccel || (atoi(yuv_hwaccel) > 0)) ) { |
||
57 | overlay = video->CreateYUVOverlay(this, w, h, format, display); |
||
58 | } |
||
59 | /* If hardware YUV overlay failed ... */ |
||
60 | if ( overlay == NULL ) { |
||
61 | overlay = SDL_CreateYUV_SW(this, w, h, format, display); |
||
62 | } |
||
63 | return overlay; |
||
64 | } |
||
65 | |||
66 | int SDL_LockYUVOverlay(SDL_Overlay *overlay) |
||
67 | { |
||
68 | return overlay->hwfuncs->Lock(current_video, overlay); |
||
69 | } |
||
70 | |||
71 | void SDL_UnlockYUVOverlay(SDL_Overlay *overlay) |
||
72 | { |
||
73 | overlay->hwfuncs->Unlock(current_video, overlay); |
||
74 | } |
||
75 | |||
76 | int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect) |
||
77 | { |
||
78 | return overlay->hwfuncs->Display(current_video, overlay, dstrect); |
||
79 | } |
||
80 | |||
81 | void SDL_FreeYUVOverlay(SDL_Overlay *overlay) |
||
82 | { |
||
83 | if ( overlay ) { |
||
84 | if ( overlay->hwfuncs ) { |
||
85 | overlay->hwfuncs->FreeHW(current_video, overlay); |
||
86 | } |
||
87 | free(overlay); |
||
88 | } |
||
89 | } |