summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/src/video/directfb
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2018-02-07 20:04:46 -0500
committerFranklin Wei <git@fwei.tk>2018-03-12 20:52:01 -0400
commit6039eb05ba6d82ef56f2868c96654c552d117bf9 (patch)
tree9db7016bcbf66cfdf7b9bc998d84c6eaff9c8378 /apps/plugins/sdl/src/video/directfb
parentef373c03b96b0be08babca581d9f10bccfd4931f (diff)
downloadrockbox-6039eb05ba6d82ef56f2868c96654c552d117bf9.tar.gz
rockbox-6039eb05ba6d82ef56f2868c96654c552d117bf9.zip
sdl: remove non-rockbox drivers
We never use any of these other drivers, so having them around just takes up space. Change-Id: Iced812162df1fef3fd55522b7e700acb6c3bcd41
Diffstat (limited to 'apps/plugins/sdl/src/video/directfb')
-rw-r--r--apps/plugins/sdl/src/video/directfb/SDL_DirectFB_events.c219
-rw-r--r--apps/plugins/sdl/src/video/directfb/SDL_DirectFB_events.h29
-rw-r--r--apps/plugins/sdl/src/video/directfb/SDL_DirectFB_keys.h135
-rw-r--r--apps/plugins/sdl/src/video/directfb/SDL_DirectFB_video.c1171
-rw-r--r--apps/plugins/sdl/src/video/directfb/SDL_DirectFB_video.h62
-rw-r--r--apps/plugins/sdl/src/video/directfb/SDL_DirectFB_yuv.c290
-rw-r--r--apps/plugins/sdl/src/video/directfb/SDL_DirectFB_yuv.h38
7 files changed, 0 insertions, 1944 deletions
diff --git a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_events.c b/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_events.c
deleted file mode 100644
index 246b75b176..0000000000
--- a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_events.c
+++ /dev/null
@@ -1,219 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21*/
22#include "SDL_config.h"
23
24/* Handle the event stream, converting DirectFB input events into SDL events */
25
26#include <sys/types.h>
27#include <sys/time.h>
28#include <unistd.h>
29#include <fcntl.h>
30#include <termios.h>
31
32#include <directfb.h>
33
34#include "SDL.h"
35#include "../SDL_sysvideo.h"
36#include "../../events/SDL_sysevents.h"
37#include "../../events/SDL_events_c.h"
38#include "SDL_DirectFB_video.h"
39#include "SDL_DirectFB_events.h"
40
41/* The translation tables from a DirectFB keycode to a SDL keysym */
42static SDLKey keymap[256];
43static SDL_keysym *DirectFB_TranslateKey (DFBInputEvent *ev, SDL_keysym *keysym);
44static int DirectFB_TranslateButton (DFBInputEvent *ev);
45
46static int posted = 0;
47
48
49void DirectFB_PumpEvents (_THIS)
50{
51 DFBInputEvent evt;
52
53 while (HIDDEN->eventbuffer->GetEvent (HIDDEN->eventbuffer,
54 DFB_EVENT (&evt)) == DFB_OK)
55 {
56 SDL_keysym keysym;
57
58 switch (evt.type)
59 {
60 case DIET_BUTTONPRESS:
61 posted += SDL_PrivateMouseButton(SDL_PRESSED,
62 DirectFB_TranslateButton (&evt), 0, 0);
63 break;
64 case DIET_BUTTONRELEASE:
65 posted += SDL_PrivateMouseButton(SDL_RELEASED,
66 DirectFB_TranslateButton (&evt), 0, 0);
67 break;
68 case DIET_KEYPRESS:
69 posted += SDL_PrivateKeyboard(SDL_PRESSED, DirectFB_TranslateKey(&evt, &keysym));
70 break;
71 case DIET_KEYRELEASE:
72 posted += SDL_PrivateKeyboard(SDL_RELEASED, DirectFB_TranslateKey(&evt, &keysym));
73 break;
74 case DIET_AXISMOTION:
75 if (evt.flags & DIEF_AXISREL)
76 {
77 if (evt.axis == DIAI_X)
78 posted += SDL_PrivateMouseMotion(0, 1, evt.axisrel, 0);
79 else if (evt.axis == DIAI_Y)
80 posted += SDL_PrivateMouseMotion(0, 1, 0, evt.axisrel);
81 }
82 else if (evt.flags & DIEF_AXISABS)
83 {
84 static int last_x, last_y;
85 if (evt.axis == DIAI_X)
86 last_x = evt.axisabs;
87 else if (evt.axis == DIAI_Y)
88 last_y = evt.axisabs;
89 posted += SDL_PrivateMouseMotion(0, 0, last_x, last_y);
90 }
91 break;
92 default:
93 ;
94 }
95 }
96}
97
98void DirectFB_InitOSKeymap (_THIS)
99{
100 int i;
101
102 /* Initialize the DirectFB key translation table */
103 for (i=0; i<SDL_arraysize(keymap); ++i)
104 keymap[i] = SDLK_UNKNOWN;
105
106 keymap[DIKI_A - DIKI_UNKNOWN] = SDLK_a;
107 keymap[DIKI_B - DIKI_UNKNOWN] = SDLK_b;
108 keymap[DIKI_C - DIKI_UNKNOWN] = SDLK_c;
109 keymap[DIKI_D - DIKI_UNKNOWN] = SDLK_d;
110 keymap[DIKI_E - DIKI_UNKNOWN] = SDLK_e;
111 keymap[DIKI_F - DIKI_UNKNOWN] = SDLK_f;
112 keymap[DIKI_G - DIKI_UNKNOWN] = SDLK_g;
113 keymap[DIKI_H - DIKI_UNKNOWN] = SDLK_h;
114 keymap[DIKI_I - DIKI_UNKNOWN] = SDLK_i;
115 keymap[DIKI_J - DIKI_UNKNOWN] = SDLK_j;
116 keymap[DIKI_K - DIKI_UNKNOWN] = SDLK_k;
117 keymap[DIKI_L - DIKI_UNKNOWN] = SDLK_l;
118 keymap[DIKI_M - DIKI_UNKNOWN] = SDLK_m;
119 keymap[DIKI_N - DIKI_UNKNOWN] = SDLK_n;
120 keymap[DIKI_O - DIKI_UNKNOWN] = SDLK_o;
121 keymap[DIKI_P - DIKI_UNKNOWN] = SDLK_p;
122 keymap[DIKI_Q - DIKI_UNKNOWN] = SDLK_q;
123 keymap[DIKI_R - DIKI_UNKNOWN] = SDLK_r;
124 keymap[DIKI_S - DIKI_UNKNOWN] = SDLK_s;
125 keymap[DIKI_T - DIKI_UNKNOWN] = SDLK_t;
126 keymap[DIKI_U - DIKI_UNKNOWN] = SDLK_u;
127 keymap[DIKI_V - DIKI_UNKNOWN] = SDLK_v;
128 keymap[DIKI_W - DIKI_UNKNOWN] = SDLK_w;
129 keymap[DIKI_X - DIKI_UNKNOWN] = SDLK_x;
130 keymap[DIKI_Y - DIKI_UNKNOWN] = SDLK_y;
131 keymap[DIKI_Z - DIKI_UNKNOWN] = SDLK_z;
132
133 keymap[DIKI_0 - DIKI_UNKNOWN] = SDLK_0;
134 keymap[DIKI_1 - DIKI_UNKNOWN] = SDLK_1;
135 keymap[DIKI_2 - DIKI_UNKNOWN] = SDLK_2;
136 keymap[DIKI_3 - DIKI_UNKNOWN] = SDLK_3;
137 keymap[DIKI_4 - DIKI_UNKNOWN] = SDLK_4;
138 keymap[DIKI_5 - DIKI_UNKNOWN] = SDLK_5;
139 keymap[DIKI_6 - DIKI_UNKNOWN] = SDLK_6;
140 keymap[DIKI_7 - DIKI_UNKNOWN] = SDLK_7;
141 keymap[DIKI_8 - DIKI_UNKNOWN] = SDLK_8;
142 keymap[DIKI_9 - DIKI_UNKNOWN] = SDLK_9;
143
144 keymap[DIKI_F1 - DIKI_UNKNOWN] = SDLK_F1;
145 keymap[DIKI_F2 - DIKI_UNKNOWN] = SDLK_F2;
146 keymap[DIKI_F3 - DIKI_UNKNOWN] = SDLK_F3;
147 keymap[DIKI_F4 - DIKI_UNKNOWN] = SDLK_F4;
148 keymap[DIKI_F5 - DIKI_UNKNOWN] = SDLK_F5;
149 keymap[DIKI_F6 - DIKI_UNKNOWN] = SDLK_F6;
150 keymap[DIKI_F7 - DIKI_UNKNOWN] = SDLK_F7;
151 keymap[DIKI_F8 - DIKI_UNKNOWN] = SDLK_F8;
152 keymap[DIKI_F9 - DIKI_UNKNOWN] = SDLK_F9;
153 keymap[DIKI_F10 - DIKI_UNKNOWN] = SDLK_F10;
154 keymap[DIKI_F11 - DIKI_UNKNOWN] = SDLK_F11;
155 keymap[DIKI_F12 - DIKI_UNKNOWN] = SDLK_F12;
156
157 keymap[DIKI_ESCAPE - DIKI_UNKNOWN] = SDLK_ESCAPE;
158 keymap[DIKI_LEFT - DIKI_UNKNOWN] = SDLK_LEFT;
159 keymap[DIKI_RIGHT - DIKI_UNKNOWN] = SDLK_RIGHT;
160 keymap[DIKI_UP - DIKI_UNKNOWN] = SDLK_UP;
161 keymap[DIKI_DOWN - DIKI_UNKNOWN] = SDLK_DOWN;
162 keymap[DIKI_CONTROL_L - DIKI_UNKNOWN] = SDLK_LCTRL;
163 keymap[DIKI_CONTROL_R - DIKI_UNKNOWN] = SDLK_RCTRL;
164 keymap[DIKI_SHIFT_L - DIKI_UNKNOWN] = SDLK_LSHIFT;
165 keymap[DIKI_SHIFT_R - DIKI_UNKNOWN] = SDLK_RSHIFT;
166 keymap[DIKI_ALT_L - DIKI_UNKNOWN] = SDLK_LALT;
167 keymap[DIKI_ALT_R - DIKI_UNKNOWN] = SDLK_RALT;
168 keymap[DIKI_TAB - DIKI_UNKNOWN] = SDLK_TAB;
169 keymap[DIKI_ENTER - DIKI_UNKNOWN] = SDLK_RETURN;
170 keymap[DIKI_SPACE - DIKI_UNKNOWN] = SDLK_SPACE;
171 keymap[DIKI_BACKSPACE - DIKI_UNKNOWN] = SDLK_BACKSPACE;
172 keymap[DIKI_INSERT - DIKI_UNKNOWN] = SDLK_INSERT;
173 keymap[DIKI_DELETE - DIKI_UNKNOWN] = SDLK_DELETE;
174 keymap[DIKI_HOME - DIKI_UNKNOWN] = SDLK_HOME;
175 keymap[DIKI_END - DIKI_UNKNOWN] = SDLK_END;
176 keymap[DIKI_PAGE_UP - DIKI_UNKNOWN] = SDLK_PAGEUP;
177 keymap[DIKI_PAGE_DOWN - DIKI_UNKNOWN] = SDLK_PAGEDOWN;
178 keymap[DIKI_CAPS_LOCK - DIKI_UNKNOWN] = SDLK_CAPSLOCK;
179 keymap[DIKI_NUM_LOCK - DIKI_UNKNOWN] = SDLK_NUMLOCK;
180 keymap[DIKI_SCROLL_LOCK - DIKI_UNKNOWN] = SDLK_SCROLLOCK;
181 keymap[DIKI_PRINT - DIKI_UNKNOWN] = SDLK_PRINT;
182 keymap[DIKI_PAUSE - DIKI_UNKNOWN] = SDLK_PAUSE;
183 keymap[DIKI_KP_DIV - DIKI_UNKNOWN] = SDLK_KP_DIVIDE;
184 keymap[DIKI_KP_MULT - DIKI_UNKNOWN] = SDLK_KP_MULTIPLY;
185 keymap[DIKI_KP_MINUS - DIKI_UNKNOWN] = SDLK_KP_MINUS;
186 keymap[DIKI_KP_PLUS - DIKI_UNKNOWN] = SDLK_KP_PLUS;
187 keymap[DIKI_KP_ENTER - DIKI_UNKNOWN] = SDLK_KP_ENTER;
188}
189
190
191static SDL_keysym *DirectFB_TranslateKey (DFBInputEvent *ev, SDL_keysym *keysym)
192{
193 /* Set the keysym information */
194 keysym->scancode = ev->key_id;
195 keysym->mod = KMOD_NONE; /* FIXME */
196 keysym->unicode = (DFB_KEY_TYPE (ev->key_symbol) == DIKT_UNICODE) ? ev->key_symbol : 0;
197
198 if (ev->key_symbol > 0 && ev->key_symbol < 128)
199 keysym->sym = ev->key_symbol;
200 else
201 keysym->sym = keymap[ev->key_id - DIKI_UNKNOWN];
202
203 return keysym;
204}
205
206static int DirectFB_TranslateButton (DFBInputEvent *ev)
207{
208 switch (ev->button)
209 {
210 case DIBI_LEFT:
211 return 1;
212 case DIBI_MIDDLE:
213 return 2;
214 case DIBI_RIGHT:
215 return 3;
216 default:
217 return 0;
218 }
219}
diff --git a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_events.h b/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_events.h
deleted file mode 100644
index 20f3967271..0000000000
--- a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_events.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21*/
22#include "SDL_config.h"
23
24#include "SDL_DirectFB_video.h"
25
26/* Functions to be exported */
27extern void DirectFB_InitOSKeymap(_THIS);
28extern void DirectFB_PumpEvents(_THIS);
29
diff --git a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_keys.h b/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_keys.h
deleted file mode 100644
index 2868ee6ffa..0000000000
--- a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_keys.h
+++ /dev/null
@@ -1,135 +0,0 @@
1
2#define SCANCODE_ESCAPE 1
3
4#define SCANCODE_1 2
5#define SCANCODE_2 3
6#define SCANCODE_3 4
7#define SCANCODE_4 5
8#define SCANCODE_5 6
9#define SCANCODE_6 7
10#define SCANCODE_7 8
11#define SCANCODE_8 9
12#define SCANCODE_9 10
13#define SCANCODE_0 11
14
15#define SCANCODE_MINUS 12
16#define SCANCODE_EQUAL 13
17
18#define SCANCODE_BACKSPACE 14
19#define SCANCODE_TAB 15
20
21#define SCANCODE_Q 16
22#define SCANCODE_W 17
23#define SCANCODE_E 18
24#define SCANCODE_R 19
25#define SCANCODE_T 20
26#define SCANCODE_Y 21
27#define SCANCODE_U 22
28#define SCANCODE_I 23
29#define SCANCODE_O 24
30#define SCANCODE_P 25
31#define SCANCODE_BRACKET_LEFT 26
32#define SCANCODE_BRACKET_RIGHT 27
33
34#define SCANCODE_ENTER 28
35
36#define SCANCODE_LEFTCONTROL 29
37
38#define SCANCODE_A 30
39#define SCANCODE_S 31
40#define SCANCODE_D 32
41#define SCANCODE_F 33
42#define SCANCODE_G 34
43#define SCANCODE_H 35
44#define SCANCODE_J 36
45#define SCANCODE_K 37
46#define SCANCODE_L 38
47#define SCANCODE_SEMICOLON 39
48#define SCANCODE_APOSTROPHE 40
49#define SCANCODE_GRAVE 41
50
51#define SCANCODE_LEFTSHIFT 42
52#define SCANCODE_BACKSLASH 43
53
54#define SCANCODE_Z 44
55#define SCANCODE_X 45
56#define SCANCODE_C 46
57#define SCANCODE_V 47
58#define SCANCODE_B 48
59#define SCANCODE_N 49
60#define SCANCODE_M 50
61#define SCANCODE_COMMA 51
62#define SCANCODE_PERIOD 52
63#define SCANCODE_SLASH 53
64
65#define SCANCODE_RIGHTSHIFT 54
66#define SCANCODE_KEYPADMULTIPLY 55
67
68#define SCANCODE_LEFTALT 56
69#define SCANCODE_SPACE 57
70#define SCANCODE_CAPSLOCK 58
71
72#define SCANCODE_F1 59
73#define SCANCODE_F2 60
74#define SCANCODE_F3 61
75#define SCANCODE_F4 62
76#define SCANCODE_F5 63
77#define SCANCODE_F6 64
78#define SCANCODE_F7 65
79#define SCANCODE_F8 66
80#define SCANCODE_F9 67
81#define SCANCODE_F10 68
82
83#define SCANCODE_NUMLOCK 69
84#define SCANCODE_SCROLLLOCK 70
85
86#define SCANCODE_KEYPAD7 71
87#define SCANCODE_CURSORUPLEFT 71
88#define SCANCODE_KEYPAD8 72
89#define SCANCODE_CURSORUP 72
90#define SCANCODE_KEYPAD9 73
91#define SCANCODE_CURSORUPRIGHT 73
92#define SCANCODE_KEYPADMINUS 74
93#define SCANCODE_KEYPAD4 75
94#define SCANCODE_CURSORLEFT 75
95#define SCANCODE_KEYPAD5 76
96#define SCANCODE_KEYPAD6 77
97#define SCANCODE_CURSORRIGHT 77
98#define SCANCODE_KEYPADPLUS 78
99#define SCANCODE_KEYPAD1 79
100#define SCANCODE_CURSORDOWNLEFT 79
101#define SCANCODE_KEYPAD2 80
102#define SCANCODE_CURSORDOWN 80
103#define SCANCODE_KEYPAD3 81
104#define SCANCODE_CURSORDOWNRIGHT 81
105#define SCANCODE_KEYPAD0 82
106#define SCANCODE_KEYPADPERIOD 83
107
108#define SCANCODE_LESS 86
109
110#define SCANCODE_F11 87
111#define SCANCODE_F12 88
112
113#define SCANCODE_KEYPADENTER 96
114#define SCANCODE_RIGHTCONTROL 97
115#define SCANCODE_CONTROL 97
116#define SCANCODE_KEYPADDIVIDE 98
117#define SCANCODE_PRINTSCREEN 99
118#define SCANCODE_RIGHTALT 100
119#define SCANCODE_BREAK 101 /* Beware: is 119 */
120#define SCANCODE_BREAK_ALTERNATIVE 119 /* on some keyboards! */
121
122#define SCANCODE_HOME 102
123#define SCANCODE_CURSORBLOCKUP 90 /* Cursor key block */
124#define SCANCODE_PAGEUP 104
125#define SCANCODE_CURSORBLOCKLEFT 92 /* Cursor key block */
126#define SCANCODE_CURSORBLOCKRIGHT 94 /* Cursor key block */
127#define SCANCODE_END 107
128#define SCANCODE_CURSORBLOCKDOWN 108 /* Cursor key block */
129#define SCANCODE_PAGEDOWN 109
130#define SCANCODE_INSERT 110
131#define SCANCODE_REMOVE 111
132
133#define SCANCODE_RIGHTWIN 126
134#define SCANCODE_LEFTWIN 125
135
diff --git a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_video.c b/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_video.c
deleted file mode 100644
index f665ec6825..0000000000
--- a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_video.c
+++ /dev/null
@@ -1,1171 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21
22 MGA CRTC2 support by Thomas Jarosch - tomj@simonv.com
23 CRTC2 support is inspired by mplayer's dfbmga driver
24 written by Ville Syrj��<syrjala@sci.fi>
25*/
26#include "SDL_config.h"
27
28/* DirectFB video driver implementation.
29*/
30
31#include <fcntl.h>
32#include <unistd.h>
33#include <sys/mman.h>
34
35#include <directfb.h>
36#include <directfb_version.h>
37
38#include "SDL_video.h"
39#include "SDL_mouse.h"
40#include "../SDL_sysvideo.h"
41#include "../SDL_pixels_c.h"
42#include "../../events/SDL_events_c.h"
43#include "SDL_DirectFB_video.h"
44#include "SDL_DirectFB_events.h"
45#include "SDL_DirectFB_yuv.h"
46
47/* The implementation dependent data for the window manager cursor */
48struct WMcursor {
49 int unused;
50};
51
52
53/* Initialization/Query functions */
54static int DirectFB_VideoInit(_THIS, SDL_PixelFormat *vformat);
55static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
56static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
57static int DirectFB_SetColors(_THIS, int firstcolor, int ncolors,
58 SDL_Color *colors);
59static void DirectFB_VideoQuit(_THIS);
60
61/* Hardware surface functions */
62static int DirectFB_AllocHWSurface(_THIS, SDL_Surface *surface);
63static int DirectFB_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
64static int DirectFB_LockHWSurface(_THIS, SDL_Surface *surface);
65static void DirectFB_UnlockHWSurface(_THIS, SDL_Surface *surface);
66static void DirectFB_FreeHWSurface(_THIS, SDL_Surface *surface);
67static int DirectFB_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst);
68static int DirectFB_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
69 SDL_Surface *dst, SDL_Rect *dstrect);
70static int DirectFB_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key);
71static int DirectFB_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha);
72static int DirectFB_FlipHWSurface(_THIS, SDL_Surface *surface);
73static int DirectFB_ShowWMCursor(_THIS, WMcursor *cursor);
74
75/* Various screen update functions available */
76static void DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
77static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect *rects);
78
79/* This is the rect EnumModes2 uses */
80struct DirectFBEnumRect {
81 SDL_Rect r;
82 struct DirectFBEnumRect* next;
83};
84
85static struct DirectFBEnumRect *enumlist = NULL;
86
87
88/* DirectFB driver bootstrap functions */
89
90static int DirectFB_Available(void)
91{
92 return 1;
93}
94
95static void DirectFB_DeleteDevice(SDL_VideoDevice *device)
96{
97 SDL_free(device->hidden);
98 SDL_free(device);
99}
100
101static SDL_VideoDevice *DirectFB_CreateDevice(int devindex)
102{
103 SDL_VideoDevice *device;
104
105 /* Initialize all variables that we clean on shutdown */
106 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
107 if (device)
108 {
109 SDL_memset (device, 0, (sizeof *device));
110 device->hidden = (struct SDL_PrivateVideoData *) malloc (sizeof (*device->hidden));
111 }
112 if (device == NULL || device->hidden == NULL)
113 {
114 SDL_OutOfMemory();
115 if (device)
116 {
117 free (device);
118 }
119 return(0);
120 }
121 SDL_memset (device->hidden, 0, sizeof (*device->hidden));
122
123 /* Set the function pointers */
124 device->VideoInit = DirectFB_VideoInit;
125 device->ListModes = DirectFB_ListModes;
126 device->SetVideoMode = DirectFB_SetVideoMode;
127 device->SetColors = DirectFB_SetColors;
128 device->UpdateRects = NULL;
129 device->CreateYUVOverlay = DirectFB_CreateYUVOverlay;
130 device->VideoQuit = DirectFB_VideoQuit;
131 device->AllocHWSurface = DirectFB_AllocHWSurface;
132 device->CheckHWBlit = DirectFB_CheckHWBlit;
133 device->FillHWRect = DirectFB_FillHWRect;
134 device->SetHWColorKey = DirectFB_SetHWColorKey;
135 device->SetHWAlpha = DirectFB_SetHWAlpha;
136 device->LockHWSurface = DirectFB_LockHWSurface;
137 device->UnlockHWSurface = DirectFB_UnlockHWSurface;
138 device->FlipHWSurface = DirectFB_FlipHWSurface;
139 device->FreeHWSurface = DirectFB_FreeHWSurface;
140 device->ShowWMCursor = DirectFB_ShowWMCursor;
141 device->SetCaption = NULL;
142 device->SetIcon = NULL;
143 device->IconifyWindow = NULL;
144 device->GrabInput = NULL;
145 device->GetWMInfo = NULL;
146 device->InitOSKeymap = DirectFB_InitOSKeymap;
147 device->PumpEvents = DirectFB_PumpEvents;
148
149 device->free = DirectFB_DeleteDevice;
150
151 return device;
152}
153
154VideoBootStrap DirectFB_bootstrap = {
155 "directfb", "DirectFB",
156 DirectFB_Available, DirectFB_CreateDevice
157};
158
159static DFBSurfacePixelFormat GetFormatForBpp (int bpp, IDirectFBDisplayLayer *layer)
160{
161 DFBDisplayLayerConfig dlc;
162 int bytes = (bpp + 7) / 8;
163
164 layer->GetConfiguration (layer, &dlc);
165
166 if (bytes == DFB_BYTES_PER_PIXEL(dlc.pixelformat) && bytes > 1)
167 return dlc.pixelformat;
168
169 switch (bytes)
170 {
171 case 1:
172 return DSPF_LUT8;
173 case 2:
174 return DSPF_RGB16;
175 case 3:
176 return DSPF_RGB24;
177 case 4:
178 return DSPF_RGB32;
179 }
180
181 return DSPF_UNKNOWN;
182}
183
184static DFBEnumerationResult EnumModesCallback (int width,
185 int height,
186 int bpp,
187 void *data)
188{
189 SDL_VideoDevice *this = (SDL_VideoDevice *)data;
190 struct DirectFBEnumRect *enumrect;
191
192 HIDDEN->nummodes++;
193
194 if (enumlist && enumlist->r.w == width && enumlist->r.h == height)
195 return DFENUM_OK;
196
197 enumrect = SDL_calloc(1, sizeof(struct DirectFBEnumRect));
198 if (!enumrect)
199 {
200 SDL_OutOfMemory();
201 return DFENUM_CANCEL;
202 }
203
204 enumrect->r.w = (Uint16)width;
205 enumrect->r.h = (Uint16)height;
206 enumrect->next = enumlist;
207
208 enumlist = enumrect;
209
210 return DFENUM_OK;
211}
212
213struct private_hwdata {
214 IDirectFBSurface *surface;
215 IDirectFBPalette *palette;
216};
217
218void SetDirectFBerror (const char *function, DFBResult code)
219{
220 const char *error = DirectFBErrorString (code);
221
222 if (error)
223 SDL_SetError("%s: %s", function, error);
224 else
225 SDL_SetError("Unknown error code from %s", function);
226}
227
228static DFBSurfacePixelFormat SDLToDFBPixelFormat (SDL_PixelFormat *format)
229{
230 if (format->Rmask && format->Gmask && format->Bmask)
231 {
232 switch (format->BitsPerPixel)
233 {
234 case 8:
235 return DSPF_LUT8;
236
237 case 16:
238 if (format->Rmask == 0xF800 &&
239 format->Gmask == 0x07E0 &&
240 format->Bmask == 0x001F)
241 return DSPF_RGB16;
242 /* fall through */
243
244 case 15:
245 if (format->Rmask == 0x7C00 &&
246 format->Gmask == 0x03E0 &&
247 format->Bmask == 0x001F)
248 return DSPF_ARGB1555;
249 break;
250
251 case 24:
252 if (format->Rmask == 0xFF0000 &&
253 format->Gmask == 0x00FF00 &&
254 format->Bmask == 0x0000FF)
255 return DSPF_RGB24;
256 break;
257
258 case 32:
259 if (format->Rmask == 0xFF0000 &&
260 format->Gmask == 0x00FF00 &&
261 format->Bmask == 0x0000FF)
262 {
263 if (format->Amask == 0xFF000000)
264 return DSPF_ARGB;
265 else
266 return DSPF_RGB32;
267 }
268 break;
269 }
270 }
271 else
272 {
273 switch (format->BitsPerPixel)
274 {
275 case 8:
276 return DSPF_LUT8;
277 case 15:
278 return DSPF_ARGB1555;
279 case 16:
280 return DSPF_RGB16;
281 case 24:
282 return DSPF_RGB24;
283 case 32:
284 return DSPF_RGB32;
285 }
286 }
287
288 return DSPF_UNKNOWN;
289}
290
291static SDL_Palette *AllocatePalette(int size)
292{
293 SDL_Palette *palette;
294 SDL_Color *colors;
295
296 palette = SDL_calloc (1, sizeof(SDL_Palette));
297 if (!palette)
298 {
299 SDL_OutOfMemory();
300 return NULL;
301 }
302
303 colors = SDL_calloc (size, sizeof(SDL_Color));
304 if (!colors)
305 {
306 SDL_OutOfMemory();
307 return NULL;
308 }
309
310 palette->ncolors = size;
311 palette->colors = colors;
312
313 return palette;
314}
315
316static int DFBToSDLPixelFormat (DFBSurfacePixelFormat pixelformat, SDL_PixelFormat *format)
317{
318 format->Amask = format->Rmask = format->Gmask = format->Bmask = 0;
319 format->BitsPerPixel = format->BytesPerPixel = 0;
320
321 switch (pixelformat)
322 {
323 case DSPF_A8:
324 format->Amask = 0x000000FF;
325 break;
326
327 case DSPF_ARGB1555:
328 format->Rmask = 0x00007C00;
329 format->Gmask = 0x000003E0;
330 format->Bmask = 0x0000001F;
331 break;
332
333 case DSPF_RGB16:
334 format->Rmask = 0x0000F800;
335 format->Gmask = 0x000007E0;
336 format->Bmask = 0x0000001F;
337 break;
338
339 case DSPF_ARGB:
340 format->Amask = 0; /* apps don't seem to like that: 0xFF000000; */
341 /* fall through */
342 case DSPF_RGB24:
343 case DSPF_RGB32:
344 format->Rmask = 0x00FF0000;
345 format->Gmask = 0x0000FF00;
346 format->Bmask = 0x000000FF;
347 break;
348
349 case DSPF_LUT8:
350 format->Rmask = 0x000000FF;
351 format->Gmask = 0x000000FF;
352 format->Bmask = 0x000000FF;
353
354 if (!format->palette)
355 format->palette = AllocatePalette(256);
356 break;
357
358 default:
359 fprintf (stderr, "SDL_DirectFB: Unsupported pixelformat (0x%08x)!\n", pixelformat);
360 return -1;
361 }
362
363 format->BitsPerPixel = DFB_BYTES_PER_PIXEL(pixelformat) * 8;
364 format->BytesPerPixel = DFB_BYTES_PER_PIXEL(pixelformat);
365
366 return 0;
367}
368
369
370int DirectFB_VideoInit(_THIS, SDL_PixelFormat *vformat)
371{
372 int i;
373 DFBResult ret;
374#if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)
375 DFBCardCapabilities caps;
376#else
377 DFBGraphicsDeviceDescription caps;
378#endif
379 DFBDisplayLayerConfig dlc;
380 struct DirectFBEnumRect *rect;
381 IDirectFB *dfb = NULL;
382 IDirectFBDisplayLayer *layer = NULL;
383 IDirectFBEventBuffer *events = NULL;
384
385 HIDDEN->c2layer = NULL, HIDDEN->c2frame = NULL;
386 HIDDEN->enable_mga_crtc2 = 0;
387 HIDDEN->mga_crtc2_stretch_overscan = 1;
388
389 ret = DirectFBInit (NULL, NULL);
390 if (ret)
391 {
392 SetDirectFBerror ("DirectFBInit", ret);
393 goto error;
394 }
395
396 ret = DirectFBCreate (&dfb);
397 if (ret)
398 {
399 SetDirectFBerror ("DirectFBCreate", ret);
400 goto error;
401 }
402
403 ret = dfb->GetDisplayLayer (dfb, DLID_PRIMARY, &layer);
404 if (ret)
405 {
406 SetDirectFBerror ("dfb->GetDisplayLayer", ret);
407 goto error;
408 }
409
410 ret = dfb->CreateInputEventBuffer (dfb, DICAPS_ALL, DFB_FALSE, &events);
411 if (ret)
412 {
413 SetDirectFBerror ("dfb->CreateEventBuffer", ret);
414 goto error;
415 }
416
417 layer->EnableCursor (layer, 1);
418
419 /* Query layer configuration to determine the current mode and pixelformat */
420 layer->GetConfiguration (layer, &dlc);
421
422 /* If current format is not supported use LUT8 as the default */
423 if (DFBToSDLPixelFormat (dlc.pixelformat, vformat))
424 DFBToSDLPixelFormat (DSPF_LUT8, vformat);
425
426 /* Enumerate the available fullscreen modes */
427 ret = dfb->EnumVideoModes (dfb, EnumModesCallback, this);
428 if (ret)
429 {
430 SetDirectFBerror ("dfb->EnumVideoModes", ret);
431 goto error;
432 }
433
434 HIDDEN->modelist = SDL_calloc (HIDDEN->nummodes + 1, sizeof(SDL_Rect *));
435 if (!HIDDEN->modelist)
436 {
437 SDL_OutOfMemory();
438 goto error;
439 }
440
441 for (i = 0, rect = enumlist; rect; ++i, rect = rect->next )
442 {
443 HIDDEN->modelist[i] = &rect->r;
444 }
445
446 HIDDEN->modelist[i] = NULL;
447
448
449 /* Query card capabilities to get the video memory size */
450#if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)
451 dfb->GetCardCapabilities (dfb, &caps);
452#else
453 dfb->GetDeviceDescription (dfb, &caps);
454#endif
455
456 this->info.wm_available = 1;
457 this->info.hw_available = 1;
458 this->info.blit_hw = 1;
459 this->info.blit_hw_CC = 1;
460 this->info.blit_hw_A = 1;
461 this->info.blit_fill = 1;
462 this->info.video_mem = caps.video_memory / 1024;
463 this->info.current_w = dlc.width;
464 this->info.current_h = dlc.height;
465
466 HIDDEN->initialized = 1;
467 HIDDEN->dfb = dfb;
468 HIDDEN->layer = layer;
469 HIDDEN->eventbuffer = events;
470
471 if (SDL_getenv("SDL_DIRECTFB_MGA_CRTC2") != NULL)
472 HIDDEN->enable_mga_crtc2 = 1;
473
474 if (HIDDEN->enable_mga_crtc2)
475 {
476 DFBDisplayLayerConfig dlc;
477 DFBDisplayLayerConfigFlags failed;
478
479 ret = dfb->GetDisplayLayer (dfb, 2, &HIDDEN->c2layer);
480 if (ret)
481 {
482 SetDirectFBerror ("dfb->GetDisplayLayer(CRTC2)", ret);
483 goto error;
484 }
485
486 ret = HIDDEN->layer->SetCooperativeLevel(HIDDEN->layer, DLSCL_EXCLUSIVE);
487 if (ret)
488 {
489 SetDirectFBerror ("layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret);
490 goto error;
491 }
492
493 ret = HIDDEN->c2layer->SetCooperativeLevel(HIDDEN->c2layer, DLSCL_EXCLUSIVE);
494 if (ret)
495 {
496 SetDirectFBerror ("c2layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret);
497 goto error;
498 }
499
500 HIDDEN->c2layer->SetOpacity(HIDDEN->c2layer, 0x0);
501
502 /* Init the surface here as it got a fixed size */
503 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE;
504 dlc.buffermode = DLBM_BACKVIDEO;
505 dlc.pixelformat = DSPF_RGB32;
506
507 ret = HIDDEN->c2layer->TestConfiguration( HIDDEN->c2layer, &dlc, &failed );
508 if (ret)
509 {
510 SetDirectFBerror ("c2layer->TestConfiguration", ret);
511 goto error;
512 }
513
514 ret = HIDDEN->c2layer->SetConfiguration( HIDDEN->c2layer, &dlc );
515 if (ret)
516 {
517 SetDirectFBerror ("c2layer->SetConfiguration", ret);
518 goto error;
519 }
520
521 ret = HIDDEN->c2layer->GetSurface( HIDDEN->c2layer, &HIDDEN->c2frame );
522 if (ret)
523 {
524 SetDirectFBerror ("c2layer->GetSurface", ret);
525 goto error;
526 }
527
528 HIDDEN->c2framesize.x = 0;
529 HIDDEN->c2framesize.y = 0;
530 HIDDEN->c2frame->GetSize( HIDDEN->c2frame, &HIDDEN->c2framesize.w, &HIDDEN->c2framesize.h);
531
532 HIDDEN->c2frame->SetBlittingFlags( HIDDEN->c2frame, DSBLIT_NOFX );
533 HIDDEN->c2frame->SetColor( HIDDEN->c2frame, 0, 0, 0, 0xff );
534
535 /* Clear CRTC2 */
536 HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff );
537 HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, 0 );
538 HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff );
539 HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, 0 );
540 HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff );
541
542 HIDDEN->c2layer->SetOpacity(HIDDEN->c2layer, 0xFF );
543
544 /* Check if overscan is possibly set */
545 if (SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN") != NULL)
546 {
547 float overscan = 0;
548 if (SDL_sscanf(SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN"), "%f", &overscan) == 1)
549 if (overscan > 0 && overscan < 2)
550 HIDDEN->mga_crtc2_stretch_overscan = overscan;
551 }
552
553 #ifdef DIRECTFB_CRTC2_DEBUG
554 printf("CRTC2 overscan: %f\n", HIDDEN->mga_crtc2_stretch_overscan);
555 #endif
556 }
557
558 return 0;
559
560 error:
561 if (events)
562 events->Release (events);
563
564 if (HIDDEN->c2frame)
565 HIDDEN->c2frame->Release (HIDDEN->c2frame);
566
567 if (HIDDEN->c2layer)
568 HIDDEN->c2layer->Release (HIDDEN->c2layer);
569
570 if (layer)
571 layer->Release (layer);
572
573 if (dfb)
574 dfb->Release (dfb);
575
576 return -1;
577}
578
579static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
580{
581 if (flags & SDL_FULLSCREEN)
582 return HIDDEN->modelist;
583 else
584 if (SDLToDFBPixelFormat (format) != DSPF_UNKNOWN)
585 return (SDL_Rect**) -1;
586
587 return NULL;
588}
589
590static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
591{
592 DFBResult ret;
593 DFBSurfaceDescription dsc;
594 DFBSurfacePixelFormat pixelformat;
595 IDirectFBSurface *surface;
596
597 fprintf (stderr, "SDL DirectFB_SetVideoMode: %dx%d@%d, flags: 0x%08x\n",
598 width, height, bpp, flags);
599
600 flags |= SDL_FULLSCREEN;
601
602 /* Release previous primary surface */
603 if (current->hwdata && current->hwdata->surface)
604 {
605 current->hwdata->surface->Release (current->hwdata->surface);
606 current->hwdata->surface = NULL;
607
608 /* And its palette if present */
609 if (current->hwdata->palette)
610 {
611 current->hwdata->palette->Release (current->hwdata->palette);
612 current->hwdata->palette = NULL;
613 }
614 }
615 else if (!current->hwdata)
616 {
617 /* Allocate the hardware acceleration data */
618 current->hwdata = (struct private_hwdata *) SDL_calloc (1, sizeof(*current->hwdata));
619 if (!current->hwdata)
620 {
621 SDL_OutOfMemory();
622 return NULL;
623 }
624 }
625
626 /* Set cooperative level depending on flag SDL_FULLSCREEN */
627 if (flags & SDL_FULLSCREEN)
628 {
629 ret = HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_FULLSCREEN);
630 if (ret && !HIDDEN->enable_mga_crtc2)
631 {
632 DirectFBError ("dfb->SetCooperativeLevel", ret);
633 flags &= ~SDL_FULLSCREEN;
634 }
635 }
636 else
637 HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_NORMAL);
638
639 /* Set video mode */
640 ret = HIDDEN->dfb->SetVideoMode (HIDDEN->dfb, width, height, bpp);
641 if (ret)
642 {
643 if (flags & SDL_FULLSCREEN)
644 {
645 flags &= ~SDL_FULLSCREEN;
646 HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_NORMAL);
647 ret = HIDDEN->dfb->SetVideoMode (HIDDEN->dfb, width, height, bpp);
648 }
649
650 if (ret)
651 {
652 SetDirectFBerror ("dfb->SetVideoMode", ret);
653 return NULL;
654 }
655 }
656
657 /* Create primary surface */
658 dsc.flags = DSDESC_CAPS | DSDESC_PIXELFORMAT;
659 dsc.caps = DSCAPS_PRIMARY | ((flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0);
660 dsc.pixelformat = GetFormatForBpp (bpp, HIDDEN->layer);
661
662 ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface);
663 if (ret && (flags & SDL_DOUBLEBUF))
664 {
665 /* Try without double buffering */
666 dsc.caps &= ~DSCAPS_FLIPPING;
667 ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface);
668 }
669 if (ret)
670 {
671 SetDirectFBerror ("dfb->CreateSurface", ret);
672 return NULL;
673 }
674
675 current->w = width;
676 current->h = height;
677 current->flags = SDL_HWSURFACE | SDL_PREALLOC;
678
679 if (flags & SDL_FULLSCREEN)
680 {
681 current->flags |= SDL_FULLSCREEN;
682 this->UpdateRects = DirectFB_DirectUpdate;
683 }
684 else
685 this->UpdateRects = DirectFB_WindowedUpdate;
686
687 if (dsc.caps & DSCAPS_FLIPPING)
688 current->flags |= SDL_DOUBLEBUF;
689
690 surface->GetPixelFormat (surface, &pixelformat);
691
692 DFBToSDLPixelFormat (pixelformat, current->format);
693
694 /* Get the surface palette (if supported) */
695 if (DFB_PIXELFORMAT_IS_INDEXED( pixelformat ))
696 {
697 surface->GetPalette (surface, &current->hwdata->palette);
698
699 current->flags |= SDL_HWPALETTE;
700 }
701
702 current->hwdata->surface = surface;
703
704 /* MGA CRTC2 stuff */
705 if (HIDDEN->enable_mga_crtc2)
706 {
707 /* no stretching if c2ssize == c2framesize */
708 HIDDEN->c2ssize.x = 0, HIDDEN->c2ssize.y = 0;
709 HIDDEN->c2ssize.w = width;
710 HIDDEN->c2ssize.h = height;
711
712 HIDDEN->c2dsize.x = 0, HIDDEN->c2dsize.y = 0;
713 HIDDEN->c2dsize.w = width;
714 HIDDEN->c2dsize.h = height;
715
716 HIDDEN->mga_crtc2_stretch = 0;
717
718 if (SDL_getenv("SDL_DIRECTFB_MGA_STRETCH") != NULL)
719 {
720 /* Normally assume a picture aspect ratio of 4:3 */
721 int zoom_aspect_x = 4, zoom_aspect_y = 3, i, j;
722
723 for (i = 1; i < 20; i++)
724 {
725 for (j = 1; j < 10; j++)
726 {
727 if ((float)width/(float)i*(float)j == height)
728 {
729 zoom_aspect_x = i;
730 zoom_aspect_y = j;
731
732 /* break the loop */
733 i = 21;
734 break;
735 }
736 }
737 }
738
739 #ifdef DIRECTFB_CRTC2_DEBUG
740 printf("Source resolution: X: %d, Y: %d, Aspect ratio: %d:%d\n", width, height, zoom_aspect_x, zoom_aspect_y);
741 printf("CRTC2 resolution: X: %d, Y: %d\n", HIDDEN->c2framesize.w, HIDDEN->c2framesize.h);
742 #endif
743
744 /* don't stretch only slightly smaller/larger images */
745 if ((float)width < (float)HIDDEN->c2framesize.w*0.95 || (float)height < (float)HIDDEN->c2framesize.h*0.95)
746 {
747 while ((float)HIDDEN->c2dsize.w < (float)HIDDEN->c2framesize.w*HIDDEN->mga_crtc2_stretch_overscan && (float)HIDDEN->c2dsize.h < (float)HIDDEN->c2framesize.h*HIDDEN->mga_crtc2_stretch_overscan)
748 {
749 HIDDEN->c2dsize.w+=zoom_aspect_x;
750 HIDDEN->c2dsize.h+=zoom_aspect_y;
751 }
752
753 /* one step down */
754 HIDDEN->c2dsize.w-=zoom_aspect_x;
755 HIDDEN->c2dsize.h-=zoom_aspect_y;
756
757 #ifdef DIRECTFB_CRTC2_DEBUG
758 printf("Stretched resolution: X: %d, Y: %d\n", HIDDEN->c2dsize.w, HIDDEN->c2dsize.h);
759 #endif
760
761 HIDDEN->mga_crtc2_stretch = 1;
762 }
763 else if ((float)width > (float)HIDDEN->c2framesize.w*0.95 || (float)height > (float)HIDDEN->c2framesize.h*0.95)
764 {
765 while ((float)HIDDEN->c2dsize.w > (float)HIDDEN->c2framesize.w*HIDDEN->mga_crtc2_stretch_overscan || (float)HIDDEN->c2dsize.h > (float)HIDDEN->c2framesize.h*HIDDEN->mga_crtc2_stretch_overscan)
766 {
767 HIDDEN->c2dsize.w-=zoom_aspect_x;
768 HIDDEN->c2dsize.h-=zoom_aspect_y;
769 }
770
771 #ifdef DIRECTFB_CRTC2_DEBUG
772 printf("Down-Stretched resolution: X: %d, Y: %d\n", HIDDEN->c2dsize.w, HIDDEN->c2dsize.h);
773 #endif
774
775 HIDDEN->mga_crtc2_stretch = 1;
776 } else {
777 #ifdef DIRECTFB_CRTC2_DEBUG
778 printf("Not stretching image\n");
779 #endif
780 }
781
782 /* Panning */
783 if (HIDDEN->c2framesize.w > HIDDEN->c2dsize.w)
784 HIDDEN->c2dsize.x = (HIDDEN->c2framesize.w - HIDDEN->c2dsize.w) / 2;
785 else
786 HIDDEN->c2dsize.x = (HIDDEN->c2dsize.w - HIDDEN->c2framesize.w) / 2;
787
788 if (HIDDEN->c2framesize.h > HIDDEN->c2dsize.h)
789 HIDDEN->c2dsize.y = (HIDDEN->c2framesize.h - HIDDEN->c2dsize.h) / 2;
790 else
791 HIDDEN->c2dsize.y = (HIDDEN->c2dsize.h - HIDDEN->c2framesize.h) / 2;
792
793 #ifdef DIRECTFB_CRTC2_DEBUG
794 printf("CRTC2 position X: %d, Y: %d\n", HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
795 #endif
796 }
797 }
798
799 return current;
800}
801
802static int DirectFB_AllocHWSurface(_THIS, SDL_Surface *surface)
803{
804 DFBResult ret;
805 DFBSurfaceDescription dsc;
806
807 /* fprintf(stderr, "SDL: DirectFB_AllocHWSurface (%dx%d@%d, flags: 0x%08x)\n",
808 surface->w, surface->h, surface->format->BitsPerPixel, surface->flags);*/
809
810 if (surface->w < 8 || surface->h < 8)
811 return -1;
812
813 /* fill surface description */
814 dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
815 dsc.width = surface->w;
816 dsc.height = surface->h;
817 dsc.caps = (surface->flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0;
818
819 /* find the right pixelformat */
820 dsc.pixelformat = SDLToDFBPixelFormat (surface->format);
821 if (dsc.pixelformat == DSPF_UNKNOWN)
822 return -1;
823
824 /* Allocate the hardware acceleration data */
825 surface->hwdata = (struct private_hwdata *) SDL_calloc (1, sizeof(*surface->hwdata));
826 if (surface->hwdata == NULL)
827 {
828 SDL_OutOfMemory();
829 return -1;
830 }
831
832 /* Create the surface */
833 ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface->hwdata->surface);
834 if (ret)
835 {
836 SetDirectFBerror ("dfb->CreateSurface", ret);
837 free (surface->hwdata);
838 surface->hwdata = NULL;
839 return -1;
840 }
841
842 surface->flags |= SDL_HWSURFACE | SDL_PREALLOC;
843
844 return 0;
845}
846
847static void DirectFB_FreeHWSurface(_THIS, SDL_Surface *surface)
848{
849 if (surface->hwdata && HIDDEN->initialized)
850 {
851 surface->hwdata->surface->Release (surface->hwdata->surface);
852 free (surface->hwdata);
853 surface->hwdata = NULL;
854 }
855}
856
857static int DirectFB_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
858{
859 /* fprintf(stderr, "SDL: DirectFB_CheckHWBlit (src->hwdata: %p, dst->hwdata: %p)\n",
860 src->hwdata, dst->hwdata);*/
861
862 if (!src->hwdata || !dst->hwdata)
863 return 0;
864
865 src->flags |= SDL_HWACCEL;
866 src->map->hw_blit = DirectFB_HWAccelBlit;
867
868 return 1;
869}
870
871static int DirectFB_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
872 SDL_Surface *dst, SDL_Rect *dstrect)
873{
874 DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
875
876 DFBRectangle sr = { srcrect->x, srcrect->y, srcrect->w, srcrect->h };
877 DFBRectangle dr = { dstrect->x, dstrect->y, dstrect->w, dstrect->h };
878
879 IDirectFBSurface *surface = dst->hwdata->surface;
880
881 if (src->flags & SDL_SRCCOLORKEY)
882 {
883 flags |= DSBLIT_SRC_COLORKEY;
884 DirectFB_SetHWColorKey (NULL, src, src->format->colorkey);
885 }
886
887 if (src->flags & SDL_SRCALPHA)
888 {
889 flags |= DSBLIT_BLEND_COLORALPHA;
890 surface->SetColor (surface, 0xff, 0xff, 0xff, src->format->alpha);
891 }
892
893 surface->SetBlittingFlags (surface, flags);
894
895 if (sr.w == dr.w && sr.h == dr.h)
896 surface->Blit (surface, src->hwdata->surface, &sr, dr.x, dr.y);
897 else
898 surface->StretchBlit (surface, src->hwdata->surface, &sr, &dr);
899
900 return 0;
901}
902
903static int DirectFB_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
904{
905 SDL_PixelFormat *fmt = dst->format;
906 IDirectFBSurface *surface = dst->hwdata->surface;
907
908 /* ugly */
909 surface->SetColor (surface,
910 (color & fmt->Rmask) >> (fmt->Rshift - fmt->Rloss),
911 (color & fmt->Gmask) >> (fmt->Gshift - fmt->Gloss),
912 (color & fmt->Bmask) << (fmt->Bloss - fmt->Bshift), 0xFF);
913 surface->FillRectangle (surface, dstrect->x, dstrect->y, dstrect->w, dstrect->h);
914
915 return 0;
916}
917
918static int DirectFB_SetHWColorKey(_THIS, SDL_Surface *src, Uint32 key)
919{
920 SDL_PixelFormat *fmt = src->format;
921 IDirectFBSurface *surface = src->hwdata->surface;
922
923 if (fmt->BitsPerPixel == 8)
924 surface->SetSrcColorKeyIndex (surface, key);
925 else
926 /* ugly */
927 surface->SetSrcColorKey (surface,
928 (key & fmt->Rmask) >> (fmt->Rshift - fmt->Rloss),
929 (key & fmt->Gmask) >> (fmt->Gshift - fmt->Gloss),
930 (key & fmt->Bmask) << (fmt->Bloss - fmt->Bshift));
931
932 return 0;
933}
934
935static int DirectFB_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha)
936{
937 return 0;
938}
939
940static int DirectFB_FlipHWSurface(_THIS, SDL_Surface *surface)
941{
942 if (HIDDEN->enable_mga_crtc2)
943 {
944 int rtn = surface->hwdata->surface->Flip (surface->hwdata->surface, NULL, 0);
945 if (HIDDEN->mga_crtc2_stretch)
946 HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame, surface->hwdata->surface, &HIDDEN->c2ssize, &HIDDEN->c2dsize);
947 else
948 HIDDEN->c2frame->Blit(HIDDEN->c2frame, surface->hwdata->surface, NULL, HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
949
950 HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
951 return rtn;
952 }
953 else
954 return surface->hwdata->surface->Flip (surface->hwdata->surface, NULL, DSFLIP_WAITFORSYNC);
955}
956
957static int DirectFB_LockHWSurface(_THIS, SDL_Surface *surface)
958{
959 DFBResult ret;
960 void *data;
961 int pitch;
962
963 ret = surface->hwdata->surface->Lock (surface->hwdata->surface,
964 DSLF_WRITE, &data, &pitch);
965 if (ret)
966 {
967 SetDirectFBerror ("surface->Lock", ret);
968 return -1;
969 }
970
971 surface->pixels = data;
972 surface->pitch = pitch;
973
974 return 0;
975}
976
977static void DirectFB_UnlockHWSurface(_THIS, SDL_Surface *surface)
978{
979 surface->hwdata->surface->Unlock (surface->hwdata->surface);
980 surface->pixels = NULL;
981}
982
983static void DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
984{
985 if (HIDDEN->enable_mga_crtc2)
986 {
987 if (HIDDEN->mga_crtc2_stretch)
988 HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame, this->screen->hwdata->surface, &HIDDEN->c2ssize, &HIDDEN->c2dsize);
989 else
990 HIDDEN->c2frame->Blit(HIDDEN->c2frame, this->screen->hwdata->surface, NULL, HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
991
992 HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
993 }
994}
995
996static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect *rects)
997{
998 DFBRegion region;
999 int i;
1000 int region_valid = 0;
1001 IDirectFBSurface *surface = this->screen->hwdata->surface;
1002
1003 for (i=0; i<numrects; ++i)
1004 {
1005 int x2, y2;
1006
1007 if ( ! rects[i].w ) /* Clipped? */
1008 continue;
1009
1010 x2 = rects[i].x + rects[i].w - 1;
1011 y2 = rects[i].y + rects[i].h - 1;
1012
1013 if (region_valid)
1014 {
1015 if (rects[i].x < region.x1)
1016 region.x1 = rects[i].x;
1017
1018 if (rects[i].y < region.y1)
1019 region.y1 = rects[i].y;
1020
1021 if (x2 > region.x2)
1022 region.x2 = x2;
1023
1024 if (y2 > region.y2)
1025 region.y2 = y2;
1026 }
1027 else
1028 {
1029 region.x1 = rects[i].x;
1030 region.y1 = rects[i].y;
1031 region.x2 = x2;
1032 region.y2 = y2;
1033
1034 region_valid = 1;
1035 }
1036 }
1037
1038 if (region_valid)
1039 {
1040 if (HIDDEN->enable_mga_crtc2)
1041 {
1042 if (HIDDEN->mga_crtc2_stretch)
1043 HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame, surface, &HIDDEN->c2ssize, &HIDDEN->c2dsize);
1044 else
1045 HIDDEN->c2frame->Blit(HIDDEN->c2frame, surface, NULL, HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
1046
1047 HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
1048 }
1049 else
1050 surface->Flip (surface, &region, DSFLIP_WAITFORSYNC);
1051 }
1052}
1053
1054int DirectFB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
1055{
1056 IDirectFBPalette *palette = this->screen->hwdata->palette;
1057
1058 if (!palette)
1059 return 0;
1060
1061 if (firstcolor > 255)
1062 return 0;
1063
1064 if (firstcolor + ncolors > 256)
1065 ncolors = 256 - firstcolor;
1066
1067 if (ncolors > 0)
1068 {
1069 int i;
1070 DFBColor entries[ncolors];
1071
1072 for (i=0; i<ncolors; i++)
1073 {
1074 entries[i].a = 0xff;
1075 entries[i].r = colors[i].r;
1076 entries[i].g = colors[i].g;
1077 entries[i].b = colors[i].b;
1078 }
1079
1080 palette->SetEntries (palette, entries, ncolors, firstcolor);
1081 }
1082
1083 return 1;
1084}
1085
1086void DirectFB_VideoQuit(_THIS)
1087{
1088 struct DirectFBEnumRect *rect = enumlist;
1089
1090 if (this->screen && this->screen->hwdata)
1091 {
1092 IDirectFBSurface *surface = this->screen->hwdata->surface;
1093 IDirectFBPalette *palette = this->screen->hwdata->palette;
1094
1095 if (palette)
1096 palette->Release (palette);
1097
1098 if (surface)
1099 surface->Release (surface);
1100
1101 this->screen->hwdata->surface = NULL;
1102 this->screen->hwdata->palette = NULL;
1103 }
1104
1105 if (HIDDEN->c2frame)
1106 {
1107 HIDDEN->c2frame->Release (HIDDEN->c2frame);
1108 HIDDEN->c2frame = NULL;
1109 }
1110
1111 if (HIDDEN->eventbuffer)
1112 {
1113 HIDDEN->eventbuffer->Release (HIDDEN->eventbuffer);
1114 HIDDEN->eventbuffer = NULL;
1115 }
1116
1117 if (HIDDEN->c2layer)
1118 {
1119 HIDDEN->c2layer->Release (HIDDEN->c2layer);
1120 HIDDEN->c2layer = NULL;
1121 }
1122
1123 if (HIDDEN->layer)
1124 {
1125 HIDDEN->layer->Release (HIDDEN->layer);
1126 HIDDEN->layer = NULL;
1127 }
1128
1129 if (HIDDEN->dfb)
1130 {
1131 HIDDEN->dfb->Release (HIDDEN->dfb);
1132 HIDDEN->dfb = NULL;
1133 }
1134
1135 /* Free video mode list */
1136 if (HIDDEN->modelist)
1137 {
1138 free (HIDDEN->modelist);
1139 HIDDEN->modelist = NULL;
1140 }
1141
1142 /* Free mode enumeration list */
1143 while (rect)
1144 {
1145 struct DirectFBEnumRect *next = rect->next;
1146 free (rect);
1147 rect = next;
1148 }
1149 enumlist = NULL;
1150
1151 HIDDEN->initialized = 0;
1152}
1153
1154
1155int DirectFB_ShowWMCursor(_THIS, WMcursor *cursor)
1156{
1157 /* We can only hide or show the default cursor */
1158 if ( cursor == NULL )
1159 {
1160 HIDDEN->layer->SetCursorOpacity(HIDDEN->layer, 0x00);
1161 }
1162 else
1163 {
1164 HIDDEN->layer->SetCursorOpacity(HIDDEN->layer, 0xFF);
1165 }
1166 return 1;
1167}
1168
1169void DirectFB_FinalQuit(void)
1170{
1171}
diff --git a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_video.h b/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_video.h
deleted file mode 100644
index e1fa12c268..0000000000
--- a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_video.h
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21*/
22#include "SDL_config.h"
23
24#ifndef _SDL_DirectFB_video_h
25#define _SDL_DirectFB_video_h
26
27#include <directfb.h>
28
29#include "SDL_mouse.h"
30#include "../SDL_sysvideo.h"
31
32#define _THIS SDL_VideoDevice *this
33
34/* Private display data */
35
36struct SDL_PrivateVideoData
37{
38 int initialized;
39
40 IDirectFB *dfb;
41 IDirectFBDisplayLayer *layer;
42 IDirectFBEventBuffer *eventbuffer;
43
44 int nummodes;
45 SDL_Rect **modelist;
46
47 /* MGA CRTC2 support */
48 int enable_mga_crtc2;
49 int mga_crtc2_stretch;
50 float mga_crtc2_stretch_overscan;
51 IDirectFBDisplayLayer *c2layer;
52 IDirectFBSurface *c2frame;
53 DFBRectangle c2ssize; /* Real screen size */
54 DFBRectangle c2dsize; /* Stretched screen size */
55 DFBRectangle c2framesize; /* CRTC2 screen size */
56};
57
58#define HIDDEN (this->hidden)
59
60void SetDirectFBerror (const char *function, DFBResult code);
61
62#endif /* _SDL_DirectFB_video_h */
diff --git a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_yuv.c b/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_yuv.c
deleted file mode 100644
index fd0cef1180..0000000000
--- a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_yuv.c
+++ /dev/null
@@ -1,290 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21*/
22#include "SDL_config.h"
23
24/* This is the DirectFB implementation of YUV video overlays */
25
26#include "SDL_video.h"
27#include "SDL_DirectFB_yuv.h"
28#include "../SDL_yuvfuncs.h"
29
30
31/* The functions used to manipulate software video overlays */
32static struct private_yuvhwfuncs directfb_yuvfuncs = {
33 DirectFB_LockYUVOverlay,
34 DirectFB_UnlockYUVOverlay,
35 DirectFB_DisplayYUVOverlay,
36 DirectFB_FreeYUVOverlay
37};
38
39struct private_yuvhwdata {
40 DFBDisplayLayerID layer_id;
41
42 IDirectFBDisplayLayer *layer;
43 IDirectFBSurface *surface;
44
45 /* These are just so we don't have to allocate them separately */
46 Uint16 pitches[3];
47 Uint8 *planes[3];
48};
49
50static DFBEnumerationResult
51enum_layers_callback( DFBDisplayLayerID id,
52 DFBDisplayLayerDescription desc,
53 void *data )
54{
55 struct private_yuvhwdata *hwdata = (struct private_yuvhwdata *) data;
56
57 /* we don't want the primary */
58 if (id == DLID_PRIMARY)
59 return DFENUM_OK;
60
61 /* take the one with a surface for video */
62 if ((desc.caps & DLCAPS_SURFACE) && (desc.type & DLTF_VIDEO))
63 {
64 hwdata->layer_id = id;
65
66 return DFENUM_CANCEL;
67 }
68
69 return DFENUM_OK;
70}
71
72
73static DFBResult CreateYUVSurface(_THIS, struct private_yuvhwdata *hwdata,
74 int width, int height, Uint32 format)
75{
76 DFBResult ret;
77 IDirectFB *dfb = HIDDEN->dfb;
78 IDirectFBDisplayLayer *layer;
79 DFBDisplayLayerConfig conf;
80
81 ret = dfb->EnumDisplayLayers (dfb, enum_layers_callback, hwdata);
82 if (ret)
83 {
84 SetDirectFBerror("IDirectFB::EnumDisplayLayers", ret);
85 return ret;
86 }
87
88 if (!hwdata->layer_id)
89 return DFB_UNSUPPORTED;
90
91 ret = dfb->GetDisplayLayer (dfb, hwdata->layer_id, &layer);
92 if (ret)
93 {
94 SetDirectFBerror("IDirectFB::GetDisplayLayer", ret);
95 return ret;
96 }
97
98 conf.flags = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT;
99 conf.width = width;
100 conf.height = height;
101
102 switch (format)
103 {
104 case SDL_YV12_OVERLAY:
105 conf.pixelformat = DSPF_YV12;
106 break;
107 case SDL_IYUV_OVERLAY:
108 conf.pixelformat = DSPF_I420;
109 break;
110 case SDL_YUY2_OVERLAY:
111 conf.pixelformat = DSPF_YUY2;
112 break;
113 case SDL_UYVY_OVERLAY:
114 conf.pixelformat = DSPF_UYVY;
115 break;
116 default:
117 fprintf (stderr, "SDL_DirectFB: Unsupported YUV format (0x%08x)!\n", format);
118 break;
119 }
120
121 /* Need to set coop level or newer DirectFB versions will fail here. */
122 ret = layer->SetCooperativeLevel (layer, DLSCL_ADMINISTRATIVE);
123 if (ret)
124 {
125 SetDirectFBerror("IDirectFBDisplayLayer::SetCooperativeLevel() failed", ret);
126 layer->Release (layer);
127 return ret;
128 }
129
130 ret = layer->SetConfiguration (layer, &conf);
131 if (ret)
132 {
133 SetDirectFBerror("IDirectFBDisplayLayer::SetConfiguration", ret);
134 layer->Release (layer);
135 return ret;
136 }
137
138 ret = layer->GetSurface (layer, &hwdata->surface);
139 if (ret)
140 {
141 SetDirectFBerror("IDirectFBDisplayLayer::GetSurface", ret);
142 layer->Release (layer);
143 return ret;
144 }
145
146 hwdata->layer = layer;
147
148 return DFB_OK;
149}
150
151SDL_Overlay *DirectFB_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
152{
153 SDL_Overlay *overlay;
154 struct private_yuvhwdata *hwdata;
155
156 /* Create the overlay structure */
157 overlay = SDL_calloc (1, sizeof(SDL_Overlay));
158 if (!overlay)
159 {
160 SDL_OutOfMemory();
161 return NULL;
162 }
163
164 /* Fill in the basic members */
165 overlay->format = format;
166 overlay->w = width;
167 overlay->h = height;
168
169 /* Set up the YUV surface function structure */
170 overlay->hwfuncs = &directfb_yuvfuncs;
171
172 /* Create the pixel data and lookup tables */
173 hwdata = SDL_calloc(1, sizeof(struct private_yuvhwdata));
174 overlay->hwdata = hwdata;
175 if (!hwdata)
176 {
177 SDL_OutOfMemory();
178 SDL_FreeYUVOverlay (overlay);
179 return NULL;
180 }
181
182 if (CreateYUVSurface (this, hwdata, width, height, format))
183 {
184 SDL_FreeYUVOverlay (overlay);
185 return NULL;
186 }
187
188 overlay->hw_overlay = 1;
189
190 /* Set up the plane pointers */
191 overlay->pitches = hwdata->pitches;
192 overlay->pixels = hwdata->planes;
193 switch (format)
194 {
195 case SDL_YV12_OVERLAY:
196 case SDL_IYUV_OVERLAY:
197 overlay->planes = 3;
198 break;
199 default:
200 overlay->planes = 1;
201 break;
202 }
203
204 /* We're all done.. */
205 return overlay;
206}
207
208int DirectFB_LockYUVOverlay(_THIS, SDL_Overlay *overlay)
209{
210 DFBResult ret;
211 void *data;
212 int pitch;
213 IDirectFBSurface *surface = overlay->hwdata->surface;
214
215 ret = surface->Lock (surface, DSLF_READ | DSLF_WRITE, &data, &pitch);
216 if (ret)
217 {
218 SetDirectFBerror("IDirectFBSurface::Lock", ret);
219 return -1;
220 }
221
222 /* Find the pitch and offset values for the overlay */
223 overlay->pitches[0] = (Uint16) pitch;
224 overlay->pixels[0] = (Uint8*) data;
225
226 switch (overlay->format)
227 {
228 case SDL_YV12_OVERLAY:
229 case SDL_IYUV_OVERLAY:
230 /* Add the two extra planes */
231 overlay->pitches[1] = overlay->pitches[0] / 2;
232 overlay->pitches[2] = overlay->pitches[0] / 2;
233 overlay->pixels[1] = overlay->pixels[0] + overlay->pitches[0] * overlay->h;
234 overlay->pixels[2] = overlay->pixels[1] + overlay->pitches[1] * overlay->h / 2;
235 break;
236 default:
237 /* Only one plane, no worries */
238 break;
239 }
240
241 return 0;
242}
243
244void DirectFB_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay)
245{
246 IDirectFBSurface *surface = overlay->hwdata->surface;
247
248 overlay->pixels[0] = overlay->pixels[1] = overlay->pixels[2] = NULL;
249
250 surface->Unlock (surface);
251}
252
253int DirectFB_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst)
254{
255 DFBResult ret;
256 DFBDisplayLayerConfig conf;
257 IDirectFBDisplayLayer *primary = HIDDEN->layer;
258 IDirectFBDisplayLayer *layer = overlay->hwdata->layer;
259
260 primary->GetConfiguration (primary, &conf);
261
262 ret = layer->SetScreenLocation (layer,
263 dst->x / (float) conf.width, dst->y / (float) conf.height,
264 dst->w / (float) conf.width, dst->h / (float) conf.height );
265 if (ret)
266 {
267 SetDirectFBerror("IDirectFBDisplayLayer::SetScreenLocation", ret);
268 return -1;
269 }
270
271 return 0;
272}
273
274void DirectFB_FreeYUVOverlay(_THIS, SDL_Overlay *overlay)
275{
276 struct private_yuvhwdata *hwdata;
277
278 hwdata = overlay->hwdata;
279 if (hwdata)
280 {
281 if (hwdata->surface)
282 hwdata->surface->Release (hwdata->surface);
283
284 if (hwdata->layer)
285 hwdata->layer->Release (hwdata->layer);
286
287 free (hwdata);
288 }
289}
290
diff --git a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_yuv.h b/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_yuv.h
deleted file mode 100644
index 64bc86fa02..0000000000
--- a/apps/plugins/sdl/src/video/directfb/SDL_DirectFB_yuv.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21*/
22#include "SDL_config.h"
23
24/* This is the DirectFB implementation of YUV video overlays */
25
26#include "SDL_video.h"
27#include "SDL_DirectFB_video.h"
28
29extern SDL_Overlay *DirectFB_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display);
30
31extern int DirectFB_LockYUVOverlay(_THIS, SDL_Overlay *overlay);
32
33extern void DirectFB_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay);
34
35extern int DirectFB_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst);
36
37extern void DirectFB_FreeYUVOverlay(_THIS, SDL_Overlay *overlay);
38