Commit 10ad97c8 authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

Restructured DirectDraw. Split into X11 and DGA driver, and multiple

files/dirs for easier maintenance. Cleaned up structs and include files. Reindented the code. Started the same for Direct3D. Driver inclusion now done by using configure/Makefile/ELF constructor tricks.
parent 227a0894
......@@ -110,6 +110,12 @@ AC_CHECK_HEADERS(dlfcn.h,
)
)
AC_SUBST(XLIB)
AC_SUBST(X_SRCS)
X_SRCS=""
AC_SUBST(DGA_SRCS)
DGA_SRCS=""
AC_SUBST(MESA_SRCS)
MESA_SRCS=""
if test "$have_x" = "yes"
then
XLIB="-lXext -lX11"
......@@ -149,10 +155,19 @@ then
then
AC_CHECK_LIB(Xxf86dga,
XDGAQueryExtension,
AC_DEFINE(HAVE_LIBXXF86DGA2) AC_DEFINE(HAVE_LIBXXF86DGA) X_PRE_LIBS="$X_PRE_LIBS -lXxf86dga",,$X_LIBS -lXext -lX11 $X_EXTRA_LIBS)
AC_DEFINE(HAVE_LIBXXF86DGA2)
AC_DEFINE(HAVE_LIBXXF86DGA)
X_PRE_LIBS="$X_PRE_LIBS -lXxf86dga"
DGA_SRCS='$(DGA_SRCS)'
,,$X_LIBS -lXext -lX11 $X_EXTRA_LIBS
)
if test "$ac_cv_lib_Xxf86dga_XDGAQueryExtension" = "no"
then
AC_CHECK_LIB(Xxf86dga,XF86DGAQueryExtension,AC_DEFINE(HAVE_LIBXXF86DGA) X_PRE_LIBS="$X_PRE_LIBS -lXxf86dga",,$X_LIBS -lXext -lX11 $X_EXTRA_LIBS)
AC_CHECK_LIB(Xxf86dga,XF86DGAQueryExtension,
AC_DEFINE(HAVE_LIBXXF86DGA)
X_PRE_LIBS="$X_PRE_LIBS -lXxf86dga"
DGA_SRCS='$(DGA_SRCS)'
,,$X_LIBS -lXext -lX11 $X_EXTRA_LIBS)
fi
fi
......@@ -191,10 +206,20 @@ then
if test "$wine_cv_mesa_version_OK" = "yes" -a "$wine_cv_mesa_version_threadsafe" = "no"
then
dnl Check for the presense of the library
AC_CHECK_LIB(GL,glXCreateContext,AC_DEFINE(HAVE_LIBMESAGL) X_PRE_LIBS="$X_PRE_LIBS -lGL",,$X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS)
AC_CHECK_LIB(GL,glXCreateContext,
AC_DEFINE(HAVE_LIBMESAGL)
X_PRE_LIBS="$X_PRE_LIBS -lGL"
MESA_SRCS='$(MESA_SRCS)'
,,
$X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS)
if test "$ac_cv_lib_GL_glXCreateContext" = "no"
then
AC_CHECK_LIB(MesaGL,glXCreateContext,AC_DEFINE(HAVE_LIBMESAGL) X_PRE_LIBS="$X_PRE_LIBS -lMesaGL",,$X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS)
AC_CHECK_LIB(MesaGL,glXCreateContext,
AC_DEFINE(HAVE_LIBMESAGL)
X_PRE_LIBS="$X_PRE_LIBS -lMesaGL"
MESA_SRCS='$(MESA_SRCS)'
,,
$X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS)
fi
dnl Check for the Color Table and Paletted Texture extensions
......@@ -215,6 +240,7 @@ then
fi
CPPFLAGS="$ac_save_CPPFLAGS"
X_SRCS='$(X_SRCS)'
else
XLIB=""
X_CFLAGS=""
......
Makefile
ddraw.spec.c
*.spec.c
*.spec.s
libddraw.so.1.0
......@@ -8,17 +8,55 @@ IMPORTS = x11drv
SPEC_SRCS = ddraw.spec
C_SRCS = \
MESA_SRCS = \
d3dcommon.c \
d3ddevices.c \
d3ddevice/mesa.c \
d3dexecutebuffer.c \
d3dlight.c \
d3dmaterial.c \
d3dtexture.c \
d3dviewport.c \
ddraw_main.c
direct3d/mesa.c \
mesa.c
DGA_SRCS = \
ddraw/dga.c \
dpalette/dga.c \
dsurface/dga.c \
dga.c
X_SRCS = \
@DGA_SRCS@ \
@MESA_SRCS@ \
ddraw/x11.c \
dpalette/x11.c \
dsurface/x11.c \
x11.c
C_SRCS = \
@X_SRCS@ \
convert.c \
d3ddevice/main.c \
dclipper/main.c \
ddraw/main.c \
direct3d/main.c \
dpalette/main.c \
dsurface/main.c \
helper.c \
main.c
SUBDIRS = \
d3ddevice \
dclipper \
ddraw \
direct3d \
dpalette \
dsurface
@MAKE_DLL_RULES@
### Dependencies:
clean::
for i in $(SUBDIRS); do (cd $$i && $(RM) $(CLEAN_FILES)); done
### Dependencies:
#include "ddraw_private.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
/* *************************************
16 / 15 bpp to palettized 8 bpp
************************************* */
static void pixel_convert_16_to_8(void *src, void *dst, DWORD width, DWORD height, LONG pitch, IDirectDrawPaletteImpl* palette) {
unsigned char *c_src = (unsigned char *) src;
unsigned short *c_dst = (unsigned short *) dst;
int y;
if (palette != NULL) {
const unsigned short * pal = (unsigned short *) palette->screen_palents;
for (y = height; y--; ) {
#if defined(__i386__) && defined(__GNUC__)
/* gcc generates slightly inefficient code for the the copy/lookup,
* it generates one excess memory access (to pal) per pixel. Since
* we know that pal is not modified by the memory write we can
* put it into a register and reduce the number of memory accesses
* from 4 to 3 pp. There are two xor eax,eax to avoid pipeline
* stalls. (This is not guaranteed to be the fastest method.)
*/
__asm__ __volatile__(
"xor %%eax,%%eax\n"
"1:\n"
" lodsb\n"
" movw (%%edx,%%eax,2),%%ax\n"
" stosw\n"
" xor %%eax,%%eax\n"
" loop 1b\n"
: "=S" (c_src), "=D" (c_dst)
: "S" (c_src), "D" (c_dst) , "c" (width), "d" (pal)
: "eax", "cc", "memory"
);
c_src+=(pitch-width);
#else
unsigned char * srclineend = c_src+width;
while (c_src < srclineend)
*c_dst++ = pal[*c_src++];
c_src+=(pitch-width);
#endif
}
} else {
WARN("No palette set...\n");
memset(dst, 0, width * height * 2);
}
}
static void palette_convert_16_to_8(
LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count
) {
int i;
unsigned short *pal = (unsigned short *) screen_palette;
for (i = 0; i < count; i++)
pal[start + i] = (((((unsigned short) palent[i].peRed) & 0xF8) << 8) |
((((unsigned short) palent[i].peBlue) & 0xF8) >> 3) |
((((unsigned short) palent[i].peGreen) & 0xFC) << 3));
}
static void palette_convert_15_to_8(
LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count
) {
int i;
unsigned short *pal = (unsigned short *) screen_palette;
for (i = 0; i < count; i++)
pal[start + i] = (((((unsigned short) palent[i].peRed) & 0xF8) << 7) |
((((unsigned short) palent[i].peBlue) & 0xF8) >> 3) |
((((unsigned short) palent[i].peGreen) & 0xF8) << 2));
}
/* *************************************
24 to palettized 8 bpp
************************************* */
static void pixel_convert_24_to_8(
void *src, void *dst, DWORD width, DWORD height, LONG pitch,
IDirectDrawPaletteImpl* palette
) {
unsigned char *c_src = (unsigned char *) src;
unsigned char *c_dst = (unsigned char *) dst;
int y;
if (palette != NULL) {
const unsigned int *pal = (unsigned int *) palette->screen_palents;
for (y = height; y--; ) {
unsigned char * srclineend = c_src+width;
while (c_src < srclineend ) {
register long pixel = pal[*c_src++];
*c_dst++ = pixel;
*c_dst++ = pixel>>8;
*c_dst++ = pixel>>16;
}
c_src+=(pitch-width);
}
} else {
WARN("No palette set...\n");
memset(dst, 0, width * height * 4);
}
}
/* *************************************
32 bpp to palettized 8 bpp
************************************* */
static void pixel_convert_32_to_8(
void *src, void *dst, DWORD width, DWORD height, LONG pitch,
IDirectDrawPaletteImpl* palette
) {
unsigned char *c_src = (unsigned char *) src;
unsigned int *c_dst = (unsigned int *) dst;
int y;
if (palette != NULL) {
const unsigned int *pal = (unsigned int *) palette->screen_palents;
for (y = height; y--; ) {
#if defined(__i386__) && defined(__GNUC__)
/* See comment in pixel_convert_16_to_8 */
__asm__ __volatile__(
"xor %%eax,%%eax\n"
"1:\n"
" lodsb\n"
" movl (%%edx,%%eax,4),%%eax\n"
" stosl\n"
" xor %%eax,%%eax\n"
" loop 1b\n"
: "=S" (c_src), "=D" (c_dst)
: "S" (c_src), "D" (c_dst) , "c" (width), "d" (pal)
: "eax", "cc", "memory"
);
c_src+=(pitch-width);
#else
unsigned char * srclineend = c_src+width;
while (c_src < srclineend )
*c_dst++ = pal[*c_src++];
c_src+=(pitch-width);
#endif
}
} else {
WARN("No palette set...\n");
memset(dst, 0, width * height * 4);
}
}
static void palette_convert_24_to_8(
LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count
) {
int i;
unsigned int *pal = (unsigned int *) screen_palette;
for (i = 0; i < count; i++)
pal[start + i] = ((((unsigned int) palent[i].peRed) << 16) |
(((unsigned int) palent[i].peGreen) << 8) |
((unsigned int) palent[i].peBlue));
}
/* *************************************
32 bpp to 16 bpp
************************************* */
static void pixel_convert_32_to_16(
void *src, void *dst, DWORD width, DWORD height, LONG pitch,
IDirectDrawPaletteImpl* palette
) {
unsigned short *c_src = (unsigned short *) src;
unsigned int *c_dst = (unsigned int *) dst;
int y;
for (y = height; y--; ) {
unsigned short * srclineend = c_src+width;
while (c_src < srclineend ) {
*c_dst++ = (((*c_src & 0xF800) << 8) |
((*c_src & 0x07E0) << 5) |
((*c_src & 0x001F) << 3));
c_src++;
}
c_src+=((pitch/2)-width);
}
}
Convert ModeEmulations[5] = {
{ { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_32_to_8, palette_convert_24_to_8 } },
{ { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { 16, 16, 0xF800, 0x07E0, 0x001F }, { pixel_convert_32_to_16, NULL } },
{ { 24, 24, 0xFF0000, 0x00FF00, 0x0000FF }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_24_to_8, palette_convert_24_to_8 } },
{ { 16, 16, 0xF800, 0x07E0, 0x001F }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_16_to_8, palette_convert_16_to_8 } },
{ { 16, 15, 0x7C00, 0x03E0, 0x001F }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_16_to_8, palette_convert_15_to_8 } },
};
......@@ -14,10 +14,7 @@
DEFAULT_DEBUG_CHANNEL(ddraw)
#ifdef HAVE_MESAGL
static void _dump_renderstate(D3DRENDERSTATETYPE type,
DWORD value) {
void _dump_renderstate(D3DRENDERSTATETYPE type, DWORD value) {
char *states[] = {
NULL,
"D3DRENDERSTATE_TEXTUREHANDLE",
......@@ -105,245 +102,5 @@ static void _dump_renderstate(D3DRENDERSTATETYPE type,
"D3DRENDERSTATE_STIPPLEPATTERN30",
"D3DRENDERSTATE_STIPPLEPATTERN31"
};
DPRINTF(" %s = 0x%08lx\n", states[type], value);
}
void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
DWORD dwRenderState, RenderState *rs)
{
if (TRACE_ON(ddraw))
_dump_renderstate(dwRenderStateType, dwRenderState);
/* First, all the stipple patterns */
if ((dwRenderStateType >= D3DRENDERSTATE_STIPPLEPATTERN00) &&
(dwRenderStateType <= D3DRENDERSTATE_STIPPLEPATTERN31)) {
ERR("Unhandled stipple !\n");
} else {
ENTER_GL();
/* All others state variables */
switch (dwRenderStateType) {
case D3DRENDERSTATE_TEXTUREHANDLE: { /* 1 */
IDirect3DTexture2Impl* tex = (IDirect3DTexture2Impl*) dwRenderState;
if (tex == NULL) {
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
} else {
TRACE("setting OpenGL texture handle : %d\n", tex->tex_name);
glEnable(GL_TEXTURE_2D);
/* Default parameters */
glBindTexture(GL_TEXTURE_2D, tex->tex_name);
/* To prevent state change, we could test here what are the parameters
stored in the texture */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, rs->mag);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, rs->min);
}
} break;
case D3DRENDERSTATE_TEXTUREPERSPECTIVE: /* 4 */
if (dwRenderState)
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
else
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
break;
case D3DRENDERSTATE_ZENABLE: /* 7 */
if (dwRenderState)
glEnable(GL_DEPTH_TEST);
else
glDisable(GL_DEPTH_TEST);
break;
case D3DRENDERSTATE_FILLMODE: /* 8 */
switch ((D3DFILLMODE) dwRenderState) {
case D3DFILL_SOLID:
break;
default:
ERR("Unhandled fill mode !\n");
}
break;
case D3DRENDERSTATE_SHADEMODE: /* 9 */
switch ((D3DSHADEMODE) dwRenderState) {
case D3DSHADE_FLAT:
glShadeModel(GL_FLAT);
break;
case D3DSHADE_GOURAUD:
glShadeModel(GL_SMOOTH);
break;
default:
ERR("Unhandled shade mode !\n");
}
break;
case D3DRENDERSTATE_ZWRITEENABLE: /* 14 */
if (dwRenderState)
glDepthMask(GL_TRUE);
else
glDepthMask(GL_FALSE);
break;
case D3DRENDERSTATE_TEXTUREMAG: /* 17 */
switch ((D3DTEXTUREFILTER) dwRenderState) {
case D3DFILTER_NEAREST:
rs->mag = GL_NEAREST;
break;
case D3DFILTER_LINEAR:
rs->mag = GL_LINEAR;
break;
default:
ERR("Unhandled texture mag !\n");
}
break;
case D3DRENDERSTATE_TEXTUREMIN: /* 18 */
switch ((D3DTEXTUREFILTER) dwRenderState) {
case D3DFILTER_NEAREST:
rs->min = GL_NEAREST;
break;
case D3DFILTER_LINEAR:
rs->mag = GL_LINEAR;
break;
default:
ERR("Unhandled texture min !\n");
}
break;
case D3DRENDERSTATE_SRCBLEND: /* 19 */
switch ((D3DBLEND) dwRenderState) {
case D3DBLEND_SRCALPHA:
rs->src = GL_SRC_ALPHA;
break;
default:
ERR("Unhandled blend mode !\n");
}
glBlendFunc(rs->src, rs->dst);
break;
case D3DRENDERSTATE_DESTBLEND: /* 20 */
switch ((D3DBLEND) dwRenderState) {
case D3DBLEND_INVSRCALPHA:
rs->dst = GL_ONE_MINUS_SRC_ALPHA;
break;
default:
ERR("Unhandled blend mode !\n");
}
glBlendFunc(rs->src, rs->dst);
break;
case D3DRENDERSTATE_TEXTUREMAPBLEND: /* 21 */
switch ((D3DTEXTUREBLEND) dwRenderState) {
case D3DTBLEND_MODULATE:
case D3DTBLEND_MODULATEALPHA:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
break;
default:
ERR("Unhandled texture environment !\n");
}
break;
case D3DRENDERSTATE_CULLMODE: /* 22 */
switch ((D3DCULL) dwRenderState) {
case D3DCULL_NONE:
glDisable(GL_CULL_FACE);
break;
case D3DCULL_CW:
glEnable(GL_CULL_FACE);
glFrontFace(GL_CW);
break;
case D3DCULL_CCW:
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);
break;
default:
ERR("Unhandled cull mode !\n");
}
break;
case D3DRENDERSTATE_ZFUNC: /* 23 */
switch ((D3DCMPFUNC) dwRenderState) {
case D3DCMP_NEVER:
glDepthFunc(GL_NEVER);
break;
case D3DCMP_LESS:
glDepthFunc(GL_LESS);
break;
case D3DCMP_EQUAL:
glDepthFunc(GL_EQUAL);
break;
case D3DCMP_LESSEQUAL:
glDepthFunc(GL_LEQUAL);
break;
case D3DCMP_GREATER:
glDepthFunc(GL_GREATER);
break;
case D3DCMP_NOTEQUAL:
glDepthFunc(GL_NOTEQUAL);
break;
case D3DCMP_GREATEREQUAL:
glDepthFunc(GL_GEQUAL);
break;
case D3DCMP_ALWAYS:
glDepthFunc(GL_ALWAYS);
break;
default:
ERR("Unexpected value\n");
}
break;
case D3DRENDERSTATE_DITHERENABLE: /* 26 */
if (dwRenderState)
glEnable(GL_DITHER);
else
glDisable(GL_DITHER);
break;
case D3DRENDERSTATE_ALPHABLENDENABLE: /* 27 */
if (dwRenderState)
glEnable(GL_BLEND);
else
glDisable(GL_BLEND);
break;
case D3DRENDERSTATE_COLORKEYENABLE: /* 41 */
if (dwRenderState)
glEnable(GL_BLEND);
else
glDisable(GL_BLEND);
break;
case D3DRENDERSTATE_FLUSHBATCH: /* 50 */
break;
default:
ERR("Unhandled Render State\n");
break;
}
LEAVE_GL();
}
}
#endif /* HAVE_MESAGL */
......@@ -14,11 +14,11 @@
#include "d3d.h"
#include "debugtools.h"
#include "d3d_private.h"
#include "mesa_private.h"
DEFAULT_DEBUG_CHANNEL(ddraw)
#define D3DDPRIVATE(x) mesa_d3dd_private *odev=((mesa_d3dd_private*)(x)->private)
#ifdef HAVE_MESAGL
DEFAULT_DEBUG_CHANNEL(ddraw)
/* Structure to store the 'semi transformed' vertices */
typedef struct {
......@@ -180,7 +180,7 @@ static void execute(LPDIRECT3DEXECUTEBUFFER lpBuff,
/* DWORD il = ilpBuff->data.dwInstructionLength; */
void *instr = ilpBuff->desc.lpData + is;
OpenGL_IDirect3DDevice *odev = (OpenGL_IDirect3DDevice *) dev;
D3DDPRIVATE((IDirect3DDeviceImpl*)dev);
TRACE("ExecuteData : \n");
if (TRACE_ON(ddraw))
......@@ -857,5 +857,3 @@ static ICOM_VTABLE(IDirect3DExecuteBuffer) executebuffer_vtable =
IDirect3DExecuteBufferImpl_Validate,
IDirect3DExecuteBufferImpl_Optimize
};
#endif /* HAVE_MESAGL */
......@@ -13,11 +13,11 @@
#include "d3d.h"
#include "debugtools.h"
#include "d3d_private.h"
#include "mesa_private.h"
DEFAULT_DEBUG_CHANNEL(ddraw)
#ifdef HAVE_MESAGL
#define D3DLPRIVATE(x) mesa_d3dl_private*dlpriv=((mesa_d3dl_private*)x->private)
static ICOM_VTABLE(IDirect3DLight) light_vtable;
......@@ -34,6 +34,7 @@ static const float zero_value[] = {
};
static void update(IDirect3DLightImpl* This) {
D3DLPRIVATE(This);
switch (This->light.dltType) {
case D3DLIGHT_POINT: /* 1 */
TRACE("Activating POINT\n");
......@@ -53,21 +54,15 @@ static void update(IDirect3DLightImpl* This) {
This->light.dvDirection.z.z);
_dump_colorvalue(" color ", This->light.dcvColor);
glLightfv(This->light_num,
GL_AMBIENT,
(float *) zero_value);
glLightfv(This->light_num,
GL_DIFFUSE,
(float *) &(This->light.dcvColor));
glLightfv(dlpriv->light_num, GL_AMBIENT, (float *) zero_value);
glLightfv(dlpriv->light_num, GL_DIFFUSE, (float *) &(This->light.dcvColor));
direction[0] = -This->light.dvDirection.x.x;
direction[1] = -This->light.dvDirection.y.y;
direction[2] = -This->light.dvDirection.z.z;
direction[3] = 0.0; /* This is a directional light */
glLightfv(This->light_num,
GL_POSITION,
(float *) direction);
glLightfv(dlpriv->light_num, GL_POSITION, (float *) direction);
} break;
case D3DLIGHT_PARALLELPOINT: /* 4 */
......@@ -75,19 +70,19 @@ static void update(IDirect3DLightImpl* This) {
break;
default:
TRACE("Not a know Light Type\n");
TRACE("Not a known Light Type: %d\n",This->light.dltType);
break;
}
}
static void activate(IDirect3DLightImpl* This) {
D3DLPRIVATE(This);
ENTER_GL();
update(This);
/* If was not active, activate it */
if (This->is_active == 0) {
glEnable(This->light_num);
glEnable(dlpriv->light_num);
This->is_active = 1;
}
LEAVE_GL();
......@@ -254,18 +249,3 @@ static ICOM_VTABLE(IDirect3DLight) light_vtable =
IDirect3DLightImpl_SetLight,
IDirect3DLightImpl_GetLight
};
#else /* HAVE_MESAGL */
/* These function should never be called if MesaGL is not present */
LPDIRECT3DLIGHT d3dlight_create_dx3(IDirect3DImpl* d3d1) {
ERR("Should not be called...\n");
return NULL;
}
LPDIRECT3DLIGHT d3dlight_create(IDirect3D2Impl* d3d2) {
ERR("Should not be called...\n");
return NULL;
}
#endif /* HAVE_MESAGL */
......@@ -12,12 +12,10 @@
#include "d3d.h"
#include "debugtools.h"
#include "d3d_private.h"
#include "mesa_private.h"
DEFAULT_DEBUG_CHANNEL(ddraw)
#ifdef HAVE_MESAGL
static ICOM_VTABLE(IDirect3DMaterial2) material2_vtable;
static ICOM_VTABLE(IDirect3DMaterial) material_vtable;
......@@ -250,18 +248,3 @@ static ICOM_VTABLE(IDirect3DMaterial2) material2_vtable =
IDirect3DMaterial2Impl_GetMaterial,
IDirect3DMaterial2Impl_GetHandle
};
#else /* HAVE_MESAGL */
LPDIRECT3DMATERIAL d3dmaterial_create(IDirect3DImpl* d3d1) {
ERR("Should not be called...\n");
return NULL;
}
LPDIRECT3DMATERIAL2 d3dmaterial2_create(IDirect3D2Impl* d3d2) {
ERR("Should not be called...\n");
return NULL;
}
#endif /* HAVE_MESAGL */
/* DirectDrawClipper implementation
*
* Copyright 2000 Marcus Meissner
*/
#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 "ddraw_private.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
/******************************************************************************
* DirectDrawCreateClipper (DDRAW.7)
*/
HRESULT WINAPI DirectDrawCreateClipper(
DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, LPUNKNOWN pUnkOuter
) {
IDirectDrawClipperImpl** ilplpDDClipper=(IDirectDrawClipperImpl**)lplpDDClipper;
TRACE("(%08lx,%p,%p)\n", dwFlags, ilplpDDClipper, pUnkOuter);
*ilplpDDClipper = (IDirectDrawClipperImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectDrawClipperImpl));
ICOM_VTBL(*ilplpDDClipper) = &ddclipvt;
(*ilplpDDClipper)->ref = 1;
(*ilplpDDClipper)->hWnd = 0;
return DD_OK;
}
/******************************************************************************
* IDirectDrawClipper
*/
static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd(
LPDIRECTDRAWCLIPPER iface, DWORD dwFlags, HWND hWnd
) {
ICOM_THIS(IDirectDrawClipperImpl,iface);
TRACE("(%p)->SetHwnd(0x%08lx,0x%08lx)\n",This,dwFlags,(DWORD)hWnd);
if( dwFlags ) {
FIXME("dwFlags = 0x%08lx, not supported.\n",dwFlags);
return DDERR_INVALIDPARAMS;
}
This->hWnd = hWnd;
return DD_OK;
}
static ULONG WINAPI IDirectDrawClipperImpl_Release(LPDIRECTDRAWCLIPPER iface) {
ICOM_THIS(IDirectDrawClipperImpl,iface);
TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
This->ref--;
if (This->ref)
return This->ref;
HeapFree(GetProcessHeap(),0,This);
return S_OK;
}
static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(
LPDIRECTDRAWCLIPPER iface,LPRECT rects,LPRGNDATA lprgn,LPDWORD hmm
) {
ICOM_THIS(IDirectDrawClipperImpl,iface);
FIXME("(%p,%p,%p,%p),stub!\n",This,rects,lprgn,hmm);
if (hmm) *hmm=0;
return DD_OK;
}
static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(
LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,DWORD hmm
) {
ICOM_THIS(IDirectDrawClipperImpl,iface);
FIXME("(%p,%p,%ld),stub!\n",This,lprgn,hmm);
return DD_OK;
}
static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface(
LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj
) {
ICOM_THIS(IDirectDrawClipperImpl,iface);
FIXME("(%p)->(%p,%p),stub!\n",This,riid,ppvObj);
return OLE_E_ENUM_NOMORE;
}
static ULONG WINAPI IDirectDrawClipperImpl_AddRef( LPDIRECTDRAWCLIPPER iface )
{
ICOM_THIS(IDirectDrawClipperImpl,iface);
TRACE("(%p)->() incrementing from %lu.\n", This, This->ref );
return ++(This->ref);
}
static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(
LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr
) {
ICOM_THIS(IDirectDrawClipperImpl,iface);
FIXME("(%p)->(%p),stub!\n",This,hWndPtr);
*hWndPtr = This->hWnd;
return DD_OK;
}
static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(
LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags
) {
ICOM_THIS(IDirectDrawClipperImpl,iface);
FIXME("(%p)->(%p,0x%08lx),stub!\n",This,lpDD,dwFlags);
return DD_OK;
}
static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(
LPDIRECTDRAWCLIPPER iface, BOOL* lpbChanged
) {
ICOM_THIS(IDirectDrawClipperImpl,iface);
FIXME("(%p)->(%p),stub!\n",This,lpbChanged);
return DD_OK;
}
ICOM_VTABLE(IDirectDrawClipper) ddclipvt =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectDrawClipperImpl_QueryInterface,
IDirectDrawClipperImpl_AddRef,
IDirectDrawClipperImpl_Release,
IDirectDrawClipperImpl_GetClipList,
IDirectDrawClipperImpl_GetHWnd,
IDirectDrawClipperImpl_Initialize,
IDirectDrawClipperImpl_IsClipListChanged,
IDirectDrawClipperImpl_SetClipList,
IDirectDrawClipperImpl_SetHwnd
};
name ddraw
type win32
import kernel32.dll
import user32.dll
import ole32.dll
@ stub DDHAL32_VidMemAlloc
@ stub DDHAL32_VidMemFree
@ stub DDInternalLock
@ stub DDInternalUnlock
@ stdcall DSoundHelp(long long long) DSoundHelp
@ stub DSoundHelp
@ stdcall DirectDrawCreate(ptr ptr ptr) DirectDrawCreate
@ stdcall DirectDrawCreateClipper(long ptr ptr) DirectDrawCreateClipper
@ stdcall DirectDrawEnumerateA(ptr ptr) DirectDrawEnumerateA
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/* DirectDraw using DGA
*
* Copyright 1997-2000 Marcus Meissner
* Copyright 1998-2000 Lionel Ulmer (most of Direct3D stuff)
*/
/* XF86DGA:
* When DirectVideo mode is enabled you can no longer use 'normal' X
* applications nor can you switch to a virtual console. Also, enabling
* only works, if you have switched to the screen where the application
* is running.
* Some ways to debug this stuff are:
* - A terminal connected to the serial port. Can be bought used for cheap.
* (This is the method I am using.)
* - Another machine connected over some kind of network.
*/
#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 "dga_private.h"
#define RESTORE__SIGNALS
DEFAULT_DEBUG_CHANNEL(ddraw);
#ifdef HAVE_LIBXXF86VM
XF86VidModeModeInfo *orig_mode = NULL;
#endif
static inline BOOL get_option( const char *name, BOOL def ) {
return PROFILE_GetWineIniBool( "x11drv", name, def );
}
static BYTE
DDRAW_DGA_Available(void)
{
int fd, 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;
}
#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
* Debian 2.x systems, don't know about
* others. --stephenc
*/
if ((fd = open("/dev/mem", O_RDWR)) != -1)
close(fd);
if (fd != -1)
return_value = 1;
else {
TRACE("You have no access to /dev/mem\n");
return_value = 0;
}
return return_value;
}
HRESULT
DGA_Create( LPDIRECTDRAW *lplpDD ) {
IDirectDrawImpl* ddraw;
dga_dd_private* dgpriv;
int memsize,banksize,major,minor,flags;
char *addr;
int depth;
int dga_version;
int width, height;
/* Get DGA availability / version */
dga_version = DDRAW_DGA_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) = &dga_ddvt;
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;
/* 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();
#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(*ilplpDD, mode_to_use);
/* Set the input handling for relative mouse movements */
X11DRV_EVENT_SetInputMehod(X11DRV_INPUT_RELATIVE);
}
#endif /* defined(HAVE_LIBXXF86DGA2) */
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 DGA_DirectDraw_GUID = { /* e2dcb020-dc60-11d1-8407-9714f5d50802 */
0xe2dcb020,
0xdc60,
0x11d1,
{0x84, 0x07, 0x97, 0x14, 0xf5, 0xd5, 0x08, 0x02}
};
ddraw_driver dga_driver = {
&DGA_DirectDraw_GUID,
"display",
"WINE XF86DGA DirectDraw Driver",
100,
DGA_Create
};
#ifdef __GNUC__
static void DGA_register(void) __attribute__((constructor));
#else /* defined(__GNUC__) */
static void __asm__dummy_dll_init(void) {
asm("\t.section .init ,\"ax\"\n"
"\tcall DGA_register\n"
"\t.previous\n");
}
#endif /* defined(__GNUC__) */
static void DGA_register(void) { ddraw_register_driver(&dga_driver); }
#ifndef __WINE_DDRAW_DGA_PRIVATE_H
#define __WINE_DDRAW_DGA_PRIVATE_H
#include "ddraw_private.h"
#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"
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;
typedef struct dga_dd_private {
DWORD fb_height; /* height of the viewport */
DWORD fb_width; /* width of the viewport */
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 */
} dga_dd_private;
typedef x11_dp_private dga_dp_private; /* reuse X11 palette stuff */
typedef struct dga_ds_private {
DWORD fb_height;
} dga_ds_private;
#endif /* __WINE_DDRAW_DGA_PRIVATE_H */
#include "config.h"
#include <assert.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include "winerror.h"
#include "ddraw.h"
#include "d3d.h"
#include "message.h"
#include "options.h"
#include "monitor.h"
#include "debugtools.h"
#include "d3d_private.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
static ICOM_VTABLE(IDirect3D) d3dvt;
static ICOM_VTABLE(IDirect3D2) d3d2vt;
/*******************************************************************************
* IDirect3D
*/
HRESULT WINAPI IDirect3DImpl_QueryInterface(
LPDIRECT3D iface,REFIID refiid,LPVOID *obj
) {
ICOM_THIS(IDirect3DImpl,iface);
/* FIXME: Not sure if this is correct */
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
if (( IsEqualGUID( &IID_IDirectDraw, refiid ) ) ||
( IsEqualGUID (&IID_IDirectDraw2, refiid ) ) ||
( IsEqualGUID( &IID_IDirectDraw4, refiid ) )
) {
*obj = This->ddraw;
IDirect3D_AddRef(iface);
TRACE(" Creating IDirectDrawX interface (%p)\n", *obj);
return S_OK;
}
if (( IsEqualGUID( &IID_IDirect3D, refiid ) ) ||
( IsEqualGUID( &IID_IUnknown, refiid ) ) ) {
*obj = This;
IDirect3D_AddRef(iface);
TRACE(" Creating IDirect3D interface (%p)\n", *obj);
return S_OK;
}
if ( IsEqualGUID( &IID_IDirect3D2, refiid ) ) {
IDirect3D2Impl* d3d;
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
d3d->ref = 1;
d3d->ddraw = This->ddraw;
IDirect3D_AddRef(iface);
ICOM_VTBL(d3d) = &d3d2vt;
*obj = d3d;
TRACE(" Creating IDirect3D2 interface (%p)\n", *obj);
return S_OK;
}
FIXME("(%p):interface for IID %s NOT found!\n",This,debugstr_guid(refiid));
return OLE_E_ENUM_NOMORE;
}
ULONG WINAPI IDirect3DImpl_AddRef(LPDIRECT3D iface) {
ICOM_THIS(IDirect3DImpl,iface);
TRACE("(%p)->() incrementing from %lu.\n", This, This->ref );
return ++(This->ref);
}
ULONG WINAPI IDirect3DImpl_Release(LPDIRECT3D iface)
{
ICOM_THIS(IDirect3DImpl,iface);
TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
if (!--(This->ref)) {
IDirectDraw2_Release((IDirectDraw2*)This->ddraw);
HeapFree(GetProcessHeap(),0,This);
return S_OK;
}
return This->ref;
}
HRESULT WINAPI IDirect3DImpl_Initialize(LPDIRECT3D iface,REFIID refiid) {
ICOM_THIS(IDirect3DImpl,iface);
/* FIXME: Not sure if this is correct */
FIXME("(%p)->(%s):stub.\n",This,debugstr_guid(refiid));
return DDERR_ALREADYINITIALIZED;
}
HRESULT WINAPI IDirect3DImpl_EnumDevices(
LPDIRECT3D iface, LPD3DENUMDEVICESCALLBACK cb, LPVOID context
) {
ICOM_THIS(IDirect3DImpl,iface);
FIXME("(%p)->(%p,%p),stub!\n",This,cb,context);
return DD_OK;
}
HRESULT WINAPI IDirect3DImpl_CreateLight(
LPDIRECT3D iface, LPDIRECT3DLIGHT *lplight, IUnknown *lpunk
) {
ICOM_THIS(IDirect3DImpl,iface);
FIXME("(%p)->(%p,%p): stub\n", This, lplight, lpunk);
return E_FAIL;
}
HRESULT WINAPI IDirect3DImpl_CreateMaterial(
LPDIRECT3D iface, LPDIRECT3DMATERIAL *lpmaterial, IUnknown *lpunk
) {
ICOM_THIS(IDirect3DImpl,iface);
FIXME("(%p)->(%p,%p): stub\n", This, lpmaterial, lpunk);
return E_FAIL;
}
HRESULT WINAPI IDirect3DImpl_CreateViewport(
LPDIRECT3D iface, LPDIRECT3DVIEWPORT *lpviewport, IUnknown *lpunk
) {
ICOM_THIS(IDirect3DImpl,iface);
FIXME("(%p)->(%p,%p): stub\n", This, lpviewport, lpunk);
return E_FAIL;
}
HRESULT WINAPI IDirect3DImpl_FindDevice(
LPDIRECT3D iface, LPD3DFINDDEVICESEARCH lpfinddevsrc,
LPD3DFINDDEVICERESULT lpfinddevrst)
{
ICOM_THIS(IDirect3DImpl,iface);
FIXME("(%p)->(%p,%p): stub\n", This, lpfinddevsrc, lpfinddevrst);
return DD_OK;
}
/* This is for checking the correctness of the prototypes/functions.
* Do not remove.
*/
static WINE_UNUSED ICOM_VTABLE(IDirect3D) d3dvt = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirect3DImpl_QueryInterface,
IDirect3DImpl_AddRef,
IDirect3DImpl_Release,
IDirect3DImpl_Initialize,
IDirect3DImpl_EnumDevices,
IDirect3DImpl_CreateLight,
IDirect3DImpl_CreateMaterial,
IDirect3DImpl_CreateViewport,
IDirect3DImpl_FindDevice
};
/*******************************************************************************
* IDirect3D2
*/
HRESULT WINAPI IDirect3D2Impl_QueryInterface(
LPDIRECT3D2 iface,REFIID refiid,LPVOID *obj) {
ICOM_THIS(IDirect3D2Impl,iface);
/* FIXME: Not sure if this is correct */
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
if ( ( IsEqualGUID( &IID_IDirectDraw, refiid ) ) ||
( IsEqualGUID( &IID_IDirectDraw2, refiid ) ) ||
( IsEqualGUID( &IID_IDirectDraw4, refiid ) ) ) {
*obj = This->ddraw;
IDirect3D2_AddRef(iface);
TRACE(" Creating IDirectDrawX interface (%p)\n", *obj);
return S_OK;
}
if ( ( IsEqualGUID( &IID_IDirect3D2, refiid ) ) ||
( IsEqualGUID( &IID_IUnknown, refiid ) ) ) {
*obj = This;
IDirect3D2_AddRef(iface);
TRACE(" Creating IDirect3D2 interface (%p)\n", *obj);
return S_OK;
}
if ( IsEqualGUID( &IID_IDirect3D, refiid ) ) {
IDirect3DImpl* d3d;
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
d3d->ref = 1;
d3d->ddraw = This->ddraw;
IDirect3D2_AddRef(iface);
ICOM_VTBL(d3d) = &d3dvt;
*obj = d3d;
TRACE(" Creating IDirect3D interface (%p)\n", *obj);
return S_OK;
}
FIXME("(%p):interface for IID %s NOT found!\n",This,debugstr_guid(refiid));
return OLE_E_ENUM_NOMORE;
}
ULONG WINAPI IDirect3D2Impl_AddRef(LPDIRECT3D2 iface) {
ICOM_THIS(IDirect3D2Impl,iface);
TRACE("(%p)->() incrementing from %lu.\n", This, This->ref );
return ++(This->ref);
}
ULONG WINAPI IDirect3D2Impl_Release(LPDIRECT3D2 iface) {
ICOM_THIS(IDirect3D2Impl,iface);
TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
if (!--(This->ref)) {
IDirectDraw2_Release((IDirectDraw2*)This->ddraw);
HeapFree(GetProcessHeap(),0,This);
return S_OK;
}
return This->ref;
}
HRESULT WINAPI IDirect3D2Impl_EnumDevices(
LPDIRECT3D2 iface,LPD3DENUMDEVICESCALLBACK cb, LPVOID context
) {
ICOM_THIS(IDirect3D2Impl,iface);
FIXME("(%p)->(%p,%p),stub!\n",This,cb,context);
return DD_OK;
}
HRESULT WINAPI IDirect3D2Impl_CreateLight(
LPDIRECT3D2 iface, LPDIRECT3DLIGHT *lplight, IUnknown *lpunk
) {
ICOM_THIS(IDirect3D2Impl,iface);
FIXME("(%p)->(%p,%p): stub\n", This, lplight, lpunk);
return E_FAIL;
}
HRESULT WINAPI IDirect3D2Impl_CreateMaterial(
LPDIRECT3D2 iface, LPDIRECT3DMATERIAL2 *lpmaterial, IUnknown *lpunk
) {
ICOM_THIS(IDirect3D2Impl,iface);
FIXME("(%p)->(%p,%p): stub\n", This, lpmaterial, lpunk);
return E_FAIL;
}
HRESULT WINAPI IDirect3D2Impl_CreateViewport(
LPDIRECT3D2 iface, LPDIRECT3DVIEWPORT2 *lpviewport, IUnknown *lpunk
) {
ICOM_THIS(IDirect3D2Impl,iface);
FIXME("(%p)->(%p,%p): stub\n", This, lpviewport, lpunk);
return E_FAIL;
}
HRESULT WINAPI IDirect3D2Impl_FindDevice(
LPDIRECT3D2 iface, LPD3DFINDDEVICESEARCH lpfinddevsrc,
LPD3DFINDDEVICERESULT lpfinddevrst)
{
ICOM_THIS(IDirect3D2Impl,iface);
FIXME("(%p)->(%p,%p): stub\n", This, lpfinddevsrc, lpfinddevrst);
return DD_OK;
}
HRESULT WINAPI IDirect3D2Impl_CreateDevice(
LPDIRECT3D2 iface, REFCLSID rguid, LPDIRECTDRAWSURFACE surface,
LPDIRECT3DDEVICE2 *device)
{
ICOM_THIS(IDirect3D2Impl,iface);
FIXME("(%p)->(%s,%p,%p): stub\n",This,debugstr_guid(rguid),surface,device);
return DDERR_INVALIDPARAMS;
}
/* This is for checking the correctness of the prototypes/functions.
* Do not remove.
*/
static WINE_UNUSED ICOM_VTABLE(IDirect3D2) d3d2vt =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirect3D2Impl_QueryInterface,
IDirect3D2Impl_AddRef,
IDirect3D2Impl_Release,
IDirect3D2Impl_EnumDevices,
IDirect3D2Impl_CreateLight,
IDirect3D2Impl_CreateMaterial,
IDirect3D2Impl_CreateViewport,
IDirect3D2Impl_FindDevice,
IDirect3D2Impl_CreateDevice
};
#include "config.h"
#include <assert.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include "winerror.h"
#include "ddraw.h"
#include "d3d.h"
#include "message.h"
#include "options.h"
#include "monitor.h"
#include "debugtools.h"
#include "mesa_private.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
/*******************************************************************************
* IDirect3D
*/
static HRESULT WINAPI MESA_IDirect3DImpl_QueryInterface(
LPDIRECT3D iface,REFIID refiid,LPVOID *obj
) {
ICOM_THIS(IDirect3DImpl,iface);
/* FIXME: Not sure if this is correct */
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
if (( IsEqualGUID( &IID_IDirectDraw, refiid ) ) ||
( IsEqualGUID (&IID_IDirectDraw2, refiid ) ) ||
( IsEqualGUID( &IID_IDirectDraw4, refiid ) )
) {
*obj = This->ddraw;
IDirect3D_AddRef(iface);
TRACE(" Creating IDirectDrawX interface (%p)\n", *obj);
return S_OK;
}
if (( IsEqualGUID( &IID_IDirect3D, refiid ) ) ||
( IsEqualGUID( &IID_IUnknown, refiid ) ) ) {
*obj = This;
IDirect3D_AddRef(iface);
TRACE(" Creating IDirect3D interface (%p)\n", *obj);
return S_OK;
}
if ( IsEqualGUID( &IID_IDirect3D2, refiid ) ) {
IDirect3D2Impl* d3d;
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
d3d->ref = 1;
d3d->ddraw = This->ddraw;
IDirect3D_AddRef(iface);
ICOM_VTBL(d3d) = &mesa_d3d2vt;
*obj = d3d;
TRACE(" Creating IDirect3D2 interface (%p)\n", *obj);
return S_OK;
}
FIXME("(%p):interface for IID %s NOT found!\n",This,debugstr_guid(refiid));
return OLE_E_ENUM_NOMORE;
}
static ULONG WINAPI MESA_IDirect3DImpl_Release(LPDIRECT3D iface)
{
ICOM_THIS(IDirect3DImpl,iface);
TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
if (!--(This->ref)) {
IDirectDraw2_Release((IDirectDraw2*)This->ddraw);
HeapFree(GetProcessHeap(),0,This);
return S_OK;
}
return This->ref;
}
static HRESULT WINAPI MESA_IDirect3DImpl_EnumDevices(
LPDIRECT3D iface, LPD3DENUMDEVICESCALLBACK cb, LPVOID context
) {
ICOM_THIS(IDirect3DImpl,iface);
FIXME("(%p)->(%p,%p),stub!\n",This,cb,context);
/* Call functions defined in d3ddevices.c */
if (!d3d_OpenGL_dx3(cb, context))
return DD_OK;
return DD_OK;
}
static HRESULT WINAPI MESA_IDirect3DImpl_CreateLight(
LPDIRECT3D iface, LPDIRECT3DLIGHT *lplight, IUnknown *lpunk
) {
ICOM_THIS(IDirect3DImpl,iface);
TRACE("(%p)->(%p,%p): stub\n", This, lplight, lpunk);
/* Call the creation function that is located in d3dlight.c */
*lplight = d3dlight_create_dx3(This);
return DD_OK;
}
static HRESULT WINAPI MESA_IDirect3DImpl_CreateMaterial(
LPDIRECT3D iface, LPDIRECT3DMATERIAL *lpmaterial, IUnknown *lpunk
) {
ICOM_THIS(IDirect3DImpl,iface);
TRACE("(%p)->(%p,%p): stub\n", This, lpmaterial, lpunk);
/* Call the creation function that is located in d3dviewport.c */
*lpmaterial = d3dmaterial_create(This);
return DD_OK;
}
static HRESULT WINAPI MESA_IDirect3DImpl_CreateViewport(
LPDIRECT3D iface, LPDIRECT3DVIEWPORT *lpviewport, IUnknown *lpunk
) {
ICOM_THIS(IDirect3DImpl,iface);
TRACE("(%p)->(%p,%p): stub\n", This, lpviewport, lpunk);
/* Call the creation function that is located in d3dviewport.c */
*lpviewport = d3dviewport_create(This);
return DD_OK;
}
static HRESULT WINAPI MESA_IDirect3DImpl_FindDevice(
LPDIRECT3D iface, LPD3DFINDDEVICESEARCH lpfinddevsrc,
LPD3DFINDDEVICERESULT lpfinddevrst)
{
ICOM_THIS(IDirect3DImpl,iface);
FIXME("(%p)->(%p,%p): stub\n", This, lpfinddevsrc, lpfinddevrst);
return DD_OK;
}
ICOM_VTABLE(IDirect3D) mesa_d3dvt =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
MESA_IDirect3DImpl_QueryInterface,
IDirect3DImpl_AddRef,
MESA_IDirect3DImpl_Release,
IDirect3DImpl_Initialize,
MESA_IDirect3DImpl_EnumDevices,
MESA_IDirect3DImpl_CreateLight,
MESA_IDirect3DImpl_CreateMaterial,
MESA_IDirect3DImpl_CreateViewport,
MESA_IDirect3DImpl_FindDevice
};
/*******************************************************************************
* IDirect3D2
*/
static HRESULT WINAPI MESA_IDirect3D2Impl_QueryInterface(
LPDIRECT3D2 iface,REFIID refiid,LPVOID *obj) {
ICOM_THIS(IDirect3D2Impl,iface);
/* FIXME: Not sure if this is correct */
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
if ( ( IsEqualGUID( &IID_IDirectDraw, refiid ) ) ||
( IsEqualGUID( &IID_IDirectDraw2, refiid ) ) ||
( IsEqualGUID( &IID_IDirectDraw4, refiid ) ) ) {
*obj = This->ddraw;
IDirect3D2_AddRef(iface);
TRACE(" Creating IDirectDrawX interface (%p)\n", *obj);
return S_OK;
}
if ( ( IsEqualGUID( &IID_IDirect3D2, refiid ) ) ||
( IsEqualGUID( &IID_IUnknown, refiid ) ) ) {
*obj = This;
IDirect3D2_AddRef(iface);
TRACE(" Creating IDirect3D2 interface (%p)\n", *obj);
return S_OK;
}
if ( IsEqualGUID( &IID_IDirect3D, refiid ) ) {
IDirect3DImpl* d3d;
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
d3d->ref = 1;
d3d->ddraw = This->ddraw;
IDirect3D2_AddRef(iface);
ICOM_VTBL(d3d) = &mesa_d3dvt;
*obj = d3d;
TRACE(" Creating IDirect3D interface (%p)\n", *obj);
return S_OK;
}
FIXME("(%p):interface for IID %s NOT found!\n",This,debugstr_guid(refiid));
return OLE_E_ENUM_NOMORE;
}
static ULONG WINAPI MESA_IDirect3D2Impl_Release(LPDIRECT3D2 iface) {
ICOM_THIS(IDirect3D2Impl,iface);
TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
if (!--(This->ref)) {
IDirectDraw2_Release((IDirectDraw2*)This->ddraw);
HeapFree(GetProcessHeap(),0,This);
return S_OK;
}
return This->ref;
}
static HRESULT WINAPI MESA_IDirect3D2Impl_EnumDevices(
LPDIRECT3D2 iface,LPD3DENUMDEVICESCALLBACK cb, LPVOID context
) {
ICOM_THIS(IDirect3D2Impl,iface);
FIXME("(%p)->(%p,%p),stub!\n",This,cb,context);
/* Call functions defined in d3ddevices.c */
if (!d3d_OpenGL(cb, context))
return DD_OK;
return DD_OK;
}
static HRESULT WINAPI MESA_IDirect3D2Impl_CreateLight(
LPDIRECT3D2 iface, LPDIRECT3DLIGHT *lplight, IUnknown *lpunk
) {
ICOM_THIS(IDirect3D2Impl,iface);
TRACE("(%p)->(%p,%p): stub\n", This, lplight, lpunk);
/* Call the creation function that is located in d3dlight.c */
*lplight = d3dlight_create(This);
return DD_OK;
}
static HRESULT WINAPI MESA_IDirect3D2Impl_CreateMaterial(
LPDIRECT3D2 iface, LPDIRECT3DMATERIAL2 *lpmaterial, IUnknown *lpunk
) {
ICOM_THIS(IDirect3D2Impl,iface);
TRACE("(%p)->(%p,%p): stub\n", This, lpmaterial, lpunk);
/* Call the creation function that is located in d3dviewport.c */
*lpmaterial = d3dmaterial2_create(This);
return DD_OK;
}
static HRESULT WINAPI MESA_IDirect3D2Impl_CreateViewport(
LPDIRECT3D2 iface, LPDIRECT3DVIEWPORT2 *lpviewport, IUnknown *lpunk
) {
ICOM_THIS(IDirect3D2Impl,iface);
TRACE("(%p)->(%p,%p): stub\n", This, lpviewport, lpunk);
/* Call the creation function that is located in d3dviewport.c */
*lpviewport = d3dviewport2_create(This);
return DD_OK;
}
static HRESULT WINAPI MESA_IDirect3D2Impl_FindDevice(
LPDIRECT3D2 iface, LPD3DFINDDEVICESEARCH lpfinddevsrc,
LPD3DFINDDEVICERESULT lpfinddevrst)
{
ICOM_THIS(IDirect3D2Impl,iface);
FIXME("(%p)->(%p,%p): stub\n", This, lpfinddevsrc, lpfinddevrst);
return DD_OK;
}
static HRESULT WINAPI MESA_IDirect3D2Impl_CreateDevice(
LPDIRECT3D2 iface, REFCLSID rguid, LPDIRECTDRAWSURFACE surface,
LPDIRECT3DDEVICE2 *device)
{
ICOM_THIS(IDirect3D2Impl,iface);
FIXME("(%p)->(%s,%p,%p): stub\n",This,debugstr_guid(rguid),surface,device);
if (is_OpenGL(rguid, (IDirectDrawSurfaceImpl*)surface, (IDirect3DDevice2Impl**)device, This)) {
IDirect3D2_AddRef(iface);
return DD_OK;
}
return DDERR_INVALIDPARAMS;
}
ICOM_VTABLE(IDirect3D2) mesa_d3d2vt =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
MESA_IDirect3D2Impl_QueryInterface,
IDirect3D2Impl_AddRef,
MESA_IDirect3D2Impl_Release,
MESA_IDirect3D2Impl_EnumDevices,
MESA_IDirect3D2Impl_CreateLight,
MESA_IDirect3D2Impl_CreateMaterial,
MESA_IDirect3D2Impl_CreateViewport,
MESA_IDirect3D2Impl_FindDevice,
MESA_IDirect3D2Impl_CreateDevice
};
HRESULT create_direct3d(LPVOID *obj,IDirectDraw2Impl* ddraw) {
IDirect3DImpl* d3d;
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
d3d->ref = 1;
d3d->ddraw = ddraw;
d3d->private = NULL; /* unused for now */
IDirectDraw_AddRef((LPDIRECTDRAW)ddraw);
ICOM_VTBL(d3d) = &mesa_d3dvt;
*obj = (LPUNKNOWN)d3d;
TRACE(" Created IDirect3D interface (%p)\n", *obj);
return S_OK;
}
HRESULT create_direct3d2(LPVOID *obj,IDirectDraw2Impl* ddraw) {
IDirect3D2Impl* d3d;
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
d3d->ref = 1;
d3d->ddraw = ddraw;
d3d->private = NULL; /* unused for now */
IDirectDraw_AddRef((LPDIRECTDRAW)ddraw);
ICOM_VTBL(d3d) = &mesa_d3d2vt;
*obj = (LPUNKNOWN)d3d;
TRACE(" Creating IDirect3D2 interface (%p)\n", *obj);
return S_OK;
}
/* DirectDrawPalette XF86DGA implementation
*
* Copyright 1997-2000 Marcus Meissner
* Copyright 1998 Lionel Ulmer (most of Direct3D stuff)
*/
#include "config.h"
#include "winerror.h"
#include <unistd.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include "debugtools.h"
#include "dga_private.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
#define DPPRIVATE(x) dga_dp_private *dppriv = ((dga_dp_private*)(x)->private)
#define DDPRIVATE(x) dga_dd_private *ddpriv = ((dga_dd_private*)(x)->private)
HRESULT WINAPI DGA_IDirectDrawPaletteImpl_SetEntries(
LPDIRECTDRAWPALETTE iface,DWORD x,DWORD start,DWORD count,LPPALETTEENTRY palent
) {
ICOM_THIS(IDirectDrawPaletteImpl,iface);
DPPRIVATE(This);
XColor xc;
Colormap cm;
int i;
TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,x,start,count,palent);
if (!dppriv->cm) /* should not happen */ {
FIXME("app tried to set colormap in non-palettized mode\n");
return DDERR_GENERIC;
}
/* FIXME: free colorcells instead of freeing whole map */
cm = dppriv->cm;
dppriv->cm = TSXCopyColormapAndFree(display,dppriv->cm);
TSXFreeColormap(display,cm);
for (i=0;i<count;i++) {
xc.red = palent[i].peRed<<8;
xc.blue = palent[i].peBlue<<8;
xc.green = palent[i].peGreen<<8;
xc.flags = DoRed|DoBlue|DoGreen;
xc.pixel = i+start;
TSXStoreColor(display,dppriv->cm,&xc);
This->palents[start+i].peRed = palent[i].peRed;
This->palents[start+i].peBlue = palent[i].peBlue;
This->palents[start+i].peGreen = palent[i].peGreen;
This->palents[start+i].peFlags = palent[i].peFlags;
}
#ifdef HAVE_LIBXXF86DGA2
if (ddpriv->version == 2) {
DDPRIVATE(This->ddraw);
TSXDGAInstallColormap(display,DefaultScreen(display),dppriv->cm);
} else
#endif /* defined(HAVE_LIBXXF86DGA2) */
TSXF86DGAInstallColormap(display,DefaultScreen(display),dppriv->cm);
return DD_OK;
}
ICOM_VTABLE(IDirectDrawPalette) dga_ddpalvt =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectDrawPaletteImpl_QueryInterface,
IDirectDrawPaletteImpl_AddRef,
Xlib_IDirectDrawPaletteImpl_Release,
IDirectDrawPaletteImpl_GetCaps,
IDirectDrawPaletteImpl_GetEntries,
IDirectDrawPaletteImpl_Initialize,
DGA_IDirectDrawPaletteImpl_SetEntries
};
/* DirectDraw - IDirectPalette base interface
*
* Copyright 1997-2000 Marcus Meissner
*/
#include "config.h"
#include "winerror.h"
#include <unistd.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include "ddraw_private.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
/******************************************************************************
* IDirectDrawPalette
*/
HRESULT WINAPI IDirectDrawPaletteImpl_GetEntries(
LPDIRECTDRAWPALETTE iface,DWORD x,DWORD start,DWORD count,LPPALETTEENTRY palent
) {
ICOM_THIS(IDirectDrawPaletteImpl,iface);
int i;
TRACE("(%p)->GetEntries(%08lx,%ld,%ld,%p)\n",This,x,start,count,palent);
for (i=0;i<count;i++) {
palent[i].peRed = This->palents[start+i].peRed;
palent[i].peBlue = This->palents[start+i].peBlue;
palent[i].peGreen = This->palents[start+i].peGreen;
palent[i].peFlags = This->palents[start+i].peFlags;
}
return DD_OK;
}
HRESULT WINAPI IDirectDrawPaletteImpl_SetEntries(
LPDIRECTDRAWPALETTE iface,DWORD x,DWORD start,DWORD count,LPPALETTEENTRY palent
) {
ICOM_THIS(IDirectDrawPaletteImpl,iface);
int i;
TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n", This,x,start,count,palent);
for (i=0;i<count;i++) {
This->palents[start+i].peRed = palent[i].peRed;
This->palents[start+i].peBlue = palent[i].peBlue;
This->palents[start+i].peGreen = palent[i].peGreen;
This->palents[start+i].peFlags = palent[i].peFlags;
}
/* Now, if we are in 'depth conversion mode', update the screen palette */
/* FIXME: we need to update the image or we won't get palette fading. */
if (This->ddraw->d.palette_convert != NULL)
This->ddraw->d.palette_convert(palent,This->screen_palents,start,count);
return DD_OK;
}
ULONG WINAPI IDirectDrawPaletteImpl_Release(LPDIRECTDRAWPALETTE iface) {
ICOM_THIS(IDirectDrawPaletteImpl,iface);
TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
if (!--(This->ref)) {
HeapFree(GetProcessHeap(),0,This);
return S_OK;
}
return This->ref;
}
ULONG WINAPI IDirectDrawPaletteImpl_AddRef(LPDIRECTDRAWPALETTE iface) {
ICOM_THIS(IDirectDrawPaletteImpl,iface);
TRACE("(%p)->() incrementing from %lu.\n", This, This->ref );
return ++(This->ref);
}
HRESULT WINAPI IDirectDrawPaletteImpl_Initialize(
LPDIRECTDRAWPALETTE iface,LPDIRECTDRAW ddraw,DWORD x,LPPALETTEENTRY palent
) {
ICOM_THIS(IDirectDrawPaletteImpl,iface);
TRACE("(%p)->(%p,%ld,%p)\n", This, ddraw, x, palent);
return DDERR_ALREADYINITIALIZED;
}
HRESULT WINAPI IDirectDrawPaletteImpl_GetCaps(
LPDIRECTDRAWPALETTE iface, LPDWORD lpdwCaps )
{
ICOM_THIS(IDirectDrawPaletteImpl,iface);
FIXME("(%p)->(%p) stub.\n", This, lpdwCaps );
return DD_OK;
}
HRESULT WINAPI IDirectDrawPaletteImpl_QueryInterface(
LPDIRECTDRAWPALETTE iface,REFIID refiid,LPVOID *obj )
{
ICOM_THIS(IDirectDrawPaletteImpl,iface);
FIXME("(%p)->(%s,%p) stub.\n",This,debugstr_guid(refiid),obj);
return S_OK;
}
ICOM_VTABLE(IDirectDrawPalette) ddraw_ddpalvt =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectDrawPaletteImpl_QueryInterface,
IDirectDrawPaletteImpl_AddRef,
IDirectDrawPaletteImpl_Release,
IDirectDrawPaletteImpl_GetCaps,
IDirectDrawPaletteImpl_GetEntries,
IDirectDrawPaletteImpl_Initialize,
IDirectDrawPaletteImpl_SetEntries
};
/* DirectDraw IDirectDrawPalette X11 implementation
*
* Copyright 1997-2000 Marcus Meissner
*/
#include "config.h"
#include "winerror.h"
#include <unistd.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include "debugtools.h"
#include "x11_private.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
#define DPPRIVATE(x) x11_dp_private *dppriv = ((x11_dp_private*)x->private)
/******************************************************************************
* IDirectDrawPalette
*/
HRESULT WINAPI Xlib_IDirectDrawPaletteImpl_SetEntries(
LPDIRECTDRAWPALETTE iface,DWORD x,DWORD start,DWORD count,LPPALETTEENTRY palent
) {
ICOM_THIS(IDirectDrawPaletteImpl,iface);
XColor xc;
int i;
DPPRIVATE(This);
TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,x,start,count,palent);
for (i=0;i<count;i++) {
xc.red = palent[i].peRed<<8;
xc.blue = palent[i].peBlue<<8;
xc.green = palent[i].peGreen<<8;
xc.flags = DoRed|DoBlue|DoGreen;
xc.pixel = start+i;
if (dppriv->cm)
TSXStoreColor(display,dppriv->cm,&xc);
This->palents[start+i].peRed = palent[i].peRed;
This->palents[start+i].peBlue = palent[i].peBlue;
This->palents[start+i].peGreen = palent[i].peGreen;
This->palents[start+i].peFlags = palent[i].peFlags;
}
/* Now, if we are in 'depth conversion mode', update the screen palette */
/* FIXME: we need to update the image or we won't get palette fading. */
if (This->ddraw->d.palette_convert != NULL) {
This->ddraw->d.palette_convert(palent,This->screen_palents,start,count);
}
return DD_OK;
}
ULONG WINAPI Xlib_IDirectDrawPaletteImpl_Release(LPDIRECTDRAWPALETTE iface) {
ICOM_THIS(IDirectDrawPaletteImpl,iface);
DPPRIVATE(This);
TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
if (!--(This->ref)) {
if (dppriv->cm) {
TSXFreeColormap(display,dppriv->cm);
dppriv->cm = 0;
}
HeapFree(GetProcessHeap(),0,This);
return S_OK;
}
return This->ref;
}
ICOM_VTABLE(IDirectDrawPalette) xlib_ddpalvt =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectDrawPaletteImpl_QueryInterface,
IDirectDrawPaletteImpl_AddRef,
Xlib_IDirectDrawPaletteImpl_Release,
IDirectDrawPaletteImpl_GetCaps,
IDirectDrawPaletteImpl_GetEntries,
IDirectDrawPaletteImpl_Initialize,
Xlib_IDirectDrawPaletteImpl_SetEntries
};
/* DirectDrawSurface XF86DGA implementation
*
* Copyright 1997-2000 Marcus Meissner
* Copyright 1998-2000 Lionel Ulmer (most of Direct3D stuff)
*/
#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 "dga_private.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
#define DDPRIVATE(x) dga_dd_private *ddpriv = ((dga_dd_private*)(x)->private)
#define DPPRIVATE(x) dga_dp_private *dppriv = ((dga_dp_private*)(x)->private)
#define DSPRIVATE(x) dga_ds_private *dspriv = ((dga_ds_private*)(x)->private)
/******************************************************************************
* IDirectDrawSurface methods
*
* Since DDS3 and DDS2 are supersets of DDS, we implement DDS3 and let
* DDS and DDS2 use those functions. (Function calls did not change (except
* using different DirectDrawSurfaceX version), just added flags and functions)
*/
HRESULT WINAPI DGA_IDirectDrawSurface4Impl_Flip(
LPDIRECTDRAWSURFACE4 iface,LPDIRECTDRAWSURFACE4 flipto,DWORD dwFlags
) {
ICOM_THIS(IDirectDrawSurface4Impl,iface);
DSPRIVATE(This);
dga_ds_private *fspriv;
IDirectDrawSurface4Impl* iflipto=(IDirectDrawSurface4Impl*)flipto;
DWORD xheight;
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;
TSXF86DGASetViewPort(display,DefaultScreen(display),0,fspriv->fb_height);
if (iflipto->s.palette) {
DPPRIVATE(iflipto);
if (dppriv->cm)
TSXF86DGAInstallColormap(display,DefaultScreen(display),dppriv->cm);
}
while (!TSXF86DGAViewPortChanged(display,DefaultScreen(display),2)) {
/* EMPTY */
}
/* 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;
}
#ifdef HAVE_LIBXXF86DGA2
HRESULT WINAPI DGA2_IDirectDrawSurface4Impl_Flip(
LPDIRECTDRAWSURFACE4 iface,LPDIRECTDRAWSURFACE4 flipto,DWORD dwFlags
) {
ICOM_THIS(IDirectDrawSurface4Impl,iface);
IDirectDrawSurface4Impl* iflipto=(IDirectDrawSurface4Impl*)flipto;
DWORD xheight;
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
) {
ICOM_THIS(IDirectDrawSurface4Impl,iface);
IDirectDrawPaletteImpl* ipal=(IDirectDrawPaletteImpl*)pal;
TRACE("(%p)->(%p)\n",This,ipal);
/* According to spec, we are only supposed to
* AddRef if this is not the same palette.
*/
if( This->s.palette != ipal ) {
dga_dp_private *fppriv;
if( ipal != NULL )
IDirectDrawPalette_AddRef( (IDirectDrawPalette*)ipal );
if( This->s.palette != NULL )
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);
}
return DD_OK;
}
ULONG WINAPI DGA_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) {
ICOM_THIS(IDirectDrawSurface4Impl,iface);
DDPRIVATE(This->s.ddraw);
DSPRIVATE(This);
TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
if (--(This->ref))
return This->ref;
IDirectDraw2_Release((IDirectDraw2*)This->s.ddraw);
/* clear out of surface list */
if (ddpriv->fb_height == -1)
HeapFree(GetProcessHeap(),0,This->s.surface_desc.u1.lpSurface);
else
ddpriv->vpmask &= ~(1<<(dspriv->fb_height/ddpriv->fb_height));
/* Free the DIBSection (if any) */
if (This->s.hdc != 0) {
SelectObject(This->s.hdc, This->s.holdbitmap);
DeleteDC(This->s.hdc);
DeleteObject(This->s.DIBsection);
}
/* Free the clipper if attached to this surface */
if( This->s.lpClipper )
IDirectDrawClipper_Release(This->s.lpClipper);
HeapFree(GetProcessHeap(),0,This);
return S_OK;
}
ICOM_VTABLE(IDirectDrawSurface4) dga_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,
DGA_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
};
#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) */
/* DirectDraw Base Functions
*
* Copyright 1997-1999 Marcus Meissner
* Copyright 1998 Lionel Ulmer (most of Direct3D stuff)
*/
#include "config.h"
#include <unistd.h>
#include <assert.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "winerror.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"
DEFAULT_DEBUG_CHANNEL(ddraw);
/******************************************************************************
* debug output functions
*/
void _dump_DDBLTFX(DWORD flagmask) {
int i;
const struct {
DWORD mask;
char *name;
} flags[] = {
#define FE(x) { x, #x},
FE(DDBLTFX_ARITHSTRETCHY)
FE(DDBLTFX_MIRRORLEFTRIGHT)
FE(DDBLTFX_MIRRORUPDOWN)
FE(DDBLTFX_NOTEARING)
FE(DDBLTFX_ROTATE180)
FE(DDBLTFX_ROTATE270)
FE(DDBLTFX_ROTATE90)
FE(DDBLTFX_ZBUFFERRANGE)
FE(DDBLTFX_ZBUFFERBASEDEST)
#undef FE
};
for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
if (flags[i].mask & flagmask)
DPRINTF("%s ",flags[i].name);
DPRINTF("\n");
}
void _dump_DDBLTFAST(DWORD flagmask) {
int i;
const struct {
DWORD mask;
char *name;
} flags[] = {
#define FE(x) { x, #x},
FE(DDBLTFAST_NOCOLORKEY)
FE(DDBLTFAST_SRCCOLORKEY)
FE(DDBLTFAST_DESTCOLORKEY)
FE(DDBLTFAST_WAIT)
#undef FE
};
for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
if (flags[i].mask & flagmask)
DPRINTF("%s ",flags[i].name);
DPRINTF("\n");
}
void _dump_DDBLT(DWORD flagmask) {
int i;
const struct {
DWORD mask;
char *name;
} flags[] = {
#define FE(x) { x, #x},
FE(DDBLT_ALPHADEST)
FE(DDBLT_ALPHADESTCONSTOVERRIDE)
FE(DDBLT_ALPHADESTNEG)
FE(DDBLT_ALPHADESTSURFACEOVERRIDE)
FE(DDBLT_ALPHAEDGEBLEND)
FE(DDBLT_ALPHASRC)
FE(DDBLT_ALPHASRCCONSTOVERRIDE)
FE(DDBLT_ALPHASRCNEG)
FE(DDBLT_ALPHASRCSURFACEOVERRIDE)
FE(DDBLT_ASYNC)
FE(DDBLT_COLORFILL)
FE(DDBLT_DDFX)
FE(DDBLT_DDROPS)
FE(DDBLT_KEYDEST)
FE(DDBLT_KEYDESTOVERRIDE)
FE(DDBLT_KEYSRC)
FE(DDBLT_KEYSRCOVERRIDE)
FE(DDBLT_ROP)
FE(DDBLT_ROTATIONANGLE)
FE(DDBLT_ZBUFFER)
FE(DDBLT_ZBUFFERDESTCONSTOVERRIDE)
FE(DDBLT_ZBUFFERDESTOVERRIDE)
FE(DDBLT_ZBUFFERSRCCONSTOVERRIDE)
FE(DDBLT_ZBUFFERSRCOVERRIDE)
FE(DDBLT_WAIT)
FE(DDBLT_DEPTHFILL)
#undef FE
};
for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
if (flags[i].mask & flagmask)
DPRINTF("%s ",flags[i].name);
DPRINTF("\n");
}
void _dump_DDSCAPS(void *in) {
int i;
const struct {
DWORD mask;
char *name;
} flags[] = {
#define FE(x) { x, #x},
FE(DDSCAPS_RESERVED1)
FE(DDSCAPS_ALPHA)
FE(DDSCAPS_BACKBUFFER)
FE(DDSCAPS_COMPLEX)
FE(DDSCAPS_FLIP)
FE(DDSCAPS_FRONTBUFFER)
FE(DDSCAPS_OFFSCREENPLAIN)
FE(DDSCAPS_OVERLAY)
FE(DDSCAPS_PALETTE)
FE(DDSCAPS_PRIMARYSURFACE)
FE(DDSCAPS_PRIMARYSURFACELEFT)
FE(DDSCAPS_SYSTEMMEMORY)
FE(DDSCAPS_TEXTURE)
FE(DDSCAPS_3DDEVICE)
FE(DDSCAPS_VIDEOMEMORY)
FE(DDSCAPS_VISIBLE)
FE(DDSCAPS_WRITEONLY)
FE(DDSCAPS_ZBUFFER)
FE(DDSCAPS_OWNDC)
FE(DDSCAPS_LIVEVIDEO)
FE(DDSCAPS_HWCODEC)
FE(DDSCAPS_MODEX)
FE(DDSCAPS_MIPMAP)
FE(DDSCAPS_RESERVED2)
FE(DDSCAPS_ALLOCONLOAD)
FE(DDSCAPS_VIDEOPORT)
FE(DDSCAPS_LOCALVIDMEM)
FE(DDSCAPS_NONLOCALVIDMEM)
FE(DDSCAPS_STANDARDVGAMODE)
FE(DDSCAPS_OPTIMIZED)
#undef FE
};
DWORD flagmask = *((DWORD *) in);
for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
if (flags[i].mask & flagmask)
DPRINTF("%s ",flags[i].name);
}
void _dump_pixelformat_flag(DWORD flagmask) {
int i;
const struct {
DWORD mask;
char *name;
} flags[] = {
#define FE(x) { x, #x},
FE(DDPF_ALPHAPIXELS)
FE(DDPF_ALPHA)
FE(DDPF_FOURCC)
FE(DDPF_PALETTEINDEXED4)
FE(DDPF_PALETTEINDEXEDTO8)
FE(DDPF_PALETTEINDEXED8)
FE(DDPF_RGB)
FE(DDPF_COMPRESSED)
FE(DDPF_RGBTOYUV)
FE(DDPF_YUV)
FE(DDPF_ZBUFFER)
FE(DDPF_PALETTEINDEXED1)
FE(DDPF_PALETTEINDEXED2)
FE(DDPF_ZPIXELS)
#undef FE
};
for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
if (flags[i].mask & flagmask)
DPRINTF("%s ",flags[i].name);
}
void _dump_paletteformat(DWORD dwFlags) {
int i;
const struct {
DWORD mask;
char *name;
} flags[] = {
#define FE(x) { x, #x},
FE(DDPCAPS_4BIT)
FE(DDPCAPS_8BITENTRIES)
FE(DDPCAPS_8BIT)
FE(DDPCAPS_INITIALIZE)
FE(DDPCAPS_PRIMARYSURFACE)
FE(DDPCAPS_PRIMARYSURFACELEFT)
FE(DDPCAPS_ALLOW256)
FE(DDPCAPS_VSYNC)
FE(DDPCAPS_1BIT)
FE(DDPCAPS_2BIT)
FE(DDPCAPS_ALPHA)
#undef FE
};
for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
if (flags[i].mask & dwFlags)
DPRINTF("%s ",flags[i].name);
DPRINTF("\n");
}
void _dump_pixelformat(void *in) {
LPDDPIXELFORMAT pf = (LPDDPIXELFORMAT) in;
DPRINTF("( ");
_dump_pixelformat_flag(pf->dwFlags);
if (pf->dwFlags & DDPF_FOURCC)
DPRINTF(", dwFourCC : %ld", pf->dwFourCC);
if (pf->dwFlags & DDPF_RGB) {
char *cmd;
DPRINTF(", RGB bits: %ld, ", pf->u.dwRGBBitCount);
switch (pf->u.dwRGBBitCount) {
case 4: cmd = "%1lx"; break;
case 8: cmd = "%02lx"; break;
case 16: cmd = "%04lx"; break;
case 24: cmd = "%06lx"; break;
case 32: cmd = "%08lx"; break;
default: ERR("Unexpected bit depth !\n"); cmd = "%d"; break;
}
DPRINTF(" R "); DPRINTF(cmd, pf->u1.dwRBitMask);
DPRINTF(" G "); DPRINTF(cmd, pf->u2.dwGBitMask);
DPRINTF(" B "); DPRINTF(cmd, pf->u3.dwBBitMask);
if (pf->dwFlags & DDPF_ALPHAPIXELS)
DPRINTF(" A "); DPRINTF(cmd, pf->u4.dwRGBAlphaBitMask);
if (pf->dwFlags & DDPF_ZPIXELS)
DPRINTF(" Z "); DPRINTF(cmd, pf->u4.dwRGBZBitMask);
}
if (pf->dwFlags & DDPF_ZBUFFER)
DPRINTF(", Z bits : %ld", pf->u.dwZBufferBitDepth);
if (pf->dwFlags & DDPF_ALPHA)
DPRINTF(", Alpha bits : %ld", pf->u.dwAlphaBitDepth);
DPRINTF(")");
}
void _dump_colorkeyflag(DWORD ck) {
int i;
const struct {
DWORD mask;
char *name;
} flags[] = {
#define FE(x) { x, #x},
FE(DDCKEY_COLORSPACE)
FE(DDCKEY_DESTBLT)
FE(DDCKEY_DESTOVERLAY)
FE(DDCKEY_SRCBLT)
FE(DDCKEY_SRCOVERLAY)
#undef FE
};
for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
if (flags[i].mask & ck)
DPRINTF("%s ",flags[i].name);
}
static void _dump_DWORD(void *in) {
DPRINTF("%ld", *((DWORD *) in));
}
static void _dump_PTR(void *in) {
DPRINTF("%p", *((void **) in));
}
void _dump_DDCOLORKEY(void *in) {
DDCOLORKEY *ddck = (DDCOLORKEY *) in;
DPRINTF(" Low : %ld - High : %ld", ddck->dwColorSpaceLowValue, ddck->dwColorSpaceHighValue);
}
void _dump_surface_desc(DDSURFACEDESC *lpddsd) {
int i;
struct {
DWORD mask;
char *name;
void (*func)(void *);
void *elt;
} flags[16], *fe = flags;
#define FE(x,f,e) do { fe->mask = x; fe->name = #x; fe->func = f; fe->elt = (void *) &(lpddsd->e); fe++; } while(0)
FE(DDSD_CAPS, _dump_DDSCAPS, ddsCaps);
FE(DDSD_HEIGHT, _dump_DWORD, dwHeight);
FE(DDSD_WIDTH, _dump_DWORD, dwWidth);
FE(DDSD_PITCH, _dump_DWORD, lPitch);
FE(DDSD_BACKBUFFERCOUNT, _dump_DWORD, dwBackBufferCount);
FE(DDSD_ZBUFFERBITDEPTH, _dump_DWORD, u.dwZBufferBitDepth);
FE(DDSD_ALPHABITDEPTH, _dump_DWORD, dwAlphaBitDepth);
FE(DDSD_PIXELFORMAT, _dump_pixelformat, ddpfPixelFormat);
FE(DDSD_CKDESTOVERLAY, _dump_DDCOLORKEY, ddckCKDestOverlay);
FE(DDSD_CKDESTBLT, _dump_DDCOLORKEY, ddckCKDestBlt);
FE(DDSD_CKSRCOVERLAY, _dump_DDCOLORKEY, ddckCKSrcOverlay);
FE(DDSD_CKSRCBLT, _dump_DDCOLORKEY, ddckCKSrcBlt);
FE(DDSD_MIPMAPCOUNT, _dump_DWORD, u.dwMipMapCount);
FE(DDSD_REFRESHRATE, _dump_DWORD, u.dwRefreshRate);
FE(DDSD_LINEARSIZE, _dump_DWORD, u1.dwLinearSize);
FE(DDSD_LPSURFACE, _dump_PTR, u1.lpSurface);
#undef FE
for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
if (flags[i].mask & lpddsd->dwFlags) {
DPRINTF(" - %s : ",flags[i].name);
flags[i].func(flags[i].elt);
DPRINTF("\n");
}
}
void _dump_cooperativelevel(DWORD cooplevel) {
int i;
const struct {
int mask;
char *name;
} flags[] = {
#define FE(x) { x, #x},
FE(DDSCL_FULLSCREEN)
FE(DDSCL_ALLOWREBOOT)
FE(DDSCL_NOWINDOWCHANGES)
FE(DDSCL_NORMAL)
FE(DDSCL_ALLOWMODEX)
FE(DDSCL_EXCLUSIVE)
FE(DDSCL_SETFOCUSWINDOW)
FE(DDSCL_SETDEVICEWINDOW)
FE(DDSCL_CREATEDEVICEWINDOW)
#undef FE
};
if (TRACE_ON(ddraw)) {
DPRINTF(" - ");
for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
if (flags[i].mask & cooplevel)
DPRINTF("%s ",flags[i].name);
DPRINTF("\n");
}
}
/* Direct3D Common functions
(c) 1998 Lionel ULMER
This file contains all MESA common code */
#include "windef.h"
#include "wine/obj_base.h"
#include "ddraw.h"
#include "d3d.h"
#include "debugtools.h"
#include "mesa_private.h"
DEFAULT_DEBUG_CHANNEL(ddraw)
#define D3DTPRIVATE(x) mesa_d3dt_private *dtpriv = (mesa_d3dt_private*)(x)->private
void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
DWORD dwRenderState, RenderState *rs)
{
if (TRACE_ON(ddraw))
_dump_renderstate(dwRenderStateType, dwRenderState);
/* First, all the stipple patterns */
if ((dwRenderStateType >= D3DRENDERSTATE_STIPPLEPATTERN00) &&
(dwRenderStateType <= D3DRENDERSTATE_STIPPLEPATTERN31)) {
ERR("Unhandled dwRenderStateType stipple %d!\n",dwRenderStateType);
} else {
ENTER_GL();
/* All others state variables */
switch (dwRenderStateType) {
case D3DRENDERSTATE_TEXTUREHANDLE: { /* 1 */
IDirect3DTexture2Impl* tex = (IDirect3DTexture2Impl*) dwRenderState;
D3DTPRIVATE(tex);
if (tex == NULL) {
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
} else {
TRACE("setting OpenGL texture handle : %d\n", dtpriv->tex_name);
glEnable(GL_TEXTURE_2D);
/* Default parameters */
glBindTexture(GL_TEXTURE_2D, dtpriv->tex_name);
/* To prevent state change, we could test here what are the parameters
stored in the texture */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, rs->mag);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, rs->min);
}
} break;
case D3DRENDERSTATE_TEXTUREPERSPECTIVE: /* 4 */
if (dwRenderState)
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
else
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
break;
case D3DRENDERSTATE_ZENABLE: /* 7 */
if (dwRenderState)
glEnable(GL_DEPTH_TEST);
else
glDisable(GL_DEPTH_TEST);
break;
case D3DRENDERSTATE_FILLMODE: /* 8 */
switch ((D3DFILLMODE) dwRenderState) {
case D3DFILL_SOLID:
break;
default:
ERR("Unhandled fill mode !\n");
}
break;
case D3DRENDERSTATE_SHADEMODE: /* 9 */
switch ((D3DSHADEMODE) dwRenderState) {
case D3DSHADE_FLAT:
glShadeModel(GL_FLAT);
break;
case D3DSHADE_GOURAUD:
glShadeModel(GL_SMOOTH);
break;
default:
ERR("Unhandled shade mode !\n");
}
break;
case D3DRENDERSTATE_ZWRITEENABLE: /* 14 */
if (dwRenderState)
glDepthMask(GL_TRUE);
else
glDepthMask(GL_FALSE);
break;
case D3DRENDERSTATE_TEXTUREMAG: /* 17 */
switch ((D3DTEXTUREFILTER) dwRenderState) {
case D3DFILTER_NEAREST:
rs->mag = GL_NEAREST;
break;
case D3DFILTER_LINEAR:
rs->mag = GL_LINEAR;
break;
default:
ERR("Unhandled texture mag !\n");
}
break;
case D3DRENDERSTATE_TEXTUREMIN: /* 18 */
switch ((D3DTEXTUREFILTER) dwRenderState) {
case D3DFILTER_NEAREST:
rs->min = GL_NEAREST;
break;
case D3DFILTER_LINEAR:
rs->mag = GL_LINEAR;
break;
default:
ERR("Unhandled texture min !\n");
}
break;
case D3DRENDERSTATE_SRCBLEND: /* 19 */
switch ((D3DBLEND) dwRenderState) {
case D3DBLEND_SRCALPHA:
rs->src = GL_SRC_ALPHA;
break;
default:
ERR("Unhandled blend mode !\n");
}
glBlendFunc(rs->src, rs->dst);
break;
case D3DRENDERSTATE_DESTBLEND: /* 20 */
switch ((D3DBLEND) dwRenderState) {
case D3DBLEND_INVSRCALPHA:
rs->dst = GL_ONE_MINUS_SRC_ALPHA;
break;
default:
ERR("Unhandled blend mode !\n");
}
glBlendFunc(rs->src, rs->dst);
break;
case D3DRENDERSTATE_TEXTUREMAPBLEND: /* 21 */
switch ((D3DTEXTUREBLEND) dwRenderState) {
case D3DTBLEND_MODULATE:
case D3DTBLEND_MODULATEALPHA:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
break;
default:
ERR("Unhandled texture environment !\n");
}
break;
case D3DRENDERSTATE_CULLMODE: /* 22 */
switch ((D3DCULL) dwRenderState) {
case D3DCULL_NONE:
glDisable(GL_CULL_FACE);
break;
case D3DCULL_CW:
glEnable(GL_CULL_FACE);
glFrontFace(GL_CW);
break;
case D3DCULL_CCW:
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);
break;
default:
ERR("Unhandled cull mode !\n");
}
break;
case D3DRENDERSTATE_ZFUNC: /* 23 */
switch ((D3DCMPFUNC) dwRenderState) {
case D3DCMP_NEVER:
glDepthFunc(GL_NEVER);
break;
case D3DCMP_LESS:
glDepthFunc(GL_LESS);
break;
case D3DCMP_EQUAL:
glDepthFunc(GL_EQUAL);
break;
case D3DCMP_LESSEQUAL:
glDepthFunc(GL_LEQUAL);
break;
case D3DCMP_GREATER:
glDepthFunc(GL_GREATER);
break;
case D3DCMP_NOTEQUAL:
glDepthFunc(GL_NOTEQUAL);
break;
case D3DCMP_GREATEREQUAL:
glDepthFunc(GL_GEQUAL);
break;
case D3DCMP_ALWAYS:
glDepthFunc(GL_ALWAYS);
break;
default:
ERR("Unexpected value\n");
}
break;
case D3DRENDERSTATE_DITHERENABLE: /* 26 */
if (dwRenderState)
glEnable(GL_DITHER);
else
glDisable(GL_DITHER);
break;
case D3DRENDERSTATE_ALPHABLENDENABLE: /* 27 */
if (dwRenderState)
glEnable(GL_BLEND);
else
glDisable(GL_BLEND);
break;
case D3DRENDERSTATE_COLORKEYENABLE: /* 41 */
if (dwRenderState)
glEnable(GL_BLEND);
else
glDisable(GL_BLEND);
break;
case D3DRENDERSTATE_FLUSHBATCH: /* 50 */
break;
default:
ERR("Unhandled dwRenderStateType %d!\n",dwRenderStateType);
break;
}
LEAVE_GL();
}
}
/* MESA private include file
(c) 1998 Lionel ULMER
This files contains all the structure that are not exported
through d3d.h and all common macros. */
#ifndef __GRAPHICS_WINE_MESA_PRIVATE_H
#define __GRAPHICS_WINE_MESA_PRIVATE_H
#include "d3d_private.h"
#include "wine_gl.h"
#include "x11drv.h"
#undef USE_OSMESA
#include "x11_private.h"
/*****************************************************************************
* IDirect3DLight MESA private structure
*/
typedef struct mesa_d3dl_private
{
GLenum light_num;
} mesa_d3dl_private;
/*****************************************************************************
* IDirect3DTexture2 MESA private structure
*/
typedef struct mesa_d3dt_private
{
GLuint tex_name;
} mesa_d3dt_private;
/*****************************************************************************
* IDirect3DViewport2 implementation structure
*/
typedef struct mesa_d3dv_private
{
GLenum nextlight;
} mesa_d3dv_private;
#ifdef USE_OSMESA
# define LEAVE_GL() ;
# define ENTER_GL() ;
#else
# define LEAVE_GL() LeaveCriticalSection( &X11DRV_CritSection )
# define ENTER_GL() EnterCriticalSection( &X11DRV_CritSection )
#endif
/* Matrix copy WITH transposition */
#define conv_mat2(mat,gl_mat) \
{ \
TRACE("%f %f %f %f\n", (mat)->_11, (mat)->_12, (mat)->_13, (mat)->_14); \
TRACE("%f %f %f %f\n", (mat)->_21, (mat)->_22, (mat)->_23, (mat)->_24); \
TRACE("%f %f %f %f\n", (mat)->_31, (mat)->_32, (mat)->_33, (mat)->_34); \
TRACE("%f %f %f %f\n", (mat)->_41, (mat)->_42, (mat)->_43, (mat)->_44); \
(gl_mat)[ 0] = (mat)->_11; \
(gl_mat)[ 1] = (mat)->_21; \
(gl_mat)[ 2] = (mat)->_31; \
(gl_mat)[ 3] = (mat)->_41; \
(gl_mat)[ 4] = (mat)->_12; \
(gl_mat)[ 5] = (mat)->_22; \
(gl_mat)[ 6] = (mat)->_32; \
(gl_mat)[ 7] = (mat)->_42; \
(gl_mat)[ 8] = (mat)->_13; \
(gl_mat)[ 9] = (mat)->_23; \
(gl_mat)[10] = (mat)->_33; \
(gl_mat)[11] = (mat)->_43; \
(gl_mat)[12] = (mat)->_14; \
(gl_mat)[13] = (mat)->_24; \
(gl_mat)[14] = (mat)->_34; \
(gl_mat)[15] = (mat)->_44; \
};
/* Matrix copy WITHOUT transposition */
#define conv_mat(mat,gl_mat) \
{ \
TRACE("%f %f %f %f\n", (mat)->_11, (mat)->_12, (mat)->_13, (mat)->_14); \
TRACE("%f %f %f %f\n", (mat)->_21, (mat)->_22, (mat)->_23, (mat)->_24); \
TRACE("%f %f %f %f\n", (mat)->_31, (mat)->_32, (mat)->_33, (mat)->_34); \
TRACE("%f %f %f %f\n", (mat)->_41, (mat)->_42, (mat)->_43, (mat)->_44); \
memcpy(gl_mat, (mat), 16 * sizeof(float)); \
};
typedef struct render_state {
/* This is used for the device mode */
GLenum src, dst;
/* This is used for textures */
GLenum mag, min;
} RenderState;
typedef struct mesa_d3dd_private {
#ifdef USE_OSMESA
OSMesaContext ctx;
unsigned char *buffer;
#else
GLXContext ctx;
#endif
/* The current render state */
RenderState rs;
/* The last type of vertex drawn */
D3DVERTEXTYPE vt;
D3DMATRIX *world_mat;
D3DMATRIX *view_mat;
D3DMATRIX *proj_mat;
} mesa_d3dd_private;
#define _dump_colorvalue(s,v) \
TRACE(" " s " : %f %f %f %f\n", \
(v).r.r, (v).g.g, (v).b.b, (v).a.a);
/* Common functions defined in d3dcommon.c */
void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
DWORD dwRenderState, RenderState *rs) ;
/* All non-static functions 'exported' by various sub-objects */
extern LPDIRECT3DTEXTURE2 d3dtexture2_create(IDirectDrawSurface4Impl* surf);
extern LPDIRECT3DTEXTURE d3dtexture_create(IDirectDrawSurface4Impl* surf);
extern LPDIRECT3DLIGHT d3dlight_create_dx3(IDirect3DImpl* d3d1);
extern LPDIRECT3DLIGHT d3dlight_create(IDirect3D2Impl* d3d2);
extern LPDIRECT3DEXECUTEBUFFER d3dexecutebuffer_create(IDirect3DDeviceImpl* d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc);
extern LPDIRECT3DMATERIAL d3dmaterial_create(IDirect3DImpl* d3d1);
extern LPDIRECT3DMATERIAL2 d3dmaterial2_create(IDirect3D2Impl* d3d2);
extern LPDIRECT3DVIEWPORT d3dviewport_create(IDirect3DImpl* d3d1);
extern LPDIRECT3DVIEWPORT2 d3dviewport2_create(IDirect3D2Impl* d3d2);
extern int is_OpenGL_dx3(REFCLSID rguid, IDirectDrawSurfaceImpl* surface, IDirect3DDeviceImpl** device);
extern int d3d_OpenGL_dx3(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) ;
extern int d3d_OpenGL(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) ;
extern int is_OpenGL(REFCLSID rguid, IDirectDrawSurfaceImpl* surface, IDirect3DDevice2Impl** device, IDirect3D2Impl* d3d);
extern LPDIRECT3DTEXTURE2 mesa_d3dtexture2_create(IDirectDrawSurface4Impl*);
extern LPDIRECT3DTEXTURE mesa_d3dtexture_create(IDirectDrawSurface4Impl*);
static const WINE_UNUSED GUID IID_D3DDEVICE2_OpenGL = {
0x39a0da38,
0x7e57,
0x11d2,
{ 0x8b,0x7c,0x0e,0x4e,0xd8,0x3c,0x2b,0x3c }
};
static const WINE_UNUSED GUID IID_D3DDEVICE_OpenGL = {
0x31416d44,
0x86ae,
0x11d2,
{ 0x82,0x2d,0xa8,0xd5,0x31,0x87,0xca,0xfa }
};
extern ICOM_VTABLE(IDirect3D) mesa_d3dvt;
extern ICOM_VTABLE(IDirect3D2) mesa_d3d2vt;
#endif /* __GRAPHICS_WINE_MESA_PRIVATE_H */
/* DirectDraw using DGA or Xlib(XSHM)
*
* Copyright 1997-1999 Marcus Meissner
* Copyright 1998 Lionel Ulmer (most of Direct3D stuff)
*/
#include "config.h"
#include <unistd.h>
#include <assert.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include "winerror.h"
#include "options.h"
#include "monitor.h"
#include "debugtools.h"
#include "ddraw.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
#include "x11_private.h"
#ifdef HAVE_LIBXXSHM
int XShmErrorFlag = 0;
#endif
static inline BOOL get_option( const char *name, BOOL def ) {
return PROFILE_GetWineIniBool( "x11drv", name, def );
}
static BOOL
DDRAW_XSHM_Available(void) {
#ifdef HAVE_LIBXXSHM
if (get_option( "UseXShm", 1 )) {
if (TSXShmQueryExtension(display)) {
int major,minor;
Bool shpix;
if (TSXShmQueryVersion(display, &major, &minor, &shpix))
return TRUE;
}
}
#endif
return FALSE;
}
static HRESULT X11_Create( LPDIRECTDRAW *lplpDD ) {
IDirectDrawImpl* ddraw;
int depth;
x11_dd_private *x11priv;
if (lplpDD == NULL) /* Testing ... this driver works all the time */
return DD_OK;
*lplpDD = (LPDIRECTDRAW)HeapAlloc(
GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(IDirectDrawImpl)
);
ddraw = (IDirectDrawImpl*)*lplpDD;
ICOM_VTBL(ddraw)= &xlib_ddvt;
ddraw->ref = 1;
ddraw->private = HeapAlloc(
GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(x11_dd_private)
);
x11priv = (x11_dd_private*)ddraw->private;
/* At DirectDraw creation, the depth is the default depth */
depth = DefaultDepthOfScreen(X11DRV_GetXScreen());
_common_depth_to_pixelformat(depth,
&(ddraw->d.directdraw_pixelformat),
&(ddraw->d.screen_pixelformat),
&(ddraw->d.pixmap_depth));
ddraw->d.height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor);
ddraw->d.width = MONITOR_GetWidth(&MONITOR_PrimaryMonitor);
#ifdef HAVE_LIBXXSHM
/* Test if XShm is available. */
if ((x11priv->xshm_active = DDRAW_XSHM_Available())) {
x11priv->xshm_compl = 0;
TRACE("Using XShm extension.\n");
}
#endif
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 X11_DirectDraw_GUID = { /* 1574a740-dc61-11d1-8407-f7875a7d1879 */
0x1574a740,
0xdc61,
0x11d1,
{0x84, 0x07, 0xf7, 0x87, 0x5a, 0x7d, 0x18, 0x79}
};
ddraw_driver x11_driver = {
&X11_DirectDraw_GUID,
"display",
"WINE X11 DirectDraw Driver",
50,
X11_Create
};
#ifdef __GNUC__
static void X11_register(void) __attribute__((constructor));
#else /* defined(__GNUC__) */
static void __asm__dummy_dll_init(void) {
asm("\t.section .init ,\"ax\"\n"
"\tcall X11_register\n"
"\t.previous\n");
#endif /* defined(__GNUC__) */
static void X11_register(void) { ddraw_register_driver(&x11_driver); }
#ifndef __WINE_DDRAW_X11_PRIVATE_H
#define __WINE_DDRAW_X11_PRIVATE_H
/* This file contains all X11 private and specific definitions.
* It may also be used by all ports that reuse X11 stuff (like XF86 DGA)
*/
#include "ts_xlib.h"
#include "ts_xutil.h"
#ifdef HAVE_LIBXXSHM
# include <sys/types.h>
# ifdef HAVE_SYS_IPC_H
# include <sys/ipc.h>
# endif
# ifdef HAVE_SYS_SHM_H
# include <sys/shm.h>
# endif
# include "ts_xshm.h"
#endif /* defined(HAVE_LIBXXSHM) */
#include "x11drv.h"
#include "ddraw_private.h"
#include "wine_gl.h"
extern ICOM_VTABLE(IDirectDraw) xlib_ddvt;
extern ICOM_VTABLE(IDirectDraw2) xlib_dd2vt;
extern ICOM_VTABLE(IDirectDraw4) xlib_dd4vt;
extern ICOM_VTABLE(IDirectDrawPalette) xlib_ddpalvt;
extern ICOM_VTABLE(IDirectDrawSurface4) xlib_dds4vt;
typedef struct x11_dd_private {
#ifdef HAVE_LIBXXSHM
int xshm_active, xshm_compl;
#endif /* defined(HAVE_LIBXXSHM) */
Window drawable;
} x11_dd_private;
typedef struct x11_dp_private {
BOOL installed; /* is colormap installed */
Colormap cm; /* the X11 Colormap associated */
} x11_dp_private;
extern HRESULT WINAPI Xlib_IDirectDrawPaletteImpl_SetEntries(LPDIRECTDRAWPALETTE,DWORD,DWORD,DWORD,LPPALETTEENTRY);
extern ULONG WINAPI Xlib_IDirectDrawPaletteImpl_Release(LPDIRECTDRAWPALETTE iface);
typedef struct x11_ds_private {
XImage *image;
#ifdef HAVE_LIBXXSHM
XShmSegmentInfo shminfo;
#endif
} x11_ds_private;
#ifdef HAVE_LIBXXSHM
extern int XShmErrorFlag;
#endif
#endif /* __WINE_DDRAW_X11_PRIVATE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment