Added DGA2 driver to DirectDraw.
This commit is contained in:
parent
5e65e2dd7a
commit
51177f96ba
|
@ -128,6 +128,8 @@ AC_SUBST(XFILES)
|
|||
XFILES=""
|
||||
AC_SUBST(DGA_SRCS)
|
||||
DGA_SRCS=""
|
||||
AC_SUBST(DGA2_SRCS)
|
||||
DGA2_SRCS=""
|
||||
AC_SUBST(MESA_SRCS)
|
||||
MESA_SRCS=""
|
||||
if test "$have_x" = "yes"
|
||||
|
@ -173,6 +175,7 @@ then
|
|||
AC_DEFINE(HAVE_LIBXXF86DGA)
|
||||
X_PRE_LIBS="$X_PRE_LIBS -lXxf86dga"
|
||||
DGA_SRCS='$(DGA_SRCS)'
|
||||
DGA2_SRCS='$(DGA2_SRCS)'
|
||||
,,$X_LIBS -lXext -lX11 $X_EXTRA_LIBS
|
||||
)
|
||||
if test "$ac_cv_lib_Xxf86dga_XDGAQueryExtension" = "no"
|
||||
|
|
|
@ -26,9 +26,15 @@ DGA_SRCS = \
|
|||
dsurface/dga.c \
|
||||
dga.c
|
||||
|
||||
DGA2_SRCS= \
|
||||
dga2.c \
|
||||
dsurface/dga2.c \
|
||||
ddraw/dga2.c
|
||||
|
||||
XFILES = \
|
||||
@DGA_SRCS@ \
|
||||
@MESA_SRCS@ \
|
||||
@DGA2_SRCS@ \
|
||||
ddraw/x11.c \
|
||||
dpalette/x11.c \
|
||||
dsurface/x11.c \
|
||||
|
|
|
@ -57,7 +57,10 @@ static XF86VidModeModeInfo *orig_mode = NULL;
|
|||
/*******************************************************************************
|
||||
* IDirectDraw
|
||||
*/
|
||||
static HRESULT WINAPI DGA_IDirectDraw2Impl_CreateSurface(
|
||||
|
||||
/* This function is used both by DGA and DGA2 drivers, thus the virtual function table
|
||||
is not set here, but in the calling function */
|
||||
HRESULT WINAPI DGA_IDirectDraw2Impl_CreateSurface_no_VT(
|
||||
LPDIRECTDRAW2 iface,LPDDSURFACEDESC lpddsd,LPDIRECTDRAWSURFACE *lpdsf,
|
||||
IUnknown *lpunk
|
||||
) {
|
||||
|
@ -85,12 +88,6 @@ static HRESULT WINAPI DGA_IDirectDraw2Impl_CreateSurface(
|
|||
IDirectDraw2_AddRef(iface);
|
||||
|
||||
dsurf->ref = 1;
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
if (ddpriv->version == 2)
|
||||
ICOM_VTBL(dsurf) = (ICOM_VTABLE(IDirectDrawSurface)*)&dga2_dds4vt;
|
||||
else
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
ICOM_VTBL(dsurf) = (ICOM_VTABLE(IDirectDrawSurface)*)&dga_dds4vt;
|
||||
dsurf->s.ddraw = This;
|
||||
dsurf->s.palette = NULL;
|
||||
dspriv->fb_height = -1; /* This is to have non-on screen surfaces freed */
|
||||
|
@ -194,84 +191,21 @@ static HRESULT WINAPI DGA_IDirectDraw2Impl_CreateSurface(
|
|||
return DD_OK;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
static HRESULT WINAPI DGA_IDirectDraw2Impl_SetCooperativeLevel(
|
||||
LPDIRECTDRAW2 iface,HWND hwnd,DWORD cooplevel
|
||||
static HRESULT WINAPI DGA_IDirectDraw2Impl_CreateSurface(
|
||||
LPDIRECTDRAW2 iface,LPDDSURFACEDESC lpddsd,LPDIRECTDRAWSURFACE *lpdsf,
|
||||
IUnknown *lpunk
|
||||
) {
|
||||
ICOM_THIS(IDirectDraw2Impl,iface);
|
||||
DDPRIVATE(This);
|
||||
HRESULT ret;
|
||||
int evbase, erbase;
|
||||
HRESULT ret;
|
||||
IDirectDrawSurfaceImpl* dsurf;
|
||||
|
||||
ret = IDirectDraw2Impl_SetCooperativeLevel(iface, hwnd, cooplevel);
|
||||
ret = DGA_IDirectDraw2Impl_CreateSurface_no_VT(iface, lpddsd, lpdsf, lpunk);
|
||||
|
||||
if (ddpriv->version != 2) {
|
||||
return ret;
|
||||
} else {
|
||||
if (ret != DD_OK)
|
||||
return ret;
|
||||
dsurf = *(IDirectDrawSurfaceImpl**)lpdsf;
|
||||
ICOM_VTBL(dsurf) = (ICOM_VTABLE(IDirectDrawSurface)*)&dga_dds4vt;
|
||||
|
||||
TSXDGAQueryExtension(display, &evbase, &erbase);
|
||||
|
||||
/* Now, start handling of DGA events giving the handle to the DDraw window
|
||||
as the window for which the event will be reported */
|
||||
TSXDGASelectInput(display, DefaultScreen(display),
|
||||
KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask );
|
||||
X11DRV_EVENT_SetDGAStatus(hwnd, evbase);
|
||||
return DD_OK;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
void _DGA_Initialize_FrameBuffer(IDirectDrawImpl *This, int mode) {
|
||||
DDPIXELFORMAT *pf = &(This->d.directdraw_pixelformat);
|
||||
DDPRIVATE(This);
|
||||
|
||||
/* Now, get the device / mode description */
|
||||
ddpriv->dev = TSXDGASetMode(display, DefaultScreen(display), mode);
|
||||
|
||||
ddpriv->fb_width = ddpriv->dev->mode.imageWidth;
|
||||
TSXDGASetViewport(display,DefaultScreen(display),0,0, XDGAFlipImmediate);
|
||||
ddpriv->fb_height = ddpriv->dev->mode.viewportHeight;
|
||||
TRACE("video framebuffer: begin %p, width %d, memsize %d\n",
|
||||
ddpriv->dev->data,
|
||||
ddpriv->dev->mode.imageWidth,
|
||||
(ddpriv->dev->mode.imageWidth *
|
||||
ddpriv->dev->mode.imageHeight *
|
||||
(ddpriv->dev->mode.bitsPerPixel / 8))
|
||||
);
|
||||
TRACE("viewport height: %d\n", ddpriv->dev->mode.viewportHeight);
|
||||
/* Get the screen dimensions as seen by Wine.
|
||||
* In that case, it may be better to ignore the -desktop mode and return the
|
||||
* real screen size => print a warning */
|
||||
This->d.height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor);
|
||||
This->d.width = MONITOR_GetWidth(&MONITOR_PrimaryMonitor);
|
||||
ddpriv->fb_addr = ddpriv->dev->data;
|
||||
ddpriv->fb_memsize = (ddpriv->dev->mode.imageWidth *
|
||||
ddpriv->dev->mode.imageHeight *
|
||||
(ddpriv->dev->mode.bitsPerPixel / 8));
|
||||
ddpriv->vpmask = 0;
|
||||
|
||||
/* Fill the screen pixelformat */
|
||||
pf->dwSize = sizeof(DDPIXELFORMAT);
|
||||
pf->dwFourCC = 0;
|
||||
pf->u.dwRGBBitCount = ddpriv->dev->mode.bitsPerPixel;
|
||||
if (ddpriv->dev->mode.depth == 8) {
|
||||
pf->dwFlags = DDPF_PALETTEINDEXED8|DDPF_RGB;
|
||||
pf->u1.dwRBitMask = 0;
|
||||
pf->u2.dwGBitMask = 0;
|
||||
pf->u3.dwBBitMask = 0;
|
||||
} else {
|
||||
pf->dwFlags = DDPF_RGB;
|
||||
pf->u1.dwRBitMask = ddpriv->dev->mode.redMask;
|
||||
pf->u2.dwGBitMask = ddpriv->dev->mode.greenMask;
|
||||
pf->u3.dwBBitMask = ddpriv->dev->mode.blueMask;
|
||||
}
|
||||
pf->u4.dwRGBAlphaBitMask= 0;
|
||||
This->d.screen_pixelformat = *pf;
|
||||
}
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
|
||||
static HRESULT WINAPI DGA_IDirectDrawImpl_SetDisplayMode(
|
||||
LPDIRECTDRAW iface,DWORD width,DWORD height,DWORD depth
|
||||
|
@ -282,45 +216,6 @@ static HRESULT WINAPI DGA_IDirectDrawImpl_SetDisplayMode(
|
|||
|
||||
TRACE("(%p)->(%ld,%ld,%ld)\n", This, width, height, depth);
|
||||
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
if (ddpriv->version == 2) {
|
||||
XDGAMode *modes = ddpriv->modes;
|
||||
int mode_to_use = -1;
|
||||
|
||||
/* Search in the list a display mode that corresponds to what is requested */
|
||||
for (i = 0; i < ddpriv->num_modes; i++) {
|
||||
if ((height == modes[i].viewportHeight) &&
|
||||
(width == modes[i].viewportWidth) &&
|
||||
(depth == modes[i].depth)
|
||||
)
|
||||
mode_to_use = modes[i].num;
|
||||
}
|
||||
|
||||
if (mode_to_use < 0) {
|
||||
ERR("Could not find matching mode !!!\n");
|
||||
return DDERR_UNSUPPORTEDMODE;
|
||||
} else {
|
||||
TRACE("Using mode number %d\n", mode_to_use);
|
||||
|
||||
TSXDGACloseFramebuffer(display, DefaultScreen(display));
|
||||
|
||||
if (!TSXDGAOpenFramebuffer(display, DefaultScreen(display))) {
|
||||
ERR("Error opening the frame buffer !!!\n");
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
|
||||
/* Initialize the frame buffer */
|
||||
_DGA_Initialize_FrameBuffer(This, mode_to_use);
|
||||
|
||||
/* Re-get (if necessary) the DGA events */
|
||||
TSXDGASelectInput(display, DefaultScreen(display),
|
||||
KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask );
|
||||
}
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
|
||||
/* We hope getting the asked for depth */
|
||||
if (_common_depth_to_pixelformat(depth, &(This->d.directdraw_pixelformat), &(This->d.screen_pixelformat), NULL) != -1) {
|
||||
/* I.e. no visual found or emulated */
|
||||
|
@ -341,9 +236,6 @@ static HRESULT WINAPI DGA_IDirectDrawImpl_SetDisplayMode(
|
|||
_common_IDirectDrawImpl_SetDisplayMode(This);
|
||||
|
||||
#ifdef HAVE_LIBXXF86VM
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
if (ddpriv->version == 1) /* Only for DGA 1.0, it crashes with DGA 2.0 */
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
{
|
||||
XF86VidModeModeInfo **all_modes, *vidmode = NULL;
|
||||
XF86VidModeModeLine mod_tmp;
|
||||
|
@ -403,7 +295,7 @@ static HRESULT WINAPI DGA_IDirectDrawImpl_SetDisplayMode(
|
|||
return DD_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DGA_IDirectDraw2Impl_GetCaps(
|
||||
HRESULT WINAPI DGA_IDirectDraw2Impl_GetCaps(
|
||||
LPDIRECTDRAW2 iface,LPDDCAPS caps1,LPDDCAPS caps2
|
||||
) {
|
||||
ICOM_THIS(IDirectDraw2Impl,iface);
|
||||
|
@ -425,6 +317,7 @@ static HRESULT WINAPI DGA_IDirectDraw2Impl_GetCaps(
|
|||
return DD_OK;
|
||||
}
|
||||
|
||||
#if 0 /* Not used as of now.... */
|
||||
static void fill_caps(LPDDCAPS caps) {
|
||||
/* This function tries to fill the capabilities of Wine's DDraw
|
||||
* implementation. Needs to be fixed, though.. */
|
||||
|
@ -458,6 +351,7 @@ static void fill_caps(LPDDCAPS caps) {
|
|||
caps->ddsCaps.dwCaps |= DDSCAPS_3DDEVICE | DDSCAPS_MIPMAP | DDSCAPS_TEXTURE | DDSCAPS_ZBUFFER;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
static HRESULT WINAPI DGA_IDirectDraw2Impl_CreatePalette(
|
||||
LPDIRECTDRAW2 iface,DWORD dwFlags,LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE *lpddpal,LPUNKNOWN lpunk
|
||||
|
@ -515,42 +409,24 @@ static HRESULT WINAPI DGA_IDirectDraw2Impl_RestoreDisplayMode(LPDIRECTDRAW2 ifac
|
|||
|
||||
static ULONG WINAPI DGA_IDirectDraw2Impl_Release(LPDIRECTDRAW2 iface) {
|
||||
ICOM_THIS(IDirectDraw2Impl,iface);
|
||||
DDPRIVATE(This);
|
||||
TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
|
||||
|
||||
if (!--(This->ref)) {
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
if (ddpriv->version == 2) {
|
||||
TRACE("Closing access to the FrameBuffer\n");
|
||||
TSXDGACloseFramebuffer(display, DefaultScreen(display));
|
||||
TRACE("Going back to normal X mode of operation\n");
|
||||
TSXDGASetMode(display, DefaultScreen(display), 0);
|
||||
|
||||
/* Set the input handling back to absolute */
|
||||
X11DRV_EVENT_SetInputMethod(X11DRV_INPUT_ABSOLUTE);
|
||||
|
||||
/* Remove the handling of DGA2 events */
|
||||
X11DRV_EVENT_SetDGAStatus(0, -1);
|
||||
|
||||
/* Free the modes list */
|
||||
TSXFree(ddpriv->modes);
|
||||
} else
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
TSXF86DGADirectVideo(display,DefaultScreen(display),0);
|
||||
if (This->d.window && GetPropA(This->d.window,ddProp))
|
||||
DestroyWindow(This->d.window);
|
||||
TSXF86DGADirectVideo(display,DefaultScreen(display),0);
|
||||
if (This->d.window && GetPropA(This->d.window,ddProp))
|
||||
DestroyWindow(This->d.window);
|
||||
#ifdef HAVE_LIBXXF86VM
|
||||
if (orig_mode) {
|
||||
TSXF86VidModeSwitchToMode(
|
||||
display,
|
||||
DefaultScreen(display),
|
||||
orig_mode
|
||||
);
|
||||
if (orig_mode->privsize)
|
||||
if (orig_mode) {
|
||||
TSXF86VidModeSwitchToMode(
|
||||
display,
|
||||
DefaultScreen(display),
|
||||
orig_mode
|
||||
);
|
||||
if (orig_mode->privsize)
|
||||
TSXFree(orig_mode->private);
|
||||
free(orig_mode);
|
||||
orig_mode = NULL;
|
||||
}
|
||||
free(orig_mode);
|
||||
orig_mode = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RESTORE_SIGNALS
|
||||
|
@ -562,7 +438,7 @@ static ULONG WINAPI DGA_IDirectDraw2Impl_Release(LPDIRECTDRAW2 iface) {
|
|||
return This->ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DGA_IDirectDraw2Impl_QueryInterface(
|
||||
HRESULT WINAPI DGA_IDirectDraw2Impl_QueryInterface(
|
||||
LPDIRECTDRAW2 iface,REFIID refiid,LPVOID *obj
|
||||
) {
|
||||
ICOM_THIS(IDirectDraw2Impl,iface);
|
||||
|
@ -612,7 +488,6 @@ static HRESULT WINAPI DGA_IDirectDraw2Impl_EnumDisplayModes(
|
|||
) {
|
||||
ICOM_THIS(IDirectDraw2Impl,iface);
|
||||
DDSURFACEDESC ddsfd;
|
||||
DDPRIVATE(This);
|
||||
static struct {
|
||||
int w,h;
|
||||
} modes[5] = { /* some usual modes */
|
||||
|
@ -635,116 +510,68 @@ static HRESULT WINAPI DGA_IDirectDraw2Impl_EnumDisplayModes(
|
|||
ddsfd.ddsCaps.dwCaps = 0;
|
||||
ddsfd.dwBackBufferCount = 1;
|
||||
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
if (ddpriv->version == 2) {
|
||||
XDGAMode *modes = ddpriv->modes;
|
||||
for (i=0;i<sizeof(depths)/sizeof(depths[0]);i++) {
|
||||
ddsfd.dwBackBufferCount = 1;
|
||||
ddsfd.ddpfPixelFormat.dwFourCC = 0;
|
||||
ddsfd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
||||
ddsfd.ddpfPixelFormat.u.dwRGBBitCount = depths[i];
|
||||
/* FIXME: those masks would have to be set in depth > 8 */
|
||||
if (depths[i]==8) {
|
||||
ddsfd.ddpfPixelFormat.u1.dwRBitMask = 0;
|
||||
ddsfd.ddpfPixelFormat.u2.dwGBitMask = 0;
|
||||
ddsfd.ddpfPixelFormat.u3.dwBBitMask = 0;
|
||||
ddsfd.ddpfPixelFormat.u4.dwRGBAlphaBitMask= 0;
|
||||
ddsfd.ddsCaps.dwCaps=DDSCAPS_PALETTE;
|
||||
ddsfd.ddpfPixelFormat.dwFlags|=DDPF_PALETTEINDEXED8;
|
||||
} else {
|
||||
ddsfd.ddpfPixelFormat.u4.dwRGBAlphaBitMask= 0;
|
||||
|
||||
ddsfd.dwFlags |= DDSD_PITCH;
|
||||
for (i = 0; i < ddpriv->num_modes; i++) {
|
||||
if (TRACE_ON(ddraw)) {
|
||||
DPRINTF(" Enumerating mode %d : %s (FB: %dx%d / VP: %dx%d) - depth %d -",
|
||||
modes[i].num,
|
||||
modes[i].name, modes[i].imageWidth, modes[i].imageHeight,
|
||||
modes[i].viewportWidth, modes[i].viewportHeight,
|
||||
modes[i].depth);
|
||||
if (modes[i].flags & XDGAConcurrentAccess) DPRINTF(" XDGAConcurrentAccess ");
|
||||
if (modes[i].flags & XDGASolidFillRect) DPRINTF(" XDGASolidFillRect ");
|
||||
if (modes[i].flags & XDGABlitRect) DPRINTF(" XDGABlitRect ");
|
||||
if (modes[i].flags & XDGABlitTransRect) DPRINTF(" XDGABlitTransRect ");
|
||||
if (modes[i].flags & XDGAPixmap) DPRINTF(" XDGAPixmap ");
|
||||
DPRINTF("\n");
|
||||
}
|
||||
/* Fill the pixel format */
|
||||
ddsfd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
|
||||
ddsfd.ddpfPixelFormat.dwFourCC = 0;
|
||||
ddsfd.ddpfPixelFormat.u4.dwRGBAlphaBitMask= 0;
|
||||
ddsfd.ddpfPixelFormat.u.dwRGBBitCount = modes[i].bitsPerPixel;
|
||||
if (modes[i].depth == 8) {
|
||||
ddsfd.ddpfPixelFormat.dwFlags = DDPF_RGB|DDPF_PALETTEINDEXED8;
|
||||
ddsfd.ddpfPixelFormat.u1.dwRBitMask = 0;
|
||||
ddsfd.ddpfPixelFormat.u2.dwGBitMask = 0;
|
||||
ddsfd.ddpfPixelFormat.u3.dwBBitMask = 0;
|
||||
ddsfd.ddsCaps.dwCaps = DDSCAPS_PALETTE;
|
||||
} else {
|
||||
ddsfd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
||||
ddsfd.ddpfPixelFormat.u1.dwRBitMask = modes[i].redMask;
|
||||
ddsfd.ddpfPixelFormat.u2.dwGBitMask = modes[i].greenMask;
|
||||
ddsfd.ddpfPixelFormat.u3.dwBBitMask = modes[i].blueMask;
|
||||
}
|
||||
|
||||
ddsfd.dwWidth = modes[i].viewportWidth;
|
||||
ddsfd.dwHeight = modes[i].viewportHeight;
|
||||
ddsfd.lPitch = modes[i].imageWidth;
|
||||
|
||||
/* Send mode to the application */
|
||||
if (!modescb(&ddsfd,context)) return DD_OK;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
for (i=0;i<sizeof(depths)/sizeof(depths[0]);i++) {
|
||||
ddsfd.dwBackBufferCount = 1;
|
||||
ddsfd.ddpfPixelFormat.dwFourCC = 0;
|
||||
ddsfd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
||||
ddsfd.ddpfPixelFormat.u.dwRGBBitCount = depths[i];
|
||||
/* FIXME: those masks would have to be set in depth > 8 */
|
||||
if (depths[i]==8) {
|
||||
ddsfd.ddpfPixelFormat.u1.dwRBitMask = 0;
|
||||
ddsfd.ddpfPixelFormat.u2.dwGBitMask = 0;
|
||||
ddsfd.ddpfPixelFormat.u3.dwBBitMask = 0;
|
||||
ddsfd.ddpfPixelFormat.u4.dwRGBAlphaBitMask= 0;
|
||||
ddsfd.ddsCaps.dwCaps=DDSCAPS_PALETTE;
|
||||
ddsfd.ddpfPixelFormat.dwFlags|=DDPF_PALETTEINDEXED8;
|
||||
} else {
|
||||
ddsfd.ddpfPixelFormat.u4.dwRGBAlphaBitMask= 0;
|
||||
|
||||
/* FIXME: We should query those from X itself */
|
||||
switch (depths[i]) {
|
||||
case 16:
|
||||
ddsfd.ddpfPixelFormat.u1.dwRBitMask = 0xF800;
|
||||
ddsfd.ddpfPixelFormat.u2.dwGBitMask = 0x07E0;
|
||||
ddsfd.ddpfPixelFormat.u3.dwBBitMask= 0x001F;
|
||||
break;
|
||||
case 24:
|
||||
ddsfd.ddpfPixelFormat.u1.dwRBitMask = 0x00FF0000;
|
||||
ddsfd.ddpfPixelFormat.u2.dwGBitMask = 0x0000FF00;
|
||||
ddsfd.ddpfPixelFormat.u3.dwBBitMask= 0x000000FF;
|
||||
break;
|
||||
case 32:
|
||||
ddsfd.ddpfPixelFormat.u1.dwRBitMask = 0x00FF0000;
|
||||
ddsfd.ddpfPixelFormat.u2.dwGBitMask = 0x0000FF00;
|
||||
ddsfd.ddpfPixelFormat.u3.dwBBitMask= 0x000000FF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ddsfd.dwWidth = MONITOR_GetWidth(&MONITOR_PrimaryMonitor);
|
||||
ddsfd.dwHeight = MONITOR_GetHeight(&MONITOR_PrimaryMonitor);
|
||||
TRACE(" enumerating (%ldx%ldx%d)\n",ddsfd.dwWidth,ddsfd.dwHeight,depths[i]);
|
||||
if (!modescb(&ddsfd,context)) return DD_OK;
|
||||
|
||||
for (j=0;j<sizeof(modes)/sizeof(modes[0]);j++) {
|
||||
ddsfd.dwWidth = modes[j].w;
|
||||
ddsfd.dwHeight = modes[j].h;
|
||||
TRACE(" enumerating (%ldx%ldx%d)\n",ddsfd.dwWidth,ddsfd.dwHeight,depths[i]);
|
||||
if (!modescb(&ddsfd,context)) return DD_OK;
|
||||
}
|
||||
|
||||
if (!(dwFlags & DDEDM_STANDARDVGAMODES)) {
|
||||
/* modeX is not standard VGA */
|
||||
|
||||
ddsfd.dwHeight = 200;
|
||||
ddsfd.dwWidth = 320;
|
||||
TRACE(" enumerating (320x200x%d)\n",depths[i]);
|
||||
if (!modescb(&ddsfd,context)) return DD_OK;
|
||||
}
|
||||
/* FIXME: We should query those from X itself */
|
||||
switch (depths[i]) {
|
||||
case 16:
|
||||
ddsfd.ddpfPixelFormat.u1.dwRBitMask = 0xF800;
|
||||
ddsfd.ddpfPixelFormat.u2.dwGBitMask = 0x07E0;
|
||||
ddsfd.ddpfPixelFormat.u3.dwBBitMask= 0x001F;
|
||||
break;
|
||||
case 24:
|
||||
ddsfd.ddpfPixelFormat.u1.dwRBitMask = 0x00FF0000;
|
||||
ddsfd.ddpfPixelFormat.u2.dwGBitMask = 0x0000FF00;
|
||||
ddsfd.ddpfPixelFormat.u3.dwBBitMask= 0x000000FF;
|
||||
break;
|
||||
case 32:
|
||||
ddsfd.ddpfPixelFormat.u1.dwRBitMask = 0x00FF0000;
|
||||
ddsfd.ddpfPixelFormat.u2.dwGBitMask = 0x0000FF00;
|
||||
ddsfd.ddpfPixelFormat.u3.dwBBitMask= 0x000000FF;
|
||||
break;
|
||||
}
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
}
|
||||
#endif
|
||||
return DD_OK;
|
||||
|
||||
ddsfd.dwWidth = MONITOR_GetWidth(&MONITOR_PrimaryMonitor);
|
||||
ddsfd.dwHeight = MONITOR_GetHeight(&MONITOR_PrimaryMonitor);
|
||||
TRACE(" enumerating (%ldx%ldx%d)\n",ddsfd.dwWidth,ddsfd.dwHeight,depths[i]);
|
||||
if (!modescb(&ddsfd,context)) return DD_OK;
|
||||
|
||||
for (j=0;j<sizeof(modes)/sizeof(modes[0]);j++) {
|
||||
ddsfd.dwWidth = modes[j].w;
|
||||
ddsfd.dwHeight = modes[j].h;
|
||||
TRACE(" enumerating (%ldx%ldx%d)\n",ddsfd.dwWidth,ddsfd.dwHeight,depths[i]);
|
||||
if (!modescb(&ddsfd,context)) return DD_OK;
|
||||
}
|
||||
|
||||
if (!(dwFlags & DDEDM_STANDARDVGAMODES)) {
|
||||
/* modeX is not standard VGA */
|
||||
|
||||
ddsfd.dwHeight = 200;
|
||||
ddsfd.dwWidth = 320;
|
||||
TRACE(" enumerating (320x200x%d)\n",depths[i]);
|
||||
if (!modescb(&ddsfd,context)) return DD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DGA_IDirectDraw2Impl_GetDisplayMode(
|
||||
HRESULT WINAPI DGA_IDirectDraw2Impl_GetDisplayMode(
|
||||
LPDIRECTDRAW2 iface,LPDDSURFACEDESC lpddsfd
|
||||
) {
|
||||
ICOM_THIS(IDirectDraw2Impl,iface);
|
||||
|
@ -794,11 +621,7 @@ struct ICOM_VTABLE(IDirectDraw) dga_ddvt =
|
|||
XCAST(GetVerticalBlankStatus)IDirectDraw2Impl_GetVerticalBlankStatus,
|
||||
XCAST(Initialize)IDirectDraw2Impl_Initialize,
|
||||
XCAST(RestoreDisplayMode)DGA_IDirectDraw2Impl_RestoreDisplayMode,
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
XCAST(SetCooperativeLevel)DGA_IDirectDraw2Impl_SetCooperativeLevel,
|
||||
#else
|
||||
XCAST(SetCooperativeLevel)IDirectDraw2Impl_SetCooperativeLevel,
|
||||
#endif
|
||||
DGA_IDirectDrawImpl_SetDisplayMode,
|
||||
XCAST(WaitForVerticalBlank)IDirectDraw2Impl_WaitForVerticalBlank,
|
||||
};
|
||||
|
@ -816,7 +639,7 @@ static HRESULT WINAPI DGA_IDirectDraw2Impl_SetDisplayMode(
|
|||
return DGA_IDirectDrawImpl_SetDisplayMode((LPDIRECTDRAW)iface,width,height,depth);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DGA_IDirectDraw2Impl_GetAvailableVidMem(
|
||||
HRESULT WINAPI DGA_IDirectDraw2Impl_GetAvailableVidMem(
|
||||
LPDIRECTDRAW2 iface,LPDDSCAPS ddscaps,LPDWORD total,LPDWORD free
|
||||
) {
|
||||
ICOM_THIS(IDirectDraw2Impl,iface);
|
||||
|
|
|
@ -0,0 +1,427 @@
|
|||
/* DirectDraw IDirectDraw XF86DGA interface
|
||||
*
|
||||
* DGA2's specific IDirectDraw functions...
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "winerror.h"
|
||||
#include "wine/exception.h"
|
||||
#include "ddraw.h"
|
||||
#include "d3d.h"
|
||||
#include "debugtools.h"
|
||||
#include "message.h"
|
||||
#include "options.h"
|
||||
#include "monitor.h"
|
||||
|
||||
DEFAULT_DEBUG_CHANNEL(ddraw);
|
||||
|
||||
#include "dga2_private.h"
|
||||
|
||||
struct ICOM_VTABLE(IDirectDraw) dga2_ddvt;
|
||||
struct ICOM_VTABLE(IDirectDraw2) dga2_dd2vt;
|
||||
struct ICOM_VTABLE(IDirectDraw4) dga2_dd4vt;
|
||||
|
||||
#define DDPRIVATE(x) dga2_dd_private *ddpriv = ((dga2_dd_private*)(x)->private)
|
||||
#define DPPRIVATE(x) dga2_dp_private *dppriv = ((dga2_dp_private*)(x)->private)
|
||||
|
||||
/*******************************************************************************
|
||||
* IDirectDraw
|
||||
*/
|
||||
static HRESULT WINAPI DGA2_IDirectDraw2Impl_CreateSurface(
|
||||
LPDIRECTDRAW2 iface,LPDDSURFACEDESC lpddsd,LPDIRECTDRAWSURFACE *lpdsf,
|
||||
IUnknown *lpunk
|
||||
) {
|
||||
HRESULT ret;
|
||||
IDirectDrawSurfaceImpl* dsurf;
|
||||
|
||||
ret = DGA_IDirectDraw2Impl_CreateSurface_no_VT(iface, lpddsd, lpdsf, lpunk);
|
||||
|
||||
dsurf = *(IDirectDrawSurfaceImpl**)lpdsf;
|
||||
ICOM_VTBL(dsurf) = (ICOM_VTABLE(IDirectDrawSurface)*)&dga2_dds4vt;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DGA2_IDirectDraw2Impl_SetCooperativeLevel(
|
||||
LPDIRECTDRAW2 iface,HWND hwnd,DWORD cooplevel
|
||||
) {
|
||||
/* ICOM_THIS(IDirectDraw2Impl,iface); */
|
||||
HRESULT ret;
|
||||
int evbase, erbase;
|
||||
|
||||
ret = IDirectDraw2Impl_SetCooperativeLevel(iface, hwnd, cooplevel);
|
||||
|
||||
if (ret != DD_OK)
|
||||
return ret;
|
||||
|
||||
TSXDGAQueryExtension(display, &evbase, &erbase);
|
||||
|
||||
/* Now, start handling of DGA events giving the handle to the DDraw window
|
||||
as the window for which the event will be reported */
|
||||
TSXDGASelectInput(display, DefaultScreen(display),
|
||||
KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask );
|
||||
X11DRV_EVENT_SetDGAStatus(hwnd, evbase);
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
void _DGA2_Initialize_FrameBuffer(IDirectDrawImpl *This, int mode) {
|
||||
DDPIXELFORMAT *pf = &(This->d.directdraw_pixelformat);
|
||||
DDPRIVATE(This);
|
||||
|
||||
/* Now, get the device / mode description */
|
||||
ddpriv->dev = TSXDGASetMode(display, DefaultScreen(display), mode);
|
||||
|
||||
ddpriv->DGA.fb_width = ddpriv->dev->mode.imageWidth;
|
||||
TSXDGASetViewport(display,DefaultScreen(display),0,0, XDGAFlipImmediate);
|
||||
ddpriv->DGA.fb_height = ddpriv->dev->mode.viewportHeight;
|
||||
TRACE("video framebuffer: begin %p, width %d, memsize %d\n",
|
||||
ddpriv->dev->data,
|
||||
ddpriv->dev->mode.imageWidth,
|
||||
(ddpriv->dev->mode.imageWidth *
|
||||
ddpriv->dev->mode.imageHeight *
|
||||
(ddpriv->dev->mode.bitsPerPixel / 8))
|
||||
);
|
||||
TRACE("viewport height: %d\n", ddpriv->dev->mode.viewportHeight);
|
||||
/* Get the screen dimensions as seen by Wine.
|
||||
* In that case, it may be better to ignore the -desktop mode and return the
|
||||
* real screen size => print a warning */
|
||||
This->d.height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor);
|
||||
This->d.width = MONITOR_GetWidth(&MONITOR_PrimaryMonitor);
|
||||
ddpriv->DGA.fb_addr = ddpriv->dev->data;
|
||||
ddpriv->DGA.fb_memsize = (ddpriv->dev->mode.imageWidth *
|
||||
ddpriv->dev->mode.imageHeight *
|
||||
(ddpriv->dev->mode.bitsPerPixel / 8));
|
||||
ddpriv->DGA.vpmask = 0;
|
||||
|
||||
/* Fill the screen pixelformat */
|
||||
pf->dwSize = sizeof(DDPIXELFORMAT);
|
||||
pf->dwFourCC = 0;
|
||||
pf->u.dwRGBBitCount = ddpriv->dev->mode.bitsPerPixel;
|
||||
if (ddpriv->dev->mode.depth == 8) {
|
||||
pf->dwFlags = DDPF_PALETTEINDEXED8|DDPF_RGB;
|
||||
pf->u1.dwRBitMask = 0;
|
||||
pf->u2.dwGBitMask = 0;
|
||||
pf->u3.dwBBitMask = 0;
|
||||
} else {
|
||||
pf->dwFlags = DDPF_RGB;
|
||||
pf->u1.dwRBitMask = ddpriv->dev->mode.redMask;
|
||||
pf->u2.dwGBitMask = ddpriv->dev->mode.greenMask;
|
||||
pf->u3.dwBBitMask = ddpriv->dev->mode.blueMask;
|
||||
}
|
||||
pf->u4.dwRGBAlphaBitMask= 0;
|
||||
This->d.screen_pixelformat = *pf;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DGA2_IDirectDrawImpl_SetDisplayMode(
|
||||
LPDIRECTDRAW iface,DWORD width,DWORD height,DWORD depth
|
||||
) {
|
||||
ICOM_THIS(IDirectDrawImpl,iface);
|
||||
DDPRIVATE(This);
|
||||
int i;
|
||||
XDGAMode *modes = ddpriv->modes;
|
||||
int mode_to_use = -1;
|
||||
|
||||
TRACE("(%p)->(%ld,%ld,%ld)\n", This, width, height, depth);
|
||||
|
||||
/* Search in the list a display mode that corresponds to what is requested */
|
||||
for (i = 0; i < ddpriv->num_modes; i++) {
|
||||
if ((height == modes[i].viewportHeight) &&
|
||||
(width == modes[i].viewportWidth) &&
|
||||
(depth == modes[i].depth)
|
||||
)
|
||||
mode_to_use = modes[i].num;
|
||||
}
|
||||
|
||||
if (mode_to_use < 0) {
|
||||
ERR("Could not find matching mode !!!\n");
|
||||
return DDERR_UNSUPPORTEDMODE;
|
||||
} else {
|
||||
TRACE("Using mode number %d\n", mode_to_use);
|
||||
|
||||
TSXDGACloseFramebuffer(display, DefaultScreen(display));
|
||||
|
||||
if (!TSXDGAOpenFramebuffer(display, DefaultScreen(display))) {
|
||||
ERR("Error opening the frame buffer !!!\n");
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
|
||||
/* Initialize the frame buffer */
|
||||
_DGA2_Initialize_FrameBuffer(This, mode_to_use);
|
||||
|
||||
/* Re-get (if necessary) the DGA events */
|
||||
TSXDGASelectInput(display, DefaultScreen(display),
|
||||
KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask );
|
||||
}
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DGA2_IDirectDraw2Impl_CreatePalette(
|
||||
LPDIRECTDRAW2 iface,DWORD dwFlags,LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE *lpddpal,LPUNKNOWN lpunk
|
||||
) {
|
||||
ICOM_THIS(IDirectDraw2Impl,iface);
|
||||
IDirectDrawPaletteImpl* ddpal;
|
||||
dga_dp_private *dppriv;
|
||||
HRESULT res;
|
||||
int xsize = 0,i;
|
||||
DDPRIVATE(This);
|
||||
|
||||
TRACE("(%p)->(%08lx,%p,%p,%p)\n",This,dwFlags,palent,lpddpal,lpunk);
|
||||
res = common_IDirectDraw2Impl_CreatePalette(This,dwFlags,palent,(IDirectDrawPaletteImpl**)lpddpal,lpunk,&xsize);
|
||||
if (res != 0)
|
||||
return res;
|
||||
ddpal = *(IDirectDrawPaletteImpl**)lpddpal;
|
||||
ddpal->private = HeapAlloc(
|
||||
GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
sizeof(dga_dp_private)
|
||||
);
|
||||
dppriv = (dga_dp_private*)ddpal->private;
|
||||
|
||||
ICOM_VTBL(ddpal)= &dga_ddpalvt;
|
||||
if (This->d.directdraw_pixelformat.u.dwRGBBitCount<=8) {
|
||||
dppriv->cm = TSXDGACreateColormap(display,DefaultScreen(display), ddpriv->dev, AllocAll);
|
||||
} else {
|
||||
ERR("why are we doing CreatePalette in hi/truecolor?\n");
|
||||
dppriv->cm = 0;
|
||||
}
|
||||
if (dppriv->cm && xsize) {
|
||||
for (i=0;i<xsize;i++) {
|
||||
XColor xc;
|
||||
|
||||
xc.red = ddpal->palents[i].peRed<<8;
|
||||
xc.blue = ddpal->palents[i].peBlue<<8;
|
||||
xc.green = ddpal->palents[i].peGreen<<8;
|
||||
xc.flags = DoRed|DoBlue|DoGreen;
|
||||
xc.pixel = i;
|
||||
TSXStoreColor(display,dppriv->cm,&xc);
|
||||
}
|
||||
}
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DGA2_IDirectDraw2Impl_RestoreDisplayMode(LPDIRECTDRAW2 iface) {
|
||||
ICOM_THIS(IDirectDraw2Impl,iface);
|
||||
TRACE("(%p)->()\n",This);
|
||||
Sleep(1000);
|
||||
|
||||
XDGACloseFramebuffer(display,DefaultScreen(display));
|
||||
XDGASetMode(display,DefaultScreen(display), 0);
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
static ULONG WINAPI DGA2_IDirectDraw2Impl_Release(LPDIRECTDRAW2 iface) {
|
||||
ICOM_THIS(IDirectDraw2Impl,iface);
|
||||
DDPRIVATE(This);
|
||||
TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
|
||||
|
||||
if (!--(This->ref)) {
|
||||
TRACE("Closing access to the FrameBuffer\n");
|
||||
TSXDGACloseFramebuffer(display, DefaultScreen(display));
|
||||
TRACE("Going back to normal X mode of operation\n");
|
||||
TSXDGASetMode(display, DefaultScreen(display), 0);
|
||||
|
||||
/* Set the input handling back to absolute */
|
||||
X11DRV_EVENT_SetInputMethod(X11DRV_INPUT_ABSOLUTE);
|
||||
|
||||
/* Remove the handling of DGA2 events */
|
||||
X11DRV_EVENT_SetDGAStatus(0, -1);
|
||||
|
||||
/* Free the modes list */
|
||||
TSXFree(ddpriv->modes);
|
||||
|
||||
HeapFree(GetProcessHeap(),0,This);
|
||||
return S_OK;
|
||||
}
|
||||
return This->ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DGA2_IDirectDraw2Impl_EnumDisplayModes(
|
||||
LPDIRECTDRAW2 iface,DWORD dwFlags,LPDDSURFACEDESC lpddsfd,LPVOID context,LPDDENUMMODESCALLBACK modescb
|
||||
) {
|
||||
ICOM_THIS(IDirectDraw2Impl,iface);
|
||||
DDSURFACEDESC ddsfd;
|
||||
DDPRIVATE(This);
|
||||
int i;
|
||||
XDGAMode *modes = ddpriv->modes;
|
||||
|
||||
TRACE("(%p)->(0x%08lx,%p,%p,%p)\n",This,dwFlags,lpddsfd,context,modescb);
|
||||
ddsfd.dwSize = sizeof(ddsfd);
|
||||
ddsfd.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_BACKBUFFERCOUNT|DDSD_PIXELFORMAT|DDSD_CAPS;
|
||||
if (dwFlags & DDEDM_REFRESHRATES) {
|
||||
ddsfd.dwFlags |= DDSD_REFRESHRATE;
|
||||
ddsfd.u.dwRefreshRate = 60;
|
||||
}
|
||||
ddsfd.ddsCaps.dwCaps = 0;
|
||||
ddsfd.dwBackBufferCount = 1;
|
||||
|
||||
|
||||
ddsfd.dwFlags |= DDSD_PITCH;
|
||||
for (i = 0; i < ddpriv->num_modes; i++) {
|
||||
if (TRACE_ON(ddraw)) {
|
||||
DPRINTF(" Enumerating mode %d : %s (FB: %dx%d / VP: %dx%d) - depth %d -",
|
||||
modes[i].num,
|
||||
modes[i].name, modes[i].imageWidth, modes[i].imageHeight,
|
||||
modes[i].viewportWidth, modes[i].viewportHeight,
|
||||
modes[i].depth);
|
||||
if (modes[i].flags & XDGAConcurrentAccess) DPRINTF(" XDGAConcurrentAccess ");
|
||||
if (modes[i].flags & XDGASolidFillRect) DPRINTF(" XDGASolidFillRect ");
|
||||
if (modes[i].flags & XDGABlitRect) DPRINTF(" XDGABlitRect ");
|
||||
if (modes[i].flags & XDGABlitTransRect) DPRINTF(" XDGABlitTransRect ");
|
||||
if (modes[i].flags & XDGAPixmap) DPRINTF(" XDGAPixmap ");
|
||||
DPRINTF("\n");
|
||||
}
|
||||
/* Fill the pixel format */
|
||||
ddsfd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
|
||||
ddsfd.ddpfPixelFormat.dwFourCC = 0;
|
||||
ddsfd.ddpfPixelFormat.u4.dwRGBAlphaBitMask= 0;
|
||||
ddsfd.ddpfPixelFormat.u.dwRGBBitCount = modes[i].bitsPerPixel;
|
||||
if (modes[i].depth == 8) {
|
||||
ddsfd.ddpfPixelFormat.dwFlags = DDPF_RGB|DDPF_PALETTEINDEXED8;
|
||||
ddsfd.ddpfPixelFormat.u1.dwRBitMask = 0;
|
||||
ddsfd.ddpfPixelFormat.u2.dwGBitMask = 0;
|
||||
ddsfd.ddpfPixelFormat.u3.dwBBitMask = 0;
|
||||
ddsfd.ddsCaps.dwCaps = DDSCAPS_PALETTE;
|
||||
} else {
|
||||
ddsfd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
||||
ddsfd.ddpfPixelFormat.u1.dwRBitMask = modes[i].redMask;
|
||||
ddsfd.ddpfPixelFormat.u2.dwGBitMask = modes[i].greenMask;
|
||||
ddsfd.ddpfPixelFormat.u3.dwBBitMask = modes[i].blueMask;
|
||||
}
|
||||
|
||||
ddsfd.dwWidth = modes[i].viewportWidth;
|
||||
ddsfd.dwHeight = modes[i].viewportHeight;
|
||||
ddsfd.lPitch = modes[i].imageWidth;
|
||||
|
||||
/* Send mode to the application */
|
||||
if (!modescb(&ddsfd,context)) return DD_OK;
|
||||
}
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
/* Note: Hack so we can reuse the old functions without compiler warnings */
|
||||
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
|
||||
# define XCAST(fun) (typeof(dga2_ddvt.fn##fun))
|
||||
#else
|
||||
# define XCAST(fun) (void *)
|
||||
#endif
|
||||
|
||||
struct ICOM_VTABLE(IDirectDraw) dga2_ddvt =
|
||||
{
|
||||
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
||||
XCAST(QueryInterface)DGA_IDirectDraw2Impl_QueryInterface,
|
||||
XCAST(AddRef)IDirectDraw2Impl_AddRef,
|
||||
XCAST(Release)DGA2_IDirectDraw2Impl_Release,
|
||||
XCAST(Compact)IDirectDraw2Impl_Compact,
|
||||
XCAST(CreateClipper)IDirectDraw2Impl_CreateClipper,
|
||||
XCAST(CreatePalette)DGA2_IDirectDraw2Impl_CreatePalette,
|
||||
XCAST(CreateSurface)DGA2_IDirectDraw2Impl_CreateSurface,
|
||||
XCAST(DuplicateSurface)IDirectDraw2Impl_DuplicateSurface,
|
||||
XCAST(EnumDisplayModes)DGA2_IDirectDraw2Impl_EnumDisplayModes,
|
||||
XCAST(EnumSurfaces)IDirectDraw2Impl_EnumSurfaces,
|
||||
XCAST(FlipToGDISurface)IDirectDraw2Impl_FlipToGDISurface,
|
||||
XCAST(GetCaps)DGA_IDirectDraw2Impl_GetCaps,
|
||||
XCAST(GetDisplayMode)DGA_IDirectDraw2Impl_GetDisplayMode,
|
||||
XCAST(GetFourCCCodes)IDirectDraw2Impl_GetFourCCCodes,
|
||||
XCAST(GetGDISurface)IDirectDraw2Impl_GetGDISurface,
|
||||
XCAST(GetMonitorFrequency)IDirectDraw2Impl_GetMonitorFrequency,
|
||||
XCAST(GetScanLine)IDirectDraw2Impl_GetScanLine,
|
||||
XCAST(GetVerticalBlankStatus)IDirectDraw2Impl_GetVerticalBlankStatus,
|
||||
XCAST(Initialize)IDirectDraw2Impl_Initialize,
|
||||
XCAST(RestoreDisplayMode)DGA2_IDirectDraw2Impl_RestoreDisplayMode,
|
||||
XCAST(SetCooperativeLevel)DGA2_IDirectDraw2Impl_SetCooperativeLevel,
|
||||
DGA2_IDirectDrawImpl_SetDisplayMode,
|
||||
XCAST(WaitForVerticalBlank)IDirectDraw2Impl_WaitForVerticalBlank,
|
||||
};
|
||||
#undef XCAST
|
||||
|
||||
/*****************************************************************************
|
||||
* IDirectDraw2
|
||||
*
|
||||
*/
|
||||
|
||||
static HRESULT WINAPI DGA2_IDirectDraw2Impl_SetDisplayMode(
|
||||
LPDIRECTDRAW2 iface,DWORD width,DWORD height,DWORD depth,DWORD dwRefreshRate, DWORD dwFlags
|
||||
) {
|
||||
FIXME( "Ignored parameters (0x%08lx,0x%08lx)\n", dwRefreshRate, dwFlags );
|
||||
return DGA2_IDirectDrawImpl_SetDisplayMode((LPDIRECTDRAW)iface,width,height,depth);
|
||||
}
|
||||
|
||||
ICOM_VTABLE(IDirectDraw2) dga2_dd2vt =
|
||||
{
|
||||
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
||||
DGA_IDirectDraw2Impl_QueryInterface,
|
||||
IDirectDraw2Impl_AddRef,
|
||||
DGA2_IDirectDraw2Impl_Release,
|
||||
IDirectDraw2Impl_Compact,
|
||||
IDirectDraw2Impl_CreateClipper,
|
||||
DGA2_IDirectDraw2Impl_CreatePalette,
|
||||
DGA2_IDirectDraw2Impl_CreateSurface,
|
||||
IDirectDraw2Impl_DuplicateSurface,
|
||||
DGA2_IDirectDraw2Impl_EnumDisplayModes,
|
||||
IDirectDraw2Impl_EnumSurfaces,
|
||||
IDirectDraw2Impl_FlipToGDISurface,
|
||||
DGA_IDirectDraw2Impl_GetCaps,
|
||||
DGA_IDirectDraw2Impl_GetDisplayMode,
|
||||
IDirectDraw2Impl_GetFourCCCodes,
|
||||
IDirectDraw2Impl_GetGDISurface,
|
||||
IDirectDraw2Impl_GetMonitorFrequency,
|
||||
IDirectDraw2Impl_GetScanLine,
|
||||
IDirectDraw2Impl_GetVerticalBlankStatus,
|
||||
IDirectDraw2Impl_Initialize,
|
||||
DGA2_IDirectDraw2Impl_RestoreDisplayMode,
|
||||
DGA2_IDirectDraw2Impl_SetCooperativeLevel,
|
||||
DGA2_IDirectDraw2Impl_SetDisplayMode,
|
||||
IDirectDraw2Impl_WaitForVerticalBlank,
|
||||
DGA_IDirectDraw2Impl_GetAvailableVidMem
|
||||
};
|
||||
|
||||
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
|
||||
# define XCAST(fun) (typeof(dga2_dd4vt.fn##fun))
|
||||
#else
|
||||
# define XCAST(fun) (void*)
|
||||
#endif
|
||||
|
||||
ICOM_VTABLE(IDirectDraw4) dga2_dd4vt =
|
||||
{
|
||||
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
||||
XCAST(QueryInterface)DGA_IDirectDraw2Impl_QueryInterface,
|
||||
XCAST(AddRef)IDirectDraw2Impl_AddRef,
|
||||
XCAST(Release)DGA2_IDirectDraw2Impl_Release,
|
||||
XCAST(Compact)IDirectDraw2Impl_Compact,
|
||||
XCAST(CreateClipper)IDirectDraw2Impl_CreateClipper,
|
||||
XCAST(CreatePalette)DGA2_IDirectDraw2Impl_CreatePalette,
|
||||
XCAST(CreateSurface)DGA2_IDirectDraw2Impl_CreateSurface,
|
||||
XCAST(DuplicateSurface)IDirectDraw2Impl_DuplicateSurface,
|
||||
XCAST(EnumDisplayModes)DGA2_IDirectDraw2Impl_EnumDisplayModes,
|
||||
XCAST(EnumSurfaces)IDirectDraw2Impl_EnumSurfaces,
|
||||
XCAST(FlipToGDISurface)IDirectDraw2Impl_FlipToGDISurface,
|
||||
XCAST(GetCaps)DGA_IDirectDraw2Impl_GetCaps,
|
||||
XCAST(GetDisplayMode)DGA_IDirectDraw2Impl_GetDisplayMode,
|
||||
XCAST(GetFourCCCodes)IDirectDraw2Impl_GetFourCCCodes,
|
||||
XCAST(GetGDISurface)IDirectDraw2Impl_GetGDISurface,
|
||||
XCAST(GetMonitorFrequency)IDirectDraw2Impl_GetMonitorFrequency,
|
||||
XCAST(GetScanLine)IDirectDraw2Impl_GetScanLine,
|
||||
XCAST(GetVerticalBlankStatus)IDirectDraw2Impl_GetVerticalBlankStatus,
|
||||
XCAST(Initialize)IDirectDraw2Impl_Initialize,
|
||||
XCAST(RestoreDisplayMode)DGA2_IDirectDraw2Impl_RestoreDisplayMode,
|
||||
XCAST(SetCooperativeLevel)DGA2_IDirectDraw2Impl_SetCooperativeLevel,
|
||||
XCAST(SetDisplayMode)DGA2_IDirectDrawImpl_SetDisplayMode,
|
||||
XCAST(WaitForVerticalBlank)IDirectDraw2Impl_WaitForVerticalBlank,
|
||||
XCAST(GetAvailableVidMem)DGA_IDirectDraw2Impl_GetAvailableVidMem,
|
||||
IDirectDraw4Impl_GetSurfaceFromDC,
|
||||
IDirectDraw4Impl_RestoreAllSurfaces,
|
||||
IDirectDraw4Impl_TestCooperativeLevel,
|
||||
IDirectDraw4Impl_GetDeviceIdentifier
|
||||
};
|
||||
#undef XCAST
|
138
dlls/ddraw/dga.c
138
dlls/ddraw/dga.c
|
@ -82,18 +82,6 @@ DDRAW_DGA_Available(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
if (majver >= 2) {
|
||||
/* We have DGA 2.0 available ! */
|
||||
if (TSXDGAOpenFramebuffer(display, DefaultScreen(display))) {
|
||||
TSXDGACloseFramebuffer(display, DefaultScreen(display));
|
||||
return_value = 2;
|
||||
} else
|
||||
return_value = 0;
|
||||
return return_value;
|
||||
}
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
|
||||
/* You don't have to be root to use DGA extensions. Simply having access
|
||||
* to /dev/mem will do the trick
|
||||
* This can be achieved by adding the user to the "kmem" group on
|
||||
|
@ -139,105 +127,47 @@ DGA_Create( LPDIRECTDRAW *lplpDD ) {
|
|||
ddraw->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(dga_dd_private));
|
||||
|
||||
dgpriv = (dga_dd_private*)ddraw->private;
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
if (dga_version == 1) {
|
||||
dgpriv->version = 1;
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
TSXF86DGAQueryVersion(display,&major,&minor);
|
||||
TRACE("XF86DGA is version %d.%d\n",major,minor);
|
||||
|
||||
TSXF86DGAQueryDirectVideo(display,DefaultScreen(display),&flags);
|
||||
if (!(flags & XF86DGADirectPresent))
|
||||
MESSAGE("direct video is NOT PRESENT.\n");
|
||||
TSXF86DGAGetVideo(display,DefaultScreen(display),&addr,&width,&banksize,&memsize);
|
||||
dgpriv->fb_width = width;
|
||||
TSXF86DGAGetViewPortSize(display,DefaultScreen(display),&width,&height);
|
||||
TSXF86DGASetViewPort(display,DefaultScreen(display),0,0);
|
||||
dgpriv->fb_height = height;
|
||||
TRACE("video framebuffer: begin %p, width %d,banksize %d,memsize %d\n",
|
||||
addr,width,banksize,memsize
|
||||
);
|
||||
TRACE("viewport height: %d\n",height);
|
||||
/* Get the screen dimensions as seen by Wine.
|
||||
* In that case, it may be better to ignore the -desktop mode and
|
||||
* return the real screen size => print a warning
|
||||
*/
|
||||
ddraw->d.height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor);
|
||||
ddraw->d.width = MONITOR_GetWidth(&MONITOR_PrimaryMonitor);
|
||||
if ((ddraw->d.height != height) || (ddraw->d.width != width))
|
||||
WARN("You seem to be running in -desktop mode. This may prove dangerous in DGA mode...\n");
|
||||
dgpriv->fb_addr = addr;
|
||||
dgpriv->fb_memsize = memsize;
|
||||
dgpriv->vpmask = 0;
|
||||
TSXF86DGAQueryVersion(display,&major,&minor);
|
||||
TRACE("XF86DGA is version %d.%d\n",major,minor);
|
||||
|
||||
/* just assume the default depth is the DGA depth too */
|
||||
depth = DefaultDepthOfScreen(X11DRV_GetXScreen());
|
||||
TSXF86DGAQueryDirectVideo(display,DefaultScreen(display),&flags);
|
||||
if (!(flags & XF86DGADirectPresent))
|
||||
MESSAGE("direct video is NOT PRESENT.\n");
|
||||
TSXF86DGAGetVideo(display,DefaultScreen(display),&addr,&width,&banksize,&memsize);
|
||||
dgpriv->fb_width = width;
|
||||
TSXF86DGAGetViewPortSize(display,DefaultScreen(display),&width,&height);
|
||||
TSXF86DGASetViewPort(display,DefaultScreen(display),0,0);
|
||||
dgpriv->fb_height = height;
|
||||
TRACE("video framebuffer: begin %p, width %d,banksize %d,memsize %d\n",
|
||||
addr,width,banksize,memsize
|
||||
);
|
||||
TRACE("viewport height: %d\n",height);
|
||||
/* Get the screen dimensions as seen by Wine.
|
||||
* In that case, it may be better to ignore the -desktop mode and
|
||||
* return the real screen size => print a warning
|
||||
*/
|
||||
ddraw->d.height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor);
|
||||
ddraw->d.width = MONITOR_GetWidth(&MONITOR_PrimaryMonitor);
|
||||
if ((ddraw->d.height != height) || (ddraw->d.width != width))
|
||||
WARN("You seem to be running in -desktop mode. This may prove dangerous in DGA mode...\n");
|
||||
dgpriv->fb_addr = addr;
|
||||
dgpriv->fb_memsize = memsize;
|
||||
dgpriv->vpmask = 0;
|
||||
|
||||
_common_depth_to_pixelformat(depth, &(ddraw->d.directdraw_pixelformat), &(ddraw->d.screen_pixelformat), NULL);
|
||||
/* The cast is because DGA2's install colormap does not return a value whereas
|
||||
DGA1 version does */
|
||||
dgpriv->InstallColormap = (void (*)(Display *, int, Colormap)) TSXF86DGAInstallColormap;
|
||||
|
||||
/* just assume the default depth is the DGA depth too */
|
||||
depth = DefaultDepthOfScreen(X11DRV_GetXScreen());
|
||||
|
||||
_common_depth_to_pixelformat(depth, &(ddraw->d.directdraw_pixelformat), &(ddraw->d.screen_pixelformat), NULL);
|
||||
|
||||
#ifdef RESTORE_SIGNALS
|
||||
SIGNAL_Init();
|
||||
SIGNAL_Init();
|
||||
#endif
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
} else {
|
||||
XDGAMode *modes;
|
||||
int i, num_modes;
|
||||
int mode_to_use = 0;
|
||||
|
||||
dgpriv->version = 2;
|
||||
|
||||
TSXDGAQueryVersion(display,&major,&minor);
|
||||
TRACE("XDGA is version %d.%d\n",major,minor);
|
||||
|
||||
TRACE("Opening the frame buffer.\n");
|
||||
if (!TSXDGAOpenFramebuffer(display, DefaultScreen(display))) {
|
||||
ERR("Error opening the frame buffer !!!\n");
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
|
||||
/* List all available modes */
|
||||
modes = TSXDGAQueryModes(display, DefaultScreen(display), &num_modes);
|
||||
dgpriv->modes = modes;
|
||||
dgpriv->num_modes = num_modes;
|
||||
|
||||
TRACE("Available modes :\n");
|
||||
for (i = 0; i < num_modes; i++) {
|
||||
if (TRACE_ON(ddraw)) {
|
||||
DPRINTF(" %d) - %s (FB: %dx%d / VP: %dx%d) - depth %d -",
|
||||
modes[i].num,
|
||||
modes[i].name, modes[i].imageWidth, modes[i].imageHeight,
|
||||
modes[i].viewportWidth, modes[i].viewportHeight,
|
||||
modes[i].depth
|
||||
);
|
||||
#define XX(x) if (modes[i].flags & x) DPRINTF(" "#x" ");
|
||||
XX(XDGAConcurrentAccess);
|
||||
XX(XDGASolidFillRect);
|
||||
XX(XDGABlitRect);
|
||||
XX(XDGABlitTransRect);
|
||||
XX(XDGAPixmap);
|
||||
#undef XX
|
||||
DPRINTF("\n");
|
||||
}
|
||||
if ((MONITOR_GetHeight(&MONITOR_PrimaryMonitor) == modes[i].viewportHeight) &&
|
||||
(MONITOR_GetWidth(&MONITOR_PrimaryMonitor) == modes[i].viewportWidth) &&
|
||||
(MONITOR_GetDepth(&MONITOR_PrimaryMonitor) == modes[i].depth)
|
||||
) {
|
||||
mode_to_use = modes[i].num;
|
||||
}
|
||||
}
|
||||
if (mode_to_use == 0) {
|
||||
ERR("Could not find mode !\n");
|
||||
mode_to_use = 1;
|
||||
} else {
|
||||
DPRINTF("Using mode number %d\n", mode_to_use);
|
||||
}
|
||||
|
||||
/* Initialize the frame buffer */
|
||||
_DGA_Initialize_FrameBuffer(*lplpDD, mode_to_use);
|
||||
/* Set the input handling for relative mouse movements */
|
||||
X11DRV_EVENT_SetInputMethod(X11DRV_INPUT_RELATIVE);
|
||||
}
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,194 @@
|
|||
/* DirectDraw using DGA2
|
||||
*
|
||||
* Based (well, plagiarized :-) ) on Marcus' dga.c
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "winerror.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#ifdef HAVE_SYS_SIGNAL_H
|
||||
# include <sys/signal.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gdi.h"
|
||||
#include "heap.h"
|
||||
#include "dc.h"
|
||||
#include "win.h"
|
||||
#include "wine/exception.h"
|
||||
#include "ddraw.h"
|
||||
#include "d3d.h"
|
||||
#include "debugtools.h"
|
||||
#include "spy.h"
|
||||
#include "message.h"
|
||||
#include "options.h"
|
||||
#include "monitor.h"
|
||||
|
||||
#include "dga2_private.h"
|
||||
|
||||
DEFAULT_DEBUG_CHANNEL(ddraw);
|
||||
|
||||
static inline BOOL get_option( const char *name, BOOL def ) {
|
||||
return PROFILE_GetWineIniBool( "x11drv", name, def );
|
||||
}
|
||||
|
||||
static BYTE
|
||||
DDRAW_DGA2_Available(void)
|
||||
{
|
||||
int evbase, evret, majver, minver;
|
||||
static BYTE return_value = 0xFF;
|
||||
|
||||
/* This prevents from probing X times for DGA */
|
||||
if (return_value != 0xFF)
|
||||
return return_value;
|
||||
|
||||
if (!get_option( "UseDGA", 1 )) {
|
||||
TRACE("UseDGA disabled.\n");
|
||||
return_value = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* First, query the extenstion and its version */
|
||||
if (!TSXF86DGAQueryExtension(display,&evbase,&evret)) {
|
||||
TRACE("DGA extension not detected.\n");
|
||||
return_value = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!TSXF86DGAQueryVersion(display,&majver,&minver)) {
|
||||
TRACE("DGA version not detected.\n");
|
||||
return_value = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (majver >= 2) {
|
||||
/* We have DGA 2.0 available ! */
|
||||
if (TSXDGAOpenFramebuffer(display, DefaultScreen(display))) {
|
||||
TSXDGACloseFramebuffer(display, DefaultScreen(display));
|
||||
return_value = 2;
|
||||
} else
|
||||
return_value = 0;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT
|
||||
DGA2_Create( LPDIRECTDRAW *lplpDD ) {
|
||||
IDirectDrawImpl* ddraw;
|
||||
dga2_dd_private* dgpriv;
|
||||
int major,minor;
|
||||
int dga_version;
|
||||
XDGAMode *modes;
|
||||
int i, num_modes;
|
||||
int mode_to_use = 0;
|
||||
|
||||
/* Get DGA availability / version */
|
||||
dga_version = DDRAW_DGA2_Available();
|
||||
if (dga_version == 0)
|
||||
return DDERR_GENERIC;
|
||||
|
||||
/* If we were just testing ... return OK */
|
||||
if (lplpDD == NULL)
|
||||
return DD_OK;
|
||||
|
||||
ddraw = (IDirectDrawImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectDrawImpl));
|
||||
*lplpDD = (LPDIRECTDRAW)ddraw;
|
||||
ddraw->ref = 1;
|
||||
ICOM_VTBL(ddraw) = &dga2_ddvt;
|
||||
|
||||
ddraw->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(dga2_dd_private));
|
||||
|
||||
dgpriv = (dga2_dd_private*)ddraw->private;
|
||||
|
||||
TSXDGAQueryVersion(display,&major,&minor);
|
||||
TRACE("XDGA is version %d.%d\n",major,minor);
|
||||
|
||||
TRACE("Opening the frame buffer.\n");
|
||||
if (!TSXDGAOpenFramebuffer(display, DefaultScreen(display))) {
|
||||
ERR("Error opening the frame buffer !!!\n");
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
|
||||
/* List all available modes */
|
||||
modes = TSXDGAQueryModes(display, DefaultScreen(display), &num_modes);
|
||||
dgpriv->modes = modes;
|
||||
dgpriv->num_modes = num_modes;
|
||||
|
||||
TRACE("Available modes :\n");
|
||||
for (i = 0; i < num_modes; i++) {
|
||||
if (TRACE_ON(ddraw)) {
|
||||
DPRINTF(" %d) - %s (FB: %dx%d / VP: %dx%d) - depth %d -",
|
||||
modes[i].num,
|
||||
modes[i].name, modes[i].imageWidth, modes[i].imageHeight,
|
||||
modes[i].viewportWidth, modes[i].viewportHeight,
|
||||
modes[i].depth
|
||||
);
|
||||
#define XX(x) if (modes[i].flags & x) DPRINTF(" "#x" ");
|
||||
XX(XDGAConcurrentAccess);
|
||||
XX(XDGASolidFillRect);
|
||||
XX(XDGABlitRect);
|
||||
XX(XDGABlitTransRect);
|
||||
XX(XDGAPixmap);
|
||||
#undef XX
|
||||
DPRINTF("\n");
|
||||
}
|
||||
if ((MONITOR_GetHeight(&MONITOR_PrimaryMonitor) == modes[i].viewportHeight) &&
|
||||
(MONITOR_GetWidth(&MONITOR_PrimaryMonitor) == modes[i].viewportWidth) &&
|
||||
(MONITOR_GetDepth(&MONITOR_PrimaryMonitor) == modes[i].depth)
|
||||
) {
|
||||
mode_to_use = modes[i].num;
|
||||
}
|
||||
}
|
||||
if (mode_to_use == 0) {
|
||||
ERR("Could not find mode !\n");
|
||||
mode_to_use = 1;
|
||||
} else {
|
||||
DPRINTF("Using mode number %d\n", mode_to_use);
|
||||
}
|
||||
|
||||
dgpriv->DGA.InstallColormap = TSXDGAInstallColormap;
|
||||
|
||||
/* Initialize the frame buffer */
|
||||
_DGA2_Initialize_FrameBuffer(ddraw, mode_to_use);
|
||||
|
||||
/* Set the input handling for relative mouse movements */
|
||||
X11DRV_EVENT_SetInputMethod(X11DRV_INPUT_RELATIVE);
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
/* Where do these GUIDs come from? mkuuid.
|
||||
* They exist solely to distinguish between the targets Wine support,
|
||||
* and should be different than any other GUIDs in existence.
|
||||
*/
|
||||
static GUID DGA2_DirectDraw_GUID = { /* e2dcb020-dc60-11d1-8407-9714f5d50803 */
|
||||
0xe2dcb020,
|
||||
0xdc60,
|
||||
0x11d1,
|
||||
{0x84, 0x07, 0x97, 0x14, 0xf5, 0xd5, 0x08, 0x03}
|
||||
};
|
||||
|
||||
ddraw_driver dga2_driver = {
|
||||
&DGA2_DirectDraw_GUID,
|
||||
"display",
|
||||
"WINE XF86DGA2 DirectDraw Driver",
|
||||
150,
|
||||
DGA2_Create
|
||||
};
|
||||
|
||||
#ifdef __GNUC__
|
||||
static void DGA2_register(void) __attribute__((constructor));
|
||||
#else /* defined(__GNUC__) */
|
||||
static void __asm__dummy_dll_init(void) {
|
||||
asm("\t.section .init ,\"ax\"\n"
|
||||
"\tcall DGA2_register\n"
|
||||
"\t.previous\n");
|
||||
}
|
||||
#endif /* defined(__GNUC__) */
|
||||
static void DGA2_register(void) { ddraw_register_driver(&dga2_driver); }
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef __WINE_DDRAW_DGA2_PRIVATE_H
|
||||
#define __WINE_DDRAW_DGA2_PRIVATE_H
|
||||
|
||||
#include "ddraw_private.h"
|
||||
#include "x11_private.h"
|
||||
#include "dga_private.h"
|
||||
|
||||
#include "ts_xf86dga.h"
|
||||
#include "ts_xf86dga2.h"
|
||||
|
||||
extern ICOM_VTABLE(IDirectDrawSurface4) dga2_dds4vt;
|
||||
extern ICOM_VTABLE(IDirectDraw) dga2_ddvt;
|
||||
|
||||
typedef struct dga2_dd_private {
|
||||
/* Reuse of the DGA code */
|
||||
dga_dd_private DGA;
|
||||
|
||||
XDGADevice *dev;
|
||||
XDGAMode *modes;
|
||||
int num_modes;
|
||||
} dga2_dd_private;
|
||||
|
||||
typedef x11_dp_private dga2_dp_private; /* reuse X11 palette stuff */
|
||||
typedef dga_ds_private dga2_ds_private; /* reuse of DGA1 surface stuff */
|
||||
|
||||
extern void _DGA2_Initialize_FrameBuffer(IDirectDrawImpl *This, int mode);
|
||||
|
||||
#endif /* __WINE_DDRAW_DGA2_PRIVATE_H */
|
|
@ -5,9 +5,6 @@
|
|||
#include "x11_private.h"
|
||||
|
||||
#include "ts_xf86dga.h"
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
# include "ts_xf86dga2.h"
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
|
||||
#ifdef HAVE_LIBXXF86VM
|
||||
# include "ts_xf86vmode.h"
|
||||
|
@ -15,10 +12,6 @@ extern XF86VidModeModeInfo *orig_mode;
|
|||
#endif /* defined(HAVE_LIBXXF86VM) */
|
||||
|
||||
extern ICOM_VTABLE(IDirectDrawSurface4) dga_dds4vt;
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
extern ICOM_VTABLE(IDirectDrawSurface4) dga2_dds4vt;
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
|
||||
extern ICOM_VTABLE(IDirectDraw) dga_ddvt;
|
||||
extern ICOM_VTABLE(IDirectDrawPalette) dga_ddpalvt;
|
||||
|
||||
|
@ -28,12 +21,7 @@ typedef struct dga_dd_private {
|
|||
caddr_t fb_addr; /* start address of the framebuffer */
|
||||
DWORD fb_memsize; /* total memory on the card */
|
||||
DWORD vpmask; /* viewports in use flag bitmap */
|
||||
DWORD version; /* DGA version */
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
XDGADevice *dev;
|
||||
XDGAMode *modes;
|
||||
int num_modes;
|
||||
#endif
|
||||
void (*InstallColormap)(Display *, int, Colormap) ;
|
||||
} dga_dd_private;
|
||||
|
||||
typedef x11_dp_private dga_dp_private; /* reuse X11 palette stuff */
|
||||
|
@ -42,8 +30,17 @@ typedef struct dga_ds_private {
|
|||
DWORD fb_height;
|
||||
} dga_ds_private;
|
||||
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
extern void _DGA_Initialize_FrameBuffer(IDirectDrawImpl *This, int mode);
|
||||
#endif
|
||||
/* For usage in DGA2 */
|
||||
extern ULONG WINAPI DGA_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) ;
|
||||
extern HRESULT WINAPI DGA_IDirectDrawSurface4Impl_SetPalette(LPDIRECTDRAWSURFACE4 iface,LPDIRECTDRAWPALETTE pal) ;
|
||||
extern HRESULT WINAPI DGA_IDirectDraw2Impl_CreateSurface_no_VT(LPDIRECTDRAW2 iface,LPDDSURFACEDESC lpddsd,
|
||||
LPDIRECTDRAWSURFACE *lpdsf,IUnknown *lpunk) ;
|
||||
|
||||
extern HRESULT WINAPI DGA_IDirectDraw2Impl_QueryInterface(LPDIRECTDRAW2 iface,REFIID refiid,LPVOID *obj) ;
|
||||
extern HRESULT WINAPI DGA_IDirectDraw2Impl_GetCaps(LPDIRECTDRAW2 iface,LPDDCAPS caps1,LPDDCAPS caps2) ;
|
||||
|
||||
extern HRESULT WINAPI DGA_IDirectDraw2Impl_GetDisplayMode(LPDIRECTDRAW2 iface,LPDDSURFACEDESC lpddsfd) ;
|
||||
extern HRESULT WINAPI DGA_IDirectDraw2Impl_GetAvailableVidMem(LPDIRECTDRAW2 iface,LPDDSCAPS ddscaps,LPDWORD total,LPDWORD free) ;
|
||||
|
||||
|
||||
#endif /* __WINE_DDRAW_DGA_PRIVATE_H */
|
||||
|
|
|
@ -55,12 +55,7 @@ HRESULT WINAPI DGA_IDirectDrawPaletteImpl_SetEntries(
|
|||
This->palents[start+i].peGreen = palent[i].peGreen;
|
||||
This->palents[start+i].peFlags = palent[i].peFlags;
|
||||
}
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
if (ddpriv->version == 2) {
|
||||
TSXDGAInstallColormap(display,DefaultScreen(display),dppriv->cm);
|
||||
} else
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
TSXF86DGAInstallColormap(display,DefaultScreen(display),dppriv->cm);
|
||||
ddpriv->InstallColormap(display,DefaultScreen(display),dppriv->cm);
|
||||
return DD_OK;
|
||||
}
|
||||
ICOM_VTABLE(IDirectDrawPalette) dga_ddpalvt =
|
||||
|
|
|
@ -69,46 +69,6 @@ HRESULT WINAPI DGA_IDirectDrawSurface4Impl_Flip(
|
|||
return DD_OK;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
HRESULT WINAPI DGA2_IDirectDrawSurface4Impl_Flip(
|
||||
LPDIRECTDRAWSURFACE4 iface,LPDIRECTDRAWSURFACE4 flipto,DWORD dwFlags
|
||||
) {
|
||||
ICOM_THIS(IDirectDrawSurface4Impl,iface);
|
||||
IDirectDrawSurface4Impl* iflipto=(IDirectDrawSurface4Impl*)flipto;
|
||||
DWORD xheight;
|
||||
DSPRIVATE(This);
|
||||
dga_ds_private *fspriv;
|
||||
LPBYTE surf;
|
||||
|
||||
TRACE("(%p)->Flip(%p,%08lx)\n",This,iflipto,dwFlags);
|
||||
iflipto = _common_find_flipto(This,iflipto);
|
||||
|
||||
/* and flip! */
|
||||
fspriv = (dga_ds_private*)iflipto->private;
|
||||
TSXDGASetViewport(display,DefaultScreen(display),0,fspriv->fb_height, XDGAFlipRetrace);
|
||||
TSXDGASync(display,DefaultScreen(display));
|
||||
TSXFlush(display);
|
||||
if (iflipto->s.palette) {
|
||||
DPPRIVATE(iflipto->s.palette);
|
||||
if (dppriv->cm)
|
||||
TSXDGAInstallColormap(display,DefaultScreen(display),dppriv->cm);
|
||||
}
|
||||
|
||||
/* We need to switch the lowlevel surfaces, for DGA this is: */
|
||||
/* The height within the framebuffer */
|
||||
xheight = dspriv->fb_height;
|
||||
dspriv->fb_height = fspriv->fb_height;
|
||||
fspriv->fb_height = xheight;
|
||||
|
||||
/* And the assciated surface pointer */
|
||||
surf = This->s.surface_desc.u1.lpSurface;
|
||||
This->s.surface_desc.u1.lpSurface = iflipto->s.surface_desc.u1.lpSurface;
|
||||
iflipto->s.surface_desc.u1.lpSurface = surf;
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
|
||||
HRESULT WINAPI DGA_IDirectDrawSurface4Impl_SetPalette(
|
||||
LPDIRECTDRAWSURFACE4 iface,LPDIRECTDRAWPALETTE pal
|
||||
) {
|
||||
|
@ -129,12 +89,7 @@ HRESULT WINAPI DGA_IDirectDrawSurface4Impl_SetPalette(
|
|||
IDirectDrawPalette_Release( (IDirectDrawPalette*)This->s.palette );
|
||||
This->s.palette = ipal;
|
||||
fppriv = (dga_dp_private*)This->s.palette->private;
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
if (ddpriv->version == 2)
|
||||
TSXDGAInstallColormap(display,DefaultScreen(display),fppriv->cm);
|
||||
else
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
TSXF86DGAInstallColormap(display,DefaultScreen(display),fppriv->cm);
|
||||
ddpriv->InstallColormap(display,DefaultScreen(display),fppriv->cm);
|
||||
}
|
||||
return DD_OK;
|
||||
}
|
||||
|
@ -218,55 +173,3 @@ ICOM_VTABLE(IDirectDrawSurface4) dga_dds4vt =
|
|||
IDirectDrawSurface4Impl_GetUniquenessValue,
|
||||
IDirectDrawSurface4Impl_ChangeUniquenessValue
|
||||
};
|
||||
|
||||
#ifdef HAVE_LIBXXF86DGA2
|
||||
ICOM_VTABLE(IDirectDrawSurface4) dga2_dds4vt =
|
||||
{
|
||||
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
||||
IDirectDrawSurface4Impl_QueryInterface,
|
||||
IDirectDrawSurface4Impl_AddRef,
|
||||
DGA_IDirectDrawSurface4Impl_Release,
|
||||
IDirectDrawSurface4Impl_AddAttachedSurface,
|
||||
IDirectDrawSurface4Impl_AddOverlayDirtyRect,
|
||||
IDirectDrawSurface4Impl_Blt,
|
||||
IDirectDrawSurface4Impl_BltBatch,
|
||||
IDirectDrawSurface4Impl_BltFast,
|
||||
IDirectDrawSurface4Impl_DeleteAttachedSurface,
|
||||
IDirectDrawSurface4Impl_EnumAttachedSurfaces,
|
||||
IDirectDrawSurface4Impl_EnumOverlayZOrders,
|
||||
DGA2_IDirectDrawSurface4Impl_Flip,
|
||||
IDirectDrawSurface4Impl_GetAttachedSurface,
|
||||
IDirectDrawSurface4Impl_GetBltStatus,
|
||||
IDirectDrawSurface4Impl_GetCaps,
|
||||
IDirectDrawSurface4Impl_GetClipper,
|
||||
IDirectDrawSurface4Impl_GetColorKey,
|
||||
IDirectDrawSurface4Impl_GetDC,
|
||||
IDirectDrawSurface4Impl_GetFlipStatus,
|
||||
IDirectDrawSurface4Impl_GetOverlayPosition,
|
||||
IDirectDrawSurface4Impl_GetPalette,
|
||||
IDirectDrawSurface4Impl_GetPixelFormat,
|
||||
IDirectDrawSurface4Impl_GetSurfaceDesc,
|
||||
IDirectDrawSurface4Impl_Initialize,
|
||||
IDirectDrawSurface4Impl_IsLost,
|
||||
IDirectDrawSurface4Impl_Lock,
|
||||
IDirectDrawSurface4Impl_ReleaseDC,
|
||||
IDirectDrawSurface4Impl_Restore,
|
||||
IDirectDrawSurface4Impl_SetClipper,
|
||||
IDirectDrawSurface4Impl_SetColorKey,
|
||||
IDirectDrawSurface4Impl_SetOverlayPosition,
|
||||
DGA_IDirectDrawSurface4Impl_SetPalette,
|
||||
IDirectDrawSurface4Impl_Unlock,
|
||||
IDirectDrawSurface4Impl_UpdateOverlay,
|
||||
IDirectDrawSurface4Impl_UpdateOverlayDisplay,
|
||||
IDirectDrawSurface4Impl_UpdateOverlayZOrder,
|
||||
IDirectDrawSurface4Impl_GetDDInterface,
|
||||
IDirectDrawSurface4Impl_PageLock,
|
||||
IDirectDrawSurface4Impl_PageUnlock,
|
||||
IDirectDrawSurface4Impl_SetSurfaceDesc,
|
||||
IDirectDrawSurface4Impl_SetPrivateData,
|
||||
IDirectDrawSurface4Impl_GetPrivateData,
|
||||
IDirectDrawSurface4Impl_FreePrivateData,
|
||||
IDirectDrawSurface4Impl_GetUniquenessValue,
|
||||
IDirectDrawSurface4Impl_ChangeUniquenessValue
|
||||
};
|
||||
#endif /* defined(HAVE_LIBXXF86DGA2) */
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/* DirectDrawSurface XF86DGA implementation
|
||||
*
|
||||
* DGA2's specific DirectDrawSurface routines
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "winerror.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "debugtools.h"
|
||||
#include "dga2_private.h"
|
||||
|
||||
DEFAULT_DEBUG_CHANNEL(ddraw);
|
||||
|
||||
#define DDPRIVATE(x) dga2_dd_private *ddpriv = ((dga2_dd_private*)(x)->private)
|
||||
#define DPPRIVATE(x) dga2_dp_private *dppriv = ((dga2_dp_private*)(x)->private)
|
||||
#define DSPRIVATE(x) dga2_ds_private *dspriv = ((dga2_ds_private*)(x)->private)
|
||||
|
||||
HRESULT WINAPI DGA2_IDirectDrawSurface4Impl_Flip(
|
||||
LPDIRECTDRAWSURFACE4 iface,LPDIRECTDRAWSURFACE4 flipto,DWORD dwFlags
|
||||
) {
|
||||
ICOM_THIS(IDirectDrawSurface4Impl,iface);
|
||||
IDirectDrawSurface4Impl* iflipto=(IDirectDrawSurface4Impl*)flipto;
|
||||
DWORD xheight;
|
||||
DSPRIVATE(This);
|
||||
dga_ds_private *fspriv;
|
||||
LPBYTE surf;
|
||||
|
||||
TRACE("(%p)->Flip(%p,%08lx)\n",This,iflipto,dwFlags);
|
||||
iflipto = _common_find_flipto(This,iflipto);
|
||||
|
||||
/* and flip! */
|
||||
fspriv = (dga_ds_private*)iflipto->private;
|
||||
TSXDGASetViewport(display,DefaultScreen(display),0,fspriv->fb_height, XDGAFlipRetrace);
|
||||
TSXDGASync(display,DefaultScreen(display));
|
||||
TSXFlush(display);
|
||||
if (iflipto->s.palette) {
|
||||
DPPRIVATE(iflipto->s.palette);
|
||||
if (dppriv->cm)
|
||||
TSXDGAInstallColormap(display,DefaultScreen(display),dppriv->cm);
|
||||
}
|
||||
|
||||
/* We need to switch the lowlevel surfaces, for DGA this is: */
|
||||
/* The height within the framebuffer */
|
||||
xheight = dspriv->fb_height;
|
||||
dspriv->fb_height = fspriv->fb_height;
|
||||
fspriv->fb_height = xheight;
|
||||
|
||||
/* And the assciated surface pointer */
|
||||
surf = This->s.surface_desc.u1.lpSurface;
|
||||
This->s.surface_desc.u1.lpSurface = iflipto->s.surface_desc.u1.lpSurface;
|
||||
iflipto->s.surface_desc.u1.lpSurface = surf;
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
ICOM_VTABLE(IDirectDrawSurface4) dga2_dds4vt =
|
||||
{
|
||||
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
||||
IDirectDrawSurface4Impl_QueryInterface,
|
||||
IDirectDrawSurface4Impl_AddRef,
|
||||
DGA_IDirectDrawSurface4Impl_Release,
|
||||
IDirectDrawSurface4Impl_AddAttachedSurface,
|
||||
IDirectDrawSurface4Impl_AddOverlayDirtyRect,
|
||||
IDirectDrawSurface4Impl_Blt,
|
||||
IDirectDrawSurface4Impl_BltBatch,
|
||||
IDirectDrawSurface4Impl_BltFast,
|
||||
IDirectDrawSurface4Impl_DeleteAttachedSurface,
|
||||
IDirectDrawSurface4Impl_EnumAttachedSurfaces,
|
||||
IDirectDrawSurface4Impl_EnumOverlayZOrders,
|
||||
DGA2_IDirectDrawSurface4Impl_Flip,
|
||||
IDirectDrawSurface4Impl_GetAttachedSurface,
|
||||
IDirectDrawSurface4Impl_GetBltStatus,
|
||||
IDirectDrawSurface4Impl_GetCaps,
|
||||
IDirectDrawSurface4Impl_GetClipper,
|
||||
IDirectDrawSurface4Impl_GetColorKey,
|
||||
IDirectDrawSurface4Impl_GetDC,
|
||||
IDirectDrawSurface4Impl_GetFlipStatus,
|
||||
IDirectDrawSurface4Impl_GetOverlayPosition,
|
||||
IDirectDrawSurface4Impl_GetPalette,
|
||||
IDirectDrawSurface4Impl_GetPixelFormat,
|
||||
IDirectDrawSurface4Impl_GetSurfaceDesc,
|
||||
IDirectDrawSurface4Impl_Initialize,
|
||||
IDirectDrawSurface4Impl_IsLost,
|
||||
IDirectDrawSurface4Impl_Lock,
|
||||
IDirectDrawSurface4Impl_ReleaseDC,
|
||||
IDirectDrawSurface4Impl_Restore,
|
||||
IDirectDrawSurface4Impl_SetClipper,
|
||||
IDirectDrawSurface4Impl_SetColorKey,
|
||||
IDirectDrawSurface4Impl_SetOverlayPosition,
|
||||
DGA_IDirectDrawSurface4Impl_SetPalette,
|
||||
IDirectDrawSurface4Impl_Unlock,
|
||||
IDirectDrawSurface4Impl_UpdateOverlay,
|
||||
IDirectDrawSurface4Impl_UpdateOverlayDisplay,
|
||||
IDirectDrawSurface4Impl_UpdateOverlayZOrder,
|
||||
IDirectDrawSurface4Impl_GetDDInterface,
|
||||
IDirectDrawSurface4Impl_PageLock,
|
||||
IDirectDrawSurface4Impl_PageUnlock,
|
||||
IDirectDrawSurface4Impl_SetSurfaceDesc,
|
||||
IDirectDrawSurface4Impl_SetPrivateData,
|
||||
IDirectDrawSurface4Impl_GetPrivateData,
|
||||
IDirectDrawSurface4Impl_FreePrivateData,
|
||||
IDirectDrawSurface4Impl_GetUniquenessValue,
|
||||
IDirectDrawSurface4Impl_ChangeUniquenessValue
|
||||
};
|
Loading…
Reference in New Issue