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

Latest commit

 

History

History
1200 lines (1030 loc) · 39.5 KB

SDL_DirectFB_render.c

File metadata and controls

1200 lines (1030 loc) · 39.5 KB
 
1
2
/*
SDL - Simple DirectMedia Layer
Feb 12, 2011
Feb 12, 2011
3
Copyright (C) 1997-2011 Sam Lantinga
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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.
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.
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
Sam Lantinga
slouken@libsdl.org
Feb 6, 2011
Feb 6, 2011
22
23
24
SDL1.3 DirectFB driver by couriersud@arcor.de
*/
25
#include "SDL_DirectFB_video.h"
Feb 6, 2011
Feb 6, 2011
26
27
28
29
30
31
32
33
34
#include "SDL_DirectFB_window.h"
#include "SDL_DirectFB_modes.h"
#include "SDL_DirectFB_shape.h"
#include "../SDL_sysvideo.h"
#include "../../render/SDL_sysrender.h"
//#include "../SDL_rect_c.h"
//#include "../SDL_yuv_sw_c.h"
Aug 31, 2008
Aug 31, 2008
36
37
38
/* the following is not yet tested ... */
#define USE_DISPLAY_PALETTE (0)
Feb 6, 2011
Feb 6, 2011
39
40
41
42
#define SDL_DFB_RENDERERDATA(rend) DirectFB_RenderData *renddata = ((rend) ? (DirectFB_RenderData *) (rend)->driverdata : NULL)
43
44
45
46
/* GDI renderer implementation */
static SDL_Renderer *DirectFB_CreateRenderer(SDL_Window * window,
Uint32 flags);
Feb 6, 2011
Feb 6, 2011
47
static void DirectFB_ActivateRenderer(SDL_Renderer * renderer);
48
49
50
static int DirectFB_CreateTexture(SDL_Renderer * renderer,
SDL_Texture * texture);
static int DirectFB_QueryTexturePixels(SDL_Renderer * renderer,
Jan 11, 2009
Jan 11, 2009
51
52
SDL_Texture * texture,
void **pixels, int *pitch);
Feb 6, 2011
Feb 6, 2011
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
static int DirectFB_SetTexturePalette(SDL_Renderer * renderer,
SDL_Texture * texture,
const SDL_Color * colors,
int firstcolor, int ncolors);
static int DirectFB_GetTexturePalette(SDL_Renderer * renderer,
SDL_Texture * texture,
SDL_Color * colors,
int firstcolor, int ncolors);
static int DirectFB_SetTextureAlphaMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int DirectFB_SetTextureColorMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int DirectFB_SetTextureBlendMode(SDL_Renderer * renderer,
SDL_Texture * texture);
static int DirectFB_SetTextureScaleMode(SDL_Renderer * renderer,
SDL_Texture * texture);
69
70
static int DirectFB_UpdateTexture(SDL_Renderer * renderer,
SDL_Texture * texture,
Jan 11, 2009
Jan 11, 2009
71
72
const SDL_Rect * rect,
const void *pixels, int pitch);
73
static int DirectFB_LockTexture(SDL_Renderer * renderer,
Jan 11, 2009
Jan 11, 2009
74
SDL_Texture * texture,
Feb 6, 2011
Feb 6, 2011
75
const SDL_Rect * rect,
Jan 11, 2009
Jan 11, 2009
76
void **pixels, int *pitch);
77
78
79
80
81
static void DirectFB_UnlockTexture(SDL_Renderer * renderer,
SDL_Texture * texture);
static void DirectFB_DirtyTexture(SDL_Renderer * renderer,
SDL_Texture * texture, int numrects,
const SDL_Rect * rects);
Feb 6, 2011
Feb 6, 2011
82
static int DirectFB_SetDrawBlendMode(SDL_Renderer * renderer);
Jan 11, 2010
Jan 11, 2010
83
84
85
86
static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer,
const SDL_Point * points, int count);
static int DirectFB_RenderDrawLines(SDL_Renderer * renderer,
const SDL_Point * points, int count);
Feb 6, 2011
Feb 6, 2011
87
88
static int DirectFB_RenderDrawRects(SDL_Renderer * renderer,
const SDL_Rect ** rects, int count);
Jan 11, 2010
Jan 11, 2010
89
90
static int DirectFB_RenderFillRects(SDL_Renderer * renderer,
const SDL_Rect ** rects, int count);
Jan 11, 2009
Jan 11, 2009
91
92
static int DirectFB_RenderCopy(SDL_Renderer * renderer,
SDL_Texture * texture,
93
94
95
96
97
98
const SDL_Rect * srcrect,
const SDL_Rect * dstrect);
static void DirectFB_RenderPresent(SDL_Renderer * renderer);
static void DirectFB_DestroyTexture(SDL_Renderer * renderer,
SDL_Texture * texture);
static void DirectFB_DestroyRenderer(SDL_Renderer * renderer);
Feb 6, 2011
Feb 6, 2011
99
100
101
102
103
static int DirectFB_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 format, void * pixels, int pitch);
static int DirectFB_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 format, const void * pixels, int pitch);
Jan 13, 2009
Jan 13, 2009
105
106
#define SDL_DFB_WINDOWSURFACE(win) IDirectFBSurface *destsurf = ((DFB_WindowData *) ((win)->driverdata))->surface;
107
108
109
110
SDL_RenderDriver DirectFB_RenderDriver = {
DirectFB_CreateRenderer,
{
"directfb",
Feb 1, 2011
Feb 1, 2011
111
(SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
Feb 6, 2011
Feb 6, 2011
112
113
114
115
116
117
118
/* (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND |
SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST |
SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST),*/
0,
Feb 6, 2011
Feb 6, 2011
120
121
/* formats filled in later */
},
122
123
124
125
126
127
0,
0}
};
typedef struct
{
Jan 13, 2009
Jan 13, 2009
128
SDL_Window *window;
129
DFBSurfaceFlipFlags flipflags;
Aug 31, 2008
Aug 31, 2008
130
int size_changed;
Dec 20, 2008
Dec 20, 2008
131
132
133
int lastBlendMode;
DFBSurfaceBlittingFlags blitFlags;
DFBSurfaceDrawingFlags drawFlags;
134
135
136
137
138
139
140
141
} DirectFB_RenderData;
typedef struct
{
IDirectFBSurface *surface;
Uint32 format;
void *pixels;
int pitch;
Feb 6, 2011
Feb 6, 2011
142
143
144
145
146
IDirectFBPalette *palette;
int isDirty;
SDL_VideoDisplay *display; /* only for yuv textures */
Jan 13, 2009
Jan 13, 2009
147
#if (DFB_VERSION_ATLEAST(1,2,0))
Aug 31, 2008
Aug 31, 2008
148
149
DFBSurfaceRenderOptions render_options;
#endif
150
151
} DirectFB_TextureData;
Aug 31, 2008
Aug 31, 2008
152
153
154
155
156
157
158
159
160
static __inline__ void
SDLtoDFBRect(const SDL_Rect * sr, DFBRectangle * dr)
{
dr->x = sr->x;
dr->y = sr->y;
dr->h = sr->h;
dr->w = sr->w;
}
Dec 20, 2008
Dec 20, 2008
161
162
163
164
165
166
167
static int
TextureHasAlpha(DirectFB_TextureData * data)
{
/* Drawing primitive ? */
if (!data)
return 0;
Feb 6, 2011
Feb 6, 2011
168
169
170
return (DFB_PIXELFORMAT_HAS_ALPHA(DirectFB_SDLToDFBPixelFormat(data->format)) ? 1 : 0);
#if 0
Dec 20, 2008
Dec 20, 2008
171
switch (data->format) {
Feb 6, 2011
Feb 6, 2011
172
173
case SDL_PIXELFORMAT_INDEX4LSB:
case SDL_PIXELFORMAT_INDEX4MSB:
Dec 20, 2008
Dec 20, 2008
174
175
176
177
178
179
180
case SDL_PIXELFORMAT_ARGB4444:
case SDL_PIXELFORMAT_ARGB1555:
case SDL_PIXELFORMAT_ARGB8888:
case SDL_PIXELFORMAT_RGBA8888:
case SDL_PIXELFORMAT_ABGR8888:
case SDL_PIXELFORMAT_BGRA8888:
case SDL_PIXELFORMAT_ARGB2101010:
Feb 6, 2011
Feb 6, 2011
181
return 1;
Dec 20, 2008
Dec 20, 2008
182
183
184
default:
return 0;
}
Feb 6, 2011
Feb 6, 2011
185
#endif
Dec 20, 2008
Dec 20, 2008
186
187
188
189
190
191
}
static void
SetBlendMode(DirectFB_RenderData * data, int blendMode,
DirectFB_TextureData * source)
{
Jan 14, 2009
Jan 14, 2009
192
193
194
SDL_DFB_WINDOWSURFACE(data->window);
//FIXME: check for format change
Dec 20, 2008
Dec 20, 2008
195
196
197
198
199
200
if (1 || data->lastBlendMode != blendMode) {
switch (blendMode) {
case SDL_BLENDMODE_NONE:
/**< No blending */
data->blitFlags = DSBLIT_NOFX;
data->drawFlags = DSDRAW_NOFX;
Aug 16, 2010
Aug 16, 2010
201
202
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE));
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO));
Dec 20, 2008
Dec 20, 2008
203
break;
Feb 6, 2011
Feb 6, 2011
204
205
206
207
208
209
210
211
#if 0
case SDL_BLENDMODE_MASK:
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
data->drawFlags = DSDRAW_BLEND;
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA));
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA));
break;
#endif
Dec 20, 2008
Dec 20, 2008
212
213
214
case SDL_BLENDMODE_BLEND:
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
data->drawFlags = DSDRAW_BLEND;
Aug 16, 2010
Aug 16, 2010
215
216
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA));
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA));
Dec 20, 2008
Dec 20, 2008
217
218
219
220
break;
case SDL_BLENDMODE_ADD:
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
data->drawFlags = DSDRAW_BLEND;
Dec 30, 2008
Dec 30, 2008
221
222
223
224
// FIXME: SRCALPHA kills performance on radeon ...
// It will be cheaper to copy the surface to
// a temporay surface and premultiply
if (source && TextureHasAlpha(source))
Aug 16, 2010
Aug 16, 2010
225
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA));
Dec 20, 2008
Dec 20, 2008
226
else
Aug 16, 2010
Aug 16, 2010
227
228
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE));
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ONE));
Feb 6, 2011
Feb 6, 2011
229
230
231
232
233
234
235
236
237
238
break;
case SDL_BLENDMODE_MOD:
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
data->drawFlags = DSDRAW_BLEND;
//SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_DESTCOLOR));
//SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO));
//data->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_ZERO));
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_SRCCOLOR));
Dec 20, 2008
Dec 20, 2008
239
240
241
242
243
244
break;
}
data->lastBlendMode = blendMode;
}
}
Feb 6, 2011
Feb 6, 2011
245
246
static int
DisplayPaletteChanged(void *userdata, SDL_Palette * palette)
Feb 6, 2011
Feb 6, 2011
248
249
250
251
252
#if USE_DISPLAY_PALETTE
DirectFB_RenderData *data = (DirectFB_RenderData *) userdata;
SDL_DFB_WINDOWSURFACE(data->window);
IDirectFBPalette *surfpal;
253
int i;
Feb 6, 2011
Feb 6, 2011
254
255
256
257
int ncolors;
DFBColor entries[256];
SDL_DFB_CHECKERR(destsurf->GetPalette(destsurf, &surfpal));
Dec 4, 2009
Dec 4, 2009
258
Feb 6, 2011
Feb 6, 2011
259
260
261
262
263
264
265
266
/* FIXME: number of colors */
ncolors = (palette->ncolors < 256 ? palette->ncolors : 256);
for (i = 0; i < ncolors; ++i) {
entries[i].r = palette->colors[i].r;
entries[i].g = palette->colors[i].g;
entries[i].b = palette->colors[i].b;
entries[i].a = palette->colors[i].unused;
Dec 4, 2009
Dec 4, 2009
267
}
Feb 6, 2011
Feb 6, 2011
268
269
270
271
272
273
274
275
276
277
278
279
280
281
SDL_DFB_CHECKERR(surfpal->SetEntries(surfpal, entries, ncolors, 0));
return 0;
error:
#else
SDL_Unsupported();
#endif
return -1;
}
static void
DirectFB_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
{
SDL_DFB_RENDERERDATA(renderer);
Feb 13, 2011
Feb 13, 2011
282
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
Feb 6, 2011
Feb 6, 2011
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/* Rebind the context to the window area and update matrices */
//SDL_CurrentContext = NULL;
//data->updateSize = SDL_TRUE;
renddata->size_changed = SDL_TRUE;
}
}
int
DirectFB_RenderClear(SDL_Renderer * renderer)
{
SDL_DFB_RENDERERDATA(renderer);
DirectFB_ActivateRenderer(renderer);
return 0;
298
299
300
301
302
303
}
SDL_Renderer *
DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags)
{
SDL_DFB_WINDOWDATA(window);
Feb 10, 2011
Feb 10, 2011
304
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
305
306
SDL_Renderer *renderer = NULL;
DirectFB_RenderData *data = NULL;
Feb 6, 2011
Feb 6, 2011
307
308
DFBSurfaceCapabilities scaps;
//char *p;
Feb 6, 2011
Feb 6, 2011
310
311
SDL_DFB_ALLOC_CLEAR(renderer, sizeof(*renderer));
SDL_DFB_ALLOC_CLEAR(data, sizeof(*data));
Feb 6, 2011
Feb 6, 2011
313
renderer->WindowEvent = DirectFB_WindowEvent;
314
renderer->CreateTexture = DirectFB_CreateTexture;
Feb 6, 2011
Feb 6, 2011
315
316
317
renderer->SetTextureAlphaMod = DirectFB_SetTextureAlphaMod;
renderer->SetTextureColorMod = DirectFB_SetTextureColorMod;
renderer->SetTextureBlendMode = DirectFB_SetTextureBlendMode;
318
319
renderer->UpdateTexture = DirectFB_UpdateTexture;
renderer->LockTexture = DirectFB_LockTexture;
Feb 6, 2011
Feb 6, 2011
320
renderer->RenderClear = DirectFB_RenderClear;
321
renderer->UnlockTexture = DirectFB_UnlockTexture;
Jan 11, 2010
Jan 11, 2010
322
323
renderer->RenderDrawPoints = DirectFB_RenderDrawPoints;
renderer->RenderDrawLines = DirectFB_RenderDrawLines;
Feb 6, 2011
Feb 6, 2011
324
/* SetDrawColor - no needed */
Jan 11, 2010
Jan 11, 2010
325
renderer->RenderFillRects = DirectFB_RenderFillRects;
Aug 16, 2010
Aug 16, 2010
326
327
/* RenderDrawEllipse - no reference implementation yet */
/* RenderFillEllipse - no reference implementation yet */
328
329
renderer->RenderCopy = DirectFB_RenderCopy;
renderer->RenderPresent = DirectFB_RenderPresent;
Feb 6, 2011
Feb 6, 2011
330
331
332
333
334
/* FIXME: Yet to be tested */
renderer->RenderReadPixels = DirectFB_RenderReadPixels;
//renderer->RenderWritePixels = DirectFB_RenderWritePixels;
335
336
renderer->DestroyTexture = DirectFB_DestroyTexture;
renderer->DestroyRenderer = DirectFB_DestroyRenderer;
Feb 6, 2011
Feb 6, 2011
337
338
339
340
341
342
343
344
345
346
347
#if 0
renderer->QueryTexturePixels = DirectFB_QueryTexturePixels;
renderer->SetTexturePalette = DirectFB_SetTexturePalette;
renderer->GetTexturePalette = DirectFB_GetTexturePalette;
renderer->SetTextureScaleMode = DirectFB_SetTextureScaleMode;
renderer->DirtyTexture = DirectFB_DirtyTexture;
renderer->SetDrawBlendMode = DirectFB_SetDrawBlendMode;
renderer->RenderDrawRects = DirectFB_RenderDrawRects;
#endif
348
renderer->info = DirectFB_RenderDriver.info;
Jan 21, 2010
Jan 21, 2010
349
renderer->window = window; /* SDL window */
350
351
renderer->driverdata = data;
Feb 6, 2011
Feb 6, 2011
352
353
renderer->info.flags =
SDL_RENDERER_ACCELERATED;
Jan 13, 2009
Jan 13, 2009
355
data->window = window;
Aug 31, 2008
Aug 31, 2008
356
357
data->flipflags = DSFLIP_PIPELINE | DSFLIP_BLIT;
358
359
if (flags & SDL_RENDERER_PRESENTVSYNC) {
Aug 16, 2010
Aug 16, 2010
360
data->flipflags |= DSFLIP_WAITFORSYNC | DSFLIP_ONSYNC;
361
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
Nov 26, 2008
Nov 26, 2008
362
363
} else
data->flipflags |= DSFLIP_ONSYNC;
Feb 6, 2011
Feb 6, 2011
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
SDL_DFB_CHECKERR(windata->surface->
GetCapabilities(windata->surface, &scaps));
#if 0
if (scaps & DSCAPS_DOUBLE)
renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
else if (scaps & DSCAPS_TRIPLE)
renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
else
renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER;
#endif
DirectFB_SetSupportedPixelFormats(&renderer->info);
#if 0
/* Set up a palette watch on the display palette */
if (display->palette) {
SDL_AddPaletteWatch(display->palette, DisplayPaletteChanged, data);
}
#endif
385
386
387
388
389
390
391
392
393
return renderer;
error:
SDL_DFB_FREE(renderer);
SDL_DFB_FREE(data);
return NULL;
}
Feb 6, 2011
Feb 6, 2011
394
static void
Aug 31, 2008
Aug 31, 2008
395
DirectFB_ActivateRenderer(SDL_Renderer * renderer)
396
397
{
SDL_DFB_RENDERERDATA(renderer);
Jul 24, 2010
Jul 24, 2010
398
SDL_Window *window = renderer->window;
399
400
SDL_DFB_WINDOWDATA(window);
Jan 11, 2009
Jan 11, 2009
401
if (renddata->size_changed || windata->wm_needs_redraw) {
Feb 6, 2011
Feb 6, 2011
402
DirectFB_AdjustWindowSurface(window);
Aug 31, 2008
Aug 31, 2008
403
}
404
405
}
Aug 31, 2008
Aug 31, 2008
406
407
static int
Aug 26, 2008
Aug 26, 2008
408
DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture)
Feb 6, 2011
Feb 6, 2011
410
//SDL_DFB_RENDERERDATA(renderer);
Jul 24, 2010
Jul 24, 2010
411
SDL_Window *window = renderer->window;
Feb 10, 2011
Feb 10, 2011
412
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
413
414
SDL_DFB_DEVICEDATA(display->device);
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
Aug 26, 2008
Aug 26, 2008
415
DirectFB_TextureData *data = texture->driverdata;
416
DFBDisplayLayerConfig layconf;
Aug 16, 2010
Aug 16, 2010
417
DFBResult ret;
Feb 6, 2011
Feb 6, 2011
419
if (devdata->use_yuv_direct && (dispdata->vidID >= 0)
Aug 26, 2008
Aug 26, 2008
420
&& (!dispdata->vidIDinuse)
421
&& SDL_ISPIXELFORMAT_FOURCC(data->format)) {
Aug 31, 2008
Aug 31, 2008
422
423
424
layconf.flags =
DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT |
DLCONF_SURFACE_CAPS;
425
426
layconf.width = texture->w;
layconf.height = texture->h;
Feb 6, 2011
Feb 6, 2011
427
layconf.pixelformat = DirectFB_SDLToDFBPixelFormat(data->format);
Aug 31, 2008
Aug 31, 2008
428
layconf.surface_caps = DSCAPS_VIDEOONLY | DSCAPS_DOUBLE;
Jan 11, 2009
Jan 11, 2009
430
431
432
433
434
435
SDL_DFB_CHECKERR(devdata->dfb->GetDisplayLayer(devdata->dfb,
dispdata->vidID,
&dispdata->vidlayer));
SDL_DFB_CHECKERR(dispdata->
vidlayer->SetCooperativeLevel(dispdata->vidlayer,
DLSCL_EXCLUSIVE));
Aug 26, 2008
Aug 26, 2008
436
Aug 31, 2008
Aug 31, 2008
437
if (devdata->use_yuv_underlays) {
Feb 6, 2011
Feb 6, 2011
438
ret = dispdata->vidlayer->SetLevel(dispdata->vidlayer, -1);
Aug 31, 2008
Aug 31, 2008
439
440
441
if (ret != DFB_OK)
SDL_DFB_DEBUG("Underlay Setlevel not supported\n");
}
Jan 11, 2009
Jan 11, 2009
442
443
444
445
446
447
SDL_DFB_CHECKERR(dispdata->
vidlayer->SetConfiguration(dispdata->vidlayer,
&layconf));
SDL_DFB_CHECKERR(dispdata->
vidlayer->GetSurface(dispdata->vidlayer,
&data->surface));
Aug 31, 2008
Aug 31, 2008
448
449
dispdata->vidIDinuse = 1;
data->display = display;
Aug 26, 2008
Aug 26, 2008
450
return 0;
Aug 26, 2008
Aug 26, 2008
452
453
return 1;
error:
Aug 31, 2008
Aug 31, 2008
454
if (dispdata->vidlayer) {
Aug 26, 2008
Aug 26, 2008
455
SDL_DFB_RELEASE(data->surface);
Jan 11, 2009
Jan 11, 2009
456
457
458
SDL_DFB_CHECKERR(dispdata->
vidlayer->SetCooperativeLevel(dispdata->vidlayer,
DLSCL_ADMINISTRATIVE));
Aug 31, 2008
Aug 31, 2008
459
SDL_DFB_RELEASE(dispdata->vidlayer);
Aug 26, 2008
Aug 26, 2008
460
461
462
463
464
465
466
}
return 1;
}
static int
DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
Jul 24, 2010
Jul 24, 2010
467
SDL_Window *window = renderer->window;
Feb 10, 2011
Feb 10, 2011
468
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
Aug 26, 2008
Aug 26, 2008
469
470
471
SDL_DFB_DEVICEDATA(display->device);
DirectFB_TextureData *data;
DFBSurfaceDescription dsc;
Oct 4, 2009
Oct 4, 2009
472
DFBSurfacePixelFormat pixelformat;
Aug 26, 2008
Aug 26, 2008
473
Feb 6, 2011
Feb 6, 2011
474
475
476
DirectFB_ActivateRenderer(renderer);
SDL_DFB_ALLOC_CLEAR(data, sizeof(*data));
Aug 26, 2008
Aug 26, 2008
477
478
texture->driverdata = data;
Oct 4, 2009
Oct 4, 2009
479
/* find the right pixelformat */
Feb 6, 2011
Feb 6, 2011
480
pixelformat = DirectFB_SDLToDFBPixelFormat(texture->format);
Oct 4, 2009
Oct 4, 2009
481
482
483
484
485
if (pixelformat == DSPF_UNKNOWN) {
SDL_SetError("Unknown pixel format %d\n", data->format);
goto error;
}
Aug 26, 2008
Aug 26, 2008
486
data->format = texture->format;
Oct 4, 2009
Oct 4, 2009
487
data->pitch = texture->w * DFB_BYTES_PER_PIXEL(pixelformat);
Aug 26, 2008
Aug 26, 2008
488
489
if (DirectFB_AcquireVidLayer(renderer, texture) != 0) {
490
491
492
493
494
/* fill surface description */
dsc.flags =
DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
dsc.width = texture->w;
dsc.height = texture->h;
Feb 6, 2011
Feb 6, 2011
495
496
497
498
499
500
if(texture->format == SDL_PIXELFORMAT_YV12 ||
texture->format == SDL_PIXELFORMAT_IYUV) {
/* dfb has problems with odd sizes -make them even internally */
dsc.width += (dsc.width % 2);
dsc.height += (dsc.height % 2);
}
Aug 26, 2008
Aug 26, 2008
501
/* <1.2 Never use DSCAPS_VIDEOONLY here. It kills performance
502
* No DSCAPS_SYSTEMONLY either - let dfb decide
Aug 26, 2008
Aug 26, 2008
503
* 1.2: DSCAPS_SYSTEMONLY boosts performance by factor ~8
Aug 31, 2008
Aug 31, 2008
504
* Depends on other settings as well. Let dfb decide.
505
*/
Aug 26, 2008
Aug 26, 2008
506
dsc.caps = DSCAPS_PREMULTIPLIED;
Aug 31, 2008
Aug 31, 2008
507
#if 0
Aug 26, 2008
Aug 26, 2008
508
509
510
511
if (texture->access == SDL_TEXTUREACCESS_STREAMING)
dsc.caps |= DSCAPS_SYSTEMONLY;
else
dsc.caps |= DSCAPS_VIDEOONLY;
Aug 31, 2008
Aug 31, 2008
512
#endif
Oct 4, 2009
Oct 4, 2009
514
dsc.pixelformat = pixelformat;
515
516
517
data->pixels = NULL;
/* Create the surface */
Jan 11, 2009
Jan 11, 2009
518
519
SDL_DFB_CHECKERR(devdata->dfb->CreateSurface(devdata->dfb, &dsc,
&data->surface));
Feb 6, 2011
Feb 6, 2011
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
if (SDL_ISPIXELFORMAT_INDEXED(data->format)
&& !SDL_ISPIXELFORMAT_FOURCC(data->format)) {
#if 1
SDL_DFB_CHECKERR(data->surface->GetPalette(data->surface, &data->palette));
#else
/* DFB has issues with blitting LUT8 surfaces.
* Creating a new palette does not help.
*/
DFBPaletteDescription pal_desc;
pal_desc.flags = DPDESC_SIZE; // | DPDESC_ENTRIES
pal_desc.size = 256;
SDL_DFB_CHECKERR(devdata->dfb->CreatePalette(devdata->dfb, &pal_desc,&data->palette));
SDL_DFB_CHECKERR(data->surface->SetPalette(data->surface, data->palette));
#endif
}
Jan 13, 2009
Jan 13, 2009
537
#if (DFB_VERSION_ATLEAST(1,2,0))
Aug 31, 2008
Aug 31, 2008
538
539
540
data->render_options = DSRO_NONE;
#endif
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
Oct 4, 2009
Oct 4, 2009
541
542
543
/* 3 plane YUVs return 1 bpp, but we need more space for other planes */
if(texture->format == SDL_PIXELFORMAT_YV12 ||
texture->format == SDL_PIXELFORMAT_IYUV) {
Feb 6, 2011
Feb 6, 2011
544
SDL_DFB_ALLOC_CLEAR(data->pixels, (texture->h * data->pitch + ((texture->h + texture->h % 2) * (data->pitch + data->pitch % 2) * 2) / 4));
Oct 4, 2009
Oct 4, 2009
545
} else {
Feb 6, 2011
Feb 6, 2011
546
SDL_DFB_ALLOC_CLEAR(data->pixels, texture->h * data->pitch);
Oct 4, 2009
Oct 4, 2009
547
}
Aug 31, 2008
Aug 31, 2008
548
549
}
550
551
552
553
554
555
556
557
558
559
return 0;
error:
SDL_DFB_RELEASE(data->palette);
SDL_DFB_RELEASE(data->surface);
SDL_DFB_FREE(texture->driverdata);
return -1;
}
static int
Jan 11, 2009
Jan 11, 2009
560
561
DirectFB_QueryTexturePixels(SDL_Renderer * renderer,
SDL_Texture * texture, void **pixels, int *pitch)
Aug 31, 2008
Aug 31, 2008
563
564
DirectFB_TextureData *texturedata =
(DirectFB_TextureData *) texture->driverdata;
Aug 31, 2008
Aug 31, 2008
566
567
568
569
570
571
572
if (texturedata->display) {
return -1;
} else {
*pixels = texturedata->pixels;
*pitch = texturedata->pitch;
}
return 0;
573
574
}
Feb 6, 2011
Feb 6, 2011
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
static int
DirectFB_SetTexturePalette(SDL_Renderer * renderer,
SDL_Texture * texture,
const SDL_Color * colors, int firstcolor,
int ncolors)
{
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
if (SDL_ISPIXELFORMAT_INDEXED(data->format)
&& !SDL_ISPIXELFORMAT_FOURCC(data->format)) {
DFBColor entries[256];
int i;
if (ncolors > 256)
ncolors = 256;
for (i = 0; i < ncolors; ++i) {
entries[i].r = colors[i].r;
entries[i].g = colors[i].g;
entries[i].b = colors[i].b;
entries[i].a = 0xff;
}
SDL_DFB_CHECKERR(data->
palette->SetEntries(data->palette, entries, ncolors, firstcolor));
return 0;
} else {
SDL_SetError("YUV textures don't have a palette");
return -1;
}
error:
return -1;
}
static int
DirectFB_GetTexturePalette(SDL_Renderer * renderer,
SDL_Texture * texture, SDL_Color * colors,
int firstcolor, int ncolors)
{
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
if (SDL_ISPIXELFORMAT_INDEXED(data->format)
&& !SDL_ISPIXELFORMAT_FOURCC(data->format)) {
DFBColor entries[256];
int i;
SDL_DFB_CHECKERR(data->
palette->GetEntries(data->palette, entries, ncolors,
firstcolor));
for (i = 0; i < ncolors; ++i) {
colors[i].r = entries[i].r;
colors[i].g = entries[i].g;
colors[i].b = entries[i].b;
colors->unused = SDL_ALPHA_OPAQUE;
}
return 0;
} else {
SDL_SetError("YUV textures don't have a palette");
return -1;
}
error:
return -1;
}
static int
DirectFB_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
return 0;
}
static int
DirectFB_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
return 0;
}
static int
DirectFB_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
switch (texture->blendMode) {
case SDL_BLENDMODE_NONE:
//case SDL_BLENDMODE_MASK:
case SDL_BLENDMODE_BLEND:
case SDL_BLENDMODE_ADD:
case SDL_BLENDMODE_MOD:
return 0;
default:
SDL_Unsupported();
texture->blendMode = SDL_BLENDMODE_NONE;
return -1;
}
}
static int
DirectFB_SetDrawBlendMode(SDL_Renderer * renderer)
{
switch (renderer->blendMode) {
case SDL_BLENDMODE_NONE:
//case SDL_BLENDMODE_MASK:
case SDL_BLENDMODE_BLEND:
case SDL_BLENDMODE_ADD:
case SDL_BLENDMODE_MOD:
return 0;
default:
SDL_Unsupported();
renderer->blendMode = SDL_BLENDMODE_NONE;
return -1;
}
}
#if 0
685
686
687
static int
DirectFB_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
Jan 13, 2009
Jan 13, 2009
688
#if (DFB_VERSION_ATLEAST(1,2,0))
Aug 31, 2008
Aug 31, 2008
689
690
691
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
692
switch (texture->scaleMode) {
Dec 12, 2010
Dec 12, 2010
693
694
case SDL_SCALEMODE_NONE:
case SDL_SCALEMODE_FAST:
Aug 31, 2008
Aug 31, 2008
695
696
data->render_options = DSRO_NONE;
break;
Dec 12, 2010
Dec 12, 2010
697
case SDL_SCALEMODE_SLOW:
Aug 31, 2008
Aug 31, 2008
698
699
data->render_options = DSRO_SMOOTH_UPSCALE | DSRO_SMOOTH_DOWNSCALE;
break;
Dec 12, 2010
Dec 12, 2010
700
case SDL_SCALEMODE_BEST:
Aug 31, 2008
Aug 31, 2008
701
702
703
data->render_options =
DSRO_SMOOTH_UPSCALE | DSRO_SMOOTH_DOWNSCALE | DSRO_ANTIALIAS;
break;
704
705
default:
SDL_Unsupported();
Aug 31, 2008
Aug 31, 2008
706
data->render_options = DSRO_NONE;
Dec 12, 2010
Dec 12, 2010
707
texture->scaleMode = SDL_SCALEMODE_NONE;
708
709
return -1;
}
Aug 31, 2008
Aug 31, 2008
710
#endif
711
712
return 0;
}
Feb 6, 2011
Feb 6, 2011
713
#endif
714
715
716
717
718
719
static int
DirectFB_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels, int pitch)
{
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
Aug 15, 2007
Aug 15, 2007
720
Uint8 *dpixels;
Aug 15, 2007
Aug 15, 2007
721
int dpitch;
Aug 15, 2007
Aug 15, 2007
722
723
724
Uint8 *src, *dst;
int row;
size_t length;
Feb 6, 2011
Feb 6, 2011
725
int bpp = DFB_BYTES_PER_PIXEL(DirectFB_SDLToDFBPixelFormat(texture->format));
Dec 30, 2008
Dec 30, 2008
726
// FIXME: SDL_BYTESPERPIXEL(texture->format) broken for yuv yv12 3 planes
Aug 15, 2007
Aug 15, 2007
727
Feb 6, 2011
Feb 6, 2011
728
729
730
731
732
733
734
DirectFB_ActivateRenderer(renderer);
if ((texture->format == SDL_PIXELFORMAT_YV12) ||
(texture->format == SDL_PIXELFORMAT_IYUV)) {
bpp = 1;
}
Aug 15, 2007
Aug 15, 2007
735
SDL_DFB_CHECKERR(data->surface->Lock(data->surface,
Aug 26, 2008
Aug 26, 2008
736
737
DSLF_WRITE | DSLF_READ,
((void **) &dpixels), &dpitch));
Aug 15, 2007
Aug 15, 2007
738
src = (Uint8 *) pixels;
Dec 30, 2008
Dec 30, 2008
739
740
dst = (Uint8 *) dpixels + rect->y * dpitch + rect->x * bpp;
length = rect->w * bpp;
Aug 15, 2007
Aug 15, 2007
741
742
743
744
for (row = 0; row < rect->h; ++row) {
SDL_memcpy(dst, src, length);
src += pitch;
dst += dpitch;
Oct 4, 2009
Oct 4, 2009
746
/* copy other planes for 3 plane formats */
Feb 6, 2011
Feb 6, 2011
747
748
if ((texture->format == SDL_PIXELFORMAT_YV12) ||
(texture->format == SDL_PIXELFORMAT_IYUV)) {
Oct 4, 2009
Oct 4, 2009
749
750
src = (Uint8 *) pixels + texture->h * pitch;
dst = (Uint8 *) dpixels + texture->h * dpitch + rect->y * dpitch / 4 + rect->x * bpp / 2;
Feb 6, 2011
Feb 6, 2011
751
for (row = 0; row < rect->h / 2 + (rect->h & 1); ++row) {
Oct 4, 2009
Oct 4, 2009
752
753
754
755
756
757
SDL_memcpy(dst, src, length / 2);
src += pitch / 2;
dst += dpitch / 2;
}
src = (Uint8 *) pixels + texture->h * pitch + texture->h * pitch / 4;
dst = (Uint8 *) dpixels + texture->h * dpitch + texture->h * dpitch / 4 + rect->y * dpitch / 4 + rect->x * bpp / 2;
Feb 6, 2011
Feb 6, 2011
758
for (row = 0; row < rect->h / 2 + (rect->h & 1); ++row) {
Oct 4, 2009
Oct 4, 2009
759
760
761
762
763
SDL_memcpy(dst, src, length / 2);
src += pitch / 2;
dst += dpitch / 2;
}
}
Aug 15, 2007
Aug 15, 2007
764
SDL_DFB_CHECKERR(data->surface->Unlock(data->surface));
Feb 6, 2011
Feb 6, 2011
765
data->isDirty = 0;
766
return 0;
Aug 15, 2007
Aug 15, 2007
767
768
error:
return 1;
Aug 15, 2007
Aug 15, 2007
769
770
771
772
773
}
static int
DirectFB_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
Feb 6, 2011
Feb 6, 2011
774
const SDL_Rect * rect, void **pixels, int *pitch)
Aug 31, 2008
Aug 31, 2008
776
777
DirectFB_TextureData *texturedata =
(DirectFB_TextureData *) texture->driverdata;
Feb 6, 2011
Feb 6, 2011
779
780
781
DirectFB_ActivateRenderer(renderer);
#if 0
Aug 31, 2008
Aug 31, 2008
782
783
if (markDirty) {
SDL_AddDirtyRect(&texturedata->dirty, rect);
Feb 6, 2011
Feb 6, 2011
785
#endif
Aug 31, 2008
Aug 31, 2008
787
788
789
if (texturedata->display) {
void *fdata;
int fpitch;
Aug 31, 2008
Aug 31, 2008
791
792
793
794
795
796
797
798
799
SDL_DFB_CHECKERR(texturedata->surface->Lock(texturedata->surface,
DSLF_WRITE | DSLF_READ,
&fdata, &fpitch));
*pitch = fpitch;
*pixels = fdata;
} else {
*pixels =
(void *) ((Uint8 *) texturedata->pixels +
rect->y * texturedata->pitch +
Feb 6, 2011
Feb 6, 2011
800
rect->x * DFB_BYTES_PER_PIXEL(DirectFB_SDLToDFBPixelFormat(texture->format)));
Aug 31, 2008
Aug 31, 2008
801
*pitch = texturedata->pitch;
Feb 6, 2011
Feb 6, 2011
802
texturedata->isDirty = 1;
Aug 31, 2008
Aug 31, 2008
803
}
804
return 0;
Aug 31, 2008
Aug 31, 2008
805
806
807
808
809
810
811
812
error:
return -1;
}
static void
DirectFB_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
Aug 31, 2008
Aug 31, 2008
813
814
DirectFB_TextureData *texturedata =
(DirectFB_TextureData *) texture->driverdata;
Feb 6, 2011
Feb 6, 2011
816
817
DirectFB_ActivateRenderer(renderer);
Aug 31, 2008
Aug 31, 2008
818
if (texturedata->display) {
Aug 16, 2010
Aug 16, 2010
819
SDL_DFB_CHECK(texturedata->surface->Unlock(texturedata->surface));
Aug 31, 2008
Aug 31, 2008
820
821
texturedata->pixels = NULL;
}
822
823
}
Feb 6, 2011
Feb 6, 2011
824
#if 0
825
826
827
828
static void
DirectFB_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
int numrects, const SDL_Rect * rects)
{
Aug 31, 2008
Aug 31, 2008
829
830
831
832
833
834
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
int i;
for (i = 0; i < numrects; ++i) {
SDL_AddDirtyRect(&data->dirty, &rects[i]);
}
Feb 6, 2011
Feb 6, 2011
836
#endif
Dec 20, 2008
Dec 20, 2008
838
839
static int
PrepareDraw(SDL_Renderer * renderer)
840
841
{
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
Jan 13, 2009
Jan 13, 2009
842
SDL_DFB_WINDOWSURFACE(data->window);
Jan 14, 2009
Jan 14, 2009
843
Dec 20, 2008
Dec 20, 2008
844
845
846
847
848
849
850
851
Uint8 r, g, b, a;
r = renderer->r;
g = renderer->g;
b = renderer->b;
a = renderer->a;
SetBlendMode(data, renderer->blendMode, NULL);
Jan 14, 2009
Jan 14, 2009
852
SDL_DFB_CHECKERR(destsurf->SetDrawingFlags(destsurf, data->drawFlags));
Dec 20, 2008
Dec 20, 2008
853
854
855
switch (renderer->blendMode) {
case SDL_BLENDMODE_NONE:
Feb 6, 2011
Feb 6, 2011
856
//case SDL_BLENDMODE_MASK:
Dec 20, 2008
Dec 20, 2008
857
858
859
case SDL_BLENDMODE_BLEND:
break;
case SDL_BLENDMODE_ADD:
Feb 6, 2011
Feb 6, 2011
860
case SDL_BLENDMODE_MOD:
Dec 20, 2008
Dec 20, 2008
861
862
863
864
865
866
r = ((int) r * (int) a) / 255;
g = ((int) g * (int) a) / 255;
b = ((int) b * (int) a) / 255;
a = 255;
break;
}
Jan 13, 2009
Jan 13, 2009
868
SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, r, g, b, a));
Dec 20, 2008
Dec 20, 2008
869
870
871
872
873
return 0;
error:
return -1;
}
Jan 11, 2010
Jan 11, 2010
874
875
static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer,
const SDL_Point * points, int count)
Dec 21, 2008
Dec 21, 2008
876
877
{
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
Jan 13, 2009
Jan 13, 2009
878
SDL_DFB_WINDOWSURFACE(data->window);
Jan 11, 2010
Jan 11, 2010
879
int i;
Dec 21, 2008
Dec 21, 2008
880
Feb 6, 2011
Feb 6, 2011
881
882
DirectFB_ActivateRenderer(renderer);
Dec 21, 2008
Dec 21, 2008
883
PrepareDraw(renderer);
Jan 11, 2010
Jan 11, 2010
884
885
for (i=0; i < count; i++)
SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, points[i].x, points[i].y, points[i].x, points[i].y));
Dec 21, 2008
Dec 21, 2008
886
887
888
889
890
return 0;
error:
return -1;
}
Jan 11, 2010
Jan 11, 2010
891
892
static int DirectFB_RenderDrawLines(SDL_Renderer * renderer,
const SDL_Point * points, int count)
Dec 20, 2008
Dec 20, 2008
893
894
{
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
Jan 13, 2009
Jan 13, 2009
895
SDL_DFB_WINDOWSURFACE(data->window);
Jan 11, 2010
Jan 11, 2010
896
int i;
Dec 20, 2008
Dec 20, 2008
897
Feb 6, 2011
Feb 6, 2011
898
899
DirectFB_ActivateRenderer(renderer);
Dec 20, 2008
Dec 20, 2008
900
PrepareDraw(renderer);
Dec 30, 2008
Dec 30, 2008
901
/* Use antialiasing when available */
Jan 13, 2009
Jan 13, 2009
902
#if (DFB_VERSION_ATLEAST(1,2,0))
Jan 14, 2009
Jan 14, 2009
903
SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf, DSRO_ANTIALIAS));
Dec 30, 2008
Dec 30, 2008
904
#endif
Jan 11, 2010
Jan 11, 2010
905
906
907
908
for (i=0; i < count - 1; i++)
SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, points[i].x, points[i].y, points[i+1].x, points[i+1].y));
Dec 20, 2008
Dec 20, 2008
909
910
911
912
913
return 0;
error:
return -1;
}
Feb 6, 2011
Feb 6, 2011
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
static int
DirectFB_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
{
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
SDL_DFB_WINDOWSURFACE(data->window);
int i;
DirectFB_ActivateRenderer(renderer);
PrepareDraw(renderer);
for (i=0; i<count; i++)
SDL_DFB_CHECKERR(destsurf->DrawRectangle(destsurf, rects[i]->x, rects[i]->y,
rects[i]->w, rects[i]->h));
return 0;
error:
return -1;
}
Jan 11, 2010
Jan 11, 2010
934
935
936
937
938
939
940
static int
DirectFB_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
{
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
SDL_DFB_WINDOWSURFACE(data->window);
int i;
Feb 6, 2011
Feb 6, 2011
941
942
DirectFB_ActivateRenderer(renderer);
Jan 11, 2010
Jan 11, 2010
943
944
945
946
947
PrepareDraw(renderer);
for (i=0; i<count; i++)
SDL_DFB_CHECKERR(destsurf->FillRectangle(destsurf, rects[i]->x, rects[i]->y,
rects[i]->w, rects[i]->h));
948
949
950
951
952
953
954
955
956
957
958
return 0;
error:
return -1;
}
static int
DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * srcrect, const SDL_Rect * dstrect)
{
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
Jan 13, 2009
Jan 13, 2009
959
SDL_DFB_WINDOWSURFACE(data->window);
960
961
DirectFB_TextureData *texturedata =
(DirectFB_TextureData *) texture->driverdata;
Feb 6, 2011
Feb 6, 2011
962
963
964
Uint8 alpha, r, g, b;
DirectFB_ActivateRenderer(renderer);
Aug 31, 2008
Aug 31, 2008
966
if (texturedata->display) {
967
int px, py;
Jul 24, 2010
Jul 24, 2010
968
SDL_Window *window = renderer->window;
969
SDL_DFB_WINDOWDATA(window);
Aug 31, 2008
Aug 31, 2008
970
971
SDL_VideoDisplay *display = texturedata->display;
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
Jan 11, 2009
Jan 11, 2009
973
974
975
976
977
SDL_DFB_CHECKERR(dispdata->
vidlayer->SetSourceRectangle(dispdata->vidlayer,
srcrect->x, srcrect->y,
srcrect->w,
srcrect->h));
Feb 6, 2011
Feb 6, 2011
978
SDL_DFB_CHECK(windata->dfbwin->GetPosition(windata->dfbwin, &px, &py));
Jan 11, 2009
Jan 11, 2009
979
980
981
982
983
984
985
986
px += windata->client.x;
py += windata->client.y;
SDL_DFB_CHECKERR(dispdata->
vidlayer->SetScreenRectangle(dispdata->vidlayer,
px + dstrect->x,
py + dstrect->y,
dstrect->w,
dstrect->h));
987
988
989
990
} else {
DFBRectangle sr, dr;
DFBSurfaceBlittingFlags flags = 0;
Feb 6, 2011
Feb 6, 2011
991
#if 0
Aug 31, 2008
Aug 31, 2008
992
993
994
if (texturedata->dirty.list) {
SDL_DirtyRect *dirty;
void *pixels;
Feb 6, 2011
Feb 6, 2011
995
int bpp = DFB_BYTES_PER_PIXEL(DirectFB_SDLToDFBPixelFormat(texture->format));
Aug 31, 2008
Aug 31, 2008
996
997
998
999
1000
int pitch = texturedata->pitch;
for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
SDL_Rect *rect = &dirty->rect;
pixels =