ReactOS  0.4.13-dev-247-g0f29b3f
d3d.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS kernel
4  * PURPOSE: Native driver for dxg implementation
5  * FILE: win32ss/reactx/dxg/d3d.c
6  * PROGRAMER: Sebastian Gasiorek (sebastian.gasiorek@reactos.org)
7  */
8 
9 #include <string.h>
10 #include <dxg_int.h>
11 
12 DWORD
13 NTAPI
15  HANDLE DdHandle,
16  PDD_CANCREATESURFACEDATA SurfaceData)
17 {
21 
23  if (!peDdL)
24  return RetVal;
25 
26  peDdGl = peDdL->peDirectDrawGlobal2;
27  gpEngFuncs.DxEngLockHdev(peDdGl->hDev);
28 
29  // assign out DirectDrawGlobal to SurfaceData
30  SurfaceData->lpDD = (PDD_DIRECTDRAW_GLOBAL)peDdGl;
31 
33  RetVal = peDdGl->d3dBufCallbacks.CanCreateD3DBuffer(SurfaceData);
34 
37 
38  return RetVal;
39 }
40 
41 DWORD
44  PEDD_SURFACE pDdSurfList, DDSURFACEDESC2 *a3,
45  DD_SURFACE_GLOBAL *pDdSurfGlob,
46  DD_SURFACE_LOCAL *pDdSurfLoc,
47  DD_SURFACE_MORE *pDdSurfMore,
48  DD_CREATESURFACEDATA *pDdCreateSurfaceData,
49  PVOID Address)
50 {
53  DD_SURFACE_LOCAL *pCurSurfLocal;
54  DD_SURFACE_GLOBAL *pCurSurfGlobal;
55  DD_SURFACE_MORE *pCurSurfMore;
56  PEDD_SURFACE pCurSurf;
57 
58  ULONG CurSurf;
59 
60  if (!pDdCreateSurfaceData)
61  return FALSE;
62 
63  if (!pDdCreateSurfaceData->dwSCnt)
64  {
65  pDdCreateSurfaceData->ddRVal = E_FAIL;
66  return FALSE;
67  }
68 
69  peDdL = (PEDD_DIRECTDRAW_LOCAL)DdHmgLock(hDirectDrawLocal, ObjType_DDLOCAL_TYPE, FALSE);
70  if (!peDdL)
71  return FALSE;
72 
73  peDdGl = peDdL->peDirectDrawGlobal2;
74 
75  if (!(pDdSurfLoc->ddsCaps.dwCaps & DDSCAPS_VISIBLE) && !(peDdGl->ddCallbacks.dwFlags & DDHAL_CB32_CREATESURFACE))
76  {
77  pDdCreateSurfaceData->ddRVal = E_FAIL;
78  return FALSE;
79  }
80 
81  pDdSurfList = (PEDD_SURFACE)EngAllocMem(FL_ZERO_MEMORY, pDdCreateSurfaceData->dwSCnt * sizeof(EDD_SURFACE), TAG_GDDP);
82  pDdSurfGlob = (DD_SURFACE_GLOBAL *)EngAllocMem(FL_ZERO_MEMORY, pDdCreateSurfaceData->dwSCnt * sizeof(DD_SURFACE_GLOBAL), TAG_GDDP);
83  pDdSurfLoc = (DD_SURFACE_LOCAL *)EngAllocMem(FL_ZERO_MEMORY, pDdCreateSurfaceData->dwSCnt * sizeof(DD_SURFACE_LOCAL), TAG_GDDP);
84  pDdSurfMore = (DD_SURFACE_MORE *)EngAllocMem(FL_ZERO_MEMORY, pDdCreateSurfaceData->dwSCnt * sizeof(DD_SURFACE_MORE), TAG_GDDP);
85 
87  gpEngFuncs.DxEngLockHdev(peDdGl->hDev);
88 
89  // create all surface objects
90  for (CurSurf = 0; CurSurf < pDdCreateSurfaceData->dwSCnt; CurSurf++)
91  {
92  pCurSurf = &pDdSurfList[CurSurf];
93  pCurSurfLocal = &pDdSurfLoc[CurSurf];
94  pCurSurfGlobal = &pDdSurfGlob[CurSurf];
95  pCurSurfMore = &pDdSurfMore[CurSurf];
96 
97  pCurSurf = intDdCreateNewSurfaceObject(
98  peDdL,
99  pCurSurf,
100  pCurSurfGlobal,
101  pCurSurfLocal,
102  pCurSurfMore);
103  Address = pCurSurf;
104  }
105 
108 
109  return DDHAL_DRIVER_HANDLED;
110 }
111 
112 DWORD
113 NTAPI
115  HANDLE hDirectDrawLocal,
116  PEDD_SURFACE pDdSurfList,
118  DD_SURFACE_GLOBAL *pDdSurfGlob,
119  DD_SURFACE_LOCAL *pDdSurfLoc,
120  DD_SURFACE_MORE *pDdSurfMore,
121  DD_CREATESURFACEDATA *pDdCreateSurfaceData,
122  PVOID Address)
123 {
124  return intDdCreateSurfaceOrBuffer(hDirectDrawLocal, pDdSurfList, a3, pDdSurfGlob, pDdSurfLoc, pDdSurfMore, pDdCreateSurfaceData, Address);
125 }
static const struct update_accum a3
Definition: msg.c:600
struct _DD_DIRECTDRAW_GLOBAL * PDD_DIRECTDRAW_GLOBAL
PDD_CANCREATESURFACE CanCreateD3DBuffer
Definition: ddrawint.h:1032
DWORD dwCaps
Definition: ddraw.h:727
#define DDHAL_DRIVER_NOTHANDLED
Definition: ddrawi.h:320
DDSCAPS ddsCaps
Definition: ddrawint.h:174
USHORT cExclusiveLock
Definition: dxg_int.h:39
PFN_DxEngUnlockShareSem DxEngUnlockShareSem
Definition: dxg_int.h:135
DXENG_FUNCTIONS gpEngFuncs
Definition: main.c:20
#define E_FAIL
Definition: ddrawi.h:102
#define FASTCALL
Definition: nt_native.h:50
PEDD_SURFACE NTAPI intDdCreateNewSurfaceObject(PEDD_DIRECTDRAW_LOCAL peDdL, HANDLE hDirectDrawLocal, PDD_SURFACE_GLOBAL pDdSurfGlob, PDD_SURFACE_LOCAL pDdSurfLoc, PDD_SURFACE_MORE pDdSurfMore)
Definition: ddraw.c:588
#define DDSCAPS_VISIBLE
Definition: ddraw.h:265
#define DDHAL_DRIVER_HANDLED
Definition: ddrawi.h:321
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
#define ObjType_DDLOCAL_TYPE
Definition: dxg_int.h:56
PVOID FASTCALL DdHmgLock(HANDLE DdHandle, UCHAR ObjectType, BOOLEAN LockOwned)
Definition: ddhmg.c:147
unsigned long DWORD
Definition: ntddk_ex.h:95
DD_BASEOBJECT pobj
Definition: directxint.h:16
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
#define InterlockedDecrement
Definition: armddk.h:52
PDD_DIRECTDRAW_GLOBAL lpDD
Definition: ddrawint.h:456
#define FL_ZERO_MEMORY
Definition: polytest.cpp:58
DWORD FASTCALL intDdCreateSurfaceOrBuffer(HANDLE hDirectDrawLocal, PEDD_SURFACE pDdSurfList, DDSURFACEDESC2 *a3, DD_SURFACE_GLOBAL *pDdSurfGlob, DD_SURFACE_LOCAL *pDdSurfLoc, DD_SURFACE_MORE *pDdSurfMore, DD_CREATESURFACEDATA *pDdCreateSurfaceData, PVOID Address)
Definition: d3d.c:43
struct _EDD_DIRECTDRAW_GLOBAL * peDirectDrawGlobal2
Definition: directxint.h:22
DD_CALLBACKS ddCallbacks
Definition: directxint.h:160
DD_D3DBUFCALLBACKS d3dBufCallbacks
Definition: directxint.h:165
struct _EDD_DIRECTDRAW_LOCAL * PEDD_DIRECTDRAW_LOCAL
DWORD dwFlags
Definition: ddrawint.h:499
#define TAG_GDDP
Definition: tags.h:5
#define DDHAL_CB32_CREATESURFACE
Definition: ddrawi.h:654
unsigned int ULONG
Definition: retypes.h:1
DWORD NTAPI DxDdCreateD3DBuffer(HANDLE hDirectDrawLocal, PEDD_SURFACE pDdSurfList, DDSURFACEDESC2 *a3, DD_SURFACE_GLOBAL *pDdSurfGlob, DD_SURFACE_LOCAL *pDdSurfLoc, DD_SURFACE_MORE *pDdSurfMore, DD_CREATESURFACEDATA *pDdCreateSurfaceData, PVOID Address)
Definition: d3d.c:114
PFN_DxEngLockHdev DxEngLockHdev
Definition: dxg_int.h:137
DWORD NTAPI DxDdCanCreateD3DBuffer(HANDLE DdHandle, PDD_CANCREATESURFACEDATA SurfaceData)
Definition: d3d.c:14
PFN_DxEngUnlockHdev DxEngUnlockHdev
Definition: dxg_int.h:138
struct _EDD_SURFACE * PEDD_SURFACE
PFN_DxEngLockShareSem DxEngLockShareSem
Definition: dxg_int.h:134