Commit d6c0f9f7 authored by Alexandre Julliard's avatar Alexandre Julliard

Authors: Andrew Lewycky <andrew@transgaming.com>, Gavriel State…

Authors: Andrew Lewycky <andrew@transgaming.com>, Gavriel State <gav@transgaming.com>, Ove Kaaven <ovek@transgaming.com> Major DirectDraw restructure/reimplementation, using an improved component object model hierarchy. The implementation currently supports: - DirectDraw over GDI/USER in a window (using DIBsections and asynchronous updates) - XVidMode - XF86DGA2 - All DirectDraw interfaces from versions 1 to 7 (at least in theory) - Hooks for Direct3D interfaces
parent 28b8ac83
......@@ -134,12 +134,6 @@ AC_SUBST(OPENGLFILES)
OPENGLFILES=""
AC_SUBST(OPENGL32_DLL)
OPENGL32_DLL=""
AC_SUBST(DGA_SRCS)
DGA_SRCS=""
AC_SUBST(DGA2_SRCS)
DGA2_SRCS=""
AC_SUBST(MESA_SRCS)
MESA_SRCS=""
if test "$have_x" = "yes"
then
XLIB="-lXext -lX11"
......@@ -212,15 +206,12 @@ then
AC_DEFINE(HAVE_LIBXXF86DGA2)
AC_DEFINE(HAVE_LIBXXF86DGA)
X_PRE_LIBS="$X_PRE_LIBS -lXxf86dga"
DGA_SRCS='$(DGA_SRCS)'
DGA2_SRCS='$(DGA2_SRCS)'
],
[ dnl *** If not found, look for XF86DGAQueryExtension()
dnl *** instead (DGA 2.0 not found)...
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
)
......@@ -292,7 +283,6 @@ then
dnl Check for the presence of the library
AC_CHECK_LIB(GL,glXCreateContext,
X_PRE_LIBS="$X_PRE_LIBS -lGL"
MESA_SRCS='$(MESA_SRCS)'
,,
$X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS)
......@@ -324,6 +314,20 @@ then
OPENGL32_DLL=opengl32
fi
AC_CHECK_HEADERS(GL/osmesa.h,
[ dnl *** If GL/osmesa.h exists...
AC_CHECK_LIB(GL, OSMesaCreateContext,
AC_DEFINE(HAVE_OSMESA),
AC_CHECK_LIB(OSMesa, OSMesaCreateContext,
[ AC_DEFINE(HAVE_OSMESA)
X_PRE_LIBS="$X_PRE_LIBS -lOSMesa"
]),
$X_LIBS -lXext -lX11 $X_EXTRA_LIBS
)
],
AC_MSG_WARN([OSMesa not found!!])
)
fi
fi
fi
......@@ -1344,7 +1348,7 @@ fi
if test "$wine_cv_opengl_version_threadsafe" = "yes" -a $OPENGL = "yes"
then
echo
echo "*** Warning: you explicitely linked in a thread-safe OpenGL version. If you"
echo "*** Warning: you explicitly linked in a thread-safe OpenGL version. If you"
echo "*** experience unusual crashes on DirectDraw games, try first to disable OpenGL"
echo "*** support before reporting bugs."
fi
......
......@@ -4,51 +4,42 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = ddraw
EXTRALIBS = $(LIBUUID)
SOVERSION = 1.0
IMPORTS = user32 x11drv gdi32 kernel32
MESA_SRCS = \
OPENGLFILES = \
d3dcommon.c \
d3ddevice/main.c \
d3ddevice/mesa.c \
d3dexecutebuffer.c \
d3dlight.c \
d3dmaterial.c \
d3dtexture.c \
d3dviewport.c \
direct3d/main.c \
direct3d/mesa.c \
mesa.c
DGA_SRCS = \
ddraw/dga.c \
dpalette/dga.c \
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 \
x11.c
C_SRCS = \
@XFILES@ \
@OPENGLFILES@ \
convert.c \
d3ddevice/main.c \
dclipper/main.c \
ddraw/dga2.c \
ddraw/main.c \
direct3d/main.c \
ddraw/thunks.c \
ddraw/user.c \
ddraw/xvidmode.c \
dpalette/main.c \
dsurface/dga2.c \
dsurface/dib.c \
dsurface/dibtexture.c \
dsurface/fakezbuffer.c \
dsurface/main.c \
dsurface/thunks.c \
dsurface/user.c \
dsurface/wndproc.c \
helper.c \
main.c
main.c \
struct_convert.c
EXTRASUBDIRS = \
d3ddevice \
......
......@@ -224,12 +224,36 @@ static void pixel_convert_32_to_24(
}
}
Convert ModeEmulations[7] = {
{ { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { 24, 24, 0xFF0000, 0x0000FF00, 0x00FF }, { pixel_convert_32_to_24, NULL } },
{ { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_32_to_8, palette_convert_24_to_8 } },
/* *************************************
16 bpp to 32 bpp
************************************* */
static void pixel_convert_16_to_32(
void *src, void *dst, DWORD width, DWORD height, LONG pitch,
IDirectDrawPaletteImpl* palette
) {
unsigned int *c_src = (unsigned int *) src;
unsigned short *c_dst = (unsigned short *) dst;
int y;
for (y = height; y--; ) {
unsigned int * srclineend = c_src+width;
while (c_src < srclineend ) {
*c_dst++ = (((*c_src & 0xF80000) >> 8) |
((*c_src & 0x00FC00) >> 5) |
((*c_src & 0x0000F8) >> 3));
c_src++;
}
c_src+=((pitch/4)-width);
}
}
Convert ModeEmulations[8] = {
{ { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { 24, 24, 0xFF0000, 0x00FF00, 0x0000FF }, { pixel_convert_32_to_24, NULL } },
{ { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { 16, 16, 0xF800, 0x07E0, 0x001F }, { pixel_convert_32_to_16, NULL } },
{ { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_32_to_8, palette_convert_24_to_8 } },
{ { 24, 24, 0xFF0000, 0x00FF00, 0x0000FF }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_24_to_8, palette_convert_24_to_8 } },
{ { 16, 15, 0x7C00, 0x03E0, 0x001F }, { 16,16, 0xf800, 0x07e0, 0x001f }, { pixel_convert_15_to_16, NULL } },
{ { 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 } },
{ { 16, 16, 0xF800, 0x07E0, 0x001F }, { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { pixel_convert_16_to_32, NULL } }
};
......@@ -178,7 +178,7 @@ struct IDirect3DTexture2Impl
/* IDirect3DTexture2 fields */
void* D3Ddevice; /* (void *) to use the same pointer
* for both Direct3D and Direct3D2 */
IDirectDrawSurface4Impl* surface;
IDirectDrawSurfaceImpl* surface;
LPVOID private;
};
......@@ -535,8 +535,8 @@ extern HRESULT WINAPI IDirect3DDeviceImpl_GetDirect3D(
);
/* All non-static functions 'exported' by various sub-objects */
extern LPDIRECT3DTEXTURE2 d3dtexture2_create(IDirectDrawSurface4Impl* surf);
extern LPDIRECT3DTEXTURE d3dtexture_create(IDirectDrawSurface4Impl* surf);
extern LPDIRECT3DTEXTURE2 d3dtexture2_create(IDirectDrawSurfaceImpl* surf);
extern LPDIRECT3DTEXTURE d3dtexture_create(IDirectDrawSurfaceImpl* surf);
extern LPDIRECT3DLIGHT d3dlight_create_dx3(IDirect3DImpl* d3d1);
extern LPDIRECT3DLIGHT d3dlight_create(IDirect3D2Impl* d3d2);
......
......@@ -28,7 +28,6 @@ ICOM_VTABLE(IDirect3DDevice) OpenGL_vtable_dx3;
#undef HAVE_BUGGY_MESAGL
#define D3DDPRIVATE(x) mesa_d3dd_private *odev=((mesa_d3dd_private*)x->private)
#define DDPRIVATE(x) x11_dd_private *ddpriv=((x11_dd_private*)(x)->d->private)
#ifndef HAVE_GLEXT_PROTOTYPES
/* This is for non-OpenGL ABI compliant glext.h headers :-) */
......@@ -48,8 +47,8 @@ static const float id_mat[16] = {
* OpenGL static functions
*/
static void set_context(IDirect3DDevice2Impl* This) {
#if COMPILABLE
D3DDPRIVATE(This);
DDPRIVATE(This->surface->s.ddraw);
#ifdef USE_OSMESA
OSMesaMakeCurrent(d3ddpriv->ctx, odev->buffer, GL_UNSIGNED_BYTE,
......@@ -59,7 +58,8 @@ static void set_context(IDirect3DDevice2Impl* This) {
if (glXMakeCurrent(display,ddpriv->drawable, odev->ctx) == False) {
ERR("Error in setting current context (context %p drawable %ld)!\n",
odev->ctx, ddpriv->drawable);
}
}
#endif
#endif
}
......@@ -123,6 +123,7 @@ static void fill_opengl_caps(D3DDEVICEDESC *d1, D3DDEVICEDESC *d2)
}
static void fill_device_capabilities(IDirectDrawImpl* ddraw) {
#if COMPILABLE
x11_dd_private *private = (x11_dd_private *) ddraw->d->private;
const char *ext_string;
Mesa_DeviceCapabilities *devcap;
......@@ -140,6 +141,7 @@ static void fill_device_capabilities(IDirectDrawImpl* ddraw) {
TRACE("Color table extension not found.\n");
}
LEAVE_GL();
#endif
}
int d3d_OpenGL(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) {
......@@ -201,6 +203,7 @@ is_OpenGL(
else
TRACE("Context created (%p)\n", odev->ctx);
#if COMPILABLE
/* Now override the surface's Flip method (if in double buffering) */
((x11_ds_private *) surface->private)->opengl_flip = TRUE;
{
......@@ -210,6 +213,7 @@ is_OpenGL(
if (chain->surfaces[i]->s.surface_desc.ddsCaps.dwCaps & DDSCAPS_FLIP)
((x11_ds_private *) chain->surfaces[i]->private)->opengl_flip = TRUE;
}
#endif
#endif
odev->rs.src = GL_ONE;
......@@ -295,21 +299,21 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb,
TRACE("Enumerating GL_RGBA unpacked (32)\n");
pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
pformat->u.dwRGBBitCount = 32;
pformat->u1.dwRBitMask = 0xFF000000;
pformat->u2.dwGBitMask = 0x00FF0000;
pformat->u3.dwBBitMask = 0x0000FF00;
pformat->u4.dwRGBAlphaBitMask = 0x000000FF;
pformat->u1.dwRGBBitCount = 32;
pformat->u2.dwRBitMask = 0xFF000000;
pformat->u3.dwGBitMask = 0x00FF0000;
pformat->u4.dwBBitMask = 0x0000FF00;
pformat->u5.dwRGBAlphaBitMask = 0x000000FF;
if (cb(&sdesc, context) == 0)
return DD_OK;
TRACE("Enumerating GL_RGB unpacked (24)\n");
pformat->dwFlags = DDPF_RGB;
pformat->u.dwRGBBitCount = 24;
pformat->u1.dwRBitMask = 0x00FF0000;
pformat->u2.dwGBitMask = 0x0000FF00;
pformat->u3.dwBBitMask = 0x000000FF;
pformat->u4.dwRGBAlphaBitMask = 0x00000000;
pformat->u1.dwRGBBitCount = 24;
pformat->u2.dwRBitMask = 0x00FF0000;
pformat->u3.dwGBitMask = 0x0000FF00;
pformat->u4.dwBBitMask = 0x000000FF;
pformat->u5.dwRGBAlphaBitMask = 0x00000000;
if (cb(&sdesc, context) == 0)
return DD_OK;
......@@ -318,62 +322,62 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb,
so that future version will work great. */
TRACE("Enumerating GL_RGB packed GL_UNSIGNED_SHORT_5_6_5 (16)\n");
pformat->dwFlags = DDPF_RGB;
pformat->u.dwRGBBitCount = 16;
pformat->u1.dwRBitMask = 0x0000F800;
pformat->u2.dwGBitMask = 0x000007E0;
pformat->u3.dwBBitMask = 0x0000001F;
pformat->u4.dwRGBAlphaBitMask = 0x00000000;
pformat->u1.dwRGBBitCount = 16;
pformat->u2.dwRBitMask = 0x0000F800;
pformat->u3.dwGBitMask = 0x000007E0;
pformat->u4.dwBBitMask = 0x0000001F;
pformat->u5.dwRGBAlphaBitMask = 0x00000000;
if (cb(&sdesc, context) == 0)
return DD_OK;
TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_5_5_5_1 (16)\n");
pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
pformat->u.dwRGBBitCount = 16;
pformat->u1.dwRBitMask = 0x0000F800;
pformat->u2.dwGBitMask = 0x000007C0;
pformat->u3.dwBBitMask = 0x0000003E;
pformat->u4.dwRGBAlphaBitMask = 0x00000001;
pformat->u1.dwRGBBitCount = 16;
pformat->u2.dwRBitMask = 0x0000F800;
pformat->u3.dwGBitMask = 0x000007C0;
pformat->u4.dwBBitMask = 0x0000003E;
pformat->u5.dwRGBAlphaBitMask = 0x00000001;
if (cb(&sdesc, context) == 0)
return DD_OK;
TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_4_4_4_4 (16)\n");
pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
pformat->u.dwRGBBitCount = 16;
pformat->u1.dwRBitMask = 0x0000F000;
pformat->u2.dwGBitMask = 0x00000F00;
pformat->u3.dwBBitMask = 0x000000F0;
pformat->u4.dwRGBAlphaBitMask = 0x0000000F;
pformat->u1.dwRGBBitCount = 16;
pformat->u2.dwRBitMask = 0x0000F000;
pformat->u3.dwGBitMask = 0x00000F00;
pformat->u4.dwBBitMask = 0x000000F0;
pformat->u5.dwRGBAlphaBitMask = 0x0000000F;
if (cb(&sdesc, context) == 0)
return DD_OK;
TRACE("Enumerating GL_RGB packed GL_UNSIGNED_BYTE_3_3_2 (8)\n");
pformat->dwFlags = DDPF_RGB;
pformat->u.dwRGBBitCount = 8;
pformat->u1.dwRBitMask = 0x0000F800;
pformat->u2.dwGBitMask = 0x000007C0;
pformat->u3.dwBBitMask = 0x0000003E;
pformat->u4.dwRGBAlphaBitMask = 0x00000001;
pformat->u1.dwRGBBitCount = 8;
pformat->u2.dwRBitMask = 0x0000F800;
pformat->u3.dwGBitMask = 0x000007C0;
pformat->u4.dwBBitMask = 0x0000003E;
pformat->u5.dwRGBAlphaBitMask = 0x00000001;
if (cb(&sdesc, context) == 0)
return DD_OK;
#endif
TRACE("Enumerating GL_ARGB (no direct OpenGL equivalent - conversion needed)\n");
pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
pformat->u.dwRGBBitCount = 16;
pformat->u1.dwRBitMask = 0x00007C00;
pformat->u2.dwGBitMask = 0x000003E0;
pformat->u3.dwBBitMask = 0x0000001F;
pformat->u4.dwRGBAlphaBitMask = 0x00008000;
pformat->u1.dwRGBBitCount = 16;
pformat->u2.dwRBitMask = 0x00007C00;
pformat->u3.dwGBitMask = 0x000003E0;
pformat->u4.dwBBitMask = 0x0000001F;
pformat->u5.dwRGBAlphaBitMask = 0x00008000;
if (cb(&sdesc, context) == 0)
return DD_OK;
TRACE("Enumerating Paletted (8)\n");
pformat->dwFlags = DDPF_PALETTEINDEXED8;
pformat->u.dwRGBBitCount = 8;
pformat->u1.dwRBitMask = 0x00000000;
pformat->u2.dwGBitMask = 0x00000000;
pformat->u3.dwBBitMask = 0x00000000;
pformat->u4.dwRGBAlphaBitMask = 0x00000000;
pformat->u1.dwRGBBitCount = 8;
pformat->u2.dwRBitMask = 0x00000000;
pformat->u3.dwGBitMask = 0x00000000;
pformat->u4.dwBBitMask = 0x00000000;
pformat->u5.dwRGBAlphaBitMask = 0x00000000;
if (cb(&sdesc, context) == 0)
return DD_OK;
......@@ -936,7 +940,7 @@ int is_OpenGL_dx3(REFCLSID rguid, IDirectDrawSurfaceImpl* surface, IDirect3DDevi
glClearColor(0.0, 0.0, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
fill_device_capabilities((IDirectDrawImpl *) surface->s.ddraw);
fill_device_capabilities((IDirectDrawImpl *) surface->ddraw_owner);
return 1;
}
......
/* DirectDrawClipper implementation
*
* Copyright 2000 Marcus Meissner
* Copyright 2000 TransGaming Technologies Inc.
*/
#include "config.h"
#include "winerror.h"
#include "debugtools.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"
#include "dclipper/main.h"
#include "ddraw/main.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
/******************************************************************************
* DirectDrawCreateClipper (DDRAW.7)
*/
static ICOM_VTABLE(IDirectDrawClipper) DDRAW_Clipper_VTable;
HRESULT WINAPI DirectDrawCreateClipper(
DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, LPUNKNOWN pUnkOuter
) {
IDirectDrawClipperImpl** ilplpDDClipper=(IDirectDrawClipperImpl**)lplpDDClipper;
TRACE("(%08lx,%p,%p)\n", dwFlags, ilplpDDClipper, pUnkOuter);
IDirectDrawClipperImpl* This;
TRACE("(%08lx,%p,%p)\n", dwFlags, lplpDDClipper, pUnkOuter);
if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(IDirectDrawClipperImpl));
if (This == NULL) return E_OUTOFMEMORY;
ICOM_INIT_INTERFACE(This, IDirectDrawClipper, DDRAW_Clipper_VTable);
This->ref = 1;
This->hWnd = 0;
This->ddraw_owner = NULL;
*ilplpDDClipper = (IDirectDrawClipperImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectDrawClipperImpl));
ICOM_VTBL(*ilplpDDClipper) = &ddclipvt;
(*ilplpDDClipper)->ref = 1;
(*ilplpDDClipper)->hWnd = 0;
*lplpDDClipper = ICOM_INTERFACE(This, IDirectDrawClipper);
return DD_OK;
}
/* This is the classfactory implementation. */
HRESULT DDRAW_CreateDirectDrawClipper(IUnknown* pUnkOuter, REFIID riid,
LPVOID* ppObj)
{
HRESULT hr;
LPDIRECTDRAWCLIPPER pClip;
hr = DirectDrawCreateClipper(0, &pClip, pUnkOuter);
if (FAILED(hr)) return hr;
hr = IDirectDrawClipper_QueryInterface(pClip, riid, ppObj);
IDirectDrawClipper_Release(pClip);
return hr;
}
/******************************************************************************
* IDirectDrawClipper
*/
static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd(
HRESULT WINAPI Main_DirectDrawClipper_SetHwnd(
LPDIRECTDRAWCLIPPER iface, DWORD dwFlags, HWND hWnd
) {
ICOM_THIS(IDirectDrawClipperImpl,iface);
......@@ -52,50 +76,77 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd(
return DD_OK;
}
static ULONG WINAPI IDirectDrawClipperImpl_Release(LPDIRECTDRAWCLIPPER iface) {
static void Main_DirectDrawClipper_Destroy(IDirectDrawClipperImpl* This)
{
if (This->ddraw_owner != NULL)
Main_DirectDraw_RemoveClipper(This->ddraw_owner, This);
HeapFree(GetProcessHeap(), 0 ,This);
}
void Main_DirectDrawClipper_ForceDestroy(IDirectDrawClipperImpl* This)
{
WARN("deleting clipper %p with refcnt %lu\n", This, This->ref);
Main_DirectDrawClipper_Destroy(This);
}
ULONG WINAPI Main_DirectDrawClipper_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;
if (--This->ref == 0)
{
Main_DirectDrawClipper_Destroy(This);
return 0;
}
else return This->ref;
}
static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(
LPDIRECTDRAWCLIPPER iface,LPRECT rects,LPRGNDATA lprgn,LPDWORD hmm
HRESULT WINAPI Main_DirectDrawClipper_GetClipList(
LPDIRECTDRAWCLIPPER iface,LPRECT prcClip,LPRGNDATA lprgn,LPDWORD pdwSize
) {
ICOM_THIS(IDirectDrawClipperImpl,iface);
FIXME("(%p,%p,%p,%p),stub!\n",This,rects,lprgn,hmm);
if (hmm) *hmm=0;
FIXME("(%p,%p,%p,%p),stub!\n",This,prcClip,lprgn,pdwSize);
abort();
if (pdwSize) *pdwSize=0;
return DD_OK;
}
static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(
LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,DWORD hmm
HRESULT WINAPI Main_DirectDrawClipper_SetClipList(
LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,DWORD pdwSize
) {
ICOM_THIS(IDirectDrawClipperImpl,iface);
FIXME("(%p,%p,%ld),stub!\n",This,lprgn,hmm);
FIXME("(%p,%p,%ld),stub!\n",This,lprgn,pdwSize);
abort();
return DD_OK;
}
static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface(
HRESULT WINAPI Main_DirectDrawClipper_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;
if (IsEqualGUID(&IID_IUnknown, riid)
|| IsEqualGUID(&IID_IDirectDrawClipper, riid))
{
*ppvObj = ICOM_INTERFACE(This, IDirectDrawClipper);
++This->ref;
return S_OK;
}
else
{
return E_NOINTERFACE;
}
}
static ULONG WINAPI IDirectDrawClipperImpl_AddRef( LPDIRECTDRAWCLIPPER iface )
ULONG WINAPI Main_DirectDrawClipper_AddRef( LPDIRECTDRAWCLIPPER iface )
{
ICOM_THIS(IDirectDrawClipperImpl,iface);
TRACE("(%p)->() incrementing from %lu.\n", This, This->ref );
return ++(This->ref);
return ++This->ref;
}
static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(
HRESULT WINAPI Main_DirectDrawClipper_GetHWnd(
LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr
) {
ICOM_THIS(IDirectDrawClipperImpl,iface);
......@@ -106,32 +157,44 @@ static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(
return DD_OK;
}
static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(
HRESULT WINAPI Main_DirectDrawClipper_Initialize(
LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags
) {
IDirectDrawImpl* pOwner;
ICOM_THIS(IDirectDrawClipperImpl,iface);
FIXME("(%p)->(%p,0x%08lx),stub!\n",This,lpDD,dwFlags);
if (This->ddraw_owner != NULL) return DDERR_ALREADYINITIALIZED;
pOwner = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, lpDD);
This->ddraw_owner = pOwner;
Main_DirectDraw_AddClipper(pOwner, This);
return DD_OK;
}
static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(
HRESULT WINAPI Main_DirectDrawClipper_IsClipListChanged(
LPDIRECTDRAWCLIPPER iface, BOOL* lpbChanged
) {
ICOM_THIS(IDirectDrawClipperImpl,iface);
FIXME("(%p)->(%p),stub!\n",This,lpbChanged);
/* XXX What is safest? */
*lpbChanged = FALSE;
return DD_OK;
}
ICOM_VTABLE(IDirectDrawClipper) ddclipvt =
static ICOM_VTABLE(IDirectDrawClipper) DDRAW_Clipper_VTable =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectDrawClipperImpl_QueryInterface,
IDirectDrawClipperImpl_AddRef,
IDirectDrawClipperImpl_Release,
IDirectDrawClipperImpl_GetClipList,
IDirectDrawClipperImpl_GetHWnd,
IDirectDrawClipperImpl_Initialize,
IDirectDrawClipperImpl_IsClipListChanged,
IDirectDrawClipperImpl_SetClipList,
IDirectDrawClipperImpl_SetHwnd
Main_DirectDrawClipper_QueryInterface,
Main_DirectDrawClipper_AddRef,
Main_DirectDrawClipper_Release,
Main_DirectDrawClipper_GetClipList,
Main_DirectDrawClipper_GetHWnd,
Main_DirectDrawClipper_Initialize,
Main_DirectDrawClipper_IsClipListChanged,
Main_DirectDrawClipper_SetClipList,
Main_DirectDrawClipper_SetHwnd
};
/* Copyright 2000 TransGaming Technologies Inc. */
#ifndef WINE_DDRAW_DCLIPPER_MAIN_H_INCLUDED
#define WINE_DDRAW_DCLIPPER_MAIN_H_INCLUDED
HRESULT WINAPI DirectDrawCreateClipper(DWORD dwFlags,
LPDIRECTDRAWCLIPPER* ppClipper,
LPUNKNOWN pUnkOuter);
HRESULT DDRAW_CreateClipper(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppObj);
void Main_DirectDrawClipper_ForceDestroy(IDirectDrawClipperImpl* This);
HRESULT WINAPI
Main_DirectDrawClipper_SetHwnd(LPDIRECTDRAWCLIPPER iface, DWORD dwFlags,
HWND hWnd);
ULONG WINAPI Main_DirectDrawClipper_Release(LPDIRECTDRAWCLIPPER iface);
HRESULT WINAPI
Main_DirectDrawClipper_GetClipList(LPDIRECTDRAWCLIPPER iface,LPRECT prcClip,
LPRGNDATA lprgn,LPDWORD pdwSize);
HRESULT WINAPI
Main_DirectDrawClipper_SetClipList(LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,
DWORD pdwSize);
HRESULT WINAPI
Main_DirectDrawClipper_QueryInterface(LPDIRECTDRAWCLIPPER iface, REFIID riid,
LPVOID* ppvObj);
ULONG WINAPI Main_DirectDrawClipper_AddRef( LPDIRECTDRAWCLIPPER iface );
HRESULT WINAPI
Main_DirectDrawClipper_GetHWnd(LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr);
HRESULT WINAPI
Main_DirectDrawClipper_Initialize(LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD,
DWORD dwFlags);
HRESULT WINAPI
Main_DirectDrawClipper_IsClipListChanged(LPDIRECTDRAWCLIPPER iface,
BOOL* lpbChanged);
#endif
/* A few helpful macros for implementing COM objects.
*
* Copyright 2000 TransGaming Technologies Inc.
*/
#include <stddef.h>
/* Generates the name for a vtable pointer for a given interface. */
/* The canonical name for a single interface is "lpVtbl". */
#define ICOM_VFIELD_MULTI_NAME2(iface) ITF_##iface
#define ICOM_VFIELD_MULTI_NAME(iface) ICOM_VFIELD_MULTI_NAME2(iface)
/* Declares a vtable pointer field in an implementation. */
#define ICOM_VFIELD_MULTI(iface) \
iface ICOM_VFIELD_MULTI_NAME(iface)
/* Returns the offset of a vtable pointer within an implementation object. */
#define ICOM_VFIELD_OFFSET(impltype, iface) \
offsetof(impltype, ICOM_VFIELD_MULTI_NAME(iface))
/* Given an interface pointer, returns the implementation pointer. */
#define ICOM_OBJECT(impltype, ifacename, ifaceptr) \
(impltype*)((ifaceptr) == NULL ? NULL \
: (char*)(ifaceptr) - ICOM_VFIELD_OFFSET(impltype,ifacename))
#define ICOM_THIS_FROM(impltype, ifacename, ifaceptr) \
impltype* This = ICOM_OBJECT(impltype, ifacename, ifaceptr)
/* Given an object and interface name, returns a pointer to that interface. */
#define ICOM_INTERFACE(implobj, iface) \
(&((implobj)->ICOM_VFIELD_MULTI_NAME(iface)))
#define ICOM_INIT_INTERFACE(implobj, ifacename, vtblname) \
do { \
(implobj)->ICOM_VFIELD_MULTI_NAME(ifacename).lpVtbl = &(vtblname); \
} while (0)
#define COM_INTERFACE_CAST(impltype, ifnamefrom, ifnameto, ifaceptr) \
ICOM_INTERFACE(ICOM_OBJECT(impltype, ifnamefrom, ifaceptr), ifnameto)
name ddraw
type win32
init DDRAW_DllMain
import user32.dll
import x11drv.dll
......
/* Copyright 2000 TransGaming Technologies, Inc. */
#ifndef WINE_DDRAW_DDRAW_DGA2_H_INCLUDED
#define WINE_DDRAW_DDRAW_DGA2_H_INCLUDED
#include <X11/extensions/xf86dga.h>
#define XF86DGA2_DDRAW_PRIV(ddraw) \
((XF86DGA2_DirectDrawImpl*)((ddraw)->private))
#define XF86DGA2_DDRAW_PRIV_VAR(name,ddraw) \
XF86DGA2_DirectDrawImpl* name = XF86DGA2_DDRAW_PRIV(ddraw)
typedef struct
{
XDGADevice* current_mode;
DWORD next_vofs;
} XF86DGA2_DirectDrawImpl_Part;
typedef struct
{
User_DirectDrawImpl_Part user;
XF86DGA2_DirectDrawImpl_Part xf86dga2;
} XF86DGA2_DirectDrawImpl;
void XF86DGA2_DirectDraw_final_release(IDirectDrawImpl* This);
HRESULT XF86DGA2_DirectDraw_create_primary(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
LPUNKNOWN pOuter);
HRESULT XF86DGA2_DirectDraw_create_backbuffer(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
LPUNKNOWN pOuter,
IDirectDrawSurfaceImpl* primary);
HRESULT XF86DGA2_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex);
HRESULT XF86DGA2_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface,
IUnknown* pUnkOuter, BOOL ex);
HRESULT WINAPI
XF86DGA2_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface,
LPDDDEVICEIDENTIFIER2 pDDDI,
DWORD dwFlags);
HRESULT WINAPI
XF86DGA2_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
DWORD dwHeight, DWORD dwBPP,
DWORD dwRefreshRate, DWORD dwFlags);
HRESULT WINAPI
XF86DGA2_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface);
#endif
/* Copyright 2000 TransGaming Technologies Inc. */
#ifndef WINE_DDRAW_DDRAW_MAIN_H_INCLUDED
#define WINE_DDRAW_DDRAW_MAIN_H_INCLUDED
/* internal virtual functions */
void Main_DirectDraw_final_release(IDirectDrawImpl* This);
HRESULT
Main_create_offscreen(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
HRESULT
Main_create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter,
DWORD dwMipMapLevel);
HRESULT
Main_create_zbuffer(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
/* internal functions */
HRESULT Main_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex);
void Main_DirectDraw_AddSurface(IDirectDrawImpl* This,
IDirectDrawSurfaceImpl* surface);
void Main_DirectDraw_RemoveSurface(IDirectDrawImpl* This,
IDirectDrawSurfaceImpl* surface);
void Main_DirectDraw_AddClipper(IDirectDrawImpl* This,
IDirectDrawClipperImpl* clipper);
void Main_DirectDraw_RemoveClipper(IDirectDrawImpl* This,
IDirectDrawClipperImpl* clipper);
void Main_DirectDraw_AddPalette(IDirectDrawImpl* This,
IDirectDrawPaletteImpl* surface);
void Main_DirectDraw_RemovePalette(IDirectDrawImpl* This,
IDirectDrawPaletteImpl* palette);
/* interface functions */
ULONG WINAPI Main_DirectDraw_AddRef(LPDIRECTDRAW7 iface);
ULONG WINAPI Main_DirectDraw_Release(LPDIRECTDRAW7 iface);
HRESULT WINAPI Main_DirectDraw_QueryInterface(LPDIRECTDRAW7 iface,
REFIID refiid,LPVOID *obj);
HRESULT WINAPI Main_DirectDraw_Compact(LPDIRECTDRAW7 iface);
HRESULT WINAPI Main_DirectDraw_CreateClipper(LPDIRECTDRAW7 iface,
DWORD dwFlags,
LPDIRECTDRAWCLIPPER *ppClipper,
IUnknown *pUnkOuter);
HRESULT WINAPI
Main_DirectDraw_CreatePalette(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPPALETTEENTRY palent,
LPDIRECTDRAWPALETTE* ppPalette,
LPUNKNOWN pUnknown);
HRESULT WINAPI
Main_DirectDraw_CreateSurface(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD,
LPDIRECTDRAWSURFACE7 *ppSurf,
IUnknown *pUnkOuter);
HRESULT WINAPI
Main_DirectDraw_DuplicateSurface(LPDIRECTDRAW7 iface, LPDIRECTDRAWSURFACE7 src,
LPDIRECTDRAWSURFACE7* dst);
HRESULT WINAPI
Main_DirectDraw_EnumSurfaces(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 lpDDSD2, LPVOID context,
LPDDENUMSURFACESCALLBACK7 callback);
HRESULT WINAPI
Main_DirectDraw_EvaluateMode(LPDIRECTDRAW7 iface,DWORD a,DWORD* b);
HRESULT WINAPI Main_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface);
HRESULT WINAPI
Main_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD pNumCodes,
LPDWORD pCodes);
HRESULT WINAPI
Main_DirectDraw_GetGDISurface(LPDIRECTDRAW7 iface,
LPDIRECTDRAWSURFACE7 *lplpGDIDDSSurface);
HRESULT WINAPI
Main_DirectDraw_GetMonitorFrequency(LPDIRECTDRAW7 iface,LPDWORD freq);
HRESULT WINAPI
Main_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine);
HRESULT WINAPI
Main_DirectDraw_GetSurfaceFromDC(LPDIRECTDRAW7 iface, HDC hdc,
LPDIRECTDRAWSURFACE7 *lpDDS);
HRESULT WINAPI
Main_DirectDraw_GetVerticalBlankStatus(LPDIRECTDRAW7 iface, LPBOOL status);
HRESULT WINAPI
Main_DirectDraw_Initialize(LPDIRECTDRAW7 iface, LPGUID lpGuid);
HRESULT WINAPI Main_DirectDraw_RestoreAllSurfaces(LPDIRECTDRAW7 iface);
HRESULT WINAPI
Main_DirectDraw_SetCooperativeLevel(LPDIRECTDRAW7 iface, HWND hwnd,
DWORD cooplevel);
HRESULT WINAPI
Main_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
DWORD dwHeight, LONG lPitch,
DWORD dwRefreshRate, DWORD dwFlags,
const DDPIXELFORMAT* pixelformat);
HRESULT WINAPI Main_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface);
HRESULT WINAPI
Main_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags,
HANDLE h);
HRESULT WINAPI
Main_DirectDraw_GetDisplayMode(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD);
HRESULT WINAPI
Main_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface,LPDDSCAPS2 ddscaps,
LPDWORD total, LPDWORD free);
HRESULT WINAPI Main_DirectDraw_TestCooperativeLevel(LPDIRECTDRAW7 iface);
HRESULT WINAPI
Main_DirectDraw_StartModeTest(LPDIRECTDRAW7 iface, LPSIZE pModes,
DWORD dwNumModes, DWORD dwFlags);
#endif
/* Copyright 2000 TransGaming Technologies Inc. */
#ifndef WINE_DDRAW_DDRAW_USER_H_INCLUDED
#define WINE_DDRAW_DDRAW_USER_H_INCLUDED
#define USER_DDRAW_PRIV(ddraw) ((User_DirectDrawImpl*)((ddraw)->private))
#define USER_DDRAW_PRIV_VAR(name,ddraw) \
User_DirectDrawImpl* name = USER_DDRAW_PRIV(ddraw)
typedef struct
{
/* empty */
} User_DirectDrawImpl_Part;
typedef struct
{
User_DirectDrawImpl_Part user;
} User_DirectDrawImpl;
void User_DirectDraw_final_release(IDirectDrawImpl* This);
HRESULT User_DirectDraw_create_primary(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
LPUNKNOWN pOuter);
HRESULT User_DirectDraw_create_backbuffer(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
LPUNKNOWN pOuter,
IDirectDrawSurfaceImpl* primary);
HRESULT User_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex);
HRESULT User_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface,
IUnknown* pUnkOuter, BOOL ex);
HRESULT WINAPI
User_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 pDDSD, LPVOID context,
LPDDENUMMODESCALLBACK2 callback);
HRESULT WINAPI
User_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps,
LPDDCAPS pHELCaps);
HRESULT WINAPI
User_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface,
LPDDDEVICEIDENTIFIER2 pDDDI,
DWORD dwFlags);
HRESULT WINAPI
User_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
DWORD dwHeight, DWORD dwBPP,
DWORD dwRefreshRate, DWORD dwFlags);
#endif
/* Copyright 2000 TransGaming Technologies, Inc. */
#ifndef WINE_DDRAW_DDRAW_XVIDMODE_H_INCLUDED
#define WINE_DDRAW_DDRAW_XVIDMODE_H_INCLUDED
#include <X11/extensions/xf86vmode.h>
#define XVIDMODE_DDRAW_PRIV(ddraw) \
((XVidMode_DirectDrawImpl*)((ddraw)->private))
#define XVIDMODE_DDRAW_PRIV_VAR(name,ddraw) \
XVidMode_DirectDrawImpl* name = XVIDMODE_DDRAW_PRIV(ddraw)
typedef struct
{
XF86VidModeModeInfo* original_mode;
XF86VidModeModeInfo* current_mode;
} XVidMode_DirectDrawImpl_Part;
typedef struct
{
User_DirectDrawImpl_Part user;
XVidMode_DirectDrawImpl_Part xvidmode;
} XVidMode_DirectDrawImpl;
void XVidMode_DirectDraw_final_release(IDirectDrawImpl* This);
HRESULT XVidMode_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex);
HRESULT XVidMode_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface,
IUnknown* pUnkOuter, BOOL ex);
HRESULT WINAPI
XVidMode_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface,
LPDDDEVICEIDENTIFIER2 pDDDI,
DWORD dwFlags);
HRESULT WINAPI
XVidMode_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
DWORD dwHeight, DWORD dwBPP,
DWORD dwRefreshRate, DWORD dwFlags);
HRESULT WINAPI
XVidMode_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface);
#endif
......@@ -342,7 +342,7 @@ ICOM_VTABLE(IDirect3D3) mesa_d3d3vt =
#undef XCAST
#endif
HRESULT create_direct3d(LPVOID *obj,IDirectDraw2Impl* ddraw) {
HRESULT create_direct3d(LPVOID *obj,IDirectDrawImpl* ddraw) {
IDirect3DImpl* d3d;
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
......@@ -357,7 +357,7 @@ HRESULT create_direct3d(LPVOID *obj,IDirectDraw2Impl* ddraw) {
return S_OK;
}
HRESULT create_direct3d2(LPVOID *obj,IDirectDraw2Impl* ddraw) {
HRESULT create_direct3d2(LPVOID *obj,IDirectDrawImpl* ddraw) {
IDirect3D2Impl* d3d;
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
......@@ -372,7 +372,7 @@ HRESULT create_direct3d2(LPVOID *obj,IDirectDraw2Impl* ddraw) {
return S_OK;
}
HRESULT create_direct3d3(LPVOID *obj,IDirectDraw2Impl* ddraw) {
HRESULT create_direct3d3(LPVOID *obj,IDirectDrawImpl* ddraw) {
IDirect3D3Impl* d3d;
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
......
/* 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)->d->private)
HRESULT WINAPI DGA_IDirectDrawPaletteImpl_SetEntries(
LPDIRECTDRAWPALETTE iface,DWORD x,DWORD start,DWORD count,LPPALETTEENTRY palent
) {
ICOM_THIS(IDirectDrawPaletteImpl,iface);
DPPRIVATE(This);
XColor xc;
int i;
TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,x,start,count,palent);
if (!dppriv->cm) /* should not happen */ {
TRACE("app tried to set colormap in non-palettized mode\n");
}
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;
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;
}
/* Flush the display queue so that palette updates are visible directly */
TSXFlush(display);
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
* Copyright 2000 TransGaming Technologies Inc.
*/
#include "config.h"
#include "winerror.h"
#include "debugtools.h"
#include <unistd.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include "ddraw_private.h"
#include "debugtools.h"
#include "dpalette/main.h"
#include "ddraw/main.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
#define SIZE_BITS (DDPCAPS_1BIT | DDPCAPS_2BIT | DDPCAPS_4BIT | DDPCAPS_8BIT)
/* For unsigned x. 0 is not a power of 2. */
#define IS_POW_2(x) (((x) & ((x) - 1)) == 0)
static ICOM_VTABLE(IDirectDrawPalette) DDRAW_Main_Palette_VTable;
/******************************************************************************
* IDirectDrawPalette
*/
HRESULT WINAPI IDirectDrawPaletteImpl_GetEntries(
LPDIRECTDRAWPALETTE iface,DWORD x,DWORD start,DWORD count,LPPALETTEENTRY palent
) {
HRESULT Main_DirectDrawPalette_Construct(IDirectDrawPaletteImpl* This,
IDirectDrawImpl* pDD, DWORD dwFlags)
{
if (!IS_POW_2(dwFlags & SIZE_BITS)) return DDERR_INVALIDPARAMS;
if (dwFlags & DDPCAPS_8BITENTRIES)
WARN("creating palette with 8 bit entries\n");
This->flags = dwFlags;
This->palNumEntries = Main_DirectDrawPalette_Size(dwFlags);
This->ref = 1;
This->final_release = Main_DirectDrawPalette_final_release;
ICOM_INIT_INTERFACE(This, IDirectDrawPalette, DDRAW_Main_Palette_VTable);
/* we could defer hpal creation until we need it,
* but does anyone have a case where it would be useful? */
This->hpal = CreatePalette((const LOGPALETTE*)&(This->palVersion));
Main_DirectDraw_AddPalette(pDD, This);
return DD_OK;
}
HRESULT
Main_DirectDrawPalette_Create(IDirectDrawImpl* pDD, DWORD dwFlags,
LPDIRECTDRAWPALETTE* ppPalette,
LPUNKNOWN pUnkOuter)
{
IDirectDrawPaletteImpl* This;
HRESULT hr;
if (pUnkOuter != NULL)
return CLASS_E_NOAGGREGATION; /* unchecked */
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
if (This == NULL) return E_OUTOFMEMORY;
hr = Main_DirectDrawPalette_Construct(This, pDD, dwFlags);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
else
*ppPalette = ICOM_INTERFACE(This, IDirectDrawPalette);
return hr;
}
DWORD Main_DirectDrawPalette_Size(DWORD dwFlags)
{
switch (dwFlags & SIZE_BITS)
{
case DDPCAPS_1BIT: return 2;
case DDPCAPS_2BIT: return 4;
case DDPCAPS_4BIT: return 16;
case DDPCAPS_8BIT: return 256;
default: assert(0); return 256;
}
}
HRESULT WINAPI
Main_DirectDrawPalette_GetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent)
{
ICOM_THIS(IDirectDrawPaletteImpl,iface);
int i;
TRACE("(%p)->GetEntries(%08lx,%ld,%ld,%p)\n",This,x,start,count,palent);
TRACE("(%p)->GetEntries(%08lx,%ld,%ld,%p)\n",This,dwFlags,dwStart,dwCount,
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;
if (dwFlags != 0) return DDERR_INVALIDPARAMS; /* unchecked */
if (dwStart + dwCount > Main_DirectDrawPalette_Size(This->flags))
return DDERR_INVALIDPARAMS;
if (This->flags & DDPCAPS_8BITENTRIES)
{
int i;
LPBYTE entry = (LPBYTE)palent;
for (i=dwStart; i < dwCount+dwStart; i++)
*entry++ = This->palents[i].peRed;
}
else
memcpy(palent, This->palents+dwStart, dwCount * sizeof(PALETTEENTRY));
return DD_OK;
}
HRESULT WINAPI IDirectDrawPaletteImpl_SetEntries(
LPDIRECTDRAWPALETTE iface,DWORD x,DWORD start,DWORD count,LPPALETTEENTRY palent
) {
HRESULT WINAPI
Main_DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
DWORD dwStart, DWORD dwCount,
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;
TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,dwFlags,dwStart,dwCount,
palent);
if (This->flags & DDPCAPS_8BITENTRIES)
{
int i;
const BYTE* entry = (const BYTE*)palent;
for (i=dwStart; i < dwCount+dwStart; i++)
This->palents[i].peRed = *entry++;
}
else {
memcpy(This->palents+dwStart, palent, dwCount * sizeof(PALETTEENTRY));
if (This->hpal)
SetPaletteEntries(This->hpal, dwStart, dwCount, This->palents+dwStart);
if (This->flags & DDPCAPS_PRIMARYSURFACE) {
/* update physical palette */
LPDIRECTDRAWSURFACE7 psurf = NULL;
IDirectDraw7_GetGDISurface(ICOM_INTERFACE(This->ddraw_owner,IDirectDraw7), &psurf);
if (psurf) {
IDirectDrawSurfaceImpl *surf = ICOM_OBJECT(IDirectDrawSurfaceImpl,
IDirectDrawSurface7, psurf);
surf->update_palette(surf, This, dwStart, dwCount, palent);
IDirectDrawSurface7_Release(psurf);
}
else ERR("can't find GDI surface!!\n");
}
}
#if 0
/* 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);
#endif
return DD_OK;
}
ULONG WINAPI IDirectDrawPaletteImpl_Release(LPDIRECTDRAWPALETTE iface) {
void Main_DirectDrawPalette_final_release(IDirectDrawPaletteImpl* This)
{
Main_DirectDraw_RemovePalette(This->ddraw_owner, This);
if (This->hpal) DeleteObject(This->hpal);
}
static void Main_DirectDrawPalette_Destroy(IDirectDrawPaletteImpl* This)
{
This->final_release(This);
if (This->private != This+1)
HeapFree(GetProcessHeap(), 0, This->private);
HeapFree(GetProcessHeap(),0,This);
}
void Main_DirectDrawPalette_ForceDestroy(IDirectDrawPaletteImpl* This)
{
WARN("deleting palette %p with refcnt %lu\n", This, This->ref);
Main_DirectDrawPalette_Destroy(This);
}
ULONG WINAPI
Main_DirectDrawPalette_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;
if (!--This->ref)
{
Main_DirectDrawPalette_Destroy(This);
return 0;
}
return This->ref;
}
ULONG WINAPI IDirectDrawPaletteImpl_AddRef(LPDIRECTDRAWPALETTE iface) {
ULONG WINAPI Main_DirectDrawPalette_AddRef(LPDIRECTDRAWPALETTE iface) {
ICOM_THIS(IDirectDrawPaletteImpl,iface);
TRACE("(%p)->() incrementing from %lu.\n", This, This->ref );
return ++(This->ref);
return ++This->ref;
}
HRESULT WINAPI IDirectDrawPaletteImpl_Initialize(
LPDIRECTDRAWPALETTE iface,LPDIRECTDRAW ddraw,DWORD x,LPPALETTEENTRY palent
) {
HRESULT WINAPI
Main_DirectDrawPalette_Initialize(LPDIRECTDRAWPALETTE iface,
LPDIRECTDRAW ddraw, DWORD dwFlags,
LPPALETTEENTRY palent)
{
ICOM_THIS(IDirectDrawPaletteImpl,iface);
TRACE("(%p)->(%p,%ld,%p)\n", This, ddraw, x, palent);
TRACE("(%p)->(%p,%ld,%p)\n", This, ddraw, dwFlags, palent);
return DDERR_ALREADYINITIALIZED;
}
HRESULT WINAPI IDirectDrawPaletteImpl_GetCaps(
LPDIRECTDRAWPALETTE iface, LPDWORD lpdwCaps )
HRESULT WINAPI
Main_DirectDrawPalette_GetCaps(LPDIRECTDRAWPALETTE iface, LPDWORD lpdwCaps)
{
ICOM_THIS(IDirectDrawPaletteImpl,iface);
FIXME("(%p)->(%p) stub.\n", This, lpdwCaps );
TRACE("(%p)->(%p)\n",This,lpdwCaps);
*lpdwCaps = This->flags;
return DD_OK;
}
HRESULT WINAPI IDirectDrawPaletteImpl_QueryInterface(
LPDIRECTDRAWPALETTE iface,REFIID refiid,LPVOID *obj )
HRESULT WINAPI
Main_DirectDrawPalette_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;
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
if (IsEqualGUID(refiid, &IID_IUnknown)
|| IsEqualGUID(refiid, &IID_IDirectDrawPalette))
{
*obj = iface;
IDirectDrawPalette_AddRef(iface);
return S_OK;
}
else
{
return E_NOINTERFACE;
}
}
ICOM_VTABLE(IDirectDrawPalette) ddraw_ddpalvt =
static ICOM_VTABLE(IDirectDrawPalette) DDRAW_Main_Palette_VTable =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectDrawPaletteImpl_QueryInterface,
IDirectDrawPaletteImpl_AddRef,
IDirectDrawPaletteImpl_Release,
IDirectDrawPaletteImpl_GetCaps,
IDirectDrawPaletteImpl_GetEntries,
IDirectDrawPaletteImpl_Initialize,
IDirectDrawPaletteImpl_SetEntries
Main_DirectDrawPalette_QueryInterface,
Main_DirectDrawPalette_AddRef,
Main_DirectDrawPalette_Release,
Main_DirectDrawPalette_GetCaps,
Main_DirectDrawPalette_GetEntries,
Main_DirectDrawPalette_Initialize,
Main_DirectDrawPalette_SetEntries
};
/* Copyright 2000 TransGaming Technologies Inc. */
#ifndef WINE_DDRAW_DPALETTE_MAIN_H_INCLUDED
#define WINE_DDRAW_DPALETTE_MAIN_H_INCLUDED
HRESULT Main_DirectDrawPalette_Construct(IDirectDrawPaletteImpl* This,
IDirectDrawImpl* pDD, DWORD dwFlags);
void Main_DirectDrawPalette_final_release(IDirectDrawPaletteImpl* This);
HRESULT
Main_DirectDrawPalette_Create(IDirectDrawImpl* pDD, DWORD dwFlags,
LPDIRECTDRAWPALETTE* ppPalette,
LPUNKNOWN pUnkOuter);
void Main_DirectDrawPalette_ForceDestroy(IDirectDrawPaletteImpl* This);
DWORD Main_DirectDrawPalette_Size(DWORD dwFlags);
HRESULT WINAPI
Main_DirectDrawPalette_GetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent);
HRESULT WINAPI
Main_DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent);
ULONG WINAPI
Main_DirectDrawPalette_Release(LPDIRECTDRAWPALETTE iface);
ULONG WINAPI Main_DirectDrawPalette_AddRef(LPDIRECTDRAWPALETTE iface);
HRESULT WINAPI
Main_DirectDrawPalette_Initialize(LPDIRECTDRAWPALETTE iface,
LPDIRECTDRAW ddraw, DWORD dwFlags,
LPPALETTEENTRY palent);
HRESULT WINAPI
Main_DirectDrawPalette_GetCaps(LPDIRECTDRAWPALETTE iface, LPDWORD lpdwCaps);
HRESULT WINAPI
Main_DirectDrawPalette_QueryInterface(LPDIRECTDRAWPALETTE iface,
REFIID refiid, LPVOID *obj);
#endif
/* 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"
#include "bitmap.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
#define DDPRIVATE(x) dga_dd_private *ddpriv = ((dga_dd_private*)(x)->d->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)
static BYTE DGA_TouchSurface(LPDIRECTDRAWSURFACE4 iface)
{
ICOM_THIS(IDirectDrawSurface4Impl,iface);
/* if the DIB section is in GdiMod state, we must
* touch the surface to get any updates from the DIB */
return *(BYTE*)(This->s.surface_desc.u1.lpSurface);
}
/******************************************************************************
* 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);
DGA_TouchSurface(iface);
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;
}
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;
if (!fppriv->cm &&
(This->s.ddraw->d->screen_pixelformat.u.dwRGBBitCount<=8) ) {
int i;
/* Delayed palette creation */
fppriv->cm = TSXCreateColormap(display,DefaultRootWindow(display),
DefaultVisualOfScreen(X11DRV_GetXScreen()),AllocAll);
for (i=0;i<256;i++) {
XColor xc;
xc.red = ipal->palents[i].peRed<<8;
xc.blue = ipal->palents[i].peBlue<<8;
xc.green = ipal->palents[i].peGreen<<8;
xc.flags = DoRed|DoBlue|DoGreen;
xc.pixel = i;
TSXStoreColor(display,fppriv->cm,&xc);
}
}
TSXF86DGAInstallColormap(display,DefaultScreen(display),fppriv->cm);
if (This->s.hdc != 0) {
/* hack: set the DIBsection color map */
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dib->colorMap = This->s.palette ? This->s.palette->screen_palents : NULL;
GDI_ReleaseObj(This->s.DIBsection);
}
TSXFlush(display);
}
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)
VirtualFree(This->s.surface_desc.u1.lpSurface, 0, MEM_RELEASE);
else
ddpriv->vpmask &= ~(1<<(dspriv->fb_height/ddpriv->fb_height));
/* Free the DIBSection (if any) */
if (This->s.hdc != 0) {
/* hack: restore the original DIBsection color map */
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dib->colorMap = dspriv->oldDIBmap;
GDI_ReleaseObj(This->s.DIBsection);
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;
}
HRESULT WINAPI DGA_IDirectDrawSurface4Impl_Unlock(
LPDIRECTDRAWSURFACE4 iface,LPVOID surface
) {
ICOM_THIS(IDirectDrawSurface4Impl,iface);
TRACE("(%p)->Unlock(%p)\n",This,surface);
/* in case this was called from ReleaseDC */
DGA_TouchSurface(iface);
return DD_OK;
}
HRESULT WINAPI DGA_IDirectDrawSurface4Impl_GetDC(LPDIRECTDRAWSURFACE4 iface,HDC* lphdc) {
ICOM_THIS(IDirectDrawSurface4Impl,iface);
DSPRIVATE(This);
int was_ok = This->s.hdc != 0;
HRESULT result = IDirectDrawSurface4Impl_GetDC(iface,lphdc);
if (This->s.hdc && !was_ok) {
/* hack: take over the DIBsection color map */
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dspriv->oldDIBmap = dib->colorMap;
dib->colorMap = This->s.palette ? This->s.palette->screen_palents : NULL;
GDI_ReleaseObj(This->s.DIBsection);
}
return result;
}
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,
DGA_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,
DGA_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
};
/* Copyright 2000 TransGaming Technologies Inc. */
#ifndef DDRAW_DSURFACE_DGA2_H_INCLUDED
#define DDRAW_DSURFACE_DGA2_H_INCLUDED
#define XF86DGA2_PRIV(surf) ((XF86DGA2_DirectDrawSurfaceImpl*)((surf)->private))
#define XF86DGA2_PRIV_VAR(name,surf) \
XF86DGA2_DirectDrawSurfaceImpl* name = XF86DGA2_PRIV(surf)
struct XF86DGA2_DirectDrawSurfaceImpl_Part
{
LPVOID fb_addr;
DWORD fb_pitch, fb_vofs;
Colormap pal;
};
typedef struct
{
struct DIB_DirectDrawSurfaceImpl_Part dib;
struct XF86DGA2_DirectDrawSurfaceImpl_Part xf86dga2;
} XF86DGA2_DirectDrawSurfaceImpl;
HRESULT
XF86DGA2_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
IDirectDrawImpl* pDD,
const DDSURFACEDESC2* pDDSD);
HRESULT
XF86DGA2_DirectDrawSurface_Create(IDirectDrawImpl *pDD,
const DDSURFACEDESC2 *pDDSD,
LPDIRECTDRAWSURFACE7 *ppSurf,
IUnknown *pUnkOuter);
void XF86DGA2_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This);
void XF86DGA2_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
IDirectDrawPaletteImpl* pal);
void XF86DGA2_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This,
IDirectDrawPaletteImpl* pal,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent);
HRESULT XF86DGA2_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
LPDIRECTDRAWSURFACE7* ppDup);
void XF86DGA2_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
IDirectDrawSurfaceImpl* back);
void XF86DGA2_DirectDrawSurface_flip_update(IDirectDrawSurfaceImpl* This);
HWND XF86DGA2_DirectDrawSurface_get_display_window(IDirectDrawSurfaceImpl* This);
#endif
/* Copyright 2000 TransGaming Technologies Inc. */
#ifndef DDRAW_DSURFACE_DIB_H_INCLUDED
#define DDRAW_DSURFACE_DIB_H_INCLUDED
#define DIB_PRIV(surf) ((DIB_DirectDrawSurfaceImpl*)((surf)->private))
#define DIB_PRIV_VAR(name, surf) \
DIB_DirectDrawSurfaceImpl* name = DIB_PRIV(surf)
struct DIB_DirectDrawSurfaceImpl_Part
{
HBITMAP DIBsection;
void* bitmap_data;
HGDIOBJ holdbitmap;
BOOL client_memory;
DWORD d3d_data[4]; /* room for Direct3D driver data */
};
typedef struct
{
struct DIB_DirectDrawSurfaceImpl_Part dib;
} DIB_DirectDrawSurfaceImpl;
HRESULT
DIB_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This,
IDirectDrawImpl *pDD,
const DDSURFACEDESC2 *pDDSD);
HRESULT
DIB_DirectDrawSurface_Create(IDirectDrawImpl *pDD,
const DDSURFACEDESC2 *pDDSD,
LPDIRECTDRAWSURFACE7 *ppSurf,
IUnknown *pUnkOuter);
void DIB_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This);
void DIB_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
IDirectDrawSurfaceImpl* back);
void DIB_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
IDirectDrawPaletteImpl* pal);
void DIB_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This,
IDirectDrawPaletteImpl* pal,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent);
HRESULT DIB_DirectDrawSurface_get_dc(IDirectDrawSurfaceImpl* This, HDC* phDC);
HRESULT DIB_DirectDrawSurface_release_dc(IDirectDrawSurfaceImpl* This,HDC hDC);
HRESULT DIB_DirectDrawSurface_alloc_dc(IDirectDrawSurfaceImpl* This,HDC* phDC);
HRESULT DIB_DirectDrawSurface_free_dc(IDirectDrawSurfaceImpl* This, HDC hDC);
HRESULT WINAPI
DIB_DirectDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT prcDest,
LPDIRECTDRAWSURFACE7 pSrcSurf, LPRECT prcSrc,
DWORD dwFlags, LPDDBLTFX pBltFx);
HRESULT WINAPI
DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dwX,
DWORD dwY, LPDIRECTDRAWSURFACE7 pSrcSurf,
LPRECT prcSrc, DWORD dwTrans);
HRESULT WINAPI
DIB_DirectDrawSurface_Restore(LPDIRECTDRAWSURFACE7 iface);
HRESULT WINAPI
DIB_DirectDrawSurface_SetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface,
LPDDSURFACEDESC2 pDDSD, DWORD dwFlags);
#endif
/* DIB Section Texture DirectDrawSurface Driver
*
* Copyright 2000 TransGaming Technologies Inc.
*/
#include "config.h"
#include "winerror.h"
#include <assert.h>
#include <stdlib.h>
#include "debugtools.h"
#include "ddraw_private.h"
#include "dsurface/main.h"
#include "dsurface/dib.h"
#include "dsurface/dibtexture.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
static ICOM_VTABLE(IDirectDrawSurface7) DIBTexture_IDirectDrawSurface7_VTable;
HRESULT
DIBTexture_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
IDirectDrawImpl* pDD,
const DDSURFACEDESC2* pDDSD)
{
HRESULT hr;
hr = DIB_DirectDrawSurface_Construct(This, pDD, pDDSD);
if (FAILED(hr)) return hr;
ICOM_INIT_INTERFACE(This, IDirectDrawSurface7,
DIBTexture_IDirectDrawSurface7_VTable);
This->final_release = DIBTexture_DirectDrawSurface_final_release;
This->duplicate_surface = DIBTexture_DirectDrawSurface_duplicate_surface;
return S_OK;
}
HRESULT
DIBTexture_DirectDrawSurface_Create(IDirectDrawImpl *pDD,
const DDSURFACEDESC2 *pDDSD,
LPDIRECTDRAWSURFACE7 *ppSurf,
IUnknown *pUnkOuter)
{
IDirectDrawSurfaceImpl* This;
HRESULT hr;
assert(pUnkOuter == NULL);
assert(pDDSD->ddsCaps.dwCaps & DDSCAPS_TEXTURE);
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*This) + sizeof(DIBTexture_DirectDrawSurfaceImpl));
if (This == NULL) return E_OUTOFMEMORY;
This->private = (DIBTexture_DirectDrawSurfaceImpl*)(This+1);
hr = DIBTexture_DirectDrawSurface_Construct(This, pDD, pDDSD);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
else
*ppSurf = ICOM_INTERFACE(This, IDirectDrawSurface7);
return hr;
}
void DIBTexture_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This)
{
DIB_DirectDrawSurface_final_release(This);
}
HRESULT
DIBTexture_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
LPDIRECTDRAWSURFACE7* ppDup)
{
return DIBTexture_DirectDrawSurface_Create(This->ddraw_owner,
&This->surface_desc, ppDup,
NULL);
}
static ICOM_VTABLE(IDirectDrawSurface7) DIBTexture_IDirectDrawSurface7_VTable =
{
Main_DirectDrawSurface_QueryInterface,
Main_DirectDrawSurface_AddRef,
Main_DirectDrawSurface_Release,
Main_DirectDrawSurface_AddAttachedSurface,
Main_DirectDrawSurface_AddOverlayDirtyRect,
DIB_DirectDrawSurface_Blt,
Main_DirectDrawSurface_BltBatch,
DIB_DirectDrawSurface_BltFast,
Main_DirectDrawSurface_DeleteAttachedSurface,
Main_DirectDrawSurface_EnumAttachedSurfaces,
Main_DirectDrawSurface_EnumOverlayZOrders,
Main_DirectDrawSurface_Flip,
Main_DirectDrawSurface_GetAttachedSurface,
Main_DirectDrawSurface_GetBltStatus,
Main_DirectDrawSurface_GetCaps,
Main_DirectDrawSurface_GetClipper,
Main_DirectDrawSurface_GetColorKey,
Main_DirectDrawSurface_GetDC,
Main_DirectDrawSurface_GetFlipStatus,
Main_DirectDrawSurface_GetOverlayPosition,
Main_DirectDrawSurface_GetPalette,
Main_DirectDrawSurface_GetPixelFormat,
Main_DirectDrawSurface_GetSurfaceDesc,
Main_DirectDrawSurface_Initialize,
Main_DirectDrawSurface_IsLost,
Main_DirectDrawSurface_Lock,
Main_DirectDrawSurface_ReleaseDC,
DIB_DirectDrawSurface_Restore,
Main_DirectDrawSurface_SetClipper,
Main_DirectDrawSurface_SetColorKey,
Main_DirectDrawSurface_SetOverlayPosition,
Main_DirectDrawSurface_SetPalette,
Main_DirectDrawSurface_Unlock,
Main_DirectDrawSurface_UpdateOverlay,
Main_DirectDrawSurface_UpdateOverlayDisplay,
Main_DirectDrawSurface_UpdateOverlayZOrder,
Main_DirectDrawSurface_GetDDInterface,
Main_DirectDrawSurface_PageLock,
Main_DirectDrawSurface_PageUnlock,
DIB_DirectDrawSurface_SetSurfaceDesc,
Main_DirectDrawSurface_SetPrivateData,
Main_DirectDrawSurface_GetPrivateData,
Main_DirectDrawSurface_FreePrivateData,
Main_DirectDrawSurface_GetUniquenessValue,
Main_DirectDrawSurface_ChangeUniquenessValue,
Main_DirectDrawSurface_SetPriority,
Main_DirectDrawSurface_GetPriority,
Main_DirectDrawSurface_SetLOD,
Main_DirectDrawSurface_GetLOD
};
/* Copyright 2000 TransGaming Technologies Inc. */
#ifndef DDRAW_DSURFACE_DIBTEXTURE_H_INCLUDED
#define DDRAW_DSURFACE_DIBTEXTURE_H_INCLUDED
#define DIBTEXTURE_PRIV(surf) \
((DIBTexture_DirectDrawSurfaceImpl*)(surf->private))
#define DIBTEXTURE_PRIV_VAR(name,surf) \
DIBTexture_DirectDrawSurfaceImpl* name = DIBTEXTURE_PRIV(surf)
/* We add a spot for 3D drivers to store some private data. A cleaner
* solution would be to use SetPrivateData, but it's much too slow. */
union DIBTexture_data
{
int i;
void* p;
};
struct DIBTexture_DirectDrawSurfaceImpl_Part
{
union DIBTexture_data data;
};
typedef struct
{
struct DIB_DirectDrawSurfaceImpl_Part dib;
struct DIBTexture_DirectDrawSurfaceImpl_Part dibtexture;
} DIBTexture_DirectDrawSurfaceImpl;
HRESULT
DIBTexture_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
IDirectDrawImpl* pDD,
const DDSURFACEDESC2* pDDSD);
HRESULT
DIBTexture_DirectDrawSurface_Create(IDirectDrawImpl *pDD,
const DDSURFACEDESC2 *pDDSD,
LPDIRECTDRAWSURFACE7 *ppSurf,
IUnknown *pUnkOuter);
void DIBTexture_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This);
HRESULT
DIBTexture_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
LPDIRECTDRAWSURFACE7* ppDup);
#endif
/* DirectDraw/Direct3D Z-Buffer stand in
*
* Copyright 2000 TransGaming Technologies Inc.
*
* This class provides a DirectDrawSurface implementation that represents
* a Z-Buffer surface. However it does not store an image and does not
* support Lock/Unlock or GetDC. It is merely a placeholder required by the
* Direct3D architecture.
*/
#include "config.h"
#include <stdlib.h>
#include <assert.h>
#include <ddraw.h>
#include <d3d.h>
#include "debugtools.h"
#include "ddcomimpl.h"
#include "ddraw_private.h"
#include "dsurface/main.h"
#include "dsurface/fakezbuffer.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
static ICOM_VTABLE(IDirectDrawSurface7) FakeZBuffer_IDirectDrawSurface7_VTable;
HRESULT FakeZBuffer_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This,
IDirectDrawImpl *pDD,
const DDSURFACEDESC2 *pDDSD)
{
HRESULT hr;
assert(pDDSD->ddsCaps.dwCaps & DDSCAPS_ZBUFFER);
hr = Main_DirectDrawSurface_Construct(This, pDD, pDDSD);
if (FAILED(hr)) return hr;
ICOM_INIT_INTERFACE(This, IDirectDrawSurface7,
FakeZBuffer_IDirectDrawSurface7_VTable);
This->final_release = FakeZBuffer_DirectDrawSurface_final_release;
This->duplicate_surface = FakeZBuffer_DirectDrawSurface_duplicate_surface;
return DD_OK;
}
/* Not an API */
HRESULT FakeZBuffer_DirectDrawSurface_Create(IDirectDrawImpl* pDD,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter)
{
IDirectDrawSurfaceImpl* This;
HRESULT hr;
assert(pUnkOuter == NULL);
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*This)
+ sizeof(FakeZBuffer_DirectDrawSurfaceImpl));
if (This == NULL) return E_OUTOFMEMORY;
This->private = (FakeZBuffer_DirectDrawSurfaceImpl*)(This+1);
hr = FakeZBuffer_DirectDrawSurface_Construct(This, pDD, pDDSD);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
else
*ppSurf = ICOM_INTERFACE(This, IDirectDrawSurface7);
return hr;
}
void
FakeZBuffer_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This)
{
return Main_DirectDrawSurface_final_release(This);
}
HRESULT
FakeZBuffer_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
LPDIRECTDRAWSURFACE7* ppDup)
{
return FakeZBuffer_DirectDrawSurface_Create(This->ddraw_owner,
&This->surface_desc, ppDup,
NULL);
}
/* put your breakpoint/abort call here */
static HRESULT cant_do_that(const char *s)
{
FIXME("attempt to %s fake z-buffer\n", s);
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
FakeZBuffer_DirectDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rdst,
LPDIRECTDRAWSURFACE7 src, LPRECT rsrc,
DWORD dwFlags, LPDDBLTFX lpbltfx)
{
return cant_do_that("blt to a");
}
HRESULT WINAPI
FakeZBuffer_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx,
DWORD dsty, LPDIRECTDRAWSURFACE7 src,
LPRECT rsrc, DWORD trans)
{
return cant_do_that("bltfast to a");
}
HRESULT WINAPI
FakeZBuffer_DirectDrawSurface_GetDC(LPDIRECTDRAWSURFACE7 iface, HDC *phDC)
{
return cant_do_that("get a DC for a");
}
HRESULT WINAPI
FakeZBuffer_DirectDrawSurface_ReleaseDC(LPDIRECTDRAWSURFACE7 iface, HDC hDC)
{
return cant_do_that("release a DC for a");
}
HRESULT WINAPI
FakeZBuffer_DirectDrawSurface_Restore(LPDIRECTDRAWSURFACE7 iface)
{
return DD_OK;
}
HRESULT WINAPI
FakeZBuffer_DirectDrawSurface_SetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface,
LPDDSURFACEDESC2 pDDSD,
DWORD dwFlags)
{
/* XXX */
abort();
return E_FAIL;
}
static ICOM_VTABLE(IDirectDrawSurface7) FakeZBuffer_IDirectDrawSurface7_VTable=
{
Main_DirectDrawSurface_QueryInterface,
Main_DirectDrawSurface_AddRef,
Main_DirectDrawSurface_Release,
Main_DirectDrawSurface_AddAttachedSurface,
Main_DirectDrawSurface_AddOverlayDirtyRect,
FakeZBuffer_DirectDrawSurface_Blt,
Main_DirectDrawSurface_BltBatch,
FakeZBuffer_DirectDrawSurface_BltFast,
Main_DirectDrawSurface_DeleteAttachedSurface,
Main_DirectDrawSurface_EnumAttachedSurfaces,
Main_DirectDrawSurface_EnumOverlayZOrders,
Main_DirectDrawSurface_Flip,
Main_DirectDrawSurface_GetAttachedSurface,
Main_DirectDrawSurface_GetBltStatus,
Main_DirectDrawSurface_GetCaps,
Main_DirectDrawSurface_GetClipper,
Main_DirectDrawSurface_GetColorKey,
FakeZBuffer_DirectDrawSurface_GetDC,
Main_DirectDrawSurface_GetFlipStatus,
Main_DirectDrawSurface_GetOverlayPosition,
Main_DirectDrawSurface_GetPalette,
Main_DirectDrawSurface_GetPixelFormat,
Main_DirectDrawSurface_GetSurfaceDesc,
Main_DirectDrawSurface_Initialize,
Main_DirectDrawSurface_IsLost,
Main_DirectDrawSurface_Lock,
FakeZBuffer_DirectDrawSurface_ReleaseDC,
FakeZBuffer_DirectDrawSurface_Restore,
Main_DirectDrawSurface_SetClipper,
Main_DirectDrawSurface_SetColorKey,
Main_DirectDrawSurface_SetOverlayPosition,
Main_DirectDrawSurface_SetPalette,
Main_DirectDrawSurface_Unlock,
Main_DirectDrawSurface_UpdateOverlay,
Main_DirectDrawSurface_UpdateOverlayDisplay,
Main_DirectDrawSurface_UpdateOverlayZOrder,
Main_DirectDrawSurface_GetDDInterface,
Main_DirectDrawSurface_PageLock,
Main_DirectDrawSurface_PageUnlock,
FakeZBuffer_DirectDrawSurface_SetSurfaceDesc,
Main_DirectDrawSurface_SetPrivateData,
Main_DirectDrawSurface_GetPrivateData,
Main_DirectDrawSurface_FreePrivateData,
Main_DirectDrawSurface_GetUniquenessValue,
Main_DirectDrawSurface_ChangeUniquenessValue,
Main_DirectDrawSurface_SetPriority,
Main_DirectDrawSurface_GetPriority,
Main_DirectDrawSurface_SetLOD,
Main_DirectDrawSurface_GetLOD
};
/* Copyright 200 TransGaming Technologies Inc. */
#ifndef DDRAW_DSURFACE_FAKEZBUFFER_H_INCLUDED
#define DDRAW_DSURFACE_FAKEZBUFFER_H_INCLUDED
struct FakeZBuffer_DirectDrawSurfaceImpl_Part
{
};
typedef struct
{
struct FakeZBuffer_DirectDrawSurfaceImpl_Part fakezbuffer;
} FakeZBuffer_DirectDrawSurfaceImpl;
HRESULT
FakeZBuffer_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
IDirectDrawImpl* pDD,
const DDSURFACEDESC2* pDDSD);
HRESULT FakeZBuffer_DirectDrawSurface_Create(IDirectDrawImpl* pDD,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter);
void
FakeZBuffer_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This);
HRESULT
FakeZBuffer_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
LPDIRECTDRAWSURFACE7* ppDup);
#endif
/* Copyright 2000 TransGaming Technologies Inc. */
#ifndef DDRAW_DSURFACE_MAIN_H_INCLUDED
#define DDRAW_DSURFACE_MAIN_H_INCLUDED
#include "ddraw_private.h"
/* Support for IDirectDrawSurface7::Set/Get/FreePrivateData. I don't think
* anybody uses it for much so a good implementation is optional. */
typedef struct PrivateData
{
struct PrivateData* next;
struct PrivateData* prev;
GUID tag;
DWORD flags; /* DDSPD_* */
DWORD uniqueness_value;
union
{
LPVOID data;
LPUNKNOWN object;
} ptr;
DWORD size;
} PrivateData;
/* Non-interface functions */
HRESULT
Main_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
IDirectDrawImpl* pDD,
const DDSURFACEDESC2* pDDSD);
void Main_DirectDrawSurface_ForceDestroy(IDirectDrawSurfaceImpl* This);
void
Main_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This);
BOOL
Main_DirectDrawSurface_attach(IDirectDrawSurfaceImpl *This,
IDirectDrawSurfaceImpl *to);
BOOL Main_DirectDrawSurface_detach(IDirectDrawSurfaceImpl *This);
void
Main_DirectDrawSurface_lock_update(IDirectDrawSurfaceImpl* This,
LPCRECT pRect);
void
Main_DirectDrawSurface_unlock_update(IDirectDrawSurfaceImpl* This,
LPCRECT pRect);
void
Main_DirectDrawSurface_lose_surface(IDirectDrawSurfaceImpl* This);
void
Main_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
IDirectDrawPaletteImpl* pal);
void
Main_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This,
IDirectDrawPaletteImpl* pal,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent);
HWND
Main_DirectDrawSurface_get_display_window(IDirectDrawSurfaceImpl* This);
void Main_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
IDirectDrawSurfaceImpl* back);
#define CHECK_LOST(This) \
do { \
if (This->lost) return DDERR_SURFACELOST; \
} while (0)
#define CHECK_TEXTURE(This) \
do { \
if (!(This->surface_desc.ddsCaps.dwCaps2 \
& DDSCAPS2_TEXTUREMANAGE)) \
return DDERR_INVALIDOBJECT; \
} while (0)
#define LOCK_OBJECT(This) do { } while (0)
#define UNLOCK_OBJECT(This) do { } while (0)
/* IDirectDrawSurface7 (partial) implementation */
ULONG WINAPI
Main_DirectDrawSurface_AddRef(LPDIRECTDRAWSURFACE7 iface);
ULONG WINAPI
Main_DirectDrawSurface_Release(LPDIRECTDRAWSURFACE7 iface);
HRESULT WINAPI
Main_DirectDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid,
LPVOID* ppObj);
HRESULT WINAPI
Main_DirectDrawSurface_AddAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
LPDIRECTDRAWSURFACE7 pAttach);
HRESULT WINAPI
Main_DirectDrawSurface_AddOverlayDirtyRect(LPDIRECTDRAWSURFACE7 iface,
LPRECT pRect);
HRESULT WINAPI
Main_DirectDrawSurface_BltBatch(LPDIRECTDRAWSURFACE7 iface,
LPDDBLTBATCH pBatch, DWORD dwCount,
DWORD dwFlags);
HRESULT WINAPI
Main_DirectDrawSurface_ChangeUniquenessValue(LPDIRECTDRAWSURFACE7 iface);
HRESULT WINAPI
Main_DirectDrawSurface_DeleteAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags,
LPDIRECTDRAWSURFACE7 pAttach);
HRESULT WINAPI
Main_DirectDrawSurface_EnumAttachedSurfaces(LPDIRECTDRAWSURFACE7 iface,
LPVOID context,
LPDDENUMSURFACESCALLBACK7 cb);
HRESULT WINAPI
Main_DirectDrawSurface_EnumOverlayZOrders(LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags, LPVOID context,
LPDDENUMSURFACESCALLBACK7 cb);
HRESULT WINAPI
Main_DirectDrawSurface_Flip(LPDIRECTDRAWSURFACE7 iface,
LPDIRECTDRAWSURFACE7 override, DWORD dwFlags);
HRESULT WINAPI
Main_DirectDrawSurface_FreePrivateData(LPDIRECTDRAWSURFACE7 iface,
REFGUID tag);
HRESULT WINAPI
Main_DirectDrawSurface_GetAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
LPDDSCAPS2 pCaps,
LPDIRECTDRAWSURFACE7* ppSurface);
HRESULT WINAPI
Main_DirectDrawSurface_GetBltStatus(LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags);
HRESULT WINAPI
Main_DirectDrawSurface_GetCaps(LPDIRECTDRAWSURFACE7 iface,
LPDDSCAPS2 pCaps);
HRESULT WINAPI
Main_DirectDrawSurface_GetClipper(LPDIRECTDRAWSURFACE7 iface,
LPDIRECTDRAWCLIPPER* ppClipper);
HRESULT WINAPI
Main_DirectDrawSurface_GetColorKey(LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags, LPDDCOLORKEY pCKey);
HRESULT WINAPI
Main_DirectDrawSurface_GetDC(LPDIRECTDRAWSURFACE7 iface, HDC *phDC);
HRESULT WINAPI
Main_DirectDrawSurface_GetDDInterface(LPDIRECTDRAWSURFACE7 iface,
LPVOID* pDD);
HRESULT WINAPI
Main_DirectDrawSurface_GetFlipStatus(LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags);
HRESULT WINAPI
Main_DirectDrawSurface_GetLOD(LPDIRECTDRAWSURFACE7 iface,
LPDWORD pdwMaxLOD);
HRESULT WINAPI
Main_DirectDrawSurface_GetOverlayPosition(LPDIRECTDRAWSURFACE7 iface,
LPLONG pX, LPLONG pY);
HRESULT WINAPI
Main_DirectDrawSurface_GetPalette(LPDIRECTDRAWSURFACE7 iface,
LPDIRECTDRAWPALETTE* ppPalette);
HRESULT WINAPI
Main_DirectDrawSurface_GetPixelFormat(LPDIRECTDRAWSURFACE7 iface,
LPDDPIXELFORMAT pDDPixelFormat);
HRESULT WINAPI
Main_DirectDrawSurface_GetPriority(LPDIRECTDRAWSURFACE7 iface,
LPDWORD pdwPriority);
HRESULT WINAPI
Main_DirectDrawSurface_GetPrivateData(LPDIRECTDRAWSURFACE7 iface, REFGUID tag,
LPVOID pBuffer, LPDWORD pcbBufferSize);
HRESULT WINAPI
Main_DirectDrawSurface_GetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface,
LPDDSURFACEDESC2 pDDSD);
HRESULT WINAPI
Main_DirectDrawSurface_GetUniquenessValue(LPDIRECTDRAWSURFACE7 iface,
LPDWORD pValue);
HRESULT WINAPI
Main_DirectDrawSurface_Initialize(LPDIRECTDRAWSURFACE7 iface,
LPDIRECTDRAW pDD, LPDDSURFACEDESC2 pDDSD);
HRESULT WINAPI
Main_DirectDrawSurface_IsLost(LPDIRECTDRAWSURFACE7 iface);
HRESULT WINAPI
Main_DirectDrawSurface_Lock(LPDIRECTDRAWSURFACE7 iface, LPRECT prect,
LPDDSURFACEDESC2 pDDSD, DWORD flags, HANDLE h);
HRESULT WINAPI
Main_DirectDrawSurface_PageLock(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags);
HRESULT WINAPI
Main_DirectDrawSurface_PageUnlock(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags);
HRESULT WINAPI
Main_DirectDrawSurface_ReleaseDC(LPDIRECTDRAWSURFACE7 iface, HDC hDC);
HRESULT WINAPI
Main_DirectDrawSurface_SetClipper(LPDIRECTDRAWSURFACE7 iface,
LPDIRECTDRAWCLIPPER pDDClipper);
HRESULT WINAPI
Main_DirectDrawSurface_SetColorKey(LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags, LPDDCOLORKEY pCKey);
HRESULT WINAPI
Main_DirectDrawSurface_SetLOD(LPDIRECTDRAWSURFACE7 iface, DWORD dwMaxLOD);
HRESULT WINAPI
Main_DirectDrawSurface_SetOverlayPosition(LPDIRECTDRAWSURFACE7 iface,
LONG X, LONG Y);
HRESULT WINAPI
Main_DirectDrawSurface_SetPalette(LPDIRECTDRAWSURFACE7 iface,
LPDIRECTDRAWPALETTE pPalette);
HRESULT WINAPI
Main_DirectDrawSurface_SetPriority(LPDIRECTDRAWSURFACE7 iface,
DWORD dwPriority);
HRESULT WINAPI
Main_DirectDrawSurface_SetPrivateData(LPDIRECTDRAWSURFACE7 iface,
REFGUID tag, LPVOID pData,
DWORD cbSize, DWORD dwFlags);
HRESULT WINAPI
Main_DirectDrawSurface_Unlock(LPDIRECTDRAWSURFACE7 iface, LPRECT pRect);
HRESULT WINAPI
Main_DirectDrawSurface_UpdateOverlay(LPDIRECTDRAWSURFACE7 iface,
LPRECT pSrcRect,
LPDIRECTDRAWSURFACE7 pDstSurface,
LPRECT pDstRect, DWORD dwFlags,
LPDDOVERLAYFX pFX);
HRESULT WINAPI
Main_DirectDrawSurface_UpdateOverlayDisplay(LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags);
HRESULT WINAPI
Main_DirectDrawSurface_UpdateOverlayZOrder(LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags,
LPDIRECTDRAWSURFACE7 pDDSRef);
#endif
/* Copyright 2000 TransGaming Technologies Inc. */
#ifndef DDRAW_DSURFACE_THUNKS_H_INCLUDED
#define DDRAW_DSURFACE_THUNKS_H_INCLUDED
extern ICOM_VTABLE(IDirectDrawSurface3) DDRAW_IDDS3_Thunk_VTable;
#endif
/* Copyright 2000 TransGaming Technologies Inc. */
#ifndef DDRAW_DSURFACE_USER_H_INCLUDED
#define DDRAW_DSURFACE_USER_H_INCLUDED
#define USER_PRIV(surf) ((User_DirectDrawSurfaceImpl*)((surf)->private))
#define USER_PRIV_VAR(name,surf) \
User_DirectDrawSurfaceImpl* name = USER_PRIV(surf)
struct User_DirectDrawSurfaceImpl_Part
{
HWND window;
HDC cached_dc;
HANDLE update_thread, update_event;
};
typedef struct
{
struct DIB_DirectDrawSurfaceImpl_Part dib;
struct User_DirectDrawSurfaceImpl_Part user;
} User_DirectDrawSurfaceImpl;
HRESULT
User_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
IDirectDrawImpl* pDD,
const DDSURFACEDESC2* pDDSD);
HRESULT
User_DirectDrawSurface_Create(IDirectDrawImpl *pDD,
const DDSURFACEDESC2 *pDDSD,
LPDIRECTDRAWSURFACE7 *ppSurf,
IUnknown *pUnkOuter);
void User_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This);
void User_DirectDrawSurface_lock_update(IDirectDrawSurfaceImpl* This,
LPCRECT pRect);
void User_DirectDrawSurface_unlock_update(IDirectDrawSurfaceImpl* This,
LPCRECT pRect);
void User_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
IDirectDrawPaletteImpl* pal);
void User_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This,
IDirectDrawPaletteImpl* pal,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent);
HRESULT User_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
LPDIRECTDRAWSURFACE7* ppDup);
void User_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
IDirectDrawSurfaceImpl* back);
void User_DirectDrawSurface_flip_update(IDirectDrawSurfaceImpl* This);
HWND User_DirectDrawSurface_get_display_window(IDirectDrawSurfaceImpl* This);
HRESULT User_DirectDrawSurface_get_dc(IDirectDrawSurfaceImpl* This, HDC* phDC);
HRESULT User_DirectDrawSurface_release_dc(IDirectDrawSurfaceImpl* This,
HDC hDC);
#endif
/* User-based primary surface driver
*
* Copyright 2000 TransGaming Technologies Inc.
*/
#include "config.h"
#include "winerror.h"
#include <assert.h>
#include <stdlib.h>
#include "debugtools.h"
#include "ddraw_private.h"
DEFAULT_DEBUG_CHANNEL(ddraw);
static LRESULT WINAPI DirectDrawSurface_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void DirectDrawSurface_RegisterClass(void)
{
WNDCLASSA wc;
memset(&wc, 0, sizeof(wc));
wc.lpfnWndProc = DirectDrawSurface_WndProc;
wc.cbWndExtra = sizeof(IDirectDrawSurfaceImpl*);
wc.hCursor = (HCURSOR)IDC_ARROWA;
wc.lpszClassName = "WINE_DDRAW";
RegisterClassA(&wc);
}
void DirectDrawSurface_UnregisterClass(void)
{
UnregisterClassA("WINE_DDRAW", 0);
}
static LRESULT WINAPI DirectDrawSurface_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
IDirectDrawSurfaceImpl *This;
LRESULT ret;
This = (IDirectDrawSurfaceImpl *)GetWindowLongA(hwnd, 0);
if (This) {
HWND window = This->ddraw_owner->window;
switch (msg) {
case WM_DESTROY:
case WM_NCDESTROY:
case WM_SHOWWINDOW:
case WM_WINDOWPOSCHANGING:
case WM_WINDOWPOSCHANGED:
case WM_SIZE:
case WM_MOVE:
case WM_ERASEBKGND:
/* since we're pretending fullscreen,
* let's not pass these on to the app */
ret = DefWindowProcA(hwnd, msg, wParam, lParam);
break;
case WM_NCHITTEST:
ret = HTCLIENT;
break;
case WM_MOUSEACTIVATE:
ret = MA_NOACTIVATE;
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC dc = BeginPaint(hwnd, &ps);
/* call User_copy_to_screen? */
EndPaint(hwnd, &ps);
ret = 0;
}
break;
default:
ret = window ? SendMessageA(window, msg, wParam, lParam)
: DefWindowProcA(hwnd, msg, wParam, lParam);
}
} else {
if (msg == WM_CREATE) {
CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
This = (IDirectDrawSurfaceImpl *)cs->lpCreateParams;
SetWindowLongA(hwnd, 0, (LONG)This);
}
ret = DefWindowProcA(hwnd, msg, wParam, lParam);
}
return ret;
}
/* Copyright 2000 TransGaming Technologies Inc. */
#ifndef DDRAW_DSURFACE_WNDPROC_H_INCLUDED
#define DDRAW_DSURFACE_WNDPROC_H_INCLUDED
void DirectDrawSurface_RegisterClass(void);
void DirectDrawSurface_UnregisterClass(void);
#endif
......@@ -14,8 +14,6 @@
#undef USE_OSMESA
#include "x11_private.h"
/*****************************************************************************
* IDirect3DLight MESA private structure
*/
......@@ -110,8 +108,8 @@ 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 LPDIRECT3DTEXTURE2 d3dtexture2_create(IDirectDrawSurfaceImpl* surf);
extern LPDIRECT3DTEXTURE d3dtexture_create(IDirectDrawSurfaceImpl* surf);
extern LPDIRECT3DLIGHT d3dlight_create_dx3(IDirect3DImpl* d3d1);
extern LPDIRECT3DLIGHT d3dlight_create(IDirect3D2Impl* d3d2);
......@@ -129,8 +127,8 @@ 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*);
extern LPDIRECT3DTEXTURE2 mesa_d3dtexture2_create(IDirectDrawSurfaceImpl*);
extern LPDIRECT3DTEXTURE mesa_d3dtexture_create(IDirectDrawSurfaceImpl*);
static const GUID WINE_UNUSED IID_D3DDEVICE2_OpenGL = {
0x39a0da38,
......
/* ddraw/d3d structure version conversion
*
* Copyright 2000 TransGaming Technologies Inc.
*/
#include <ddraw.h>
#include <string.h>
#include "ddraw_private.h"
void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut)
{
/* 2 adds three additional caps fields to the end. Both versions
* are unversioned. */
pOut->dwCaps = pIn->dwCaps;
pOut->dwCaps2 = 0;
pOut->dwCaps3 = 0;
pOut->dwCaps4 = 0;
}
void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER* pIn,
DDDEVICEIDENTIFIER2* pOut)
{
/* 2 adds a dwWHQLLevel field to the end. Both structures are
* unversioned. */
memcpy(pOut, pIn, sizeof(*pOut));
}
/* 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 "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;
}
#ifdef HAVE_XVIDEO
static BOOL
DDRAW_XVIDEO_Available(x11_dd_private *x11ddp) {
unsigned int p_version, p_release, p_request_base, p_event_base, p_error_base;
if (TSXvQueryExtension(display, &p_version, &p_release, &p_request_base,
&p_event_base, &p_error_base) == Success) {
XvAdaptorInfo *ai;
int num_adaptators, i, default_port;
if ((p_version < 2) || ((p_version == 2) && (p_release < 2))) {
TRACE("XVideo extension does NOT support needed features (need version 2.2) !\n");
return FALSE;
}
if (TSXvQueryAdaptors(display, X11DRV_GetXRootWindow(), &num_adaptators, &ai) != Success) {
TRACE("Failed to get list of adaptators.\n");
return FALSE;
}
if (num_adaptators == 0) {
TRACE("No XVideo supporting adaptators found.\n");
return FALSE;
}
default_port = PROFILE_GetWineIniInt("x11drv", "XVideoPort", -1);
for (i = 0; i < num_adaptators; i++) {
if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) {
/* This supports everything I want : XvImages and the possibility to put something */
if (default_port == -1) {
default_port = ai[i].base_id;
break;
} else {
if ((ai[i].base_id <= default_port) &&
((ai[i].base_id + ai[i].num_ports) > default_port)) {
break;
}
}
}
}
if (i == num_adaptators) {
if (default_port != -1) {
ERR("User specified port (%d) not found.\n", default_port);
} else {
TRACE("No input + image capable device found.\n");
}
TSXvFreeAdaptorInfo(ai);
return FALSE;
}
x11ddp->port_id = default_port;
TRACE("XVideo support available (using version %d.%d)\n", p_version, p_release);
TSXvFreeAdaptorInfo(ai);
return TRUE;
}
return FALSE;
}
#endif
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->d = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*(ddraw->d)));
ddraw->d->ref = 1;
ddraw->d->private = HeapAlloc(
GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(x11_dd_private)
);
x11priv = (x11_dd_private*)ddraw->d->private;
/* At DirectDraw creation, the depth is the default depth */
depth = DefaultDepthOfScreen(X11DRV_GetXScreen());
switch (_common_depth_to_pixelformat(depth,(LPDIRECTDRAW)ddraw)) {
case -2: ERR("no depth conversion mode for depth %d found\n",depth); break;
case -1: WARN("No conversion needed for depth %d.\n",depth); break;
case 0: MESSAGE("Conversion needed from %d.\n",depth); break;
}
ddraw->d->height = GetSystemMetrics(SM_CYSCREEN);
ddraw->d->width = GetSystemMetrics(SM_CXSCREEN);
#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
#ifdef HAVE_XVIDEO
/* Test if XVideo support is available */
if ((x11priv->xvideo_active = DDRAW_XVIDEO_Available(x11priv))) {
TRACE("Using XVideo extension on port '%ld'.\n", x11priv->port_id);
}
#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
};
DECL_GLOBAL_CONSTRUCTOR(X11_register) { 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 "config.h"
#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) */
#ifdef HAVE_LIBXXF86VM
# include "ts_xf86vmode.h"
extern XF86VidModeModeInfo *orig_mode;
#endif /* defined(HAVE_LIBXXF86VM) */
extern void xf86vmode_setdisplaymode(DWORD,DWORD);
extern void xf86vmode_restore();
#ifdef HAVE_XVIDEO
#include "ts_xvideo.h"
#else
/* Fake type so that NOT to have too many #ifdef XVideo lying around */
typedef int XvImage;
#endif
#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(IDirectDraw7) xlib_dd7vt;
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) */
#ifdef HAVE_XVIDEO
BOOL xvideo_active;
XvPortID port_id;
#endif
Window drawable;
void *device_capabilities;
} 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 {
BOOL is_overlay;
union {
XImage *image;
struct {
/* The 'image' field should be in FIRST !!!! The Flip function depends on that... */
XvImage *image;
BOOL shown;
RECT src_rect;
RECT dst_rect;
LPDIRECTDRAWSURFACE dest_surface;
} overlay;
} info;
#ifdef HAVE_LIBXXSHM
XShmSegmentInfo shminfo;
#endif
int *oldDIBmap;
BOOL opengl_flip;
} x11_ds_private;
#ifdef HAVE_LIBXXSHM
extern int XShmErrorFlag;
#endif
#endif /* __WINE_DDRAW_X11_PRIVATE_H */
This is an outline of the architecture. Many details are
skipped, but hopefully this is useful.
By Andrew Lewycky <andrew@transgaming.com>
(with updates by Ove Kåven <ovek@transgaming.com>)
* DirectDraw inheritance tree
Main
|
User
|-----------\
XVidMode DGA2
Most of the DirectDraw functionality is implemented in a common base
class. Derived classes are responsible for providing display
mode functions (Enum, Set, Restore), GetCaps, GetDevice identifier
and internal functions called to create primary and backbuffer
surfaces.
User provides for DirectDraw capabilities based on drawing to a
Wine window. It uses the User DirectDrawSurface implementation
for primary and backbuffer surfaces.
XVidMode attempt to use the XFree86 VidMode extension to set the
display resolution to match the parameters to SetDisplayMode.
DGA2 attempt to use the XFree86 DGA 2.x extension to set the
display resolution and direct access to the framebuffer, if the
full-screen-exclusive cooperative level is used. If not, it just
uses the User implementation.
* DirectDrawSurface inheritance tree
Main
|--------------\
| |
DIB Fake Z-Buffer
|
|------\---------\
| | |
User DGA2 DIBTexture
Main provides a very simple base class that does not implement any of
the image-related functions. Therefore it does not place any
constraints on how the surface data is stored.
DIB stores the surface data in a DIB section. It is used by the Main
DirectDraw driver to create off-screen surfaces.
User implements primary and backbuffer surfaces for the User DirectDraw
driver. If it is a primary surface, it will attempt to keep itself
synchronized to the window.
DGA2 surfaces claims an appropriate section of framebuffer space and
lets DIB build its DIB section on top of it.
Fake Z-Buffer surfaces are used by Direct3D to indicate that a primary
surface has an associated z-buffer. For a first implementation, it
doesn't need to store any image data since it is just a placeholder.
(Actually 3D programs will rarely use Lock or GetDC on primary
surfaces, backbuffers or z-buffers so we may want to arrange for
lazy allocation of the DIB sections.)
* Interface Thunks
Only the most recent version of an interface needs to be implemented.
Other versions are handled by having thunks convert their parameters
and call the root version.
Not all interface versions have thunks. Some versions could be combined
because their parameters were compatible. For example if a structure
changes but the structure has a dwSize field, methods using that structure
are compatible, as long as the implementation remembers to take the dwSize
into account.
Interface thunks for Direct3D are more complicated since the paradigm
changed between versions.
* Logical Object Layout
The objects are split into the generic part (essentially the fields for
Main) and a private part. This is necessary because some objects
can be created with CoCreateInstance, then Initialized later. Only
at initialisation time do we know which class to use. Each class
except Main declares a Part structure and adds that to its Impl.
For example, the DIBTexture DirectDrawSurface implementation looks
like this:
struct DIBTexture_DirectDrawSurfaceImpl_Part
{
union DIBTexture_data data; /*declared in the real header*/
};
typedef struct
{
struct DIB_DirectDrawSurfaceImpl_Part dib;
struct DIBTexture_DirectDrawSurfaceImpl_Part dibtexture;
} DIBTexture_DirectDrawSurfaceImpl;
So the DIBTexture surface class is derived from the DIB surface
class and it adds one piece of data, a union.
Main does not have a Part structure. Its fields are stored in
IDirectDrawImpl/IDirectDrawSurfaceImpl.
To access private data, one says
DIBTexture_DirectDrawSurfaceImpl* priv = This->private;
do_something_with(priv->dibtexture.data);
* Creating Objects
Classes have two functions relevant to object creation, Create and
Construct. To create a new object, the class' Create function is
called. It allocates enough memory for IDirectDrawImpl or
IDirectDrawSurfaceImpl as well as the private data for derived
classes and then calls Construct.
Each class's Construct function calls the base class's Construct,
then does the necessary initialization.
For example, creating a primary surface with the user ddraw driver
calls User_DirectDrawSurface_Create which allocates memory for the
object and calls User_DirectDrawSurface_Construct to initialize it.
This calls DIB_DirectDrawSurface_Construct which calls
Main_DirectDrawSurface_Construct.
......@@ -129,5 +129,8 @@
/* Define if the X libraries support XVideo */
#undef HAVE_XVIDEO
/* Define if Mesa's OSMesa (off-screen rendering) library is present */
#undef HAVE_OSMESA
/* Define if Linux-style gethostbyname_r and gethostbyaddr_r are available */
#undef HAVE_LINUX_GETHOSTBYNAME_R_6
......@@ -164,6 +164,9 @@
/* Define if the X libraries support XVideo */
#undef HAVE_XVIDEO
/* Define if Mesa's OSMesa (off-screen rendering) library is present */
#undef HAVE_OSMESA
/* Define if Linux-style gethostbyname_r and gethostbyaddr_r are available */
#undef HAVE_LINUX_GETHOSTBYNAME_R_6
......@@ -290,6 +293,9 @@
/* Define if you have the <GL/glx.h> header file. */
#undef HAVE_GL_GLX_H
/* Define if you have the <GL/osmesa.h> header file. */
#undef HAVE_GL_OSMESA_H
/* Define if you have the <X11/XKBlib.h> header file. */
#undef HAVE_X11_XKBLIB_H
......
......@@ -100,7 +100,7 @@ int VGA_GetMode(unsigned*Height,unsigned*Width,unsigned*Depth)
if (!lpddsurf) return 1;
if (Height) *Height=sdesc.dwHeight;
if (Width) *Width=sdesc.dwWidth;
if (Depth) *Depth=sdesc.ddpfPixelFormat.u.dwRGBBitCount;
if (Depth) *Depth=sdesc.ddpfPixelFormat.u1.dwRGBBitCount;
return 0;
}
......@@ -147,16 +147,16 @@ LPSTR VGA_Lock(unsigned*Pitch,unsigned*Height,unsigned*Width,unsigned*Depth)
ERR("could not lock surface!\n");
return NULL;
}
if (Pitch) *Pitch=sdesc.lPitch;
if (Pitch) *Pitch=sdesc.u1.lPitch;
if (Height) *Height=sdesc.dwHeight;
if (Width) *Width=sdesc.dwWidth;
if (Depth) *Depth=sdesc.ddpfPixelFormat.u.dwRGBBitCount;
return sdesc.u1.lpSurface;
if (Depth) *Depth=sdesc.ddpfPixelFormat.u1.dwRGBBitCount;
return sdesc.lpSurface;
}
void VGA_Unlock(void)
{
IDirectDrawSurface_Unlock(lpddsurf,sdesc.u1.lpSurface);
IDirectDrawSurface_Unlock(lpddsurf,sdesc.lpSurface);
}
/*** TEXT MODE ***/
......
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