annotate src/video/directfb/SDL_DirectFB_video.c @ 478:f8482d7c9595

Date: Tue, 27 Aug 2002 19:07:38 +0200 From: Denis Oliver Kropp Subject: YUV support I just added YUV overlay support to the DirectFB backend.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 31 Aug 2002 04:13:28 +0000
parents 22581630aab7
children 0009aadb3d01
rev   line source
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
297
f6ffac90895c Updated copyright information for 2002
Sam Lantinga <slouken@libsdl.org>
parents: 286
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Library General Public License for more details.
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 219
diff changeset
20 slouken@libsdl.org
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 #ifdef SAVE_RCSID
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 static char rcsid =
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 "@(#) $Id$";
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #endif
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 /* DirectFB video driver implementation.
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include <stdlib.h>
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
32 #include <string.h>
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 #include <stdio.h>
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 #include <fcntl.h>
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #include <unistd.h>
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #include <sys/mman.h>
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #include <directfb.h>
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 #include "SDL.h"
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 #include "SDL_error.h"
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 #include "SDL_video.h"
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 #include "SDL_mouse.h"
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 #include "SDL_sysvideo.h"
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 #include "SDL_pixels_c.h"
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 #include "SDL_events_c.h"
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 #include "SDL_DirectFB_video.h"
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 #include "SDL_DirectFB_events.h"
478
f8482d7c9595 Date: Tue, 27 Aug 2002 19:07:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 477
diff changeset
49 #include "SDL_DirectFB_yuv.h"
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 /* Initialization/Query functions */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 static int DirectFB_VideoInit(_THIS, SDL_PixelFormat *vformat);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 static int DirectFB_SetColors(_THIS, int firstcolor, int ncolors,
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 SDL_Color *colors);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 static void DirectFB_VideoQuit(_THIS);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 /* Hardware surface functions */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 static int DirectFB_AllocHWSurface(_THIS, SDL_Surface *surface);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 static int DirectFB_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 static int DirectFB_LockHWSurface(_THIS, SDL_Surface *surface);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 static void DirectFB_UnlockHWSurface(_THIS, SDL_Surface *surface);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 static void DirectFB_FreeHWSurface(_THIS, SDL_Surface *surface);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 static int DirectFB_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 static int DirectFB_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 SDL_Surface *dst, SDL_Rect *dstrect);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 static int DirectFB_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 static int DirectFB_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 static int DirectFB_FlipHWSurface(_THIS, SDL_Surface *surface);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 /* Various screen update functions available */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 static void DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect *rects);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 /* This is the rect EnumModes2 uses */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 struct DirectFBEnumRect {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 SDL_Rect r;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 struct DirectFBEnumRect* next;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 };
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
83 static struct DirectFBEnumRect *enumlist = NULL;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 /* DirectFB driver bootstrap functions */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 static int DirectFB_Available(void)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 return 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 static void DirectFB_DeleteDevice(SDL_VideoDevice *device)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 free(device->hidden);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 free(device);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 static SDL_VideoDevice *DirectFB_CreateDevice(int devindex)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 SDL_VideoDevice *device;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 /* Initialize all variables that we clean on shutdown */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 if (device)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 memset (device, 0, (sizeof *device));
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 device->hidden = (struct SDL_PrivateVideoData *) malloc (sizeof (*device->hidden));
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 if (device == NULL || device->hidden == NULL)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 SDL_OutOfMemory();
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 if (device)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 free (device);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 return(0);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 memset (device->hidden, 0, sizeof (*device->hidden));
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 /* Set the function pointers */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 device->VideoInit = DirectFB_VideoInit;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 device->ListModes = DirectFB_ListModes;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 device->SetVideoMode = DirectFB_SetVideoMode;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 device->SetColors = DirectFB_SetColors;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 device->UpdateRects = NULL;
478
f8482d7c9595 Date: Tue, 27 Aug 2002 19:07:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 477
diff changeset
127 device->CreateYUVOverlay = DirectFB_CreateYUVOverlay;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 device->VideoQuit = DirectFB_VideoQuit;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 device->AllocHWSurface = DirectFB_AllocHWSurface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 device->CheckHWBlit = DirectFB_CheckHWBlit;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 device->FillHWRect = DirectFB_FillHWRect;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 device->SetHWColorKey = DirectFB_SetHWColorKey;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 device->SetHWAlpha = DirectFB_SetHWAlpha;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 device->LockHWSurface = DirectFB_LockHWSurface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 device->UnlockHWSurface = DirectFB_UnlockHWSurface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 device->FlipHWSurface = DirectFB_FlipHWSurface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 device->FreeHWSurface = DirectFB_FreeHWSurface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 device->SetCaption = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 device->SetIcon = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 device->IconifyWindow = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 device->GrabInput = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 device->GetWMInfo = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 device->InitOSKeymap = DirectFB_InitOSKeymap;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 device->PumpEvents = DirectFB_PumpEvents;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 device->free = DirectFB_DeleteDevice;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 return device;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 VideoBootStrap DirectFB_bootstrap = {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 "directfb", "DirectFB",
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 DirectFB_Available, DirectFB_CreateDevice
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 };
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
156 static DFBSurfacePixelFormat GetFormatForBpp (int bpp, IDirectFBDisplayLayer *layer)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
157 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
158 DFBDisplayLayerConfig dlc;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
159 int bytes = (bpp + 7) / 8;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
160
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
161 layer->GetConfiguration (layer, &dlc);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
162
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
163 if (bytes == DFB_BYTES_PER_PIXEL(dlc.pixelformat) && bytes > 1)
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
164 return dlc.pixelformat;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
165
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
166 switch (bytes)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
167 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
168 case 1:
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
169 return DSPF_LUT8;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
170 case 2:
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
171 return DSPF_RGB16;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
172 case 3:
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
173 return DSPF_RGB24;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
174 case 4:
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
175 return DSPF_RGB32;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
176 }
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
177
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
178 return DSPF_UNKNOWN;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
179 }
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
180
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 static DFBEnumerationResult EnumModesCallback (unsigned int width,
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 unsigned int height,
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 unsigned int bpp,
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 void *data)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 SDL_VideoDevice *this = (SDL_VideoDevice *)data;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 struct DirectFBEnumRect *enumrect;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
189 HIDDEN->nummodes++;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
190
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
191 enumrect = calloc(1, sizeof(struct DirectFBEnumRect));
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
192 if (!enumrect)
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 {
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
194 SDL_OutOfMemory();
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
195 return DFENUM_CANCEL;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
198 enumrect->r.w = width;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
199 enumrect->r.h = height;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
200 enumrect->next = enumlist;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
201
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
202 enumlist = enumrect;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
203
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 return DFENUM_OK;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 struct private_hwdata {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 IDirectFBSurface *surface;
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
209 IDirectFBPalette *palette;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 };
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 void SetDirectFBerror (const char *function, DFBResult code)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 const char *error = DirectFBErrorString (code);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 if (error)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 SDL_SetError("%s: %s", function, error);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 else
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 SDL_SetError("Unknown error code from %s", function);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 static DFBSurfacePixelFormat SDLToDFBPixelFormat (SDL_PixelFormat *format)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 if (format->Rmask && format->Gmask && format->Bmask)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 switch (format->BitsPerPixel)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 {
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
228 case 8:
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
229 return DSPF_LUT8;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
230
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 case 16:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 if (format->Rmask == 0xF800 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 format->Gmask == 0x07E0 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 format->Bmask == 0x001F)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 return DSPF_RGB16;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 /* fall through */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 case 15:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 if (format->Rmask == 0x7C00 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 format->Gmask == 0x03E0 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 format->Bmask == 0x001F)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 return DSPF_RGB15;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 break;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 case 24:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 if (format->Rmask == 0xFF0000 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 format->Gmask == 0x00FF00 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 format->Bmask == 0x0000FF)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 return DSPF_RGB24;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 break;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
251
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 case 32:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 if (format->Rmask == 0xFF0000 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 format->Gmask == 0x00FF00 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 format->Bmask == 0x0000FF)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 if (format->Amask == 0xFF000000)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 return DSPF_ARGB;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 else
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 return DSPF_RGB32;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 break;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 else
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 switch (format->BitsPerPixel)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 {
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
269 case 8:
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
270 return DSPF_LUT8;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 case 15:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 return DSPF_RGB15;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 case 16:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 return DSPF_RGB16;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 case 24:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 return DSPF_RGB24;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 case 32:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 return DSPF_RGB32;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 return DSPF_UNKNOWN;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
285 static SDL_Palette *AllocatePalette(int size)
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
286 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
287 SDL_Palette *palette;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
288 SDL_Color *colors;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
289
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
290 palette = calloc (1, sizeof(SDL_Palette));
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
291 if (!palette)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
292 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
293 SDL_OutOfMemory();
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
294 return NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
295 }
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
296
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
297 colors = calloc (size, sizeof(SDL_Color));
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
298 if (!colors)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
299 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
300 SDL_OutOfMemory();
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
301 return NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
302 }
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
303
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
304 palette->ncolors = size;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
305 palette->colors = colors;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
306
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
307 return palette;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
308 }
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
309
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 static int DFBToSDLPixelFormat (DFBSurfacePixelFormat pixelformat, SDL_PixelFormat *format)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 format->Amask = format->Rmask = format->Gmask = format->Bmask = 0;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
313 format->BitsPerPixel = format->BytesPerPixel = 0;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 switch (pixelformat)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 case DSPF_A8:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 format->Amask = 0x000000FF;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 break;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
320
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 case DSPF_RGB15:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 format->Rmask = 0x00007C00;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 format->Gmask = 0x000003E0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 format->Bmask = 0x0000001F;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 break;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
326
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 case DSPF_RGB16:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 format->Rmask = 0x0000F800;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 format->Gmask = 0x000007E0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 format->Bmask = 0x0000001F;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 break;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
332
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 case DSPF_ARGB:
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
334 format->Amask = 0; /* apps don't seem to like that: 0xFF000000; */
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 /* fall through */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 case DSPF_RGB24:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 case DSPF_RGB32:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 format->Rmask = 0x00FF0000;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 format->Gmask = 0x0000FF00;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 format->Bmask = 0x000000FF;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 break;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
342
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
343 case DSPF_LUT8:
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
344 format->Rmask = 0x000000FF;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
345 format->Gmask = 0x000000FF;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
346 format->Bmask = 0x000000FF;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
347
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
348 if (!format->palette)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
349 format->palette = AllocatePalette(256);
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
350 break;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
351
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 default:
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
353 fprintf (stderr, "SDL_DirectFB: Unsupported pixelformat (0x%08x)!\n", pixelformat);
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 return -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
357 format->BitsPerPixel = DFB_BYTES_PER_PIXEL(pixelformat) * 8;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
358 format->BytesPerPixel = DFB_BYTES_PER_PIXEL(pixelformat);
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 return 0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 int DirectFB_VideoInit(_THIS, SDL_PixelFormat *vformat)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 {
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
366 int i;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
367 DFBResult ret;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
368 DFBCardCapabilities caps;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
369 DFBDisplayLayerConfig dlc;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
370 struct DirectFBEnumRect *rect;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
371 IDirectFB *dfb = NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
372 IDirectFBDisplayLayer *layer = NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
373 IDirectFBEventBuffer *events = NULL;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 ret = DirectFBInit (NULL, NULL);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 SetDirectFBerror ("DirectFBInit", ret);
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
380 goto error;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 ret = DirectFBCreate (&dfb);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 SetDirectFBerror ("DirectFBCreate", ret);
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
387 goto error;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 ret = dfb->GetDisplayLayer (dfb, DLID_PRIMARY, &layer);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 SetDirectFBerror ("dfb->GetDisplayLayer", ret);
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
394 goto error;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
397 ret = dfb->CreateEventBuffer (dfb, DICAPS_ALL, &events);
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 {
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
400 SetDirectFBerror ("dfb->CreateEventBuffer", ret);
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
401 goto error;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 layer->EnableCursor (layer, 1);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 /* Query layer configuration to determine the current mode and pixelformat */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 layer->GetConfiguration (layer, &dlc);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
409 /* If current format is not supported use LUT8 as the default */
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
410 if (DFBToSDLPixelFormat (dlc.pixelformat, vformat))
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
411 DFBToSDLPixelFormat (DSPF_LUT8, vformat);
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 /* Enumerate the available fullscreen modes */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 ret = dfb->EnumVideoModes (dfb, EnumModesCallback, this);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 SetDirectFBerror ("dfb->EnumVideoModes", ret);
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
418 goto error;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 }
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
420
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
421 HIDDEN->modelist = calloc (HIDDEN->nummodes + 1, sizeof(SDL_Rect *));
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
422 if (!HIDDEN->modelist)
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 {
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
424 SDL_OutOfMemory();
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
425 goto error;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
428 for (i = 0, rect = enumlist; rect; ++i, rect = rect->next )
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
429 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
430 HIDDEN->modelist[i] = &rect->r;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
431 }
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
432
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
433 HIDDEN->modelist[i] = NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
434
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
435
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 /* Query card capabilities to get the video memory size */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 dfb->GetCardCapabilities (dfb, &caps);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 this->info.wm_available = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 this->info.hw_available = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 this->info.blit_hw = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442 this->info.blit_hw_CC = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 this->info.blit_hw_A = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 this->info.blit_fill = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 this->info.video_mem = caps.video_memory / 1024;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 HIDDEN->initialized = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 HIDDEN->dfb = dfb;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 HIDDEN->layer = layer;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
450 HIDDEN->eventbuffer = events;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 return 0;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
453
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
454 error:
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
455 if (events)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
456 events->Release (events);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
457
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
458 if (layer)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
459 layer->Release (layer);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
460
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
461 if (dfb)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
462 dfb->Release (dfb);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
463
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
464 return -1;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 if (flags & SDL_FULLSCREEN)
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
470 return HIDDEN->modelist;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 else
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472 if (SDLToDFBPixelFormat (format) != DSPF_UNKNOWN)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 return (SDL_Rect**) -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475 return NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
478 static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479 {
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
480 DFBResult ret;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
481 DFBSurfaceDescription dsc;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
482 DFBSurfacePixelFormat pixelformat;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
483 IDirectFBSurface *surface;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 fprintf (stderr, "SDL DirectFB_SetVideoMode: %dx%d@%d, flags: 0x%08x\n",
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486 width, height, bpp, flags);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
487
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488 flags |= SDL_FULLSCREEN;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490 /* Release previous primary surface */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491 if (current->hwdata && current->hwdata->surface)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 current->hwdata->surface->Release (current->hwdata->surface);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
494 current->hwdata->surface = NULL;
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
495
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
496 /* And its palette if present */
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
497 if (current->hwdata->palette)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
498 {
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
499 current->hwdata->palette->Release (current->hwdata->palette);
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
500 current->hwdata->palette = NULL;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
501 }
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 else if (!current->hwdata)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505 /* Allocate the hardware acceleration data */
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
506 current->hwdata = (struct private_hwdata *) calloc (1, sizeof(*current->hwdata));
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 if (!current->hwdata)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509 SDL_OutOfMemory();
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
510 return NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
511 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514 /* Set cooperative level depending on flag SDL_FULLSCREEN */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 if (flags & SDL_FULLSCREEN)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
516 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
517 ret = HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_FULLSCREEN);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 DirectFBError ("dfb->SetCooperativeLevel", ret);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521 flags &= ~SDL_FULLSCREEN;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
524 else
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
525 HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_NORMAL);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
526
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
527 /* Set video mode */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 ret = HIDDEN->dfb->SetVideoMode (HIDDEN->dfb, width, height, bpp);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
529 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
530 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
531 if (flags & SDL_FULLSCREEN)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
533 flags &= ~SDL_FULLSCREEN;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
534 HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_NORMAL);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
535 ret = HIDDEN->dfb->SetVideoMode (HIDDEN->dfb, width, height, bpp);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
537
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 SetDirectFBerror ("dfb->SetVideoMode", ret);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 return NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
543 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
544
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545 /* Create primary surface */
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
546 dsc.flags = DSDESC_CAPS | DSDESC_PIXELFORMAT;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
547 dsc.caps = DSCAPS_PRIMARY | ((flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
548 dsc.pixelformat = GetFormatForBpp (bpp, HIDDEN->layer);
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
550 ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface);
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
551 if (ret && (flags & SDL_DOUBLEBUF))
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
553 /* Try without double buffering */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
554 dsc.caps &= ~DSCAPS_FLIPPING;
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
555 ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface);
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
556 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
557 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
559 SetDirectFBerror ("dfb->CreateSurface", ret);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560 return NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
562
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
563 current->w = width;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
564 current->h = height;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565 current->flags = SDL_HWSURFACE | SDL_PREALLOC;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
566
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567 if (flags & SDL_FULLSCREEN)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
568 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569 current->flags |= SDL_FULLSCREEN;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
570 this->UpdateRects = DirectFB_DirectUpdate;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
571 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
572 else
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
573 this->UpdateRects = DirectFB_WindowedUpdate;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
574
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
575 if (dsc.caps & DSCAPS_FLIPPING)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
576 current->flags |= SDL_DOUBLEBUF;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
577
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
578 surface->GetPixelFormat (surface, &pixelformat);
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
579
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580 DFBToSDLPixelFormat (pixelformat, current->format);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
581
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
582 /* Get the surface palette (if supported) */
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
583 if (DFB_PIXELFORMAT_IS_INDEXED( pixelformat ))
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
584 {
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
585 surface->GetPalette (surface, &current->hwdata->palette);
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
586
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
587 current->flags |= SDL_HWPALETTE;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
588 }
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
589
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
590 current->hwdata->surface = surface;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
591
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592 return current;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
594
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
595 static int DirectFB_AllocHWSurface(_THIS, SDL_Surface *surface)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
597 DFBResult ret;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
598 DFBSurfaceDescription dsc;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
599
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
600 /* fprintf(stderr, "SDL: DirectFB_AllocHWSurface (%dx%d@%d, flags: 0x%08x)\n",
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
601 surface->w, surface->h, surface->format->BitsPerPixel, surface->flags);*/
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
602
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
603 if (surface->w < 8 || surface->h < 8)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
604 return -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
605
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
606 /* fill surface description */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
607 dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
608 dsc.width = surface->w;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
609 dsc.height = surface->h;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
610 dsc.caps = (surface->flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
611
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
612 /* find the right pixelformat */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 dsc.pixelformat = SDLToDFBPixelFormat (surface->format);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
614 if (dsc.pixelformat == DSPF_UNKNOWN)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
615 return -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
616
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
617 /* Allocate the hardware acceleration data */
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
618 surface->hwdata = (struct private_hwdata *) calloc (1, sizeof(*surface->hwdata));
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
619 if (surface->hwdata == NULL)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
620 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
621 SDL_OutOfMemory();
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
622 return -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
623 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
624
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
625 /* Create the surface */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
626 ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface->hwdata->surface);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
628 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
629 SetDirectFBerror ("dfb->CreateSurface", ret);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
630 free (surface->hwdata);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
631 surface->hwdata = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
632 return -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
633 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
634
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
635 surface->flags |= SDL_HWSURFACE | SDL_PREALLOC;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
636
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
637 return 0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
638 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
639
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
640 static void DirectFB_FreeHWSurface(_THIS, SDL_Surface *surface)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
641 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
642 if (surface->hwdata && HIDDEN->initialized)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
643 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
644 surface->hwdata->surface->Release (surface->hwdata->surface);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
645 free (surface->hwdata);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
646 surface->hwdata = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
647 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
648 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
649
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
650 static int DirectFB_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
651 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
652 /* fprintf(stderr, "SDL: DirectFB_CheckHWBlit (src->hwdata: %p, dst->hwdata: %p)\n",
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
653 src->hwdata, dst->hwdata);*/
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
654
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
655 if (!src->hwdata || !dst->hwdata)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
656 return 0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
657
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
658 src->flags |= SDL_HWACCEL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
659 src->map->hw_blit = DirectFB_HWAccelBlit;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
660
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
661 return 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
662 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
663
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
664 static int DirectFB_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
665 SDL_Surface *dst, SDL_Rect *dstrect)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
666 {
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
667 DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
668
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
669 DFBRectangle sr = { srcrect->x, srcrect->y, srcrect->w, srcrect->h };
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
670 DFBRectangle dr = { dstrect->x, dstrect->y, dstrect->w, dstrect->h };
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
671
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
672 IDirectFBSurface *surface = dst->hwdata->surface;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
673
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
674 if (src->flags & SDL_SRCCOLORKEY)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
675 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
676 flags |= DSBLIT_SRC_COLORKEY;
219
f928da36f0e9 Updated SDL DirectFB backend for DirectFB version 0.9.7
Sam Lantinga <slouken@libsdl.org>
parents: 167
diff changeset
677 DirectFB_SetHWColorKey (NULL, src, src->format->colorkey);
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
678 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
679
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
680 if (src->flags & SDL_SRCALPHA)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
681 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
682 flags |= DSBLIT_BLEND_COLORALPHA;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
683 surface->SetColor (surface, 0xff, 0xff, 0xff, src->format->alpha);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
684 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
685
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
686 surface->SetBlittingFlags (surface, flags);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
687
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
688 if (sr.w == dr.w && sr.h == dr.h)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
689 surface->Blit (surface, src->hwdata->surface, &sr, dr.x, dr.y);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
690 else
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
691 surface->StretchBlit (surface, src->hwdata->surface, &sr, &dr);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
692
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
693 return 0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
694 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
695
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
696 static int DirectFB_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
697 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
698 SDL_PixelFormat *fmt = dst->format;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
699 IDirectFBSurface *surface = dst->hwdata->surface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
700
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
701 /* ugly */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
702 surface->SetColor (surface,
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
703 (color & fmt->Rmask) >> (fmt->Rshift - fmt->Rloss),
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
704 (color & fmt->Gmask) >> (fmt->Gshift - fmt->Gloss),
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
705 (color & fmt->Bmask) << (fmt->Bloss - fmt->Bshift), 0xFF);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
706 surface->FillRectangle (surface, dstrect->x, dstrect->y, dstrect->w, dstrect->h);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
707
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
708 return 0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
709 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
710
219
f928da36f0e9 Updated SDL DirectFB backend for DirectFB version 0.9.7
Sam Lantinga <slouken@libsdl.org>
parents: 167
diff changeset
711 static int DirectFB_SetHWColorKey(_THIS, SDL_Surface *src, Uint32 key)
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
712 {
219
f928da36f0e9 Updated SDL DirectFB backend for DirectFB version 0.9.7
Sam Lantinga <slouken@libsdl.org>
parents: 167
diff changeset
713 SDL_PixelFormat *fmt = src->format;
f928da36f0e9 Updated SDL DirectFB backend for DirectFB version 0.9.7
Sam Lantinga <slouken@libsdl.org>
parents: 167
diff changeset
714 IDirectFBSurface *surface = src->hwdata->surface;
f928da36f0e9 Updated SDL DirectFB backend for DirectFB version 0.9.7
Sam Lantinga <slouken@libsdl.org>
parents: 167
diff changeset
715
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
716 if (fmt->BitsPerPixel == 8)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
717 surface->SetSrcColorKeyIndex (surface, key);
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
718 else
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
719 /* ugly */
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
720 surface->SetSrcColorKey (surface,
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
721 (key & fmt->Rmask) >> (fmt->Rshift - fmt->Rloss),
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
722 (key & fmt->Gmask) >> (fmt->Gshift - fmt->Gloss),
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
723 (key & fmt->Bmask) << (fmt->Bloss - fmt->Bshift));
219
f928da36f0e9 Updated SDL DirectFB backend for DirectFB version 0.9.7
Sam Lantinga <slouken@libsdl.org>
parents: 167
diff changeset
724
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
725 return 0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
726 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
727
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
728 static int DirectFB_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
729 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
730 return 0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
731 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
732
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
733 static int DirectFB_FlipHWSurface(_THIS, SDL_Surface *surface)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
734 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
735 return surface->hwdata->surface->Flip (surface->hwdata->surface, NULL, DSFLIP_WAITFORSYNC);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
736 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
737
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
738 static int DirectFB_LockHWSurface(_THIS, SDL_Surface *surface)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
739 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
740 DFBResult ret;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
741 void *data;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
742 int pitch;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
743
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
744 ret = surface->hwdata->surface->Lock (surface->hwdata->surface,
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
745 DSLF_WRITE, &data, &pitch);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
746 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
747 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
748 SetDirectFBerror ("surface->Lock", ret);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
749 return -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
750 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
751
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
752 surface->pixels = data;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
753 surface->pitch = pitch;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
754
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
755 return 0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
756 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
757
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
758 static void DirectFB_UnlockHWSurface(_THIS, SDL_Surface *surface)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
759 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
760 surface->hwdata->surface->Unlock (surface->hwdata->surface);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
761 surface->pixels = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
762 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
763
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
764 static void DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
765 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
766 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
767
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
768 static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect *rects)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
769 {
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
770 DFBRegion region;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
771 int i;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
772 int region_valid = 0;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
773 IDirectFBSurface *surface = this->screen->hwdata->surface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
774
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
775 for (i=0; i<numrects; ++i)
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
776 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
777 int x2, y2;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
778
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
779 if ( ! rects[i].w ) /* Clipped? */
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
780 continue;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
781
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
782 x2 = rects[i].x + rects[i].w - 1;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
783 y2 = rects[i].y + rects[i].h - 1;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
784
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
785 if (region_valid)
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
786 {
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
787 if (rects[i].x < region.x1)
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
788 region.x1 = rects[i].x;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
789
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
790 if (rects[i].y < region.y1)
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
791 region.y1 = rects[i].y;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
792
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
793 if (x2 > region.x2)
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
794 region.x2 = x2;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
795
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
796 if (y2 > region.y2)
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
797 region.y2 = y2;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
798 }
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
799 else
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
800 {
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
801 region.x1 = rects[i].x;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
802 region.y1 = rects[i].y;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
803 region.x2 = x2;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
804 region.y2 = y2;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
805
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
806 region_valid = 1;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
807 }
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
808 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
809
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
810 if (region_valid)
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
811 surface->Flip (surface, &region, DSFLIP_WAITFORSYNC);
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
812 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
813
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
814 int DirectFB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
815 {
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
816 IDirectFBPalette *palette = this->screen->hwdata->palette;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
817
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
818 if (!palette)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
819 return 0;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
820
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
821 if (firstcolor > 255)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
822 return 0;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
823
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
824 if (firstcolor + ncolors > 256)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
825 ncolors = 256 - firstcolor;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
826
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
827 if (ncolors > 0)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
828 {
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
829 int i;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
830 DFBColor entries[ncolors];
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
831
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
832 for (i=0; i<ncolors; i++)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
833 {
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
834 entries[i].a = 0xff;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
835 entries[i].r = colors[i].r;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
836 entries[i].g = colors[i].g;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
837 entries[i].b = colors[i].b;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
838 }
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
839
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
840 palette->SetEntries (palette, entries, ncolors, firstcolor);
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
841 }
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
842
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
843 return 1;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
844 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
845
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
846 void DirectFB_VideoQuit(_THIS)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
847 {
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
848 struct DirectFBEnumRect *rect = enumlist;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
849 IDirectFBSurface *surface = this->screen->hwdata->surface;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
850 IDirectFBPalette *palette = this->screen->hwdata->palette;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
851
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
852 if (palette)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
853 palette->Release (palette);
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
854
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
855 if (surface)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
856 surface->Release (surface);
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
857
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
858 this->screen->hwdata->surface = NULL;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
859 this->screen->hwdata->palette = NULL;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
860
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
861 if (HIDDEN->eventbuffer)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
862 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
863 HIDDEN->eventbuffer->Release (HIDDEN->eventbuffer);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
864 HIDDEN->eventbuffer = NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
865 }
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
866
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
867 if (HIDDEN->layer)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
868 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
869 HIDDEN->layer->Release (HIDDEN->layer);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
870 HIDDEN->layer = NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
871 }
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
872
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
873 if (HIDDEN->dfb)
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
874 {
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
875 HIDDEN->dfb->Release (HIDDEN->dfb);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
876 HIDDEN->dfb = NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
877 }
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
878
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
879 /* Free video mode list */
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
880 if (HIDDEN->modelist)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
881 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
882 free (HIDDEN->modelist);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
883 HIDDEN->modelist = NULL;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
884 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
885
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
886 /* Free mode enumeration list */
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
887 while (rect)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
888 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
889 struct DirectFBEnumRect *next = rect->next;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
890 free (rect);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
891 rect = next;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
892 }
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
893 enumlist = NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
894
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
895 HIDDEN->initialized = 0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
896 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
897
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
898 void DirectFB_FinalQuit(void)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
899 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
900 }