Commit a8591ca8 authored by Sam Lantinga's avatar Sam Lantinga

DirectFB driver update

Couriersud to Sam

the attached patch brings the DirectFB driver back in line with recent
SDL 1.3 developments.
parent dc564a22
......@@ -386,11 +386,11 @@ DirectFB_QuitModes(_THIS)
SDL_VideoDisplay *display = &_this->displays[i];
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
SDL_GetDesktopDisplayModeForDisplay(display, &tmode);
SDL_GetDesktopDisplayMode(i, &tmode);
tmode.format = SDL_PIXELFORMAT_UNKNOWN;
DirectFB_SetDisplayMode(_this, display, &tmode);
SDL_GetDesktopDisplayModeForDisplay(display, &tmode);
SDL_GetDesktopDisplayMode(i, &tmode);
DirectFB_SetDisplayMode(_this, display, &tmode);
if (dispdata->layer) {
......
......@@ -30,7 +30,7 @@
#include "../SDL_sysvideo.h"
#define SDL_DFB_DISPLAYDATA(win) DFB_DisplayData *dispdata = ((win) ? (DFB_DisplayData *) (win)->display->driverdata : NULL)
#define SDL_DFB_DISPLAYDATA(win) DFB_DisplayData *dispdata = ((win) ? (DFB_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata : NULL)
typedef struct _DFB_DisplayData DFB_DisplayData;
struct _DFB_DisplayData
......
This diff is collapsed.
......@@ -26,6 +26,7 @@
#include "SDL_DirectFB_video.h"
#if SDL_DIRECTFB_OPENGL
#include "SDL_DirectFB_opengl.h"
#include "SDL_DirectFB_window.h"
......
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
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
SDL1.3 DirectFB driver by couriersud@arcor.de
*/
#include "SDL_assert.h"
#include "SDL_DirectFB_video.h"
#include "SDL_DirectFB_shape.h"
#include "SDL_DirectFB_window.h"
#include "../SDL_shape_internals.h"
SDL_Window*
DirectFB_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
return SDL_CreateWindow(title,x,y,w,h,flags /*| SDL_DFB_WINDOW_SHAPED */);
}
SDL_WindowShaper*
DirectFB_CreateShaper(SDL_Window* window) {
SDL_WindowShaper* result = NULL;
result = malloc(sizeof(SDL_WindowShaper));
result->window = window;
result->mode.mode = ShapeModeDefault;
result->mode.parameters.binarizationCutoff = 1;
result->userx = result->usery = 0;
SDL_ShapeData* data = SDL_malloc(sizeof(SDL_ShapeData));
result->driverdata = data;
data->surface = NULL;
window->shaper = result;
int resized_properly = DirectFB_ResizeWindowShape(window);
SDL_assert(resized_properly == 0);
return result;
}
int
DirectFB_ResizeWindowShape(SDL_Window* window) {
SDL_ShapeData* data = window->shaper->driverdata;
SDL_assert(data != NULL);
if (window->x != -1000)
{
window->shaper->userx = window->x;
window->shaper->usery = window->y;
}
SDL_SetWindowPosition(window,-1000,-1000);
return 0;
}
int
DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
if(shaper == NULL || shape == NULL || shaper->driverdata == NULL)
return -1;
if(shape->format->Amask == 0 && SDL_SHAPEMODEALPHA(shape_mode->mode))
return -2;
if(shape->w != shaper->window->w || shape->h != shaper->window->h)
return -3;
{
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(shaper->window);
SDL_DFB_DEVICEDATA(display->device);
Uint32 *pixels;
Sint32 pitch;
Uint32 h,w;
Uint8 *src, *bitmap;
DFBSurfaceDescription dsc;
SDL_ShapeData *data = shaper->driverdata;
SDL_DFB_RELEASE(data->surface);
dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
dsc.width = shape->w;
dsc.height = shape->h;
dsc.caps = DSCAPS_PREMULTIPLIED;
dsc.pixelformat = DSPF_ARGB;
SDL_DFB_CHECKERR(devdata->dfb->CreateSurface(devdata->dfb, &dsc, &data->surface));
/* Assume that shaper->alphacutoff already has a value, because SDL_SetWindowShape() should have given it one. */
SDL_DFB_ALLOC_CLEAR(bitmap, shape->w * shape->h);
SDL_CalculateShapeBitmap(shaper->mode,shape,bitmap,1);
src = bitmap;
SDL_DFB_CHECK(data->surface->Lock(data->surface, DSLF_WRITE | DSLF_READ, (void **) &pixels, &pitch));
h = shaper->window->h;
while (h--) {
for (w = 0; w < shaper->window->w; w++) {
if (*src)
pixels[w] = 0xFFFFFFFF;
else
pixels[w] = 0;
src++;
}
pixels += (pitch >> 2);
}
SDL_DFB_CHECK(data->surface->Unlock(data->surface));
SDL_DFB_FREE(bitmap);
/* FIXME: Need to call this here - Big ?? */
DirectFB_WM_RedrawLayout(SDL_GetDisplayForWindow(shaper->window)->device, shaper->window);
}
return 0;
error:
return -1;
}
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
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
SDL1.3 DirectFB driver by couriersud@arcor.de
*/
#ifndef _SDL_DirectFB_shape_h
#define _SDL_DirectFB_shape_h
#include <directfb.h>
#include "../SDL_sysvideo.h"
#include "SDL_shape.h"
typedef struct {
IDirectFBSurface *surface;
} SDL_ShapeData;
extern SDL_Window* DirectFB_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
extern SDL_WindowShaper* DirectFB_CreateShaper(SDL_Window* window);
extern int DirectFB_ResizeWindowShape(SDL_Window* window);
extern int DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);
#endif /* _SDL_DirectFB_shape_h */
......@@ -133,6 +133,10 @@ DirectFB_CreateDevice(int devindex)
device->DestroyWindow = DirectFB_DestroyWindow;
device->GetWindowWMInfo = DirectFB_GetWindowWMInfo;
/* Not supported by DFB, for completeness */
device->SetWindowGammaRamp = DirectFB_SetWindowGammaRamp;
device->GetWindowGammaRamp = DirectFB_GetWindowGammaRamp;
#if SDL_DIRECTFB_OPENGL
device->GL_LoadLibrary = DirectFB_GL_LoadLibrary;
device->GL_GetProcAddress = DirectFB_GL_GetProcAddress;
......@@ -168,34 +172,34 @@ DirectFB_DeviceInformation(IDirectFB * dfb)
dfb->GetDeviceDescription(dfb, &desc);
SDL_DFB_LOG( "DirectFB Device Information\n");
SDL_DFB_LOG( "===========================\n");
SDL_DFB_LOG( "Name: %s\n", desc.name);
SDL_DFB_LOG( "Vendor: %s\n", desc.vendor);
SDL_DFB_LOG( "Driver Name: %s\n", desc.driver.name);
SDL_DFB_LOG( "Driver Vendor: %s\n", desc.driver.vendor);
SDL_DFB_LOG( "Driver Version: %d.%d\n", desc.driver.major,
SDL_DFB_LOG( "DirectFB Device Information");
SDL_DFB_LOG( "===========================");
SDL_DFB_LOG( "Name: %s", desc.name);
SDL_DFB_LOG( "Vendor: %s", desc.vendor);
SDL_DFB_LOG( "Driver Name: %s", desc.driver.name);
SDL_DFB_LOG( "Driver Vendor: %s", desc.driver.vendor);
SDL_DFB_LOG( "Driver Version: %d.%d", desc.driver.major,
desc.driver.minor);
SDL_DFB_LOG( "\nVideo memoory: %d\n", desc.video_memory);
SDL_DFB_LOG( "Video memoory: %d", desc.video_memory);
SDL_DFB_LOG( "\nBlitting flags:\n");
SDL_DFB_LOG( "Blitting flags:");
for (n = 0; blitting_flags[n].flag; n++) {
if (desc.blitting_flags & blitting_flags[n].flag)
SDL_DFB_LOG( " %s\n", blitting_flags[n].name);
SDL_DFB_LOG( " %s", blitting_flags[n].name);
}
SDL_DFB_LOG( "\nDrawing flags:\n");
SDL_DFB_LOG( "Drawing flags:");
for (n = 0; drawing_flags[n].flag; n++) {
if (desc.drawing_flags & drawing_flags[n].flag)
SDL_DFB_LOG( " %s\n", drawing_flags[n].name);
SDL_DFB_LOG( " %s", drawing_flags[n].name);
}
SDL_DFB_LOG( "\nAcceleration flags:\n");
SDL_DFB_LOG( "Acceleration flags:");
for (n = 0; acceleration_mask[n].mask; n++) {
if (desc.acceleration_mask & acceleration_mask[n].mask)
SDL_DFB_LOG( " %s\n", acceleration_mask[n].name);
SDL_DFB_LOG( " %s", acceleration_mask[n].name);
}
......
......@@ -45,7 +45,9 @@
(DFB_COMPILEDVERSION >= DFB_VERSIONNUM(X, Y, Z))
#if (DFB_VERSION_ATLEAST(1,0,0))
#ifdef SDL_VIDEO_OPENGL
#define SDL_DIRECTFB_OPENGL 1
#endif
#else
#error "SDL_DIRECTFB: Please compile against libdirectfb version >= 1.0.0"
#endif
......@@ -93,7 +95,7 @@
#define SDL_DFB_LOG(x...) \
do { \
fprintf(LOG_CHANNEL, SDL_DFB_CONTEXT); \
fprintf(LOG_CHANNEL, "%s: ", SDL_DFB_CONTEXT); \
fprintf(LOG_CHANNEL, x ); \
fprintf(LOG_CHANNEL, "\n"); \
} while (0)
......
......@@ -489,6 +489,20 @@ DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
}
}
int
DirectFB_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
{
SDL_Unsupported();
return -1;
}
int
DirectFB_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp)
{
SDL_Unsupported();
return -1;
}
void
DirectFB_AdjustWindowSurface(SDL_Window * window)
{
......
......@@ -78,6 +78,10 @@ extern void DirectFB_DestroyWindow(_THIS, SDL_Window * window);
extern SDL_bool DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info);
extern int DirectFB_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
extern int DirectFB_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
extern void DirectFB_AdjustWindowSurface(SDL_Window * window);
#endif /* _SDL_directfb_window_h */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment