annotate src/video/directfb/SDL_DirectFB_video.c @ 477:22581630aab7

Date: Tue, 27 Aug 2002 16:14:11 +0200 From: Denis Oliver Kropp Subject: Palette support and 8bit color keying fix This patch adds support for 8bit palette modes dropping the RGB332 stuff. It also fixes color keying for 8bit. testsprite (without -bpp >8) looks correct again.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 31 Aug 2002 04:06:37 +0000
parents 1c4be4a16410
children f8482d7c9595
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"
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49
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 /* Initialization/Query functions */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 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
53 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
54 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
55 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
56 SDL_Color *colors);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 static void DirectFB_VideoQuit(_THIS);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 /* Hardware surface functions */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 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
61 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
62 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
63 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
64 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
65 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
66 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
67 SDL_Surface *dst, SDL_Rect *dstrect);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 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
69 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
70 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
71
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 /* Various screen update functions available */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 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
74 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
75
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 /* This is the rect EnumModes2 uses */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 struct DirectFBEnumRect {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 SDL_Rect r;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 struct DirectFBEnumRect* next;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 };
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
82 static struct DirectFBEnumRect *enumlist = NULL;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83
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 /* DirectFB driver bootstrap functions */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 static int DirectFB_Available(void)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 return 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 }
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 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
93 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 free(device->hidden);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 free(device);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 }
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 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
99 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 SDL_VideoDevice *device;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 /* 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
103 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
104 if (device)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 memset (device, 0, (sizeof *device));
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 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
108 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 if (device == NULL || device->hidden == NULL)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 SDL_OutOfMemory();
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 if (device)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 free (device);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 return(0);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 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
119
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 /* Set the function pointers */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 device->VideoInit = DirectFB_VideoInit;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 device->ListModes = DirectFB_ListModes;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 device->SetVideoMode = DirectFB_SetVideoMode;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 device->SetColors = DirectFB_SetColors;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 device->UpdateRects = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 device->VideoQuit = DirectFB_VideoQuit;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 device->AllocHWSurface = DirectFB_AllocHWSurface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 device->CheckHWBlit = DirectFB_CheckHWBlit;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 device->FillHWRect = DirectFB_FillHWRect;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 device->SetHWColorKey = DirectFB_SetHWColorKey;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 device->SetHWAlpha = DirectFB_SetHWAlpha;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 device->LockHWSurface = DirectFB_LockHWSurface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 device->UnlockHWSurface = DirectFB_UnlockHWSurface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 device->FlipHWSurface = DirectFB_FlipHWSurface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 device->FreeHWSurface = DirectFB_FreeHWSurface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 device->SetCaption = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 device->SetIcon = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 device->IconifyWindow = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 device->GrabInput = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 device->GetWMInfo = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 device->InitOSKeymap = DirectFB_InitOSKeymap;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 device->PumpEvents = DirectFB_PumpEvents;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 device->free = DirectFB_DeleteDevice;
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 return device;
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
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 VideoBootStrap DirectFB_bootstrap = {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 "directfb", "DirectFB",
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 DirectFB_Available, DirectFB_CreateDevice
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 };
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
154 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
155 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
156 DFBDisplayLayerConfig dlc;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
157 int bytes = (bpp + 7) / 8;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
158
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
159 layer->GetConfiguration (layer, &dlc);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
160
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
161 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
162 return dlc.pixelformat;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
163
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
164 switch (bytes)
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 case 1:
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
167 return DSPF_LUT8;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
168 case 2:
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
169 return DSPF_RGB16;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
170 case 3:
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
171 return DSPF_RGB24;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
172 case 4:
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
173 return DSPF_RGB32;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
174 }
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
175
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
176 return DSPF_UNKNOWN;
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
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 static DFBEnumerationResult EnumModesCallback (unsigned int width,
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 unsigned int height,
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 unsigned int bpp,
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 void *data)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 SDL_VideoDevice *this = (SDL_VideoDevice *)data;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 struct DirectFBEnumRect *enumrect;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
187 HIDDEN->nummodes++;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
188
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
189 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
190 if (!enumrect)
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 {
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
192 SDL_OutOfMemory();
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
193 return DFENUM_CANCEL;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
196 enumrect->r.w = width;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
197 enumrect->r.h = height;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
198 enumrect->next = enumlist;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
199
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
200 enumlist = enumrect;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
201
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 return DFENUM_OK;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 struct private_hwdata {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 IDirectFBSurface *surface;
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
207 IDirectFBPalette *palette;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 };
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 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
211 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 const char *error = DirectFBErrorString (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 if (error)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 SDL_SetError("%s: %s", function, error);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 else
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 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
218 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 static DFBSurfacePixelFormat SDLToDFBPixelFormat (SDL_PixelFormat *format)
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 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
223 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 switch (format->BitsPerPixel)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 {
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
226 case 8:
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
227 return DSPF_LUT8;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
228
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 case 16:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 if (format->Rmask == 0xF800 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 format->Gmask == 0x07E0 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 format->Bmask == 0x001F)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 return DSPF_RGB16;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 /* fall through */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 case 15:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 if (format->Rmask == 0x7C00 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 format->Gmask == 0x03E0 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 format->Bmask == 0x001F)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 return DSPF_RGB15;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 break;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 case 24:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 if (format->Rmask == 0xFF0000 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 format->Gmask == 0x00FF00 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 format->Bmask == 0x0000FF)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 return DSPF_RGB24;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 break;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
249
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 case 32:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 if (format->Rmask == 0xFF0000 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 format->Gmask == 0x00FF00 &&
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 format->Bmask == 0x0000FF)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 if (format->Amask == 0xFF000000)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 return DSPF_ARGB;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 else
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 return DSPF_RGB32;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 break;
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 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 else
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 switch (format->BitsPerPixel)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 {
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
267 case 8:
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
268 return DSPF_LUT8;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 case 15:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 return DSPF_RGB15;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 case 16:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 return DSPF_RGB16;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 case 24:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 return DSPF_RGB24;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 case 32:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 return DSPF_RGB32;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 }
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 return DSPF_UNKNOWN;
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
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
283 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
284 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
285 SDL_Palette *palette;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
286 SDL_Color *colors;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
287
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
288 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
289 if (!palette)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
290 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
291 SDL_OutOfMemory();
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
292 return NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
293 }
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
294
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
295 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
296 if (!colors)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
297 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
298 SDL_OutOfMemory();
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
299 return NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
300 }
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
301
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
302 palette->ncolors = size;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
303 palette->colors = colors;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
304
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
305 return palette;
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
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 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
309 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 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
311 format->BitsPerPixel = format->BytesPerPixel = 0;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 switch (pixelformat)
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 case DSPF_A8:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 format->Amask = 0x000000FF;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 break;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
318
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 case DSPF_RGB15:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 format->Rmask = 0x00007C00;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 format->Gmask = 0x000003E0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 format->Bmask = 0x0000001F;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 break;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
324
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 case DSPF_RGB16:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 format->Rmask = 0x0000F800;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 format->Gmask = 0x000007E0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 format->Bmask = 0x0000001F;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 break;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
330
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 case DSPF_ARGB:
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
332 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
333 /* fall through */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 case DSPF_RGB24:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 case DSPF_RGB32:
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 format->Rmask = 0x00FF0000;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 format->Gmask = 0x0000FF00;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 format->Bmask = 0x000000FF;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 break;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
340
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
341 case DSPF_LUT8:
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
342 format->Rmask = 0x000000FF;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
343 format->Gmask = 0x000000FF;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
344 format->Bmask = 0x000000FF;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
345
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
346 if (!format->palette)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
347 format->palette = AllocatePalette(256);
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
348 break;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
349
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 default:
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
351 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
352 return -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
355 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
356 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
357
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 return 0;
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
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 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
363 {
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
364 int i;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
365 DFBResult ret;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
366 DFBCardCapabilities caps;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
367 DFBDisplayLayerConfig dlc;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
368 struct DirectFBEnumRect *rect;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
369 IDirectFB *dfb = NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
370 IDirectFBDisplayLayer *layer = NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
371 IDirectFBEventBuffer *events = NULL;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 ret = DirectFBInit (NULL, NULL);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 SetDirectFBerror ("DirectFBInit", ret);
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
378 goto error;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 ret = DirectFBCreate (&dfb);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 SetDirectFBerror ("DirectFBCreate", ret);
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
385 goto error;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 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
389 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 SetDirectFBerror ("dfb->GetDisplayLayer", ret);
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
392 goto error;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
395 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
396 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 {
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
398 SetDirectFBerror ("dfb->CreateEventBuffer", ret);
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
399 goto error;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 layer->EnableCursor (layer, 1);
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 /* 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
405 layer->GetConfiguration (layer, &dlc);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
407 /* 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
408 if (DFBToSDLPixelFormat (dlc.pixelformat, vformat))
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
409 DFBToSDLPixelFormat (DSPF_LUT8, vformat);
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 /* Enumerate the available fullscreen modes */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 ret = dfb->EnumVideoModes (dfb, EnumModesCallback, this);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 SetDirectFBerror ("dfb->EnumVideoModes", ret);
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
416 goto error;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 }
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
418
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
419 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
420 if (!HIDDEN->modelist)
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 {
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
422 SDL_OutOfMemory();
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
423 goto error;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
426 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
427 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
428 HIDDEN->modelist[i] = &rect->r;
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
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
431 HIDDEN->modelist[i] = NULL;
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
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 /* 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
435 dfb->GetCardCapabilities (dfb, &caps);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 this->info.wm_available = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 this->info.hw_available = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 this->info.blit_hw = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 this->info.blit_hw_CC = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 this->info.blit_hw_A = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442 this->info.blit_fill = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 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
444
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 HIDDEN->initialized = 1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 HIDDEN->dfb = dfb;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 HIDDEN->layer = layer;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
448 HIDDEN->eventbuffer = events;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450 return 0;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
451
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
452 error:
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
453 if (events)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
454 events->Release (events);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
455
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
456 if (layer)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
457 layer->Release (layer);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
458
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
459 if (dfb)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
460 dfb->Release (dfb);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
461
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
462 return -1;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
463 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 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
466 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 if (flags & SDL_FULLSCREEN)
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
468 return HIDDEN->modelist;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 else
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470 if (SDLToDFBPixelFormat (format) != DSPF_UNKNOWN)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 return (SDL_Rect**) -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 return NULL;
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
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
476 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
477 {
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
478 DFBResult ret;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
479 DFBSurfaceDescription dsc;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
480 DFBSurfacePixelFormat pixelformat;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
481 IDirectFBSurface *surface;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483 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
484 width, height, bpp, flags);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486 flags |= SDL_FULLSCREEN;
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 /* Release previous primary surface */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 if (current->hwdata && current->hwdata->surface)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491 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
492 current->hwdata->surface = NULL;
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
493
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
494 /* And its palette if present */
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
495 if (current->hwdata->palette)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
496 {
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
497 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
498 current->hwdata->palette = NULL;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
499 }
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 else if (!current->hwdata)
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 /* 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
504 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
505 if (!current->hwdata)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 SDL_OutOfMemory();
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508 return NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
510 }
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 /* 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
513 if (flags & SDL_FULLSCREEN)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 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
516 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
517 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518 DirectFBError ("dfb->SetCooperativeLevel", ret);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 flags &= ~SDL_FULLSCREEN;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522 else
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523 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
524
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
525 /* Set video mode */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
526 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
527 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
529 if (flags & SDL_FULLSCREEN)
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 flags &= ~SDL_FULLSCREEN;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 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
533 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
534 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
535
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536 if (ret)
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 SetDirectFBerror ("dfb->SetVideoMode", ret);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 return NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 }
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 /* Create primary surface */
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
544 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
545 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
546 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
547
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
548 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
549 if (ret && (flags & SDL_DOUBLEBUF))
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
551 /* Try without double buffering */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552 dsc.caps &= ~DSCAPS_FLIPPING;
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
553 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
554 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
555 if (ret)
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 SetDirectFBerror ("dfb->CreateSurface", ret);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 return NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
559 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561 current->w = width;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
562 current->h = height;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
563 current->flags = SDL_HWSURFACE | SDL_PREALLOC;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
564
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565 if (flags & SDL_FULLSCREEN)
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 current->flags |= SDL_FULLSCREEN;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
568 this->UpdateRects = DirectFB_DirectUpdate;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
570 else
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
571 this->UpdateRects = DirectFB_WindowedUpdate;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
572
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
573 if (dsc.caps & DSCAPS_FLIPPING)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
574 current->flags |= SDL_DOUBLEBUF;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
575
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
576 surface->GetPixelFormat (surface, &pixelformat);
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
577
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
578 DFBToSDLPixelFormat (pixelformat, current->format);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
579
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
580 /* 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
581 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
582 {
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
583 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
584
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
585 current->flags |= SDL_HWPALETTE;
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
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
588 current->hwdata->surface = surface;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
589
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
590 return current;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
591 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 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
594 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
595 DFBResult ret;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596 DFBSurfaceDescription dsc;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
597
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
598 /* 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
599 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
600
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
601 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
602 return -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
603
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
604 /* fill surface description */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
605 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
606 dsc.width = surface->w;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
607 dsc.height = surface->h;
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
608 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
609
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
610 /* find the right pixelformat */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
611 dsc.pixelformat = SDLToDFBPixelFormat (surface->format);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
612 if (dsc.pixelformat == DSPF_UNKNOWN)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 return -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
614
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
615 /* 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
616 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
617 if (surface->hwdata == NULL)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
618 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
619 SDL_OutOfMemory();
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
620 return -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
621 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
622
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
623 /* Create the surface */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
624 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
625 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
626 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627 SetDirectFBerror ("dfb->CreateSurface", ret);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
628 free (surface->hwdata);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
629 surface->hwdata = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
630 return -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
631 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
632
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
633 surface->flags |= SDL_HWSURFACE | SDL_PREALLOC;
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 return 0;
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
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
638 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
639 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
640 if (surface->hwdata && HIDDEN->initialized)
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 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
643 free (surface->hwdata);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
644 surface->hwdata = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
645 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
646 }
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 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
649 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
650 /* 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
651 src->hwdata, dst->hwdata);*/
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
652
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
653 if (!src->hwdata || !dst->hwdata)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
654 return 0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
655
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
656 src->flags |= SDL_HWACCEL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
657 src->map->hw_blit = DirectFB_HWAccelBlit;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
658
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
659 return 1;
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
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
662 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
663 SDL_Surface *dst, SDL_Rect *dstrect)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
664 {
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
665 DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
167
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 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
668 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
669
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
670 IDirectFBSurface *surface = dst->hwdata->surface;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
671
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
672 if (src->flags & SDL_SRCCOLORKEY)
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 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
675 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
676 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
677
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
678 if (src->flags & SDL_SRCALPHA)
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 flags |= DSBLIT_BLEND_COLORALPHA;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
681 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
682 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
683
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
684 surface->SetBlittingFlags (surface, flags);
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 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
687 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
688 else
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
689 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
690
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
691 return 0;
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
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
694 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
695 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
696 SDL_PixelFormat *fmt = dst->format;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
697 IDirectFBSurface *surface = dst->hwdata->surface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
698
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
699 /* ugly */
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
700 surface->SetColor (surface,
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
701 (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
702 (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
703 (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
704 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
705
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
706 return 0;
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
219
f928da36f0e9 Updated SDL DirectFB backend for DirectFB version 0.9.7
Sam Lantinga <slouken@libsdl.org>
parents: 167
diff changeset
709 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
710 {
219
f928da36f0e9 Updated SDL DirectFB backend for DirectFB version 0.9.7
Sam Lantinga <slouken@libsdl.org>
parents: 167
diff changeset
711 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
712 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
713
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
714 if (fmt->BitsPerPixel == 8)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
715 surface->SetSrcColorKeyIndex (surface, key);
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
716 else
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
717 /* ugly */
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
718 surface->SetSrcColorKey (surface,
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
719 (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
720 (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
721 (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
722
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
723 return 0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
724 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
725
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
726 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
727 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
728 return 0;
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
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
731 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
732 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
733 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
734 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
735
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
736 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
737 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
738 DFBResult ret;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
739 void *data;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
740 int pitch;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
741
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
742 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
743 DSLF_WRITE, &data, &pitch);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
744 if (ret)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
745 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
746 SetDirectFBerror ("surface->Lock", ret);
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
747 return -1;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
748 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
749
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
750 surface->pixels = data;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
751 surface->pitch = pitch;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
752
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
753 return 0;
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
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
756 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
757 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
758 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
759 surface->pixels = NULL;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
760 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
761
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
762 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
763 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
764 }
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 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
767 {
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
768 DFBRegion region;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
769 int i;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
770 int region_valid = 0;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
771 IDirectFBSurface *surface = this->screen->hwdata->surface;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
772
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
773 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
774 {
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
775 int x2, y2;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
776
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
777 if ( ! rects[i].w ) /* Clipped? */
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
778 continue;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
779
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
780 x2 = rects[i].x + rects[i].w - 1;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
781 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
782
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
783 if (region_valid)
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
784 {
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
785 if (rects[i].x < region.x1)
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
786 region.x1 = rects[i].x;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
787
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
788 if (rects[i].y < region.y1)
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
789 region.y1 = rects[i].y;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
790
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
791 if (x2 > region.x2)
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
792 region.x2 = x2;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
793
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
794 if (y2 > region.y2)
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
795 region.y2 = y2;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
796 }
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
797 else
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 region.x1 = rects[i].x;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
800 region.y1 = rects[i].y;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
801 region.x2 = x2;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
802 region.y2 = y2;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
803
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
804 region_valid = 1;
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
805 }
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
806 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
807
286
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
808 if (region_valid)
3ea69fd0b095 Updated for DirectFB 0.9.9
Sam Lantinga <slouken@libsdl.org>
parents: 259
diff changeset
809 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
810 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
811
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
812 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
813 {
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
814 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
815
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
816 if (!palette)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
817 return 0;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
818
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
819 if (firstcolor > 255)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
820 return 0;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
821
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
822 if (firstcolor + ncolors > 256)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
823 ncolors = 256 - firstcolor;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
824
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
825 if (ncolors > 0)
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 int i;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
828 DFBColor entries[ncolors];
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
829
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
830 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
831 {
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
832 entries[i].a = 0xff;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
833 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
834 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
835 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
836 }
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
837
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
838 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
839 }
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
840
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
841 return 1;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
842 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
843
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
844 void DirectFB_VideoQuit(_THIS)
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
845 {
477
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
846 struct DirectFBEnumRect *rect = enumlist;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
847 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
848 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
849
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
850 if (palette)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
851 palette->Release (palette);
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
852
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
853 if (surface)
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
854 surface->Release (surface);
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
855
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
856 this->screen->hwdata->surface = NULL;
22581630aab7 Date: Tue, 27 Aug 2002 16:14:11 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 464
diff changeset
857 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
858
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
859 if (HIDDEN->eventbuffer)
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 HIDDEN->eventbuffer->Release (HIDDEN->eventbuffer);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
862 HIDDEN->eventbuffer = NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
863 }
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
864
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
865 if (HIDDEN->layer)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
866 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
867 HIDDEN->layer->Release (HIDDEN->layer);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
868 HIDDEN->layer = NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
869 }
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
870
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
871 if (HIDDEN->dfb)
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 HIDDEN->dfb->Release (HIDDEN->dfb);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
874 HIDDEN->dfb = NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
875 }
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
876
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
877 /* Free video mode list */
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
878 if (HIDDEN->modelist)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
879 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
880 free (HIDDEN->modelist);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
881 HIDDEN->modelist = NULL;
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
882 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
883
464
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
884 /* Free mode enumeration list */
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
885 while (rect)
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
886 {
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
887 struct DirectFBEnumRect *next = rect->next;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
888 free (rect);
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
889 rect = next;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
890 }
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
891 enumlist = NULL;
1c4be4a16410 Date: Fri, 23 Aug 2002 11:48:56 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
892
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
893 HIDDEN->initialized = 0;
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
894 }
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
895
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
896 void DirectFB_FinalQuit(void)
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 }