DXGL r47 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r46‎ | r47 | r48 >
Date:20:11, 25 December 2011
Author:admin
Status:new
Tags:
Comment:
Add COM initialization for DDraw and clipper objects
Modified paths:
  • /ddraw/ddraw.cpp (modified) (history)
  • /ddraw/glClassFactory.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawClipper.cpp (modified) (history)
  • /ddraw/glDirectDrawClipper.h (modified) (history)

Diff [purge]

Index: ddraw/ddraw.cpp
@@ -121,7 +121,7 @@
122122 }
123123 HRESULT WINAPI DirectDrawCreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter)
124124 {
125 - *lplpDDClipper = new glDirectDrawClipper(dwFlags,lplpDDClipper,pUnkOuter,NULL);
 125+ *lplpDDClipper = new glDirectDrawClipper(dwFlags,NULL);
126126 return DD_OK;
127127 }
128128 HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkOuter)
@@ -235,7 +235,8 @@
236236 }
237237 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
238238 {
239 - if(rclsid != CLSID_DirectDraw) return CLASS_E_CLASSNOTAVAILABLE;
 239+ if((rclsid != CLSID_DirectDraw) && (rclsid != CLSID_DirectDraw7) &&
 240+ (rclsid != CLSID_DirectDrawClipper)) return CLASS_E_CLASSNOTAVAILABLE;
240241 glClassFactory *factory = new glClassFactory;
241242 if(factory == NULL) return E_OUTOFMEMORY;
242243 HRESULT result = factory->QueryInterface(riid,ppv);
Index: ddraw/glClassFactory.cpp
@@ -17,7 +17,11 @@
1818
1919 #include "common.h"
2020 #include "glClassFactory.h"
 21+#include "glDirectDraw.h"
 22+#include "glDirectDrawClipper.h"
2123
 24+LONG locks;
 25+
2226 ULONG WINAPI glClassFactory::AddRef()
2327 {
2428 refcount++;
@@ -34,17 +38,55 @@
3539
3640 HRESULT WINAPI glClassFactory::QueryInterface(REFIID riid, void** ppvObj)
3741 {
38 - FIXME("glClassFactory::QueryInterface: stub");
39 - return E_FAIL;
 42+ if((riid == IID_IUnknown) || (riid == IID_IClassFactory))
 43+ {
 44+ *ppvObj = this;
 45+ }
 46+ else
 47+ {
 48+ *ppvObj = NULL;
 49+ return E_NOINTERFACE;
 50+ }
 51+ return S_OK;
4052 }
4153 HRESULT WINAPI glClassFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
4254 {
 55+ glDirectDraw7 *glDD7;
 56+ if(pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
 57+ if(riid == IID_IDirectDraw)
 58+ {
 59+ glDD7 = new glDirectDraw7;
 60+ *ppvObject = new glDirectDraw1(glDD7);
 61+ return S_OK;
 62+ }
 63+ if(riid == IID_IDirectDraw2)
 64+ {
 65+ glDD7 = new glDirectDraw7;
 66+ *ppvObject = new glDirectDraw2(glDD7);
 67+ return S_OK;
 68+ }
 69+ if(riid == IID_IDirectDraw4)
 70+ {
 71+ glDD7 = new glDirectDraw7;
 72+ *ppvObject = new glDirectDraw4(glDD7);
 73+ return S_OK;
 74+ }
 75+ if(riid == IID_IDirectDraw7)
 76+ {
 77+ *ppvObject = new glDirectDraw7();
 78+ return S_OK;
 79+ }
 80+ if(riid == IID_IDirectDrawClipper)
 81+ {
 82+ *ppvObject = new glDirectDrawClipper();
 83+ }
4384 FIXME("glClassFactory::CreateInterface: stub");
44 - return E_FAIL;
 85+ return E_NOINTERFACE;
4586 }
4687 HRESULT WINAPI glClassFactory::LockServer(BOOL fLock)
4788 {
48 - FIXME("glClassFactory::LockServer: stub");
49 - return E_FAIL;
 89+ if(fLock) InterlockedIncrement(&locks);
 90+ else InterlockedDecrement(&locks);
 91+ return S_OK;
5092 }
5193
Index: ddraw/glDirectDraw.cpp
@@ -672,7 +672,7 @@
673673 ZeroMemory(&clippers[clippercountmax],1024*sizeof(glDirectDrawClipper *));
674674 clippercountmax += 1024;
675675 }
676 - clippers[clippercount-1] = new glDirectDrawClipper(dwFlags,lplpDDClipper,pUnkOuter,this);
 676+ clippers[clippercount-1] = new glDirectDrawClipper(dwFlags,this);
677677 *lplpDDClipper = clippers[clippercount-1];
678678 return DD_OK;
679679 }
@@ -874,7 +874,8 @@
875875 useguid = true;
876876 FIXME("Display GUIDs not yet supported, using primary.\n");
877877 }
878 - return 0;
 878+ initialized = true;
 879+ return DD_OK;
879880 }
880881 HRESULT WINAPI glDirectDraw7::RestoreDisplayMode()
881882 {
Index: ddraw/glDirectDrawClipper.cpp
@@ -18,20 +18,30 @@
1919 #include "common.h"
2020 #include "glDirectDrawClipper.h"
2121
22 -glDirectDrawClipper::glDirectDrawClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter, glDirectDraw7 *parent)
 22+glDirectDrawClipper::glDirectDrawClipper()
2323 {
24 - glDD7 = parent;
25 - if(glDD7) hasparent = true;
26 - else hasparent = false;
27 - hWnd = NULL;
 24+ initialized = false;
2825 refcount = 1;
2926 }
 27+
 28+glDirectDrawClipper::glDirectDrawClipper(DWORD dwFlags, glDirectDraw7 *parent)
 29+{
 30+ initialized = false;
 31+ refcount = 1;
 32+ Initialize((LPDIRECTDRAW)parent,dwFlags);
 33+}
3034 glDirectDrawClipper::~glDirectDrawClipper()
3135 {
3236 }
3337 HRESULT WINAPI glDirectDrawClipper::QueryInterface(REFIID riid, LPVOID* obp)
3438 {
35 - ERR(E_NOINTERFACE);
 39+ if(riid == IID_IDirectDrawClipper)
 40+ {
 41+ *obp = this;
 42+ this->AddRef();
 43+ return S_OK;
 44+ }
 45+ return E_NOINTERFACE;
3646 }
3747 ULONG WINAPI glDirectDrawClipper::AddRef()
3848 {
@@ -54,13 +64,19 @@
5565 HRESULT WINAPI glDirectDrawClipper::GetHWnd(HWND FAR *lphWnd)
5666 {
5767 *lphWnd = hWnd;
58 - if(!hWnd) ERR(DDERR_INVALIDOBJECT);
 68+ if(!hWnd) return DDERR_INVALIDOBJECT;
5969 return DD_OK;
6070 }
6171 HRESULT WINAPI glDirectDrawClipper::Initialize(LPDIRECTDRAW lpDD, DWORD dwFlags)
6272 {
63 - FIXME("IDirectDrawClipper::Initialize: stub");
64 - ERR(DDERR_GENERIC);
 73+ if(initialized) return DDERR_ALREADYINITIALIZED;
 74+ glDD7 = (glDirectDraw7*)lpDD;
 75+ if(glDD7) hasparent = true;
 76+ else hasparent = false;
 77+ hWnd = NULL;
 78+ refcount = 1;
 79+ initialized = true;
 80+ return DD_OK;
6581 }
6682 HRESULT WINAPI glDirectDrawClipper::IsClipListChanged(BOOL FAR *lpbChanged)
6783 {
Index: ddraw/glDirectDrawClipper.h
@@ -24,7 +24,8 @@
2525 class glDirectDrawClipper : public IDirectDrawClipper
2626 {
2727 public:
28 - glDirectDrawClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter, glDirectDraw7 *parent);
 28+ glDirectDrawClipper();
 29+ glDirectDrawClipper(DWORD dwFlags, glDirectDraw7 *parent);
2930 ~glDirectDrawClipper();
3031 // ddraw api
3132 HRESULT WINAPI QueryInterface(REFIID riid, LPVOID* obp);
@@ -40,6 +41,7 @@
4142 ULONG refcount;
4243 glDirectDraw7 *glDD7;
4344 bool hasparent;
 45+ bool initialized;
4446 HWND hWnd;
4547 };
4648 #endif //_GLDIRECTDRAWCLIPPER_H
\ No newline at end of file