Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
1178 lines (965 loc) · 34 KB

SDL_DirectFB_video.c

File metadata and controls

1178 lines (965 loc) · 34 KB
 
Feb 1, 2006
Feb 1, 2006
2
3
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Feb 1, 2006
Feb 1, 2006
5
6
7
8
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
Feb 1, 2006
Feb 1, 2006
10
11
12
13
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
Feb 1, 2006
Feb 1, 2006
15
16
17
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Feb 1, 2006
Feb 1, 2006
19
20
Sam Lantinga
slouken@libsdl.org
Oct 3, 2003
Oct 3, 2003
21
22
23
24
MGA CRTC2 support by Thomas Jarosch - tomj@simonv.com
CRTC2 support is inspired by mplayer's dfbmga driver
written by Ville Syrj��<syrjala@sci.fi>
Feb 21, 2006
Feb 21, 2006
26
#include "SDL_config.h"
27
28
29
30
31
32
33
34
35
/* DirectFB video driver implementation.
*/
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <directfb.h>
Nov 1, 2005
Nov 1, 2005
36
#include <directfb_version.h>
37
38
39
#include "SDL_video.h"
#include "SDL_mouse.h"
Feb 16, 2006
Feb 16, 2006
40
41
42
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
43
44
#include "SDL_DirectFB_video.h"
#include "SDL_DirectFB_events.h"
Aug 31, 2002
Aug 31, 2002
45
#include "SDL_DirectFB_yuv.h"
Jan 4, 2004
Jan 4, 2004
47
/* The implementation dependent data for the window manager cursor */
May 28, 2006
May 28, 2006
48
49
50
struct WMcursor
{
int unused;
Jan 4, 2004
Jan 4, 2004
51
52
};
53
54
/* Initialization/Query functions */
May 29, 2006
May 29, 2006
55
56
57
58
59
60
61
62
63
static int DirectFB_VideoInit(_THIS, SDL_PixelFormat * vformat);
static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat * format,
Uint32 flags);
static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface * current,
int width, int height, int bpp,
Uint32 flags);
static int DirectFB_SetColors(_THIS, int firstcolor, int ncolors,
SDL_Color * colors);
static void DirectFB_VideoQuit(_THIS);
64
65
/* Hardware surface functions */
May 29, 2006
May 29, 2006
66
67
68
69
70
71
72
73
74
75
76
77
78
static int DirectFB_AllocHWSurface(_THIS, SDL_Surface * surface);
static int DirectFB_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect,
Uint32 color);
static int DirectFB_LockHWSurface(_THIS, SDL_Surface * surface);
static void DirectFB_UnlockHWSurface(_THIS, SDL_Surface * surface);
static void DirectFB_FreeHWSurface(_THIS, SDL_Surface * surface);
static int DirectFB_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst);
static int DirectFB_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect);
static int DirectFB_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key);
static int DirectFB_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha);
static int DirectFB_FlipHWSurface(_THIS, SDL_Surface * surface);
static int DirectFB_ShowWMCursor(_THIS, WMcursor * cursor);
79
80
/* Various screen update functions available */
May 29, 2006
May 29, 2006
81
82
static void DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect * rects);
static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect * rects);
83
84
/* This is the rect EnumModes2 uses */
May 28, 2006
May 28, 2006
85
86
87
88
struct DirectFBEnumRect
{
SDL_Rect r;
struct DirectFBEnumRect *next;
Aug 24, 2002
Aug 24, 2002
91
static struct DirectFBEnumRect *enumlist = NULL;
92
93
94
95
/* DirectFB driver bootstrap functions */
May 28, 2006
May 28, 2006
96
static int
May 29, 2006
May 29, 2006
97
DirectFB_Available(void)
May 28, 2006
May 28, 2006
99
return 1;
May 28, 2006
May 28, 2006
102
static void
May 29, 2006
May 29, 2006
103
DirectFB_DeleteDevice(SDL_VideoDevice * device)
May 29, 2006
May 29, 2006
105
106
SDL_free(device->hidden);
SDL_free(device);
May 28, 2006
May 28, 2006
109
static SDL_VideoDevice *
May 29, 2006
May 29, 2006
110
DirectFB_CreateDevice(int devindex)
May 28, 2006
May 28, 2006
112
113
114
SDL_VideoDevice *device;
/* Initialize all variables that we clean on shutdown */
May 29, 2006
May 29, 2006
115
device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
May 28, 2006
May 28, 2006
116
if (device) {
May 29, 2006
May 29, 2006
117
SDL_memset(device, 0, (sizeof *device));
May 28, 2006
May 28, 2006
118
device->hidden = (struct SDL_PrivateVideoData *)
May 29, 2006
May 29, 2006
119
malloc(sizeof(*device->hidden));
May 28, 2006
May 28, 2006
121
if (device == NULL || device->hidden == NULL) {
May 29, 2006
May 29, 2006
122
SDL_OutOfMemory();
May 28, 2006
May 28, 2006
123
if (device) {
May 29, 2006
May 29, 2006
124
free(device);
May 28, 2006
May 28, 2006
126
return (0);
May 29, 2006
May 29, 2006
128
SDL_memset(device->hidden, 0, sizeof(*device->hidden));
May 28, 2006
May 28, 2006
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* Set the function pointers */
device->VideoInit = DirectFB_VideoInit;
device->ListModes = DirectFB_ListModes;
device->SetVideoMode = DirectFB_SetVideoMode;
device->SetColors = DirectFB_SetColors;
device->UpdateRects = NULL;
device->CreateYUVOverlay = DirectFB_CreateYUVOverlay;
device->VideoQuit = DirectFB_VideoQuit;
device->AllocHWSurface = DirectFB_AllocHWSurface;
device->CheckHWBlit = DirectFB_CheckHWBlit;
device->FillHWRect = DirectFB_FillHWRect;
device->SetHWColorKey = DirectFB_SetHWColorKey;
device->SetHWAlpha = DirectFB_SetHWAlpha;
device->LockHWSurface = DirectFB_LockHWSurface;
device->UnlockHWSurface = DirectFB_UnlockHWSurface;
device->FlipHWSurface = DirectFB_FlipHWSurface;
device->FreeHWSurface = DirectFB_FreeHWSurface;
device->ShowWMCursor = DirectFB_ShowWMCursor;
device->SetCaption = NULL;
device->SetIcon = NULL;
device->IconifyWindow = NULL;
device->GrabInput = NULL;
device->GetWMInfo = NULL;
device->InitOSKeymap = DirectFB_InitOSKeymap;
device->PumpEvents = DirectFB_PumpEvents;
device->free = DirectFB_DeleteDevice;
return device;
159
160
161
}
VideoBootStrap DirectFB_bootstrap = {
May 28, 2006
May 28, 2006
162
163
"directfb", "DirectFB",
DirectFB_Available, DirectFB_CreateDevice
May 28, 2006
May 28, 2006
166
static DFBSurfacePixelFormat
May 29, 2006
May 29, 2006
167
GetFormatForBpp(int bpp, IDirectFBDisplayLayer * layer)
Aug 24, 2002
Aug 24, 2002
168
{
May 28, 2006
May 28, 2006
169
170
DFBDisplayLayerConfig dlc;
int bytes = (bpp + 7) / 8;
Aug 24, 2002
Aug 24, 2002
171
May 29, 2006
May 29, 2006
172
layer->GetConfiguration(layer, &dlc);
Aug 24, 2002
Aug 24, 2002
173
May 29, 2006
May 29, 2006
174
if (bytes == DFB_BYTES_PER_PIXEL(dlc.pixelformat) && bytes > 1)
May 28, 2006
May 28, 2006
175
return dlc.pixelformat;
Aug 24, 2002
Aug 24, 2002
176
May 28, 2006
May 28, 2006
177
switch (bytes) {
Aug 24, 2002
Aug 24, 2002
178
case 1:
May 28, 2006
May 28, 2006
179
return DSPF_LUT8;
Aug 24, 2002
Aug 24, 2002
180
case 2:
May 28, 2006
May 28, 2006
181
return DSPF_RGB16;
Aug 24, 2002
Aug 24, 2002
182
case 3:
May 28, 2006
May 28, 2006
183
return DSPF_RGB24;
Aug 24, 2002
Aug 24, 2002
184
case 4:
May 28, 2006
May 28, 2006
185
return DSPF_RGB32;
Aug 24, 2002
Aug 24, 2002
186
187
}
May 28, 2006
May 28, 2006
188
return DSPF_UNKNOWN;
Aug 24, 2002
Aug 24, 2002
189
190
}
May 28, 2006
May 28, 2006
191
static DFBEnumerationResult
May 29, 2006
May 29, 2006
192
EnumModesCallback(int width, int height, int bpp, void *data)
May 28, 2006
May 28, 2006
194
195
SDL_VideoDevice *this = (SDL_VideoDevice *) data;
struct DirectFBEnumRect *enumrect;
May 28, 2006
May 28, 2006
197
HIDDEN->nummodes++;
Aug 24, 2002
Aug 24, 2002
198
May 28, 2006
May 28, 2006
199
200
if (enumlist && enumlist->r.w == width && enumlist->r.h == height)
return DFENUM_OK;
May 17, 2006
May 17, 2006
201
May 29, 2006
May 29, 2006
202
enumrect = SDL_calloc(1, sizeof(struct DirectFBEnumRect));
May 28, 2006
May 28, 2006
203
if (!enumrect) {
May 29, 2006
May 29, 2006
204
SDL_OutOfMemory();
May 28, 2006
May 28, 2006
205
return DFENUM_CANCEL;
May 28, 2006
May 28, 2006
208
209
210
enumrect->r.w = (Uint16) width;
enumrect->r.h = (Uint16) height;
enumrect->next = enumlist;
Aug 24, 2002
Aug 24, 2002
211
May 28, 2006
May 28, 2006
212
enumlist = enumrect;
Aug 24, 2002
Aug 24, 2002
213
May 28, 2006
May 28, 2006
214
return DFENUM_OK;
May 28, 2006
May 28, 2006
217
218
219
220
struct private_hwdata
{
IDirectFBSurface *surface;
IDirectFBPalette *palette;
May 28, 2006
May 28, 2006
223
void
May 29, 2006
May 29, 2006
224
SetDirectFBerror(const char *function, DFBResult code)
May 29, 2006
May 29, 2006
226
const char *error = DirectFBErrorString(code);
May 28, 2006
May 28, 2006
228
if (error)
May 29, 2006
May 29, 2006
229
SDL_SetError("%s: %s", function, error);
May 28, 2006
May 28, 2006
230
else
May 29, 2006
May 29, 2006
231
SDL_SetError("Unknown error code from %s", function);
May 28, 2006
May 28, 2006
234
static DFBSurfacePixelFormat
May 29, 2006
May 29, 2006
235
SDLToDFBPixelFormat(SDL_PixelFormat * format)
May 28, 2006
May 28, 2006
237
238
if (format->Rmask && format->Gmask && format->Bmask) {
switch (format->BitsPerPixel) {
Aug 31, 2002
Aug 31, 2002
239
case 8:
May 28, 2006
May 28, 2006
240
241
return DSPF_LUT8;
May 28, 2006
May 28, 2006
243
244
245
246
247
if (format->Rmask == 0xF800 &&
format->Gmask == 0x07E0 && format->Bmask == 0x001F)
return DSPF_RGB16;
/* fall through */
May 28, 2006
May 28, 2006
249
250
251
252
253
if (format->Rmask == 0x7C00 &&
format->Gmask == 0x03E0 && format->Bmask == 0x001F)
return DSPF_ARGB1555;
break;
May 28, 2006
May 28, 2006
255
256
257
258
if (format->Rmask == 0xFF0000 &&
format->Gmask == 0x00FF00 && format->Bmask == 0x0000FF)
return DSPF_RGB24;
break;
Aug 24, 2002
Aug 24, 2002
259
May 28, 2006
May 28, 2006
261
262
263
264
265
266
if (format->Rmask == 0xFF0000 &&
format->Gmask == 0x00FF00 && format->Bmask == 0x0000FF) {
if (format->Amask == 0xFF000000)
return DSPF_ARGB;
else
return DSPF_RGB32;
May 28, 2006
May 28, 2006
268
break;
May 28, 2006
May 28, 2006
270
271
} else {
switch (format->BitsPerPixel) {
Aug 24, 2002
Aug 24, 2002
272
case 8:
May 28, 2006
May 28, 2006
273
274
275
276
277
278
279
280
281
282
return DSPF_LUT8;
case 15:
return DSPF_ARGB1555;
case 16:
return DSPF_RGB16;
case 24:
return DSPF_RGB24;
case 32:
return DSPF_RGB32;
}
May 28, 2006
May 28, 2006
285
return DSPF_UNKNOWN;
May 28, 2006
May 28, 2006
288
static SDL_Palette *
May 29, 2006
May 29, 2006
289
AllocatePalette(int size)
Aug 24, 2002
Aug 24, 2002
290
{
May 28, 2006
May 28, 2006
291
292
293
SDL_Palette *palette;
SDL_Color *colors;
May 29, 2006
May 29, 2006
294
palette = SDL_calloc(1, sizeof(SDL_Palette));
May 28, 2006
May 28, 2006
295
if (!palette) {
May 29, 2006
May 29, 2006
296
SDL_OutOfMemory();
May 28, 2006
May 28, 2006
297
return NULL;
Aug 24, 2002
Aug 24, 2002
298
299
}
May 29, 2006
May 29, 2006
300
colors = SDL_calloc(size, sizeof(SDL_Color));
May 28, 2006
May 28, 2006
301
if (!colors) {
May 29, 2006
May 29, 2006
302
SDL_OutOfMemory();
May 28, 2006
May 28, 2006
303
return NULL;
Aug 24, 2002
Aug 24, 2002
304
305
}
May 28, 2006
May 28, 2006
306
307
palette->ncolors = size;
palette->colors = colors;
Aug 24, 2002
Aug 24, 2002
308
May 28, 2006
May 28, 2006
309
return palette;
Aug 24, 2002
Aug 24, 2002
310
311
}
May 28, 2006
May 28, 2006
312
static int
May 29, 2006
May 29, 2006
313
314
DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat,
SDL_PixelFormat * format)
May 28, 2006
May 28, 2006
316
317
format->Amask = format->Rmask = format->Gmask = format->Bmask = 0;
format->BitsPerPixel = format->BytesPerPixel = 0;
May 28, 2006
May 28, 2006
319
switch (pixelformat) {
320
case DSPF_A8:
May 28, 2006
May 28, 2006
321
322
format->Amask = 0x000000FF;
break;
Aug 24, 2002
Aug 24, 2002
323
Jan 28, 2004
Jan 28, 2004
324
case DSPF_ARGB1555:
May 28, 2006
May 28, 2006
325
326
327
328
format->Rmask = 0x00007C00;
format->Gmask = 0x000003E0;
format->Bmask = 0x0000001F;
break;
Aug 24, 2002
Aug 24, 2002
329
330
case DSPF_RGB16:
May 28, 2006
May 28, 2006
331
332
333
334
format->Rmask = 0x0000F800;
format->Gmask = 0x000007E0;
format->Bmask = 0x0000001F;
break;
Aug 24, 2002
Aug 24, 2002
335
336
case DSPF_ARGB:
May 28, 2006
May 28, 2006
337
338
format->Amask = 0; /* apps don't seem to like that: 0xFF000000; */
/* fall through */
339
340
case DSPF_RGB24:
case DSPF_RGB32:
May 28, 2006
May 28, 2006
341
342
343
344
format->Rmask = 0x00FF0000;
format->Gmask = 0x0000FF00;
format->Bmask = 0x000000FF;
break;
Aug 24, 2002
Aug 24, 2002
345
Aug 31, 2002
Aug 31, 2002
346
case DSPF_LUT8:
May 28, 2006
May 28, 2006
347
348
349
format->Rmask = 0x000000FF;
format->Gmask = 0x000000FF;
format->Bmask = 0x000000FF;
Aug 24, 2002
Aug 24, 2002
350
May 28, 2006
May 28, 2006
351
if (!format->palette)
May 29, 2006
May 29, 2006
352
format->palette = AllocatePalette(256);
May 28, 2006
May 28, 2006
353
break;
Aug 24, 2002
Aug 24, 2002
354
May 29, 2006
May 29, 2006
356
357
358
fprintf(stderr,
"SDL_DirectFB: Unsupported pixelformat (0x%08x)!\n",
pixelformat);
May 28, 2006
May 28, 2006
359
return -1;
May 29, 2006
May 29, 2006
362
363
format->BitsPerPixel = DFB_BYTES_PER_PIXEL(pixelformat) * 8;
format->BytesPerPixel = DFB_BYTES_PER_PIXEL(pixelformat);
May 28, 2006
May 28, 2006
365
return 0;
May 28, 2006
May 28, 2006
369
int
May 29, 2006
May 29, 2006
370
DirectFB_VideoInit(_THIS, SDL_PixelFormat * vformat)
May 28, 2006
May 28, 2006
372
373
int i;
DFBResult ret;
Nov 1, 2005
Nov 1, 2005
374
#if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)
May 28, 2006
May 28, 2006
375
DFBCardCapabilities caps;
Nov 1, 2005
Nov 1, 2005
376
#else
May 28, 2006
May 28, 2006
377
DFBGraphicsDeviceDescription caps;
Nov 1, 2005
Nov 1, 2005
378
#endif
May 28, 2006
May 28, 2006
379
380
381
382
383
384
385
386
387
388
DFBDisplayLayerConfig dlc;
struct DirectFBEnumRect *rect;
IDirectFB *dfb = NULL;
IDirectFBDisplayLayer *layer = NULL;
IDirectFBEventBuffer *events = NULL;
HIDDEN->c2layer = NULL, HIDDEN->c2frame = NULL;
HIDDEN->enable_mga_crtc2 = 0;
HIDDEN->mga_crtc2_stretch_overscan = 1;
May 29, 2006
May 29, 2006
389
ret = DirectFBInit(NULL, NULL);
May 28, 2006
May 28, 2006
390
if (ret) {
May 29, 2006
May 29, 2006
391
SetDirectFBerror("DirectFBInit", ret);
May 28, 2006
May 28, 2006
392
goto error;
May 29, 2006
May 29, 2006
395
ret = DirectFBCreate(&dfb);
May 28, 2006
May 28, 2006
396
if (ret) {
May 29, 2006
May 29, 2006
397
SetDirectFBerror("DirectFBCreate", ret);
May 28, 2006
May 28, 2006
398
goto error;
May 29, 2006
May 29, 2006
401
ret = dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer);
May 28, 2006
May 28, 2006
402
if (ret) {
May 29, 2006
May 29, 2006
403
SetDirectFBerror("dfb->GetDisplayLayer", ret);
May 28, 2006
May 28, 2006
404
goto error;
May 29, 2006
May 29, 2006
407
ret = dfb->CreateInputEventBuffer(dfb, DICAPS_ALL, DFB_FALSE, &events);
May 28, 2006
May 28, 2006
408
if (ret) {
May 29, 2006
May 29, 2006
409
SetDirectFBerror("dfb->CreateEventBuffer", ret);
May 28, 2006
May 28, 2006
410
goto error;
May 28, 2006
May 28, 2006
412
May 29, 2006
May 29, 2006
413
layer->EnableCursor(layer, 1);
May 28, 2006
May 28, 2006
414
415
/* Query layer configuration to determine the current mode and pixelformat */
May 29, 2006
May 29, 2006
416
layer->GetConfiguration(layer, &dlc);
May 28, 2006
May 28, 2006
417
418
/* If current format is not supported use LUT8 as the default */
May 29, 2006
May 29, 2006
419
420
if (DFBToSDLPixelFormat(dlc.pixelformat, vformat))
DFBToSDLPixelFormat(DSPF_LUT8, vformat);
May 28, 2006
May 28, 2006
421
422
/* Enumerate the available fullscreen modes */
May 29, 2006
May 29, 2006
423
ret = dfb->EnumVideoModes(dfb, EnumModesCallback, this);
May 28, 2006
May 28, 2006
424
if (ret) {
May 29, 2006
May 29, 2006
425
SetDirectFBerror("dfb->EnumVideoModes", ret);
May 28, 2006
May 28, 2006
426
goto error;
Aug 24, 2002
Aug 24, 2002
428
May 29, 2006
May 29, 2006
429
HIDDEN->modelist = SDL_calloc(HIDDEN->nummodes + 1, sizeof(SDL_Rect *));
May 28, 2006
May 28, 2006
430
if (!HIDDEN->modelist) {
May 29, 2006
May 29, 2006
431
SDL_OutOfMemory();
May 28, 2006
May 28, 2006
432
goto error;
Aug 24, 2002
Aug 24, 2002
433
434
}
May 28, 2006
May 28, 2006
435
436
for (i = 0, rect = enumlist; rect; ++i, rect = rect->next) {
HIDDEN->modelist[i] = &rect->r;
May 28, 2006
May 28, 2006
439
HIDDEN->modelist[i] = NULL;
Aug 24, 2002
Aug 24, 2002
440
441
May 28, 2006
May 28, 2006
442
/* Query card capabilities to get the video memory size */
Nov 1, 2005
Nov 1, 2005
443
#if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)
May 29, 2006
May 29, 2006
444
dfb->GetCardCapabilities(dfb, &caps);
Nov 1, 2005
Nov 1, 2005
445
#else
May 29, 2006
May 29, 2006
446
dfb->GetDeviceDescription(dfb, &caps);
Nov 1, 2005
Nov 1, 2005
447
#endif
May 28, 2006
May 28, 2006
449
450
451
452
453
454
455
456
457
458
459
460
461
this->info.wm_available = 1;
this->info.hw_available = 1;
this->info.blit_hw = 1;
this->info.blit_hw_CC = 1;
this->info.blit_hw_A = 1;
this->info.blit_fill = 1;
this->info.video_mem = caps.video_memory / 1024;
HIDDEN->initialized = 1;
HIDDEN->dfb = dfb;
HIDDEN->layer = layer;
HIDDEN->eventbuffer = events;
May 29, 2006
May 29, 2006
462
if (SDL_getenv("SDL_DIRECTFB_MGA_CRTC2") != NULL)
May 28, 2006
May 28, 2006
463
464
465
466
467
468
HIDDEN->enable_mga_crtc2 = 1;
if (HIDDEN->enable_mga_crtc2) {
DFBDisplayLayerConfig dlc;
DFBDisplayLayerConfigFlags failed;
May 29, 2006
May 29, 2006
469
ret = dfb->GetDisplayLayer(dfb, 2, &HIDDEN->c2layer);
May 28, 2006
May 28, 2006
470
if (ret) {
May 29, 2006
May 29, 2006
471
SetDirectFBerror("dfb->GetDisplayLayer(CRTC2)", ret);
May 28, 2006
May 28, 2006
472
goto error;
Oct 3, 2003
Oct 3, 2003
473
474
}
May 28, 2006
May 28, 2006
475
ret =
May 29, 2006
May 29, 2006
476
477
HIDDEN->layer->SetCooperativeLevel(HIDDEN->layer,
DLSCL_EXCLUSIVE);
May 28, 2006
May 28, 2006
478
479
480
481
if (ret) {
SetDirectFBerror
("layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret);
goto error;
Oct 3, 2003
Oct 3, 2003
482
}
May 28, 2006
May 28, 2006
483
484
ret =
May 29, 2006
May 29, 2006
485
486
HIDDEN->c2layer->SetCooperativeLevel(HIDDEN->c2layer,
DLSCL_EXCLUSIVE);
May 28, 2006
May 28, 2006
487
488
489
490
if (ret) {
SetDirectFBerror
("c2layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret);
goto error;
Oct 3, 2003
Oct 3, 2003
491
492
}
May 29, 2006
May 29, 2006
493
HIDDEN->c2layer->SetOpacity(HIDDEN->c2layer, 0x0);
May 28, 2006
May 28, 2006
494
495
496
497
498
499
500
/* Init the surface here as it got a fixed size */
dlc.flags = DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE;
dlc.buffermode = DLBM_BACKVIDEO;
dlc.pixelformat = DSPF_RGB32;
ret =
May 29, 2006
May 29, 2006
501
502
HIDDEN->c2layer->TestConfiguration(HIDDEN->c2layer, &dlc,
&failed);
May 28, 2006
May 28, 2006
503
if (ret) {
May 29, 2006
May 29, 2006
504
SetDirectFBerror("c2layer->TestConfiguration", ret);
May 28, 2006
May 28, 2006
505
goto error;
Oct 3, 2003
Oct 3, 2003
506
}
May 28, 2006
May 28, 2006
507
May 29, 2006
May 29, 2006
508
ret = HIDDEN->c2layer->SetConfiguration(HIDDEN->c2layer, &dlc);
May 28, 2006
May 28, 2006
509
if (ret) {
May 29, 2006
May 29, 2006
510
SetDirectFBerror("c2layer->SetConfiguration", ret);
May 28, 2006
May 28, 2006
511
goto error;
Oct 3, 2003
Oct 3, 2003
512
}
May 28, 2006
May 28, 2006
513
May 29, 2006
May 29, 2006
514
ret = HIDDEN->c2layer->GetSurface(HIDDEN->c2layer, &HIDDEN->c2frame);
May 28, 2006
May 28, 2006
515
if (ret) {
May 29, 2006
May 29, 2006
516
SetDirectFBerror("c2layer->GetSurface", ret);
May 28, 2006
May 28, 2006
517
goto error;
Oct 3, 2003
Oct 3, 2003
518
519
}
May 28, 2006
May 28, 2006
520
521
HIDDEN->c2framesize.x = 0;
HIDDEN->c2framesize.y = 0;
May 29, 2006
May 29, 2006
522
523
HIDDEN->c2frame->GetSize(HIDDEN->c2frame, &HIDDEN->c2framesize.w,
&HIDDEN->c2framesize.h);
May 28, 2006
May 28, 2006
524
May 29, 2006
May 29, 2006
525
526
HIDDEN->c2frame->SetBlittingFlags(HIDDEN->c2frame, DSBLIT_NOFX);
HIDDEN->c2frame->SetColor(HIDDEN->c2frame, 0, 0, 0, 0xff);
May 28, 2006
May 28, 2006
527
528
/* Clear CRTC2 */
May 29, 2006
May 29, 2006
529
530
531
532
533
HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff);
HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, 0);
HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff);
HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, 0);
HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff);
May 28, 2006
May 28, 2006
534
May 29, 2006
May 29, 2006
535
HIDDEN->c2layer->SetOpacity(HIDDEN->c2layer, 0xFF);
May 28, 2006
May 28, 2006
536
537
/* Check if overscan is possibly set */
May 29, 2006
May 29, 2006
538
if (SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN") != NULL) {
May 28, 2006
May 28, 2006
539
540
float overscan = 0;
if (SDL_sscanf
May 29, 2006
May 29, 2006
541
(SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN"), "%f",
May 28, 2006
May 28, 2006
542
543
544
545
546
&overscan) == 1)
if (overscan > 0 && overscan < 2)
HIDDEN->mga_crtc2_stretch_overscan = overscan;
}
#ifdef DIRECTFB_CRTC2_DEBUG
May 29, 2006
May 29, 2006
547
printf("CRTC2 overscan: %f\n", HIDDEN->mga_crtc2_stretch_overscan);
May 28, 2006
May 28, 2006
548
#endif
Oct 3, 2003
Oct 3, 2003
549
550
}
May 28, 2006
May 28, 2006
551
return 0;
Aug 24, 2002
Aug 24, 2002
552
May 28, 2006
May 28, 2006
553
554
error:
if (events)
May 29, 2006
May 29, 2006
555
events->Release(events);
Oct 3, 2003
Oct 3, 2003
556
May 28, 2006
May 28, 2006
557
if (HIDDEN->c2frame)
May 29, 2006
May 29, 2006
558
HIDDEN->c2frame->Release(HIDDEN->c2frame);
Oct 3, 2003
Oct 3, 2003
559
May 28, 2006
May 28, 2006
560
if (HIDDEN->c2layer)
May 29, 2006
May 29, 2006
561
HIDDEN->c2layer->Release(HIDDEN->c2layer);
Aug 24, 2002
Aug 24, 2002
562
May 28, 2006
May 28, 2006
563
if (layer)
May 29, 2006
May 29, 2006
564
layer->Release(layer);
Aug 24, 2002
Aug 24, 2002
565
May 28, 2006
May 28, 2006
566
if (dfb)
May 29, 2006
May 29, 2006
567
dfb->Release(dfb);
May 28, 2006
May 28, 2006
568
569
return -1;
May 28, 2006
May 28, 2006
572
static SDL_Rect **
May 29, 2006
May 29, 2006
573
DirectFB_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
May 28, 2006
May 28, 2006
575
576
if (flags & SDL_FULLSCREEN)
return HIDDEN->modelist;
May 29, 2006
May 29, 2006
577
else if (SDLToDFBPixelFormat(format) != DSPF_UNKNOWN)
May 28, 2006
May 28, 2006
578
return (SDL_Rect **) - 1;
May 28, 2006
May 28, 2006
580
return NULL;
May 28, 2006
May 28, 2006
583
static SDL_Surface *
May 29, 2006
May 29, 2006
584
585
DirectFB_SetVideoMode(_THIS, SDL_Surface * current, int width, int height,
int bpp, Uint32 flags)
May 28, 2006
May 28, 2006
587
588
589
590
591
DFBResult ret;
DFBSurfaceDescription dsc;
DFBSurfacePixelFormat pixelformat;
IDirectFBSurface *surface;
May 29, 2006
May 29, 2006
592
593
fprintf(stderr, "SDL DirectFB_SetVideoMode: %dx%d@%d, flags: 0x%08x\n",
width, height, bpp, flags);
May 28, 2006
May 28, 2006
594
595
596
597
598
flags |= SDL_FULLSCREEN;
/* Release previous primary surface */
if (current->hwdata && current->hwdata->surface) {
May 29, 2006
May 29, 2006
599
current->hwdata->surface->Release(current->hwdata->surface);
May 28, 2006
May 28, 2006
600
601
602
603
current->hwdata->surface = NULL;
/* And its palette if present */
if (current->hwdata->palette) {
May 29, 2006
May 29, 2006
604
current->hwdata->palette->Release(current->hwdata->palette);
May 28, 2006
May 28, 2006
605
606
607
608
609
current->hwdata->palette = NULL;
}
} else if (!current->hwdata) {
/* Allocate the hardware acceleration data */
current->hwdata =
May 29, 2006
May 29, 2006
610
(struct private_hwdata *) SDL_calloc(1, sizeof(*current->hwdata));
May 28, 2006
May 28, 2006
611
if (!current->hwdata) {
May 29, 2006
May 29, 2006
612
SDL_OutOfMemory();
May 28, 2006
May 28, 2006
613
return NULL;
Aug 31, 2002
Aug 31, 2002
614
}
May 28, 2006
May 28, 2006
617
618
/* Set cooperative level depending on flag SDL_FULLSCREEN */
if (flags & SDL_FULLSCREEN) {
May 29, 2006
May 29, 2006
619
ret = HIDDEN->dfb->SetCooperativeLevel(HIDDEN->dfb, DFSCL_FULLSCREEN);
May 28, 2006
May 28, 2006
620
if (ret && !HIDDEN->enable_mga_crtc2) {
May 29, 2006
May 29, 2006
621
DirectFBError("dfb->SetCooperativeLevel", ret);
May 28, 2006
May 28, 2006
622
flags &= ~SDL_FULLSCREEN;
May 28, 2006
May 28, 2006
624
} else
May 29, 2006
May 29, 2006
625
HIDDEN->dfb->SetCooperativeLevel(HIDDEN->dfb, DFSCL_NORMAL);
May 28, 2006
May 28, 2006
626
627
/* Set video mode */
May 29, 2006
May 29, 2006
628
ret = HIDDEN->dfb->SetVideoMode(HIDDEN->dfb, width, height, bpp);
May 28, 2006
May 28, 2006
629
630
631
if (ret) {
if (flags & SDL_FULLSCREEN) {
flags &= ~SDL_FULLSCREEN;
May 29, 2006
May 29, 2006
632
633
HIDDEN->dfb->SetCooperativeLevel(HIDDEN->dfb, DFSCL_NORMAL);
ret = HIDDEN->dfb->SetVideoMode(HIDDEN->dfb, width, height, bpp);
May 28, 2006
May 28, 2006
636
if (ret) {
May 29, 2006
May 29, 2006
637
SetDirectFBerror("dfb->SetVideoMode", ret);
May 28, 2006
May 28, 2006
638
return NULL;
May 28, 2006
May 28, 2006
642
643
644
645
/* Create primary surface */
dsc.flags = DSDESC_CAPS | DSDESC_PIXELFORMAT;
dsc.caps =
DSCAPS_PRIMARY | ((flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0);
May 29, 2006
May 29, 2006
646
dsc.pixelformat = GetFormatForBpp(bpp, HIDDEN->layer);
May 28, 2006
May 28, 2006
647
May 29, 2006
May 29, 2006
648
ret = HIDDEN->dfb->CreateSurface(HIDDEN->dfb, &dsc, &surface);
May 28, 2006
May 28, 2006
649
650
651
if (ret && (flags & SDL_DOUBLEBUF)) {
/* Try without double buffering */
dsc.caps &= ~DSCAPS_FLIPPING;
May 29, 2006
May 29, 2006
652
ret = HIDDEN->dfb->CreateSurface(HIDDEN->dfb, &dsc, &surface);
May 28, 2006
May 28, 2006
654
if (ret) {
May 29, 2006
May 29, 2006
655
SetDirectFBerror("dfb->CreateSurface", ret);
May 28, 2006
May 28, 2006
656
return NULL;
May 28, 2006
May 28, 2006
659
660
661
current->w = width;
current->h = height;
current->flags = SDL_HWSURFACE | SDL_PREALLOC;
May 28, 2006
May 28, 2006
663
664
665
666
667
if (flags & SDL_FULLSCREEN) {
current->flags |= SDL_FULLSCREEN;
this->UpdateRects = DirectFB_DirectUpdate;
} else
this->UpdateRects = DirectFB_WindowedUpdate;
May 28, 2006
May 28, 2006
669
670
if (dsc.caps & DSCAPS_FLIPPING)
current->flags |= SDL_DOUBLEBUF;
May 29, 2006
May 29, 2006
672
surface->GetPixelFormat(surface, &pixelformat);
Aug 31, 2002
Aug 31, 2002
673
May 29, 2006
May 29, 2006
674
DFBToSDLPixelFormat(pixelformat, current->format);
May 28, 2006
May 28, 2006
676
/* Get the surface palette (if supported) */
May 29, 2006
May 29, 2006
677
678
if (DFB_PIXELFORMAT_IS_INDEXED(pixelformat)) {
surface->GetPalette(surface, &current->hwdata->palette);
Aug 31, 2002
Aug 31, 2002
679
May 28, 2006
May 28, 2006
680
current->flags |= SDL_HWPALETTE;
Aug 31, 2002
Aug 31, 2002
681
682
}
May 28, 2006
May 28, 2006
683
current->hwdata->surface = surface;
Oct 3, 2003
Oct 3, 2003
684
May 28, 2006
May 28, 2006
685
686
687
688
689
690
691
692
693
694
695
696
697
/* MGA CRTC2 stuff */
if (HIDDEN->enable_mga_crtc2) {
/* no stretching if c2ssize == c2framesize */
HIDDEN->c2ssize.x = 0, HIDDEN->c2ssize.y = 0;
HIDDEN->c2ssize.w = width;
HIDDEN->c2ssize.h = height;
HIDDEN->c2dsize.x = 0, HIDDEN->c2dsize.y = 0;
HIDDEN->c2dsize.w = width;
HIDDEN->c2dsize.h = height;
HIDDEN->mga_crtc2_stretch = 0;
May 29, 2006
May 29, 2006
698
if (SDL_getenv("SDL_DIRECTFB_MGA_STRETCH") != NULL) {
May 28, 2006
May 28, 2006
699
700
701
702
703
704
705
706
707
708
709
710
711
/* Normally assume a picture aspect ratio of 4:3 */
int zoom_aspect_x = 4, zoom_aspect_y = 3, i, j;
for (i = 1; i < 20; i++) {
for (j = 1; j < 10; j++) {
if ((float) width / (float) i * (float) j == height) {
zoom_aspect_x = i;
zoom_aspect_y = j;
/* break the loop */
i = 21;
break;
}
Oct 3, 2003
Oct 3, 2003
712
}
May 28, 2006
May 28, 2006
713
}
Oct 3, 2003
Oct 3, 2003
714
May 28, 2006
May 28, 2006
715
716
717
718
#ifdef DIRECTFB_CRTC2_DEBUG
printf
("Source resolution: X: %d, Y: %d, Aspect ratio: %d:%d\n",
width, height, zoom_aspect_x, zoom_aspect_y);
May 29, 2006
May 29, 2006
719
720
printf("CRTC2 resolution: X: %d, Y: %d\n",
HIDDEN->c2framesize.w, HIDDEN->c2framesize.h);
May 28, 2006
May 28, 2006
721
#endif
Oct 3, 2003
Oct 3, 2003
722
May 28, 2006
May 28, 2006
723
724
725
726
727
728
729
730
731
732
733
734
/* don't stretch only slightly smaller/larger images */
if ((float) width < (float) HIDDEN->c2framesize.w * 0.95
|| (float) height < (float) HIDDEN->c2framesize.h * 0.95) {
while ((float) HIDDEN->c2dsize.w <
(float) HIDDEN->c2framesize.w *
HIDDEN->mga_crtc2_stretch_overscan
&& (float) HIDDEN->c2dsize.h <
(float) HIDDEN->c2framesize.h *
HIDDEN->mga_crtc2_stretch_overscan) {
HIDDEN->c2dsize.w += zoom_aspect_x;
HIDDEN->c2dsize.h += zoom_aspect_y;
}
Oct 3, 2003
Oct 3, 2003
735
May 28, 2006
May 28, 2006
736
737
738
/* one step down */
HIDDEN->c2dsize.w -= zoom_aspect_x;
HIDDEN->c2dsize.h -= zoom_aspect_y;
Oct 3, 2003
Oct 3, 2003
739
May 28, 2006
May 28, 2006
740
#ifdef DIRECTFB_CRTC2_DEBUG
May 29, 2006
May 29, 2006
741
742
printf("Stretched resolution: X: %d, Y: %d\n",
HIDDEN->c2dsize.w, HIDDEN->c2dsize.h);
May 28, 2006
May 28, 2006
743
#endif
May 28, 2006
May 28, 2006
745
746
747
748
749
750
751
752
753
754
755
756
757
HIDDEN->mga_crtc2_stretch = 1;
} else if ((float) width > (float) HIDDEN->c2framesize.w * 0.95
|| (float) height >
(float) HIDDEN->c2framesize.h * 0.95) {
while ((float) HIDDEN->c2dsize.w >
(float) HIDDEN->c2framesize.w *
HIDDEN->mga_crtc2_stretch_overscan
|| (float) HIDDEN->c2dsize.h >
(float) HIDDEN->c2framesize.h *
HIDDEN->mga_crtc2_stretch_overscan) {
HIDDEN->c2dsize.w -= zoom_aspect_x;
HIDDEN->c2dsize.h -= zoom_aspect_y;
}
May 28, 2006
May 28, 2006
759
#ifdef DIRECTFB_CRTC2_DEBUG
May 29, 2006
May 29, 2006
760
761
printf("Down-Stretched resolution: X: %d, Y: %d\n",
HIDDEN->c2dsize.w, HIDDEN->c2dsize.h);
May 28, 2006
May 28, 2006
762
#endif
May 28, 2006
May 28, 2006
764
765
766
HIDDEN->mga_crtc2_stretch = 1;
} else {
#ifdef DIRECTFB_CRTC2_DEBUG
May 29, 2006
May 29, 2006
767
printf("Not stretching image\n");
May 28, 2006
May 28, 2006
768
769
#endif
}
May 28, 2006
May 28, 2006
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
/* Panning */
if (HIDDEN->c2framesize.w > HIDDEN->c2dsize.w)
HIDDEN->c2dsize.x =
(HIDDEN->c2framesize.w - HIDDEN->c2dsize.w) / 2;
else
HIDDEN->c2dsize.x =
(HIDDEN->c2dsize.w - HIDDEN->c2framesize.w) / 2;
if (HIDDEN->c2framesize.h > HIDDEN->c2dsize.h)
HIDDEN->c2dsize.y =
(HIDDEN->c2framesize.h - HIDDEN->c2dsize.h) / 2;
else
HIDDEN->c2dsize.y =
(HIDDEN->c2dsize.h - HIDDEN->c2framesize.h) / 2;
#ifdef DIRECTFB_CRTC2_DEBUG
May 29, 2006
May 29, 2006
787
788
printf("CRTC2 position X: %d, Y: %d\n", HIDDEN->c2dsize.x,
HIDDEN->c2dsize.y);
May 28, 2006
May 28, 2006
789
790
791
#endif
}
}
May 28, 2006
May 28, 2006
793
794
return current;
}
May 28, 2006
May 28, 2006
796
static int
May 29, 2006
May 29, 2006
797
DirectFB_AllocHWSurface(_THIS, SDL_Surface * surface)
May 28, 2006
May 28, 2006
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
{
DFBResult ret;
DFBSurfaceDescription dsc;
/* fprintf(stderr, "SDL: DirectFB_AllocHWSurface (%dx%d@%d, flags: 0x%08x)\n",
surface->w, surface->h, surface->format->BitsPerPixel, surface->flags); */
if (surface->w < 8 || surface->h < 8)
return -1;
/* fill surface description */
dsc.flags =
DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
dsc.width = surface->w;
dsc.height = surface->h;
dsc.caps = (surface->flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0;
/* find the right pixelformat */
May 29, 2006
May 29, 2006
816
dsc.pixelformat = SDLToDFBPixelFormat(surface->format);
May 28, 2006
May 28, 2006
817
818
819
820
821
if (dsc.pixelformat == DSPF_UNKNOWN)
return -1;
/* Allocate the hardware acceleration data */
surface->hwdata =
May 29, 2006
May 29, 2006
822
(struct private_hwdata *) SDL_calloc(1, sizeof(*surface->hwdata));
May 28, 2006
May 28, 2006
823
if (surface->hwdata == NULL) {
May 29, 2006
May 29, 2006
824
SDL_OutOfMemory();
May 28, 2006
May 28, 2006
825
return -1;
May 28, 2006
May 28, 2006
828
829
/* Create the surface */
ret =
May 29, 2006
May 29, 2006
830
831
HIDDEN->dfb->CreateSurface(HIDDEN->dfb, &dsc,
&surface->hwdata->surface);
May 28, 2006
May 28, 2006
832
if (ret) {
May 29, 2006
May 29, 2006
833
834
SetDirectFBerror("dfb->CreateSurface", ret);
free(surface->hwdata);
May 28, 2006
May 28, 2006
835
836
surface->hwdata = NULL;
return -1;
May 28, 2006
May 28, 2006
839
surface->flags |= SDL_HWSURFACE | SDL_PREALLOC;
May 28, 2006
May 28, 2006
841
return 0;
May 28, 2006
May 28, 2006
844
static void
May 29, 2006
May 29, 2006
845
DirectFB_FreeHWSurface(_THIS, SDL_Surface * surface)
May 28, 2006
May 28, 2006
847
if (surface->hwdata && HIDDEN->initialized) {
May 29, 2006
May 29, 2006
848
849
surface->hwdata->surface->Release(surface->hwdata->surface);
free(surface->hwdata);
May 28, 2006
May 28, 2006
850
surface->hwdata = NULL;
May 28, 2006
May 28, 2006
854
static int
May 29, 2006
May 29, 2006
855
DirectFB_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst)
May 28, 2006
May 28, 2006
857
858
/* fprintf(stderr, "SDL: DirectFB_CheckHWBlit (src->hwdata: %p, dst->hwdata: %p)\n",
src->hwdata, dst->hwdata); */
May 28, 2006
May 28, 2006
860
861
if (!src->hwdata || !dst->hwdata)
return 0;
May 28, 2006
May 28, 2006
863
864
src->flags |= SDL_HWACCEL;
src->map->hw_blit = DirectFB_HWAccelBlit;
May 28, 2006
May 28, 2006
866
return 1;
May 28, 2006
May 28, 2006
869
static int
May 29, 2006
May 29, 2006
870
871
DirectFB_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect)
May 28, 2006
May 28, 2006
873
DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
May 28, 2006
May 28, 2006
875
876
DFBRectangle sr = { srcrect->x, srcrect->y, srcrect->w, srcrect->h };
DFBRectangle dr = { dstrect->x, dstrect->y, dstrect->w, dstrect->h };
May 28, 2006
May 28, 2006
878
IDirectFBSurface *surface = dst->hwdata->surface;
May 28, 2006
May 28, 2006
880
881
if (src->flags & SDL_SRCCOLORKEY) {
flags |= DSBLIT_SRC_COLORKEY;
May 29, 2006
May 29, 2006
882
DirectFB_SetHWColorKey(NULL, src, src->format->colorkey);
May 28, 2006
May 28, 2006
885
886
if (src->flags & SDL_SRCALPHA) {
flags |= DSBLIT_BLEND_COLORALPHA;
May 29, 2006
May 29, 2006
887
surface->SetColor(surface, 0xff, 0xff, 0xff, src->format->alpha);
May 29, 2006
May 29, 2006
890
surface->SetBlittingFlags(surface, flags);
May 28, 2006
May 28, 2006
892
if (sr.w == dr.w && sr.h == dr.h)
May 29, 2006
May 29, 2006
893
surface->Blit(surface, src->hwdata->surface, &sr, dr.x, dr.y);
May 28, 2006
May 28, 2006
894
else
May 29, 2006
May 29, 2006
895
surface->StretchBlit(surface, src->hwdata->surface, &sr, &dr);
May 28, 2006
May 28, 2006
897
return 0;
May 28, 2006
May 28, 2006
900
static int
May 29, 2006
May 29, 2006
901
902
DirectFB_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect,
Uint32 color)
May 28, 2006
May 28, 2006
904
905
SDL_PixelFormat *fmt = dst->format;
IDirectFBSurface *surface = dst->hwdata->surface;
May 28, 2006
May 28, 2006
907
/* ugly */
May 29, 2006
May 29, 2006
908
909
910
911
912
913
914
surface->SetColor(surface,
(color & fmt->Rmask) >> (fmt->Rshift - fmt->Rloss),
(color & fmt->Gmask) >> (fmt->Gshift - fmt->Gloss),
(color & fmt->Bmask) << (fmt->Bloss - fmt->Bshift),
0xFF);
surface->FillRectangle(surface, dstrect->x, dstrect->y, dstrect->w,
dstrect->h);
May 28, 2006
May 28, 2006
916
return 0;
May 28, 2006
May 28, 2006
919
static int
May 29, 2006
May 29, 2006
920
DirectFB_SetHWColorKey(_THIS, SDL_Surface * src, Uint32 key)
May 28, 2006
May 28, 2006
922
923
SDL_PixelFormat *fmt = src->format;
IDirectFBSurface *surface = src->hwdata->surface;
Nov 1, 2001
Nov 1, 2001
924
May 28, 2006
May 28, 2006
925
if (fmt->BitsPerPixel == 8)
May 29, 2006
May 29, 2006
926
surface->SetSrcColorKeyIndex(surface, key);
May 28, 2006
May 28, 2006
927
928
else
/* ugly */
May 29, 2006
May 29, 2006
929
930
931
932
933
934
935
surface->SetSrcColorKey(surface,
(key & fmt->Rmask) >> (fmt->Rshift -
fmt->Rloss),
(key & fmt->Gmask) >> (fmt->Gshift -
fmt->Gloss),
(key & fmt->Bmask) << (fmt->Bloss -
fmt->Bshift));
Nov 1, 2001
Nov 1, 2001
936
May 28, 2006
May 28, 2006
937
return 0;
May 28, 2006
May 28, 2006
940
static int
May 29, 2006
May 29, 2006
941
DirectFB_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha)
May 28, 2006
May 28, 2006
943
return 0;
May 28, 2006
May 28, 2006
946
static int
May 29, 2006
May 29, 2006
947
DirectFB_FlipHWSurface(_THIS, SDL_Surface * surface)
May 28, 2006
May 28, 2006
949
950
if (HIDDEN->enable_mga_crtc2) {
int rtn =
May 29, 2006
May 29, 2006
951
952
surface->hwdata->surface->Flip(surface->hwdata->surface, NULL,
0);
May 28, 2006
May 28, 2006
953
if (HIDDEN->mga_crtc2_stretch)
May 29, 2006
May 29, 2006
954
955
956
HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame,
surface->hwdata->surface,
&HIDDEN->c2ssize, &HIDDEN->c2dsize);
May 28, 2006
May 28, 2006
957
else
May 29, 2006
May 29, 2006
958
959
960
HIDDEN->c2frame->Blit(HIDDEN->c2frame,
surface->hwdata->surface, NULL,
HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
May 28, 2006
May 28, 2006
961
May 29, 2006
May 29, 2006
962
HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
May 28, 2006
May 28, 2006
963
964
return rtn;
} else
May 29, 2006
May 29, 2006
965
966
return surface->hwdata->surface->Flip(surface->hwdata->surface, NULL,
DSFLIP_WAITFORSYNC);
May 28, 2006
May 28, 2006
969
static int
May 29, 2006
May 29, 2006
970
DirectFB_LockHWSurface(_THIS, SDL_Surface * surface)
May 28, 2006
May 28, 2006
972
973
974
975
DFBResult ret;
void *data;
int pitch;
May 29, 2006
May 29, 2006
976
977
ret = surface->hwdata->surface->Lock(surface->hwdata->surface,
DSLF_WRITE, &data, &pitch);
May 28, 2006
May 28, 2006
978
if (ret) {
May 29, 2006
May 29, 2006
979
SetDirectFBerror("surface->Lock", ret);
May 28, 2006
May 28, 2006
980
return -1;
May 28, 2006
May 28, 2006
983
984
surface->pixels = data;
surface->pitch = pitch;
May 28, 2006
May 28, 2006
986
return 0;
May 28, 2006
May 28, 2006
989
static void
May 29, 2006
May 29, 2006
990
DirectFB_UnlockHWSurface(_THIS, SDL_Surface * surface)
May 29, 2006
May 29, 2006
992
surface->hwdata->surface->Unlock(surface->hwdata->surface);
May 28, 2006
May 28, 2006
993
surface->pixels = NULL;
May 28, 2006
May 28, 2006
996
static void
May 29, 2006
May 29, 2006
997
DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect * rects)
May 28, 2006
May 28, 2006
999
1000
if (HIDDEN->enable_mga_crtc2) {
if (HIDDEN->mga_crtc2_stretch)