2007-08-11 21:51:19 +00:00
|
|
|
/*
|
|
|
|
SDL - Simple DirectMedia Layer
|
2008-12-08 00:27:32 +00:00
|
|
|
Copyright (C) 1997-2009 Sam Lantinga
|
2007-08-11 21:51:19 +00:00
|
|
|
|
|
|
|
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 implementation by couriersud@arcor.de
|
|
|
|
|
|
|
|
*/
|
|
|
|
#include "SDL_config.h"
|
|
|
|
|
|
|
|
#include "SDL_DirectFB_video.h"
|
|
|
|
#include "SDL_DirectFB_render.h"
|
|
|
|
#include "../SDL_rect_c.h"
|
|
|
|
#include "../SDL_yuv_sw_c.h"
|
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
/* the following is not yet tested ... */
|
|
|
|
#define USE_DISPLAY_PALETTE (0)
|
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
/* GDI renderer implementation */
|
|
|
|
|
|
|
|
static SDL_Renderer *DirectFB_CreateRenderer(SDL_Window * window,
|
|
|
|
Uint32 flags);
|
|
|
|
static int DirectFB_DisplayModeChanged(SDL_Renderer * renderer);
|
2008-08-31 16:04:32 +00:00
|
|
|
static int DirectFB_ActivateRenderer(SDL_Renderer * renderer);
|
2007-08-11 21:51:19 +00:00
|
|
|
static int DirectFB_CreateTexture(SDL_Renderer * renderer,
|
|
|
|
SDL_Texture * texture);
|
|
|
|
static int DirectFB_QueryTexturePixels(SDL_Renderer * renderer,
|
2009-01-11 23:49:23 +00:00
|
|
|
SDL_Texture * texture,
|
|
|
|
void **pixels, int *pitch);
|
2007-08-11 21:51:19 +00:00
|
|
|
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,
|
2009-01-11 23:49:23 +00:00
|
|
|
SDL_Color * colors,
|
|
|
|
int firstcolor, int ncolors);
|
2007-08-11 21:51:19 +00:00
|
|
|
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);
|
|
|
|
static int DirectFB_UpdateTexture(SDL_Renderer * renderer,
|
|
|
|
SDL_Texture * texture,
|
2009-01-11 23:49:23 +00:00
|
|
|
const SDL_Rect * rect,
|
|
|
|
const void *pixels, int pitch);
|
2007-08-11 21:51:19 +00:00
|
|
|
static int DirectFB_LockTexture(SDL_Renderer * renderer,
|
2009-01-11 23:49:23 +00:00
|
|
|
SDL_Texture * texture,
|
|
|
|
const SDL_Rect * rect, int markDirty,
|
|
|
|
void **pixels, int *pitch);
|
2007-08-11 21:51:19 +00:00
|
|
|
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);
|
2010-01-11 21:49:09 +00:00
|
|
|
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);
|
|
|
|
static int DirectFB_RenderDrawRects(SDL_Renderer * renderer,
|
|
|
|
const SDL_Rect ** rects, int count);
|
|
|
|
static int DirectFB_RenderFillRects(SDL_Renderer * renderer,
|
|
|
|
const SDL_Rect ** rects, int count);
|
2009-01-11 23:49:23 +00:00
|
|
|
static int DirectFB_RenderCopy(SDL_Renderer * renderer,
|
|
|
|
SDL_Texture * texture,
|
2007-08-11 21:51:19 +00:00
|
|
|
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);
|
|
|
|
|
2009-01-13 22:59:02 +00:00
|
|
|
#define SDL_DFB_WINDOWSURFACE(win) IDirectFBSurface *destsurf = ((DFB_WindowData *) ((win)->driverdata))->surface;
|
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
SDL_RenderDriver DirectFB_RenderDriver = {
|
|
|
|
DirectFB_CreateRenderer,
|
|
|
|
{
|
|
|
|
"directfb",
|
|
|
|
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
|
|
|
|
SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
|
2008-11-26 21:59:35 +00:00
|
|
|
SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
|
|
|
|
SDL_RENDERER_ACCELERATED),
|
2007-08-11 21:51:19 +00:00
|
|
|
(SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
|
|
|
|
SDL_TEXTUREMODULATE_ALPHA),
|
2009-01-11 23:49:23 +00:00
|
|
|
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND |
|
|
|
|
SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
|
2008-08-31 16:04:32 +00:00
|
|
|
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST |
|
|
|
|
SDL_TEXTURESCALEMODE_SLOW | SDL_TEXTURESCALEMODE_BEST),
|
2007-08-11 21:51:19 +00:00
|
|
|
14,
|
|
|
|
{
|
|
|
|
SDL_PIXELFORMAT_INDEX4LSB,
|
2008-08-31 16:04:32 +00:00
|
|
|
SDL_PIXELFORMAT_INDEX8,
|
2007-08-11 21:51:19 +00:00
|
|
|
SDL_PIXELFORMAT_RGB332,
|
|
|
|
SDL_PIXELFORMAT_RGB555,
|
|
|
|
SDL_PIXELFORMAT_RGB565,
|
|
|
|
SDL_PIXELFORMAT_RGB888,
|
|
|
|
SDL_PIXELFORMAT_ARGB8888,
|
|
|
|
SDL_PIXELFORMAT_ARGB4444,
|
|
|
|
SDL_PIXELFORMAT_ARGB1555,
|
|
|
|
SDL_PIXELFORMAT_RGB24,
|
|
|
|
SDL_PIXELFORMAT_YV12,
|
|
|
|
SDL_PIXELFORMAT_IYUV,
|
|
|
|
SDL_PIXELFORMAT_YUY2,
|
|
|
|
SDL_PIXELFORMAT_UYVY},
|
|
|
|
0,
|
|
|
|
0}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_Window *window;
|
2007-08-11 21:51:19 +00:00
|
|
|
DFBSurfaceFlipFlags flipflags;
|
|
|
|
int isyuvdirect;
|
2008-08-31 16:04:32 +00:00
|
|
|
int size_changed;
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
int lastBlendMode;
|
|
|
|
DFBSurfaceBlittingFlags blitFlags;
|
|
|
|
DFBSurfaceDrawingFlags drawFlags;
|
2007-08-11 21:51:19 +00:00
|
|
|
} DirectFB_RenderData;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
IDirectFBSurface *surface;
|
|
|
|
Uint32 format;
|
|
|
|
void *pixels;
|
|
|
|
int pitch;
|
|
|
|
IDirectFBPalette *palette;
|
2008-08-31 16:04:32 +00:00
|
|
|
SDL_VideoDisplay *display;
|
|
|
|
SDL_DirtyRectList dirty;
|
2009-01-13 21:17:38 +00:00
|
|
|
#if (DFB_VERSION_ATLEAST(1,2,0))
|
2008-08-31 16:04:32 +00:00
|
|
|
DFBSurfaceRenderOptions render_options;
|
|
|
|
#endif
|
2007-08-11 21:51:19 +00:00
|
|
|
} DirectFB_TextureData;
|
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
TextureHasAlpha(DirectFB_TextureData * data)
|
|
|
|
{
|
|
|
|
/* Drawing primitive ? */
|
|
|
|
if (!data)
|
|
|
|
return 0;
|
|
|
|
switch (data->format) {
|
|
|
|
case SDL_PIXELFORMAT_INDEX4LSB:
|
|
|
|
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:
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
SetBlendMode(DirectFB_RenderData * data, int blendMode,
|
|
|
|
DirectFB_TextureData * source)
|
|
|
|
{
|
2009-01-14 04:25:32 +00:00
|
|
|
SDL_DFB_WINDOWSURFACE(data->window);
|
|
|
|
|
|
|
|
//FIXME: check for format change
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
if (1 || data->lastBlendMode != blendMode) {
|
|
|
|
switch (blendMode) {
|
|
|
|
case SDL_BLENDMODE_NONE:
|
|
|
|
/**< No blending */
|
|
|
|
data->blitFlags = DSBLIT_NOFX;
|
|
|
|
data->drawFlags = DSDRAW_NOFX;
|
2009-01-13 22:59:02 +00:00
|
|
|
destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE);
|
|
|
|
destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO);
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
break;
|
|
|
|
case SDL_BLENDMODE_MASK:
|
|
|
|
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
|
|
|
data->drawFlags = DSDRAW_BLEND;
|
2009-01-13 22:59:02 +00:00
|
|
|
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
|
2009-01-14 04:25:32 +00:00
|
|
|
destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA);
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
break;
|
|
|
|
case SDL_BLENDMODE_BLEND:
|
|
|
|
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
|
|
|
data->drawFlags = DSDRAW_BLEND;
|
2009-01-13 22:59:02 +00:00
|
|
|
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
|
2009-01-14 04:25:32 +00:00
|
|
|
destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA);
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
break;
|
|
|
|
case SDL_BLENDMODE_ADD:
|
|
|
|
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
|
|
|
data->drawFlags = DSDRAW_BLEND;
|
2008-12-30 17:02:53 +00:00
|
|
|
// FIXME: SRCALPHA kills performance on radeon ...
|
|
|
|
// It will be cheaper to copy the surface to
|
|
|
|
// a temporay surface and premultiply
|
|
|
|
if (source && TextureHasAlpha(source))
|
2009-01-14 04:25:32 +00:00
|
|
|
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
else
|
2009-01-13 22:59:02 +00:00
|
|
|
destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE);
|
|
|
|
destsurf->SetDstBlendFunction(destsurf, DSBF_ONE);
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
break;
|
|
|
|
case SDL_BLENDMODE_MOD:
|
|
|
|
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
|
|
|
data->drawFlags = DSDRAW_BLEND;
|
2009-01-13 22:59:02 +00:00
|
|
|
destsurf->SetSrcBlendFunction(destsurf, DSBF_DESTCOLOR);
|
|
|
|
destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO);
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
data->lastBlendMode = blendMode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
void
|
|
|
|
DirectFB_AddRenderDriver(_THIS)
|
|
|
|
{
|
|
|
|
int i;
|
2009-12-04 08:45:08 +00:00
|
|
|
|
|
|
|
for (i = 0; i < _this->num_displays; ++i) {
|
2009-12-01 05:57:15 +00:00
|
|
|
SDL_AddRenderDriver(&_this->displays[i], &DirectFB_RenderDriver);
|
2009-12-04 08:45:08 +00:00
|
|
|
}
|
2007-08-11 21:51:19 +00:00
|
|
|
}
|
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
static int
|
|
|
|
DisplayPaletteChanged(void *userdata, SDL_Palette * palette)
|
|
|
|
{
|
|
|
|
#if USE_DISPLAY_PALETTE
|
|
|
|
DirectFB_RenderData *data = (DirectFB_RenderData *) userdata;
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_WINDOWSURFACE(data->window);
|
2008-08-31 16:04:32 +00:00
|
|
|
IDirectFBPalette *surfpal;
|
|
|
|
|
|
|
|
int ret;
|
|
|
|
int i;
|
|
|
|
int ncolors;
|
|
|
|
DFBColor entries[256];
|
|
|
|
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_CHECKERR(destsurf->GetPalette(destsurf, &surfpal));
|
2008-08-31 16:04:32 +00:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
SDL_DFB_CHECKERR(surfpal->SetEntries(surfpal, entries, ncolors, 0));
|
|
|
|
return 0;
|
|
|
|
error:
|
2009-12-01 05:57:15 +00:00
|
|
|
#else
|
|
|
|
SDL_Unsupported();
|
2008-08-31 16:04:32 +00:00
|
|
|
#endif
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
SDL_Renderer *
|
|
|
|
DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|
|
|
{
|
|
|
|
SDL_DFB_WINDOWDATA(window);
|
2010-01-21 06:21:52 +00:00
|
|
|
SDL_VideoDisplay *display = window->display;
|
2007-08-11 21:51:19 +00:00
|
|
|
SDL_Renderer *renderer = NULL;
|
|
|
|
DirectFB_RenderData *data = NULL;
|
|
|
|
DFBResult ret;
|
|
|
|
DFBSurfaceCapabilities scaps;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
SDL_DFB_CALLOC(renderer, 1, sizeof(*renderer));
|
|
|
|
SDL_DFB_CALLOC(data, 1, sizeof(*data));
|
|
|
|
|
|
|
|
renderer->DisplayModeChanged = DirectFB_DisplayModeChanged;
|
2008-08-31 16:04:32 +00:00
|
|
|
renderer->ActivateRenderer = DirectFB_ActivateRenderer;
|
2007-08-11 21:51:19 +00:00
|
|
|
renderer->CreateTexture = DirectFB_CreateTexture;
|
|
|
|
renderer->QueryTexturePixels = DirectFB_QueryTexturePixels;
|
|
|
|
renderer->SetTexturePalette = DirectFB_SetTexturePalette;
|
|
|
|
renderer->GetTexturePalette = DirectFB_GetTexturePalette;
|
|
|
|
renderer->SetTextureAlphaMod = DirectFB_SetTextureAlphaMod;
|
|
|
|
renderer->SetTextureColorMod = DirectFB_SetTextureColorMod;
|
|
|
|
renderer->SetTextureBlendMode = DirectFB_SetTextureBlendMode;
|
|
|
|
renderer->SetTextureScaleMode = DirectFB_SetTextureScaleMode;
|
|
|
|
renderer->UpdateTexture = DirectFB_UpdateTexture;
|
|
|
|
renderer->LockTexture = DirectFB_LockTexture;
|
|
|
|
renderer->UnlockTexture = DirectFB_UnlockTexture;
|
|
|
|
renderer->DirtyTexture = DirectFB_DirtyTexture;
|
2010-01-11 21:49:09 +00:00
|
|
|
renderer->RenderDrawPoints = DirectFB_RenderDrawPoints;
|
|
|
|
renderer->RenderDrawLines = DirectFB_RenderDrawLines;
|
|
|
|
renderer->RenderFillRects = DirectFB_RenderFillRects;
|
|
|
|
renderer->RenderDrawRects = DirectFB_RenderDrawRects;
|
2007-08-11 21:51:19 +00:00
|
|
|
renderer->RenderCopy = DirectFB_RenderCopy;
|
|
|
|
renderer->RenderPresent = DirectFB_RenderPresent;
|
|
|
|
renderer->DestroyTexture = DirectFB_DestroyTexture;
|
|
|
|
renderer->DestroyRenderer = DirectFB_DestroyRenderer;
|
|
|
|
renderer->info = DirectFB_RenderDriver.info;
|
2010-01-21 06:21:52 +00:00
|
|
|
renderer->window = window; /* SDL window */
|
2007-08-11 21:51:19 +00:00
|
|
|
renderer->driverdata = data;
|
|
|
|
|
|
|
|
renderer->info.flags =
|
|
|
|
SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTDISCARD;
|
|
|
|
|
2009-01-13 22:59:02 +00:00
|
|
|
data->window = window;
|
2008-08-31 16:04:32 +00:00
|
|
|
|
|
|
|
data->flipflags = DSFLIP_PIPELINE | DSFLIP_BLIT;
|
2007-08-11 21:51:19 +00:00
|
|
|
|
|
|
|
if (flags & SDL_RENDERER_PRESENTVSYNC) {
|
2008-11-26 21:59:35 +00:00
|
|
|
data->flipflags |= DSFLIP_WAITFORSYNC;
|
2007-08-11 21:51:19 +00:00
|
|
|
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
|
2008-11-26 21:59:35 +00:00
|
|
|
} else
|
|
|
|
data->flipflags |= DSFLIP_ONSYNC;
|
2007-08-11 21:51:19 +00:00
|
|
|
|
2009-01-14 04:25:32 +00:00
|
|
|
SDL_DFB_CHECKERR(windata->surface->
|
|
|
|
GetCapabilities(windata->surface, &scaps));
|
2007-08-11 21:51:19 +00:00
|
|
|
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;
|
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
data->isyuvdirect = 0; /* default is off! */
|
2009-01-11 23:49:23 +00:00
|
|
|
p = SDL_getenv(DFBENV_USE_YUV_DIRECT);
|
2007-08-11 21:51:19 +00:00
|
|
|
if (p)
|
|
|
|
data->isyuvdirect = atoi(p);
|
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
/* Set up a palette watch on the display palette */
|
|
|
|
if (display->palette) {
|
|
|
|
SDL_AddPaletteWatch(display->palette, DisplayPaletteChanged, data);
|
|
|
|
}
|
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
return renderer;
|
|
|
|
|
|
|
|
error:
|
|
|
|
SDL_DFB_FREE(renderer);
|
|
|
|
SDL_DFB_FREE(data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DFBSurfacePixelFormat
|
|
|
|
SDLToDFBPixelFormat(Uint32 format)
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case SDL_PIXELFORMAT_INDEX4LSB:
|
|
|
|
return DSPF_ALUT44;
|
|
|
|
case SDL_PIXELFORMAT_INDEX8:
|
|
|
|
return DSPF_LUT8;
|
|
|
|
case SDL_PIXELFORMAT_RGB332:
|
|
|
|
return DSPF_RGB332;
|
|
|
|
case SDL_PIXELFORMAT_RGB555:
|
|
|
|
return DSPF_ARGB1555;
|
|
|
|
case SDL_PIXELFORMAT_ARGB4444:
|
|
|
|
return DSPF_ARGB4444;
|
|
|
|
case SDL_PIXELFORMAT_ARGB1555:
|
|
|
|
return DSPF_ARGB1555;
|
|
|
|
case SDL_PIXELFORMAT_RGB565:
|
|
|
|
return DSPF_RGB16;
|
|
|
|
case SDL_PIXELFORMAT_RGB24:
|
|
|
|
return DSPF_RGB24;
|
|
|
|
case SDL_PIXELFORMAT_RGB888:
|
|
|
|
return DSPF_RGB32;
|
|
|
|
case SDL_PIXELFORMAT_ARGB8888:
|
|
|
|
return DSPF_ARGB;
|
|
|
|
case SDL_PIXELFORMAT_YV12:
|
|
|
|
return DSPF_YV12; /* Planar mode: Y + V + U (3 planes) */
|
|
|
|
case SDL_PIXELFORMAT_IYUV:
|
|
|
|
return DSPF_I420; /* Planar mode: Y + U + V (3 planes) */
|
|
|
|
case SDL_PIXELFORMAT_YUY2:
|
|
|
|
return DSPF_YUY2; /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
|
|
|
|
case SDL_PIXELFORMAT_UYVY:
|
|
|
|
return DSPF_UYVY; /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
|
|
|
case SDL_PIXELFORMAT_YVYU:
|
|
|
|
return DSPF_UNKNOWN; /* Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
|
|
|
case SDL_PIXELFORMAT_INDEX1LSB:
|
|
|
|
return DSPF_UNKNOWN;
|
|
|
|
case SDL_PIXELFORMAT_INDEX1MSB:
|
|
|
|
return DSPF_UNKNOWN;
|
|
|
|
case SDL_PIXELFORMAT_INDEX4MSB:
|
|
|
|
return DSPF_UNKNOWN;
|
|
|
|
case SDL_PIXELFORMAT_RGB444:
|
2009-01-13 21:17:38 +00:00
|
|
|
#if (DFB_VERSION_ATLEAST(1,2,0))
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
return DSPF_RGB444;
|
|
|
|
#else
|
2007-08-11 21:51:19 +00:00
|
|
|
return DSPF_UNKNOWN;
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
#endif
|
2007-08-11 21:51:19 +00:00
|
|
|
case SDL_PIXELFORMAT_BGR24:
|
|
|
|
return DSPF_UNKNOWN;
|
|
|
|
case SDL_PIXELFORMAT_BGR888:
|
|
|
|
return DSPF_UNKNOWN;
|
|
|
|
case SDL_PIXELFORMAT_RGBA8888:
|
|
|
|
return DSPF_UNKNOWN;
|
|
|
|
case SDL_PIXELFORMAT_ABGR8888:
|
|
|
|
return DSPF_UNKNOWN;
|
|
|
|
case SDL_PIXELFORMAT_BGRA8888:
|
|
|
|
return DSPF_UNKNOWN;
|
|
|
|
case SDL_PIXELFORMAT_ARGB2101010:
|
|
|
|
return DSPF_UNKNOWN;
|
|
|
|
default:
|
|
|
|
return DSPF_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-08-31 16:04:32 +00:00
|
|
|
DirectFB_ActivateRenderer(SDL_Renderer * renderer)
|
2007-08-11 21:51:19 +00:00
|
|
|
{
|
|
|
|
SDL_DFB_RENDERERDATA(renderer);
|
|
|
|
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
|
|
|
SDL_DFB_WINDOWDATA(window);
|
|
|
|
|
2009-01-11 23:49:23 +00:00
|
|
|
if (renddata->size_changed || windata->wm_needs_redraw) {
|
|
|
|
DirectFB_AdjustWindowSurface(window);
|
2008-08-31 16:04:32 +00:00
|
|
|
}
|
2007-08-11 21:51:19 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
static int
|
|
|
|
DirectFB_DisplayModeChanged(SDL_Renderer * renderer)
|
|
|
|
{
|
|
|
|
SDL_DFB_RENDERERDATA(renderer);
|
|
|
|
|
|
|
|
renddata->size_changed = SDL_TRUE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
static int
|
2008-08-26 02:32:45 +00:00
|
|
|
DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture)
|
2007-08-11 21:51:19 +00:00
|
|
|
{
|
|
|
|
SDL_DFB_RENDERERDATA(renderer);
|
|
|
|
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
2010-01-21 06:21:52 +00:00
|
|
|
SDL_VideoDisplay *display = window->display;
|
2007-08-11 21:51:19 +00:00
|
|
|
SDL_DFB_DEVICEDATA(display->device);
|
|
|
|
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
|
2008-08-26 02:32:45 +00:00
|
|
|
DirectFB_TextureData *data = texture->driverdata;
|
2007-08-11 21:51:19 +00:00
|
|
|
DFBDisplayLayerConfig layconf;
|
2008-08-26 02:32:45 +00:00
|
|
|
int ret;
|
2007-08-11 21:51:19 +00:00
|
|
|
|
|
|
|
if (renddata->isyuvdirect && (dispdata->vidID >= 0)
|
2008-08-26 02:32:45 +00:00
|
|
|
&& (!dispdata->vidIDinuse)
|
2007-08-11 21:51:19 +00:00
|
|
|
&& SDL_ISPIXELFORMAT_FOURCC(data->format)) {
|
2008-08-31 16:04:32 +00:00
|
|
|
layconf.flags =
|
|
|
|
DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT |
|
|
|
|
DLCONF_SURFACE_CAPS;
|
2007-08-11 21:51:19 +00:00
|
|
|
layconf.width = texture->w;
|
|
|
|
layconf.height = texture->h;
|
|
|
|
layconf.pixelformat = SDLToDFBPixelFormat(data->format);
|
2008-08-31 16:04:32 +00:00
|
|
|
layconf.surface_caps = DSCAPS_VIDEOONLY | DSCAPS_DOUBLE;
|
2007-08-11 21:51:19 +00:00
|
|
|
|
2009-01-11 23:49:23 +00:00
|
|
|
SDL_DFB_CHECKERR(devdata->dfb->GetDisplayLayer(devdata->dfb,
|
|
|
|
dispdata->vidID,
|
|
|
|
&dispdata->vidlayer));
|
|
|
|
SDL_DFB_CHECKERR(dispdata->
|
|
|
|
vidlayer->SetCooperativeLevel(dispdata->vidlayer,
|
|
|
|
DLSCL_EXCLUSIVE));
|
2008-08-26 02:32:45 +00:00
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
if (devdata->use_yuv_underlays) {
|
|
|
|
ret = dispdata->vidlayer->SetLevel(dispdata->vidlayer, -1);
|
|
|
|
if (ret != DFB_OK)
|
|
|
|
SDL_DFB_DEBUG("Underlay Setlevel not supported\n");
|
|
|
|
}
|
2009-01-11 23:49:23 +00:00
|
|
|
SDL_DFB_CHECKERR(dispdata->
|
|
|
|
vidlayer->SetConfiguration(dispdata->vidlayer,
|
|
|
|
&layconf));
|
|
|
|
SDL_DFB_CHECKERR(dispdata->
|
|
|
|
vidlayer->GetSurface(dispdata->vidlayer,
|
|
|
|
&data->surface));
|
2008-08-31 16:04:32 +00:00
|
|
|
dispdata->vidIDinuse = 1;
|
|
|
|
data->display = display;
|
2008-08-26 02:32:45 +00:00
|
|
|
return 0;
|
2007-08-11 21:51:19 +00:00
|
|
|
}
|
2008-08-26 02:32:45 +00:00
|
|
|
return 1;
|
|
|
|
error:
|
2008-08-31 16:04:32 +00:00
|
|
|
if (dispdata->vidlayer) {
|
2008-08-26 02:32:45 +00:00
|
|
|
SDL_DFB_RELEASE(data->surface);
|
2009-01-11 23:49:23 +00:00
|
|
|
SDL_DFB_CHECKERR(dispdata->
|
|
|
|
vidlayer->SetCooperativeLevel(dispdata->vidlayer,
|
|
|
|
DLSCL_ADMINISTRATIVE));
|
2008-08-31 16:04:32 +00:00
|
|
|
SDL_DFB_RELEASE(dispdata->vidlayer);
|
2008-08-26 02:32:45 +00:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|
|
|
{
|
|
|
|
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
2010-01-21 06:21:52 +00:00
|
|
|
SDL_VideoDisplay *display = window->display;
|
2008-08-26 02:32:45 +00:00
|
|
|
SDL_DFB_DEVICEDATA(display->device);
|
|
|
|
DirectFB_TextureData *data;
|
|
|
|
DFBResult ret;
|
|
|
|
DFBSurfaceDescription dsc;
|
2009-10-04 04:03:37 +00:00
|
|
|
DFBSurfacePixelFormat pixelformat;
|
2008-08-26 02:32:45 +00:00
|
|
|
|
|
|
|
SDL_DFB_CALLOC(data, 1, sizeof(*data));
|
|
|
|
texture->driverdata = data;
|
|
|
|
|
2009-10-04 04:03:37 +00:00
|
|
|
/* find the right pixelformat */
|
|
|
|
pixelformat = SDLToDFBPixelFormat(texture->format);
|
|
|
|
if (pixelformat == DSPF_UNKNOWN) {
|
|
|
|
SDL_SetError("Unknown pixel format %d\n", data->format);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2008-08-26 02:32:45 +00:00
|
|
|
data->format = texture->format;
|
2009-10-04 04:03:37 +00:00
|
|
|
data->pitch = texture->w * DFB_BYTES_PER_PIXEL(pixelformat);
|
2008-08-26 02:32:45 +00:00
|
|
|
|
|
|
|
if (DirectFB_AcquireVidLayer(renderer, texture) != 0) {
|
2007-08-11 21:51:19 +00:00
|
|
|
/* fill surface description */
|
|
|
|
dsc.flags =
|
|
|
|
DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
|
|
|
|
dsc.width = texture->w;
|
|
|
|
dsc.height = texture->h;
|
2008-08-26 02:32:45 +00:00
|
|
|
/* <1.2 Never use DSCAPS_VIDEOONLY here. It kills performance
|
2007-08-11 21:51:19 +00:00
|
|
|
* No DSCAPS_SYSTEMONLY either - let dfb decide
|
2008-08-26 02:32:45 +00:00
|
|
|
* 1.2: DSCAPS_SYSTEMONLY boosts performance by factor ~8
|
2008-08-31 16:04:32 +00:00
|
|
|
* Depends on other settings as well. Let dfb decide.
|
2007-08-11 21:51:19 +00:00
|
|
|
*/
|
2008-08-26 02:32:45 +00:00
|
|
|
dsc.caps = DSCAPS_PREMULTIPLIED;
|
2008-08-31 16:04:32 +00:00
|
|
|
#if 0
|
2008-08-26 02:32:45 +00:00
|
|
|
if (texture->access == SDL_TEXTUREACCESS_STREAMING)
|
|
|
|
dsc.caps |= DSCAPS_SYSTEMONLY;
|
|
|
|
else
|
|
|
|
dsc.caps |= DSCAPS_VIDEOONLY;
|
2008-08-31 16:04:32 +00:00
|
|
|
#endif
|
2007-08-11 21:51:19 +00:00
|
|
|
|
2009-10-04 04:03:37 +00:00
|
|
|
dsc.pixelformat = pixelformat;
|
2007-08-11 21:51:19 +00:00
|
|
|
data->pixels = NULL;
|
|
|
|
|
|
|
|
/* Create the surface */
|
2009-01-11 23:49:23 +00:00
|
|
|
SDL_DFB_CHECKERR(devdata->dfb->CreateSurface(devdata->dfb, &dsc,
|
|
|
|
&data->surface));
|
2007-08-11 21:51:19 +00:00
|
|
|
if (SDL_ISPIXELFORMAT_INDEXED(data->format)
|
|
|
|
&& !SDL_ISPIXELFORMAT_FOURCC(data->format)) {
|
2009-01-11 23:49:23 +00:00
|
|
|
SDL_DFB_CHECKERR(data->surface->GetPalette(data->surface,
|
|
|
|
&data->palette));
|
2007-08-11 21:51:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2009-01-13 21:17:38 +00:00
|
|
|
#if (DFB_VERSION_ATLEAST(1,2,0))
|
2008-08-31 16:04:32 +00:00
|
|
|
data->render_options = DSRO_NONE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
2009-10-04 04:03:37 +00:00
|
|
|
/* 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) {
|
|
|
|
SDL_DFB_CALLOC(data->pixels, 1, (texture->h * data->pitch * 3 + texture->h * data->pitch * 3 % 2) / 2);
|
|
|
|
} else {
|
|
|
|
SDL_DFB_CALLOC(data->pixels, 1, texture->h * data->pitch);
|
|
|
|
}
|
2008-08-31 16:04:32 +00:00
|
|
|
}
|
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
SDL_DFB_RELEASE(data->palette);
|
|
|
|
SDL_DFB_RELEASE(data->surface);
|
|
|
|
SDL_DFB_FREE(texture->driverdata);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-01-11 23:49:23 +00:00
|
|
|
DirectFB_QueryTexturePixels(SDL_Renderer * renderer,
|
|
|
|
SDL_Texture * texture, void **pixels, int *pitch)
|
2007-08-11 21:51:19 +00:00
|
|
|
{
|
2008-08-31 16:04:32 +00:00
|
|
|
DirectFB_TextureData *texturedata =
|
|
|
|
(DirectFB_TextureData *) texture->driverdata;
|
2007-08-11 21:51:19 +00:00
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
if (texturedata->display) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
*pixels = texturedata->pixels;
|
|
|
|
*pitch = texturedata->pitch;
|
|
|
|
}
|
|
|
|
return 0;
|
2007-08-11 21:51:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-01-11 23:49:23 +00:00
|
|
|
DirectFB_SetTexturePalette(SDL_Renderer * renderer,
|
|
|
|
SDL_Texture * texture,
|
2007-08-11 21:51:19 +00:00
|
|
|
const SDL_Color * colors, int firstcolor,
|
|
|
|
int ncolors)
|
|
|
|
{
|
|
|
|
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
|
|
|
|
DFBResult ret;
|
|
|
|
|
|
|
|
if (SDL_ISPIXELFORMAT_INDEXED(data->format)
|
|
|
|
&& !SDL_ISPIXELFORMAT_FOURCC(data->format)) {
|
|
|
|
DFBColor entries[256];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2009-01-11 23:49:23 +00:00
|
|
|
SDL_DFB_CHECKERR(data->
|
|
|
|
palette->SetEntries(data->palette, entries, ncolors,
|
|
|
|
firstcolor));
|
2007-08-11 21:51:19 +00:00
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
SDL_SetError("YUV textures don't have a palette");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
error:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-01-11 23:49:23 +00:00
|
|
|
DirectFB_GetTexturePalette(SDL_Renderer * renderer,
|
|
|
|
SDL_Texture * texture, SDL_Color * colors,
|
|
|
|
int firstcolor, int ncolors)
|
2007-08-11 21:51:19 +00:00
|
|
|
{
|
|
|
|
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
|
|
|
|
DFBResult ret;
|
|
|
|
|
|
|
|
if (SDL_ISPIXELFORMAT_INDEXED(data->format)
|
|
|
|
&& !SDL_ISPIXELFORMAT_FOURCC(data->format)) {
|
|
|
|
DFBColor entries[256];
|
|
|
|
int i;
|
|
|
|
|
2009-01-11 23:49:23 +00:00
|
|
|
SDL_DFB_CHECKERR(data->
|
|
|
|
palette->GetEntries(data->palette, entries, ncolors,
|
|
|
|
firstcolor));
|
2007-08-11 21:51:19 +00:00
|
|
|
|
|
|
|
for (i = 0; i < ncolors; ++i) {
|
|
|
|
colors[i].r = entries[i].r;
|
|
|
|
colors[i].g = entries[i].g;
|
|
|
|
colors[i].b = entries[i].b;
|
2008-08-31 16:04:32 +00:00
|
|
|
colors->unused = SDL_ALPHA_OPAQUE;
|
2007-08-11 21:51:19 +00:00
|
|
|
}
|
|
|
|
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) {
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
case SDL_BLENDMODE_NONE:
|
|
|
|
case SDL_BLENDMODE_MASK:
|
|
|
|
case SDL_BLENDMODE_BLEND:
|
|
|
|
case SDL_BLENDMODE_ADD:
|
|
|
|
case SDL_BLENDMODE_MOD:
|
2007-08-11 21:51:19 +00:00
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
SDL_Unsupported();
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
texture->blendMode = SDL_BLENDMODE_NONE;
|
2007-08-11 21:51:19 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
DirectFB_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
|
|
|
|
{
|
2009-01-13 21:17:38 +00:00
|
|
|
#if (DFB_VERSION_ATLEAST(1,2,0))
|
2008-08-31 16:04:32 +00:00
|
|
|
|
|
|
|
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
|
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
switch (texture->scaleMode) {
|
|
|
|
case SDL_TEXTURESCALEMODE_NONE:
|
|
|
|
case SDL_TEXTURESCALEMODE_FAST:
|
2008-08-31 16:04:32 +00:00
|
|
|
data->render_options = DSRO_NONE;
|
|
|
|
break;
|
2007-08-11 21:51:19 +00:00
|
|
|
case SDL_TEXTURESCALEMODE_SLOW:
|
2008-08-31 16:04:32 +00:00
|
|
|
data->render_options = DSRO_SMOOTH_UPSCALE | DSRO_SMOOTH_DOWNSCALE;
|
|
|
|
break;
|
2007-08-11 21:51:19 +00:00
|
|
|
case SDL_TEXTURESCALEMODE_BEST:
|
2008-08-31 16:04:32 +00:00
|
|
|
data->render_options =
|
|
|
|
DSRO_SMOOTH_UPSCALE | DSRO_SMOOTH_DOWNSCALE | DSRO_ANTIALIAS;
|
|
|
|
break;
|
2007-08-11 21:51:19 +00:00
|
|
|
default:
|
|
|
|
SDL_Unsupported();
|
2008-08-31 16:04:32 +00:00
|
|
|
data->render_options = DSRO_NONE;
|
2007-08-11 21:51:19 +00:00
|
|
|
texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
|
|
|
|
return -1;
|
|
|
|
}
|
2008-08-31 16:04:32 +00:00
|
|
|
#endif
|
2007-08-11 21:51:19 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2007-08-15 03:19:21 +00:00
|
|
|
DFBResult ret;
|
|
|
|
Uint8 *dpixels;
|
2007-08-15 03:50:49 +00:00
|
|
|
int dpitch;
|
2007-08-15 03:19:21 +00:00
|
|
|
Uint8 *src, *dst;
|
|
|
|
int row;
|
|
|
|
size_t length;
|
2008-12-30 17:02:53 +00:00
|
|
|
int bpp = DFB_BYTES_PER_PIXEL(SDLToDFBPixelFormat(texture->format));
|
|
|
|
// FIXME: SDL_BYTESPERPIXEL(texture->format) broken for yuv yv12 3 planes
|
2007-08-15 03:19:21 +00:00
|
|
|
|
|
|
|
SDL_DFB_CHECKERR(data->surface->Lock(data->surface,
|
2008-08-26 02:32:45 +00:00
|
|
|
DSLF_WRITE | DSLF_READ,
|
|
|
|
((void **) &dpixels), &dpitch));
|
2007-08-15 03:19:21 +00:00
|
|
|
src = (Uint8 *) pixels;
|
2008-12-30 17:02:53 +00:00
|
|
|
dst = (Uint8 *) dpixels + rect->y * dpitch + rect->x * bpp;
|
|
|
|
length = rect->w * bpp;
|
2007-08-15 03:19:21 +00:00
|
|
|
for (row = 0; row < rect->h; ++row) {
|
|
|
|
SDL_memcpy(dst, src, length);
|
|
|
|
src += pitch;
|
|
|
|
dst += dpitch;
|
2007-08-11 21:51:19 +00:00
|
|
|
}
|
2009-10-04 04:03:37 +00:00
|
|
|
/* copy other planes for 3 plane formats */
|
|
|
|
if (texture->format == SDL_PIXELFORMAT_YV12 ||
|
|
|
|
texture->format == SDL_PIXELFORMAT_IYUV) {
|
|
|
|
src = (Uint8 *) pixels + texture->h * pitch;
|
|
|
|
dst = (Uint8 *) dpixels + texture->h * dpitch + rect->y * dpitch / 4 + rect->x * bpp / 2;
|
|
|
|
for (row = 0; row < rect->h / 2; ++row) {
|
|
|
|
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;
|
|
|
|
for (row = 0; row < rect->h / 2; ++row) {
|
|
|
|
SDL_memcpy(dst, src, length / 2);
|
|
|
|
src += pitch / 2;
|
|
|
|
dst += dpitch / 2;
|
|
|
|
}
|
|
|
|
}
|
2007-08-15 03:50:49 +00:00
|
|
|
SDL_DFB_CHECKERR(data->surface->Unlock(data->surface));
|
2007-08-11 21:51:19 +00:00
|
|
|
return 0;
|
2007-08-15 03:50:49 +00:00
|
|
|
error:
|
|
|
|
return 1;
|
2007-08-15 03:19:21 +00:00
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
DirectFB_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
2009-01-11 23:49:23 +00:00
|
|
|
const SDL_Rect * rect, int markDirty,
|
|
|
|
void **pixels, int *pitch)
|
2007-08-11 21:51:19 +00:00
|
|
|
{
|
2008-08-31 16:04:32 +00:00
|
|
|
DirectFB_TextureData *texturedata =
|
|
|
|
(DirectFB_TextureData *) texture->driverdata;
|
2007-08-11 21:51:19 +00:00
|
|
|
DFBResult ret;
|
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
if (markDirty) {
|
|
|
|
SDL_AddDirtyRect(&texturedata->dirty, rect);
|
2007-08-11 21:51:19 +00:00
|
|
|
}
|
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
if (texturedata->display) {
|
|
|
|
void *fdata;
|
|
|
|
int fpitch;
|
2007-08-11 21:51:19 +00:00
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
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 +
|
2009-10-04 04:03:37 +00:00
|
|
|
rect->x * DFB_BYTES_PER_PIXEL(SDLToDFBPixelFormat(texture->format)));
|
2008-08-31 16:04:32 +00:00
|
|
|
*pitch = texturedata->pitch;
|
|
|
|
}
|
2007-08-11 21:51:19 +00:00
|
|
|
return 0;
|
2008-08-31 16:04:32 +00:00
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
error:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
DirectFB_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|
|
|
{
|
2008-08-31 16:04:32 +00:00
|
|
|
DirectFB_TextureData *texturedata =
|
|
|
|
(DirectFB_TextureData *) texture->driverdata;
|
2007-08-11 21:51:19 +00:00
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
if (texturedata->display) {
|
|
|
|
texturedata->surface->Unlock(texturedata->surface);
|
|
|
|
texturedata->pixels = NULL;
|
|
|
|
}
|
2007-08-11 21:51:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
DirectFB_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|
|
|
int numrects, const SDL_Rect * rects)
|
|
|
|
{
|
2008-08-31 16:04:32 +00:00
|
|
|
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < numrects; ++i) {
|
|
|
|
SDL_AddDirtyRect(&data->dirty, &rects[i]);
|
|
|
|
}
|
2007-08-11 21:51:19 +00:00
|
|
|
}
|
|
|
|
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
static int
|
|
|
|
PrepareDraw(SDL_Renderer * renderer)
|
2007-08-11 21:51:19 +00:00
|
|
|
{
|
|
|
|
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_WINDOWSURFACE(data->window);
|
2009-01-14 04:25:32 +00:00
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
DFBResult ret;
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
Uint8 r, g, b, a;
|
|
|
|
|
|
|
|
r = renderer->r;
|
|
|
|
g = renderer->g;
|
|
|
|
b = renderer->b;
|
|
|
|
a = renderer->a;
|
|
|
|
|
|
|
|
SetBlendMode(data, renderer->blendMode, NULL);
|
2009-01-14 04:25:32 +00:00
|
|
|
SDL_DFB_CHECKERR(destsurf->SetDrawingFlags(destsurf, data->drawFlags));
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
|
|
|
|
switch (renderer->blendMode) {
|
|
|
|
case SDL_BLENDMODE_NONE:
|
|
|
|
case SDL_BLENDMODE_MASK:
|
|
|
|
case SDL_BLENDMODE_BLEND:
|
|
|
|
break;
|
|
|
|
case SDL_BLENDMODE_ADD:
|
|
|
|
case SDL_BLENDMODE_MOD:
|
|
|
|
r = ((int) r * (int) a) / 255;
|
|
|
|
g = ((int) g * (int) a) / 255;
|
|
|
|
b = ((int) b * (int) a) / 255;
|
|
|
|
a = 255;
|
|
|
|
break;
|
|
|
|
}
|
2007-08-11 21:51:19 +00:00
|
|
|
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, r, g, b, a));
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
return 0;
|
|
|
|
error:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-01-11 21:49:09 +00:00
|
|
|
static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer,
|
|
|
|
const SDL_Point * points, int count)
|
2008-12-21 17:39:41 +00:00
|
|
|
{
|
|
|
|
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_WINDOWSURFACE(data->window);
|
2008-12-21 17:39:41 +00:00
|
|
|
DFBResult ret;
|
2010-01-11 21:49:09 +00:00
|
|
|
int i;
|
2008-12-21 17:39:41 +00:00
|
|
|
|
|
|
|
PrepareDraw(renderer);
|
2010-01-11 21:49:09 +00:00
|
|
|
for (i=0; i < count; i++)
|
|
|
|
SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, points[i].x, points[i].y, points[i].x, points[i].y));
|
2008-12-21 17:39:41 +00:00
|
|
|
return 0;
|
|
|
|
error:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-01-11 21:49:09 +00:00
|
|
|
static int DirectFB_RenderDrawLines(SDL_Renderer * renderer,
|
|
|
|
const SDL_Point * points, int count)
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
{
|
|
|
|
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_WINDOWSURFACE(data->window);
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
DFBResult ret;
|
2010-01-11 21:49:09 +00:00
|
|
|
int i;
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
|
|
|
|
PrepareDraw(renderer);
|
2008-12-30 17:02:53 +00:00
|
|
|
/* Use antialiasing when available */
|
2009-01-13 21:17:38 +00:00
|
|
|
#if (DFB_VERSION_ATLEAST(1,2,0))
|
2009-01-14 04:25:32 +00:00
|
|
|
SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf, DSRO_ANTIALIAS));
|
2008-12-30 17:02:53 +00:00
|
|
|
#endif
|
2010-01-11 21:49:09 +00:00
|
|
|
|
|
|
|
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));
|
|
|
|
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
return 0;
|
|
|
|
error:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-01-11 21:49:09 +00:00
|
|
|
DirectFB_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
{
|
|
|
|
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_WINDOWSURFACE(data->window);
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
DFBResult ret;
|
2010-01-11 21:49:09 +00:00
|
|
|
int i;
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
|
|
|
|
PrepareDraw(renderer);
|
2010-01-11 21:49:09 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
DFBResult ret;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
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));
|
2007-08-11 21:51:19 +00:00
|
|
|
|
|
|
|
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;
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_WINDOWSURFACE(data->window);
|
2007-08-11 21:51:19 +00:00
|
|
|
DirectFB_TextureData *texturedata =
|
|
|
|
(DirectFB_TextureData *) texture->driverdata;
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
Uint8 alpha = 0xFF;
|
2007-08-11 21:51:19 +00:00
|
|
|
DFBResult ret;
|
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
if (texturedata->display) {
|
2007-08-11 21:51:19 +00:00
|
|
|
int px, py;
|
|
|
|
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
|
|
|
SDL_DFB_WINDOWDATA(window);
|
2008-08-31 16:04:32 +00:00
|
|
|
SDL_VideoDisplay *display = texturedata->display;
|
|
|
|
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
|
2007-08-11 21:51:19 +00:00
|
|
|
|
2009-01-11 23:49:23 +00:00
|
|
|
SDL_DFB_CHECKERR(dispdata->
|
|
|
|
vidlayer->SetSourceRectangle(dispdata->vidlayer,
|
|
|
|
srcrect->x, srcrect->y,
|
|
|
|
srcrect->w,
|
|
|
|
srcrect->h));
|
2007-08-11 21:51:19 +00:00
|
|
|
windata->window->GetPosition(windata->window, &px, &py);
|
2009-01-11 23:49:23 +00:00
|
|
|
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));
|
2007-08-11 21:51:19 +00:00
|
|
|
} else {
|
|
|
|
DFBRectangle sr, dr;
|
|
|
|
DFBSurfaceBlittingFlags flags = 0;
|
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
if (texturedata->dirty.list) {
|
|
|
|
SDL_DirtyRect *dirty;
|
|
|
|
void *pixels;
|
2009-10-04 04:03:37 +00:00
|
|
|
int bpp = DFB_BYTES_PER_PIXEL(SDLToDFBPixelFormat(texture->format));
|
2008-08-31 16:04:32 +00:00
|
|
|
int pitch = texturedata->pitch;
|
|
|
|
|
|
|
|
for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
|
|
|
|
SDL_Rect *rect = &dirty->rect;
|
|
|
|
pixels =
|
|
|
|
(void *) ((Uint8 *) texturedata->pixels +
|
|
|
|
rect->y * pitch + rect->x * bpp);
|
|
|
|
DirectFB_UpdateTexture(renderer, texture, rect,
|
|
|
|
texturedata->pixels,
|
|
|
|
texturedata->pitch);
|
|
|
|
}
|
|
|
|
SDL_ClearDirtyRects(&texturedata->dirty);
|
|
|
|
}
|
2007-08-11 21:51:19 +00:00
|
|
|
|
2008-08-31 16:04:32 +00:00
|
|
|
SDLtoDFBRect(srcrect, &sr);
|
|
|
|
SDLtoDFBRect(dstrect, &dr);
|
2007-08-11 21:51:19 +00:00
|
|
|
|
2009-01-14 04:25:32 +00:00
|
|
|
SDL_DFB_CHECKERR(destsurf->
|
|
|
|
SetColor(destsurf, 0xFF, 0xFF, 0xFF, 0xFF));
|
|
|
|
if (texture->
|
|
|
|
modMode & (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA))
|
|
|
|
{
|
2008-08-26 02:32:45 +00:00
|
|
|
if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
|
2007-08-11 21:51:19 +00:00
|
|
|
alpha = texture->a;
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF,
|
2009-01-14 04:25:32 +00:00
|
|
|
0xFF, alpha));
|
2008-08-26 02:32:45 +00:00
|
|
|
}
|
|
|
|
if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_CHECKERR(destsurf->SetColor(destsurf,
|
2009-01-14 04:25:32 +00:00
|
|
|
texture->r,
|
|
|
|
texture->g,
|
|
|
|
texture->b, alpha));
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
flags |= DSBLIT_COLORIZE;
|
2008-08-26 02:32:45 +00:00
|
|
|
}
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
if (alpha < 0xFF)
|
|
|
|
flags |= DSBLIT_SRC_PREMULTCOLOR;
|
|
|
|
} else
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF,
|
2009-01-14 04:25:32 +00:00
|
|
|
0xFF, 0xFF));
|
2007-08-11 21:51:19 +00:00
|
|
|
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
SetBlendMode(data, texture->blendMode, texturedata);
|
2008-08-26 02:32:45 +00:00
|
|
|
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_CHECKERR(destsurf->SetBlittingFlags(destsurf,
|
2009-01-14 04:25:32 +00:00
|
|
|
data->blitFlags | flags));
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
|
2009-01-13 21:17:38 +00:00
|
|
|
#if (DFB_VERSION_ATLEAST(1,2,0))
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf,
|
2009-01-14 04:25:32 +00:00
|
|
|
texturedata->
|
|
|
|
render_options));
|
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403346
2008-12-20 12:00:00 +00:00
|
|
|
#endif
|
2008-08-31 16:04:32 +00:00
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_CHECKERR(destsurf->Blit(destsurf,
|
2009-01-14 04:25:32 +00:00
|
|
|
texturedata->surface,
|
|
|
|
&sr, dr.x, dr.y));
|
2007-08-11 21:51:19 +00:00
|
|
|
} else {
|
2009-01-13 22:59:02 +00:00
|
|
|
SDL_DFB_CHECKERR(destsurf->StretchBlit(destsurf,
|
2009-01-14 04:25:32 +00:00
|
|
|
texturedata->surface,
|
|
|
|
&sr, &dr));
|
2007-08-11 21:51:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
error:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
DirectFB_RenderPresent(SDL_Renderer * renderer)
|
|
|
|
{
|
|
|
|
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
|
|
|
|
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
2009-01-11 23:49:23 +00:00
|
|
|
SDL_DFB_WINDOWDATA(window);
|
2007-08-11 21:51:19 +00:00
|
|
|
|
|
|
|
DFBRectangle sr;
|
|
|
|
DFBResult ret;
|
|
|
|
|
|
|
|
sr.x = 0;
|
|
|
|
sr.y = 0;
|
|
|
|
sr.w = window->w;
|
|
|
|
sr.h = window->h;
|
|
|
|
|
|
|
|
/* Send the data to the display */
|
2009-01-11 23:49:23 +00:00
|
|
|
SDL_DFB_CHECK(windata->window_surface->Flip(windata->window_surface, NULL,
|
|
|
|
data->flipflags));
|
2007-08-11 21:51:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
DirectFB_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|
|
|
{
|
|
|
|
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
|
|
|
|
|
|
|
|
if (!data) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SDL_DFB_RELEASE(data->palette);
|
|
|
|
SDL_DFB_RELEASE(data->surface);
|
2008-08-26 02:32:45 +00:00
|
|
|
if (data->display) {
|
2008-08-31 16:04:32 +00:00
|
|
|
DFB_DisplayData *dispdata =
|
|
|
|
(DFB_DisplayData *) data->display->driverdata;
|
|
|
|
dispdata->vidIDinuse = 0;
|
|
|
|
dispdata->vidlayer->SetCooperativeLevel(dispdata->vidlayer,
|
|
|
|
DLSCL_ADMINISTRATIVE);
|
|
|
|
SDL_DFB_RELEASE(dispdata->vidlayer);
|
2008-08-26 02:32:45 +00:00
|
|
|
}
|
2008-08-31 16:04:32 +00:00
|
|
|
SDL_FreeDirtyRects(&data->dirty);
|
|
|
|
SDL_DFB_FREE(data->pixels);
|
2007-08-11 21:51:19 +00:00
|
|
|
SDL_free(data);
|
|
|
|
texture->driverdata = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
DirectFB_DestroyRenderer(SDL_Renderer * renderer)
|
|
|
|
{
|
|
|
|
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
|
2009-01-14 04:25:32 +00:00
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
if (data) {
|
|
|
|
SDL_free(data);
|
|
|
|
}
|
|
|
|
SDL_free(renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|