Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c87fd4a6
Commit
c87fd4a6
authored
Aug 19, 2010
by
Henri Verbeet
Committed by
Alexandre Julliard
Aug 20, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw: Add a separate function for ddraw initialization.
parent
0e955dae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
127 deletions
+88
-127
ddraw.c
dlls/ddraw/ddraw.c
+69
-10
ddraw_private.h
dlls/ddraw/ddraw_private.h
+5
-21
main.c
dlls/ddraw/main.c
+14
-96
No files found.
dlls/ddraw/ddraw.c
View file @
c87fd4a6
...
...
@@ -5246,7 +5246,7 @@ HRESULT IDirect3DImpl_GetCaps(IWineD3D *wined3d, D3DDEVICEDESC *desc1, D3DDEVICE
/*****************************************************************************
* IDirectDraw7 VTable
*****************************************************************************/
const
IDirectDraw7Vtbl
IDirectDraw7_V
tbl
=
static
const
struct
IDirectDraw7Vtbl
ddraw7_v
tbl
=
{
/* IUnknown */
ddraw7_QueryInterface
,
...
...
@@ -5286,7 +5286,7 @@ const IDirectDraw7Vtbl IDirectDraw7_Vtbl =
ddraw7_EvaluateMode
};
const
struct
IDirectDraw4Vtbl
IDirectDraw4_V
tbl
=
static
const
struct
IDirectDraw4Vtbl
ddraw4_v
tbl
=
{
/* IUnknown */
ddraw4_QueryInterface
,
...
...
@@ -5323,7 +5323,7 @@ const struct IDirectDraw4Vtbl IDirectDraw4_Vtbl =
ddraw4_GetDeviceIdentifier
,
};
const
struct
IDirectDraw3Vtbl
IDirectDraw3_V
tbl
=
static
const
struct
IDirectDraw3Vtbl
ddraw3_v
tbl
=
{
/* IUnknown */
ddraw3_QueryInterface
,
...
...
@@ -5356,7 +5356,7 @@ const struct IDirectDraw3Vtbl IDirectDraw3_Vtbl =
ddraw3_GetSurfaceFromDC
,
};
const
struct
IDirectDraw2Vtbl
IDirectDraw2_V
tbl
=
static
const
struct
IDirectDraw2Vtbl
ddraw2_v
tbl
=
{
/* IUnknown */
ddraw2_QueryInterface
,
...
...
@@ -5387,7 +5387,7 @@ const struct IDirectDraw2Vtbl IDirectDraw2_Vtbl =
ddraw2_GetAvailableVidMem
,
};
const
struct
IDirectDrawVtbl
IDirectDraw1_V
tbl
=
static
const
struct
IDirectDrawVtbl
ddraw1_v
tbl
=
{
/* IUnknown */
ddraw1_QueryInterface
,
...
...
@@ -5416,7 +5416,7 @@ const struct IDirectDrawVtbl IDirectDraw1_Vtbl =
ddraw1_WaitForVerticalBlank
,
};
const
IDirect3D7Vtbl
IDirect3D7_V
tbl
=
static
const
struct
IDirect3D7Vtbl
d3d7_v
tbl
=
{
/* IUnknown methods */
d3d7_QueryInterface
,
...
...
@@ -5430,7 +5430,7 @@ const IDirect3D7Vtbl IDirect3D7_Vtbl =
d3d7_EvictManagedTextures
};
const
IDirect3D3Vtbl
IDirect3D3_V
tbl
=
static
const
struct
IDirect3D3Vtbl
d3d3_v
tbl
=
{
/* IUnknown methods */
d3d3_QueryInterface
,
...
...
@@ -5448,7 +5448,7 @@ const IDirect3D3Vtbl IDirect3D3_Vtbl =
d3d3_EvictManagedTextures
};
const
IDirect3D2Vtbl
IDirect3D2_V
tbl
=
static
const
struct
IDirect3D2Vtbl
d3d2_v
tbl
=
{
/* IUnknown methods */
d3d2_QueryInterface
,
...
...
@@ -5463,7 +5463,7 @@ const IDirect3D2Vtbl IDirect3D2_Vtbl =
d3d2_CreateDevice
};
const
IDirect3DVtbl
IDirect3D1_V
tbl
=
static
const
struct
IDirect3DVtbl
d3d1_v
tbl
=
{
/* IUnknown methods */
d3d1_QueryInterface
,
...
...
@@ -5812,7 +5812,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
return
hr
;
}
const
IWineD3DDeviceParentVtbl
ddraw_wined3d_device_parent_vtbl
=
static
const
IWineD3DDeviceParentVtbl
ddraw_wined3d_device_parent_vtbl
=
{
/* IUnknown methods */
device_parent_QueryInterface
,
...
...
@@ -5826,3 +5826,62 @@ const IWineD3DDeviceParentVtbl ddraw_wined3d_device_parent_vtbl =
device_parent_CreateVolume
,
device_parent_CreateSwapChain
,
};
HRESULT
ddraw_init
(
IDirectDrawImpl
*
ddraw
,
WINED3DDEVTYPE
device_type
)
{
HRESULT
hr
;
HDC
hDC
;
ddraw
->
lpVtbl
=
&
ddraw7_vtbl
;
ddraw
->
IDirectDraw_vtbl
=
&
ddraw1_vtbl
;
ddraw
->
IDirectDraw2_vtbl
=
&
ddraw2_vtbl
;
ddraw
->
IDirectDraw3_vtbl
=
&
ddraw3_vtbl
;
ddraw
->
IDirectDraw4_vtbl
=
&
ddraw4_vtbl
;
ddraw
->
IDirect3D_vtbl
=
&
d3d1_vtbl
;
ddraw
->
IDirect3D2_vtbl
=
&
d3d2_vtbl
;
ddraw
->
IDirect3D3_vtbl
=
&
d3d3_vtbl
;
ddraw
->
IDirect3D7_vtbl
=
&
d3d7_vtbl
;
ddraw
->
device_parent_vtbl
=
&
ddraw_wined3d_device_parent_vtbl
;
ddraw
->
numIfaces
=
1
;
ddraw
->
ref7
=
1
;
/* See comments in IDirectDrawImpl_CreateNewSurface for a description of
* this field. */
ddraw
->
ImplType
=
DefaultSurfaceType
;
/* Get the current screen settings. */
hDC
=
GetDC
(
0
);
ddraw
->
orig_bpp
=
GetDeviceCaps
(
hDC
,
BITSPIXEL
)
*
GetDeviceCaps
(
hDC
,
PLANES
);
ReleaseDC
(
0
,
hDC
);
ddraw
->
orig_width
=
GetSystemMetrics
(
SM_CXSCREEN
);
ddraw
->
orig_height
=
GetSystemMetrics
(
SM_CYSCREEN
);
if
(
!
LoadWineD3D
())
{
ERR
(
"Failed to load wined3d - broken OpenGL setup?
\n
"
);
return
DDERR_NODIRECTDRAWSUPPORT
;
}
ddraw
->
wineD3D
=
pWineDirect3DCreate
(
7
,
(
IUnknown
*
)
ddraw
);
if
(
!
ddraw
->
wineD3D
)
{
WARN
(
"Failed to create a wined3d object.
\n
"
);
return
E_OUTOFMEMORY
;
}
hr
=
IWineD3D_CreateDevice
(
ddraw
->
wineD3D
,
WINED3DADAPTER_DEFAULT
,
device_type
,
NULL
,
0
,
(
IUnknown
*
)
ddraw
,
(
IWineD3DDeviceParent
*
)
&
ddraw
->
device_parent_vtbl
,
&
ddraw
->
wineD3DDevice
);
if
(
FAILED
(
hr
))
{
WARN
(
"Failed to create a wined3d device, hr %#x.
\n
"
,
hr
);
IWineD3D_Release
(
ddraw
->
wineD3D
);
return
hr
;
}
/* Get the amount of video memory */
ddraw
->
total_vidmem
=
IWineD3DDevice_GetAvailableTextureMem
(
ddraw
->
wineD3DDevice
);
list_init
(
&
ddraw
->
surface_list
);
return
DD_OK
;
}
dlls/ddraw/ddraw_private.h
View file @
c87fd4a6
...
...
@@ -160,13 +160,7 @@ struct IDirectDrawImpl
#define DDRAW_WINDOW_CLASS_NAME "ddraw_wc"
/* Declare the VTables. They can be found ddraw.c */
extern
const
IDirectDraw7Vtbl
IDirectDraw7_Vtbl
DECLSPEC_HIDDEN
;
extern
const
IDirectDraw4Vtbl
IDirectDraw4_Vtbl
DECLSPEC_HIDDEN
;
extern
const
IDirectDraw3Vtbl
IDirectDraw3_Vtbl
DECLSPEC_HIDDEN
;
extern
const
IDirectDraw2Vtbl
IDirectDraw2_Vtbl
DECLSPEC_HIDDEN
;
extern
const
IDirectDrawVtbl
IDirectDraw1_Vtbl
DECLSPEC_HIDDEN
;
extern
const
IWineD3DDeviceParentVtbl
ddraw_wined3d_device_parent_vtbl
DECLSPEC_HIDDEN
;
HRESULT
ddraw_init
(
IDirectDrawImpl
*
ddraw
,
WINED3DDEVTYPE
device_type
)
DECLSPEC_HIDDEN
;
/* Helper structures */
typedef
struct
EnumDisplayModesCBS
...
...
@@ -213,6 +207,10 @@ static inline IDirectDrawImpl *ddraw_from_d3d7(IDirect3D7 *iface)
/* The default surface type */
extern
WINED3DSURFTYPE
DefaultSurfaceType
DECLSPEC_HIDDEN
;
extern
typeof
(
WineDirect3DCreateClipper
)
*
pWineDirect3DCreateClipper
DECLSPEC_HIDDEN
;
extern
typeof
(
WineDirect3DCreate
)
*
pWineDirect3DCreate
DECLSPEC_HIDDEN
;
/*****************************************************************************
* IDirectDrawSurface implementation structure
*****************************************************************************/
...
...
@@ -426,18 +424,6 @@ struct EnumTextureFormatsCBS
void
*
Context
;
};
/*****************************************************************************
* IDirect3D implementation
*****************************************************************************/
/* No implementation structure as this is only another interface to DirectDraw */
/* the Vtables */
extern
const
IDirect3DVtbl
IDirect3D1_Vtbl
DECLSPEC_HIDDEN
;
extern
const
IDirect3D2Vtbl
IDirect3D2_Vtbl
DECLSPEC_HIDDEN
;
extern
const
IDirect3D3Vtbl
IDirect3D3_Vtbl
DECLSPEC_HIDDEN
;
extern
const
IDirect3D7Vtbl
IDirect3D7_Vtbl
DECLSPEC_HIDDEN
;
/* Structure for EnumZBufferFormats */
struct
EnumZBufferFormatsData
{
...
...
@@ -460,8 +446,6 @@ struct IDirectDrawClipperImpl
HRESULT
ddraw_clipper_init
(
IDirectDrawClipperImpl
*
clipper
)
DECLSPEC_HIDDEN
;
typeof
(
WineDirect3DCreateClipper
)
*
pWineDirect3DCreateClipper
DECLSPEC_HIDDEN
;
/*****************************************************************************
* IDirectDrawPalette implementation structure
*****************************************************************************/
...
...
dlls/ddraw/main.c
View file @
c87fd4a6
...
...
@@ -33,13 +33,14 @@
#include "wine/exception.h"
#include "winreg.h"
static
typeof
(
WineDirect3DCreate
)
*
pWineDirect3DCreate
;
WINE_DEFAULT_DEBUG_CHANNEL
(
ddraw
);
/* The configured default surface */
WINED3DSURFTYPE
DefaultSurfaceType
=
SURFACE_UNKNOWN
;
typeof
(
WineDirect3DCreateClipper
)
*
pWineDirect3DCreateClipper
DECLSPEC_HIDDEN
;
typeof
(
WineDirect3DCreate
)
*
pWineDirect3DCreate
DECLSPEC_HIDDEN
;
/* DDraw list and critical section */
static
struct
list
global_ddraw_list
=
LIST_INIT
(
global_ddraw_list
);
...
...
@@ -220,12 +221,9 @@ DDRAW_Create(const GUID *guid,
IUnknown
*
UnkOuter
,
REFIID
iid
)
{
IDirectDrawImpl
*
This
=
NULL
;
HRESULT
hr
;
IWineD3D
*
wineD3D
=
NULL
;
IWineD3DDevice
*
wineD3DDevice
=
NULL
;
HDC
hDC
;
WINED3DDEVTYPE
devicetype
;
IDirectDrawImpl
*
This
;
HRESULT
hr
;
TRACE
(
"(%s,%p,%p)
\n
"
,
debugstr_guid
(
guid
),
DD
,
UnkOuter
);
...
...
@@ -263,99 +261,19 @@ DDRAW_Create(const GUID *guid,
return
E_OUTOFMEMORY
;
}
/* The interfaces:
* IDirectDraw and IDirect3D are the same object,
* QueryInterface is used to get other interfaces.
*/
This
->
lpVtbl
=
&
IDirectDraw7_Vtbl
;
This
->
IDirectDraw_vtbl
=
&
IDirectDraw1_Vtbl
;
This
->
IDirectDraw2_vtbl
=
&
IDirectDraw2_Vtbl
;
This
->
IDirectDraw3_vtbl
=
&
IDirectDraw3_Vtbl
;
This
->
IDirectDraw4_vtbl
=
&
IDirectDraw4_Vtbl
;
This
->
IDirect3D_vtbl
=
&
IDirect3D1_Vtbl
;
This
->
IDirect3D2_vtbl
=
&
IDirect3D2_Vtbl
;
This
->
IDirect3D3_vtbl
=
&
IDirect3D3_Vtbl
;
This
->
IDirect3D7_vtbl
=
&
IDirect3D7_Vtbl
;
This
->
device_parent_vtbl
=
&
ddraw_wined3d_device_parent_vtbl
;
/* See comments in IDirectDrawImpl_CreateNewSurface for a description
* of this member.
* Read from a registry key, should add a winecfg option later
*/
This
->
ImplType
=
DefaultSurfaceType
;
/* Get the current screen settings */
hDC
=
GetDC
(
0
);
This
->
orig_bpp
=
GetDeviceCaps
(
hDC
,
BITSPIXEL
)
*
GetDeviceCaps
(
hDC
,
PLANES
);
ReleaseDC
(
0
,
hDC
);
This
->
orig_width
=
GetSystemMetrics
(
SM_CXSCREEN
);
This
->
orig_height
=
GetSystemMetrics
(
SM_CYSCREEN
);
if
(
!
LoadWineD3D
())
{
ERR
(
"Couldn't load WineD3D - OpenGL libs not present?
\n
"
);
hr
=
DDERR_NODIRECTDRAWSUPPORT
;
goto
err_out
;
}
/* Initialize WineD3D
*
* All Rendering (2D and 3D) is relayed to WineD3D,
* but DirectDraw specific management, like DDSURFACEDESC and DDPIXELFORMAT
* structure handling is handled in this lib.
*/
wineD3D
=
pWineDirect3DCreate
(
7
/* DXVersion */
,
(
IUnknown
*
)
This
/* Parent */
);
if
(
!
wineD3D
)
hr
=
ddraw_init
(
This
,
devicetype
);
if
(
FAILED
(
hr
))
{
ERR
(
"Failed to initialise WineD3D
\n
"
);
hr
=
E_OUTOFMEMORY
;
goto
err_out
;
}
This
->
wineD3D
=
wineD3D
;
TRACE
(
"WineD3D created at %p
\n
"
,
wineD3D
);
/* Initialized member...
*
* It is set to false at creation time, and set to true in
* IDirectDraw7::Initialize. Its sole purpose is to return DD_OK on
* initialize only once
*/
This
->
initialized
=
FALSE
;
/* Initialize WineD3DDevice
*
* It is used for screen setup, surface and palette creation
* When a Direct3DDevice7 is created, the D3D capabilities of WineD3D are
* initialized
*/
hr
=
IWineD3D_CreateDevice
(
wineD3D
,
0
/* D3D_ADAPTER_DEFAULT */
,
devicetype
,
NULL
/* FocusWindow, don't know yet */
,
0
/* BehaviorFlags */
,
(
IUnknown
*
)
This
,
(
IWineD3DDeviceParent
*
)
&
This
->
device_parent_vtbl
,
&
wineD3DDevice
);
if
(
FAILED
(
hr
))
{
ERR
(
"Failed to create a wineD3DDevice, result = %x
\n
"
,
hr
);
goto
err_out
;
WARN
(
"Failed to initialize ddraw object, hr %#x.
\n
"
,
hr
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
return
hr
;
}
This
->
wineD3DDevice
=
wineD3DDevice
;
TRACE
(
"wineD3DDevice created at %p
\n
"
,
This
->
wineD3DDevice
);
/* Get the amount of video memory */
This
->
total_vidmem
=
IWineD3DDevice_GetAvailableTextureMem
(
This
->
wineD3DDevice
);
list_init
(
&
This
->
surface_list
);
list_add_head
(
&
global_ddraw_list
,
&
This
->
ddraw_list_entry
);
/* Call QueryInterface to get the pointer to the requested interface. This also initializes
* The required refcount
*/
hr
=
IDirectDraw7_QueryInterface
((
IDirectDraw7
*
)
This
,
iid
,
DD
);
if
(
SUCCEEDED
(
hr
))
return
DD_OK
;
err_out:
/* Let's hope we never need this ;) */
if
(
wineD3DDevice
)
IWineD3DDevice_Release
(
wineD3DDevice
);
if
(
wineD3D
)
IWineD3D_Release
(
wineD3D
);
HeapFree
(
GetProcessHeap
(),
0
,
This
->
decls
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
IDirectDraw7_Release
((
IDirectDraw7
*
)
This
);
if
(
SUCCEEDED
(
hr
))
list_add_head
(
&
global_ddraw_list
,
&
This
->
ddraw_list_entry
);
else
WARN
(
"Failed to query interface %s from ddraw object %p.
\n
"
,
debugstr_guid
(
iid
),
This
);
return
hr
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment