Mercurial > sdl-ios-xcode
annotate src/video/SDL_yuv.c @ 1341:d02b552e5304
Configure dynamically generates SDL_config.h
I'm still wrestling with autoheader, but this should work for now...
Fixed lots of build problems with C library support disabled
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 07 Feb 2006 12:11:33 +0000 |
parents | 604d73db6802 |
children | c71e05b4dc2e |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 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 | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
81
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 /* This is the implementation of the YUV video surface support */ | |
24 | |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
25 #include "SDL_stdlib.h" |
1341
d02b552e5304
Configure dynamically generates SDL_config.h
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
26 #include "SDL_string.h" |
0 | 27 #include "SDL_video.h" |
660
73440ac574a2
You can't create a YUV overlay in OpenGL mode
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
28 #include "SDL_error.h" |
0 | 29 #include "SDL_sysvideo.h" |
30 #include "SDL_yuvfuncs.h" | |
31 #include "SDL_yuv_sw_c.h" | |
32 | |
33 | |
34 SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format, | |
35 SDL_Surface *display) | |
36 { | |
37 SDL_VideoDevice *video = current_video; | |
38 SDL_VideoDevice *this = current_video; | |
39 const char *yuv_hwaccel; | |
40 SDL_Overlay *overlay; | |
41 | |
760
cf9dd3aa6756
Oops, we only want to fail creation if the display surface is an OpenGL surface.
Sam Lantinga <slouken@libsdl.org>
parents:
660
diff
changeset
|
42 if ( (display->flags & SDL_OPENGL) == SDL_OPENGL ) { |
660
73440ac574a2
You can't create a YUV overlay in OpenGL mode
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
43 SDL_SetError("YUV overlays are not supported in OpenGL mode"); |
73440ac574a2
You can't create a YUV overlay in OpenGL mode
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
44 return NULL; |
73440ac574a2
You can't create a YUV overlay in OpenGL mode
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
45 } |
0 | 46 |
47 /* Display directly on video surface, if possible */ | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
48 if ( SDL_getenv("SDL_VIDEO_YUV_DIRECT") ) { |
81
1a2723474f12
Added the SDL_VIDEO_YUV_DIRECT hack for better performance when the
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
49 if ( (display == SDL_PublicSurface) && |
1a2723474f12
Added the SDL_VIDEO_YUV_DIRECT hack for better performance when the
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
50 ((SDL_VideoSurface->format->BytesPerPixel == 2) || |
1a2723474f12
Added the SDL_VIDEO_YUV_DIRECT hack for better performance when the
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
51 (SDL_VideoSurface->format->BytesPerPixel == 4)) ) { |
1a2723474f12
Added the SDL_VIDEO_YUV_DIRECT hack for better performance when the
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
52 display = SDL_VideoSurface; |
1a2723474f12
Added the SDL_VIDEO_YUV_DIRECT hack for better performance when the
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
53 } |
0 | 54 } |
660
73440ac574a2
You can't create a YUV overlay in OpenGL mode
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
55 overlay = NULL; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
56 yuv_hwaccel = SDL_getenv("SDL_VIDEO_YUV_HWACCEL"); |
0 | 57 if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) && |
1341
d02b552e5304
Configure dynamically generates SDL_config.h
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
58 (!yuv_hwaccel || (SDL_atoi(yuv_hwaccel) > 0)) ) { |
0 | 59 overlay = video->CreateYUVOverlay(this, w, h, format, display); |
60 } | |
61 /* If hardware YUV overlay failed ... */ | |
62 if ( overlay == NULL ) { | |
63 overlay = SDL_CreateYUV_SW(this, w, h, format, display); | |
64 } | |
65 return overlay; | |
66 } | |
67 | |
68 int SDL_LockYUVOverlay(SDL_Overlay *overlay) | |
69 { | |
70 return overlay->hwfuncs->Lock(current_video, overlay); | |
71 } | |
72 | |
73 void SDL_UnlockYUVOverlay(SDL_Overlay *overlay) | |
74 { | |
75 overlay->hwfuncs->Unlock(current_video, overlay); | |
76 } | |
77 | |
78 int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect) | |
79 { | |
80 return overlay->hwfuncs->Display(current_video, overlay, dstrect); | |
81 } | |
82 | |
83 void SDL_FreeYUVOverlay(SDL_Overlay *overlay) | |
84 { | |
85 if ( overlay ) { | |
86 if ( overlay->hwfuncs ) { | |
87 overlay->hwfuncs->FreeHW(current_video, overlay); | |
88 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
89 SDL_free(overlay); |
0 | 90 } |
91 } |