DXGL r447 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r446‎ | r447 | r448 >
Date:16:20, 26 May 2014
Author:admin
Status:new
Tags:
Comment:
Use C-style struct for glDirectDrawClipper.
Modified paths:
  • /ddraw/ddraw.cpp (modified) (history)
  • /ddraw/glClassFactory.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDraw.h (modified) (history)
  • /ddraw/glDirectDrawClipper.cpp (modified) (history)
  • /ddraw/glDirectDrawClipper.h (modified) (history)
  • /ddraw/glDirectDrawPalette.c (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.h (modified) (history)

Diff [purge]

Index: ddraw/ddraw.cpp
@@ -227,15 +227,7 @@
228228 HRESULT WINAPI DirectDrawCreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter)
229229 {
230230 TRACE_ENTER(3,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
231 - *lplpDDClipper = new glDirectDrawClipper(dwFlags,NULL);
232 - if(!lplpDDClipper)
233 - {
234 - TRACE_EXIT(23,DDERR_OUTOFMEMORY);
235 - return DDERR_OUTOFMEMORY;
236 - }
237 - TRACE_VAR("*lplpDDClipper",14,*lplpDDClipper);
238 - TRACE_EXIT(23,DD_OK);
239 - return DD_OK;
 231+ TRACE_RET(HRESULT, 23, glDirectDrawClipper_Create(dwFlags, NULL, lplpDDClipper));
240232 }
241233
242234 /**
Index: ddraw/glClassFactory.cpp
@@ -103,10 +103,7 @@
104104 }
105105 if(riid == IID_IDirectDrawClipper)
106106 {
107 - *ppvObject = new glDirectDrawClipper();
108 - TRACE_VAR("*ppvObject",14,*ppvObject);
109 - TRACE_EXIT(23,S_OK);
110 - return S_OK;
 107+ TRACE_RET(HRESULT, 23, glDirectDrawClipper_CreateNoInit((LPDIRECTDRAWCLIPPER*)ppvObject));
111108 }
112109 FIXME("glClassFactory::CreateInterface: stub");
113110 TRACE_EXIT(23,E_NOINTERFACE);
Index: ddraw/glDirectDraw.cpp
@@ -615,7 +615,7 @@
616616 {
617617 for(int i = 0; i < clippercount; i++)
618618 {
619 - if(clippers[i]) clippers[i]->Release();
 619+ if(clippers[i]) glDirectDrawClipper_Release(clippers[i]);
620620 clippers[i] = NULL;
621621 }
622622 free(clippers);
@@ -810,11 +810,7 @@
811811 ZeroMemory(&clippers[clippercountmax],1024*sizeof(glDirectDrawClipper *));
812812 clippercountmax += 1024;
813813 }
814 - clippers[clippercount-1] = new glDirectDrawClipper(dwFlags,this);
815 - *lplpDDClipper = clippers[clippercount-1];
816 - TRACE_VAR("*lplpDDClipper",14,*lplpDDClipper);
817 - TRACE_EXIT(23,DD_OK);
818 - return DD_OK;
 814+ TRACE_RET(HRESULT, 23, glDirectDrawClipper_Create(dwFlags, this, lplpDDClipper));
819815 }
820816 HRESULT WINAPI glDirectDraw7::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
821817 {
Index: ddraw/glDirectDraw.h
@@ -22,7 +22,7 @@
2323 #define DXGLBLT_NOPALSHADER 0x80000000
2424
2525 class glDirectDrawSurface7;
26 -class glDirectDrawClipper;
 26+struct glDirectDrawClipper;
2727 class glDirect3D7;
2828 class glRenderer;
2929
Index: ddraw/glDirectDrawClipper.cpp
@@ -21,40 +21,61 @@
2222 #include "glDirectDraw.h"
2323 #include "glDirectDrawClipper.h"
2424
25 -glDirectDrawClipper::glDirectDrawClipper()
 25+glDirectDrawClipperVtbl glDirectDrawClipper_iface =
2626 {
27 - TRACE_ENTER(1,14,this);
28 - initialized = false;
29 - refcount = 1;
30 - TRACE_EXIT(-1,0);
31 -}
 27+ glDirectDrawClipper_QueryInterface,
 28+ glDirectDrawClipper_AddRef,
 29+ glDirectDrawClipper_Release,
 30+ glDirectDrawClipper_GetClipList,
 31+ glDirectDrawClipper_GetHWnd,
 32+ glDirectDrawClipper_Initialize,
 33+ glDirectDrawClipper_IsClipListChanged,
 34+ glDirectDrawClipper_SetClipList,
 35+ glDirectDrawClipper_SetHWnd
 36+};
3237
33 -glDirectDrawClipper::glDirectDrawClipper(DWORD dwFlags, glDirectDraw7 *parent)
 38+HRESULT glDirectDrawClipper_CreateNoInit(LPDIRECTDRAWCLIPPER *lplpDDClipper)
3439 {
35 - TRACE_ENTER(3,14,this,9,dwFlags,14,parent);
36 - initialized = false;
37 - refcount = 1;
38 - Initialize((LPDIRECTDRAW)parent,dwFlags);
39 - TRACE_EXIT(-1,0);
 40+ glDirectDrawClipper *newclipper;
 41+ TRACE_ENTER(1, 14, lplpDDClipper);
 42+ if (!lplpDDClipper) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 43+ newclipper = (glDirectDrawClipper*)malloc(sizeof(glDirectDrawClipper));
 44+ if (!newclipper) TRACE_RET(HRESULT, 23, DDERR_OUTOFMEMORY);
 45+ ZeroMemory(newclipper, sizeof(glDirectDrawClipper));
 46+ newclipper->refcount = 1;
 47+ newclipper->initialized = false;
 48+ newclipper->lpVtbl = &glDirectDrawClipper_iface;
 49+ if (lplpDDClipper) *lplpDDClipper = (LPDIRECTDRAWCLIPPER)newclipper;
 50+ TRACE_EXIT(23, DD_OK);
 51+ return DD_OK;
4052 }
41 -glDirectDrawClipper::~glDirectDrawClipper()
 53+
 54+HRESULT glDirectDrawClipper_Create(DWORD dwFlags, glDirectDraw7 *parent, LPDIRECTDRAWCLIPPER *lplpDDClipper)
4255 {
43 - TRACE_ENTER(1,14,this);
44 - if (cliplist) free(cliplist);
45 - if (vertices) free(vertices);
46 - if (indices) free(indices);
47 - if(glDD7) glDD7->DeleteClipper(this);
48 - TRACE_EXIT(-1,0);
 56+ glDirectDrawClipper *newclipper;
 57+ TRACE_ENTER(3, 9, dwFlags, 14, parent, 14, lplpDDClipper);
 58+ if (!lplpDDClipper) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 59+ newclipper = (glDirectDrawClipper*)malloc(sizeof(glDirectDrawClipper));
 60+ if (!newclipper) TRACE_RET(HRESULT, 23, DDERR_OUTOFMEMORY);
 61+ ZeroMemory(newclipper, sizeof(glDirectDrawClipper));
 62+ newclipper->refcount = 1;
 63+ newclipper->initialized = false;
 64+ newclipper->lpVtbl = &glDirectDrawClipper_iface;
 65+ glDirectDrawClipper_Initialize(newclipper, (LPDIRECTDRAW)parent, dwFlags);
 66+ if (lplpDDClipper) *lplpDDClipper = (LPDIRECTDRAWCLIPPER)newclipper;
 67+ TRACE_EXIT(23, DD_OK);
 68+ return DD_OK;
4969 }
50 -HRESULT WINAPI glDirectDrawClipper::QueryInterface(REFIID riid, LPVOID* obp)
 70+
 71+HRESULT WINAPI glDirectDrawClipper_QueryInterface(glDirectDrawClipper *This, REFIID riid, LPVOID* obp)
5172 {
52 - TRACE_ENTER(3,14,this,24,&riid,14,obp);
53 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 73+ TRACE_ENTER(3,14,This,24,&riid,14,obp);
 74+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
5475 if(!obp) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
5576 if(riid == IID_IUnknown)
5677 {
57 - this->AddRef();
58 - *obp = this;
 78+ glDirectDrawClipper_AddRef(This);
 79+ *obp = This;
5980 TRACE_VAR("*obp",14,*obp);
6081 TRACE_EXIT(23,DD_OK);
6182 return DD_OK;
@@ -61,9 +82,9 @@
6283 }
6384 if(riid == IID_IDirectDrawClipper)
6485 {
65 - *obp = this;
66 - this->AddRef();
67 - TRACE_VAR("*obp",14,*obp);
 86+ *obp = This;
 87+ glDirectDrawClipper_AddRef(This);
 88+ TRACE_VAR("*obp", 14, *obp);
6889 TRACE_EXIT(23,DD_OK);
6990 return DD_OK;
7091 }
@@ -70,75 +91,83 @@
7192 TRACE_EXIT(23,E_NOINTERFACE);
7293 return E_NOINTERFACE;
7394 }
74 -ULONG WINAPI glDirectDrawClipper::AddRef()
 95+ULONG WINAPI glDirectDrawClipper_AddRef(glDirectDrawClipper *This)
7596 {
76 - TRACE_ENTER(1,14,this);
77 - if(!this) TRACE_RET(ULONG,8,0);
78 - refcount++;
79 - TRACE_EXIT(8,refcount);
80 - return refcount;
 97+ TRACE_ENTER(1,14,This);
 98+ if(!This) TRACE_RET(ULONG,8,0);
 99+ This->refcount++;
 100+ TRACE_EXIT(8,This->refcount);
 101+ return This->refcount;
81102 }
82 -ULONG WINAPI glDirectDrawClipper::Release()
 103+ULONG WINAPI glDirectDrawClipper_Release(glDirectDrawClipper *This)
83104 {
84 - TRACE_ENTER(1,14,this);
85 - if(!this) TRACE_RET(ULONG,8,0);
 105+ TRACE_ENTER(1,14,This);
 106+ if(!This) TRACE_RET(ULONG,8,0);
86107 ULONG ret;
87 - refcount--;
88 - ret = refcount;
89 - if(refcount == 0) delete this;
 108+ This->refcount--;
 109+ ret = This->refcount;
 110+ if (This->refcount == 0)
 111+ {
 112+ if (This->cliplist) free(This->cliplist);
 113+ if (This->vertices) free(This->vertices);
 114+ if (This->indices) free(This->indices);
 115+ if (This->glDD7) This->glDD7->DeleteClipper(This);
 116+ free(This);
 117+ };
90118 TRACE_EXIT(8,ret);
91119 return ret;
92120 }
93 -HRESULT WINAPI glDirectDrawClipper::GetClipList(LPRECT lpRect, LPRGNDATA lpClipList, LPDWORD lpdwSize)
 121+HRESULT WINAPI glDirectDrawClipper_GetClipList(glDirectDrawClipper *This, LPRECT lpRect, LPRGNDATA lpClipList, LPDWORD lpdwSize)
94122 {
95 - TRACE_ENTER(4,14,this,26,lpRect,14,lpClipList,14,lpdwSize);
96 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 123+ TRACE_ENTER(4,14,This,26,lpRect,14,lpClipList,14,lpdwSize);
 124+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
97125 FIXME("IDirectDrawClipper::GetClipList: stub");
98126 TRACE_EXIT(23,DDERR_GENERIC);
99127 ERR(DDERR_GENERIC);
100128 }
101 -HRESULT WINAPI glDirectDrawClipper::GetHWnd(HWND FAR *lphWnd)
 129+HRESULT WINAPI glDirectDrawClipper_GetHWnd(glDirectDrawClipper *This, HWND FAR *lphWnd)
102130 {
103 - TRACE_ENTER(2,14,this,14,lphWnd);
104 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
105 - if(!hWnd) TRACE_RET(HRESULT,23,DDERR_NOHWND);
106 - *lphWnd = hWnd;
 131+ TRACE_ENTER(2,14,This,14,lphWnd);
 132+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 133+ if(!This->hWnd) TRACE_RET(HRESULT,23,DDERR_NOHWND);
 134+ *lphWnd = This->hWnd;
107135 TRACE_VAR("*lphWnd",13,*lphWnd);
108136 TRACE_EXIT(23,DD_OK);
109137 return DD_OK;
110138 }
111 -HRESULT WINAPI glDirectDrawClipper::Initialize(LPDIRECTDRAW lpDD, DWORD dwFlags)
 139+HRESULT WINAPI glDirectDrawClipper_Initialize(glDirectDrawClipper *This, LPDIRECTDRAW lpDD, DWORD dwFlags)
112140 {
113 - TRACE_ENTER(3,14,this,14,lpDD,9,dwFlags);
114 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
115 - if(initialized) TRACE_RET(HRESULT,23,DDERR_ALREADYINITIALIZED);
116 - glDD7 = (glDirectDraw7*)lpDD;
117 - if(glDD7) hasparent = true;
118 - else hasparent = false;
119 - hWnd = NULL;
120 - cliplist = NULL;
121 - vertices = NULL;
122 - indices = NULL;
123 - hascliplist = false;
124 - maxsize = clipsize = 0;
125 - refcount = 1;
126 - initialized = true;
 141+ TRACE_ENTER(3,14,This,14,lpDD,9,dwFlags);
 142+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 143+ if(This->initialized) TRACE_RET(HRESULT,23,DDERR_ALREADYINITIALIZED);
 144+ This->glDD7 = (glDirectDraw7*)lpDD;
 145+ if(This->glDD7) This->hasparent = true;
 146+ else This->hasparent = false;
 147+ This->hWnd = NULL;
 148+ This->cliplist = NULL;
 149+ This->vertices = NULL;
 150+ This->indices = NULL;
 151+ This->hascliplist = false;
 152+ This->maxsize = This->clipsize = 0;
 153+ This->refcount = 1;
 154+ This->initialized = true;
 155+ This->dirty = true;
127156 TRACE_EXIT(23,DD_OK);
128157 return DD_OK;
129158 }
130 -HRESULT WINAPI glDirectDrawClipper::IsClipListChanged(BOOL FAR *lpbChanged)
 159+HRESULT WINAPI glDirectDrawClipper_IsClipListChanged(glDirectDrawClipper *This, BOOL FAR *lpbChanged)
131160 {
132 - TRACE_ENTER(2,14,this,14,lpbChanged);
133 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 161+ TRACE_ENTER(2,14,This,14,lpbChanged);
 162+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
134163 FIXME("IDirectDrawClipper::IsClipListChanged: stub");
135164 TRACE_EXIT(23,DDERR_GENERIC);
136165 ERR(DDERR_GENERIC);
137166 }
138 -HRESULT WINAPI glDirectDrawClipper::SetClipList(LPRGNDATA lpClipList, DWORD dwFlags)
 167+HRESULT WINAPI glDirectDrawClipper_SetClipList(glDirectDrawClipper *This, LPRGNDATA lpClipList, DWORD dwFlags)
139168 {
140 - TRACE_ENTER(3,14,this,14,lpClipList,9,dwFlags);
141 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
142 - if(hWnd) TRACE_RET(HRESULT,23,DDERR_CLIPPERISUSINGHWND);
 169+ TRACE_ENTER(3,14,This,14,lpClipList,9,dwFlags);
 170+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 171+ if(This->hWnd) TRACE_RET(HRESULT,23,DDERR_CLIPPERISUSINGHWND);
143172 bool memfail;
144173 if(lpClipList)
145174 {
@@ -146,80 +175,81 @@
147176 if(lpClipList->rdh.iType != RDH_RECTANGLES) TRACE_RET(HRESULT,23,DDERR_INVALIDCLIPLIST);
148177 if(lpClipList->rdh.nRgnSize != lpClipList->rdh.nCount * sizeof(RECT))
149178 TRACE_RET(HRESULT,23,DDERR_INVALIDCLIPLIST);
150 - if(!cliplist)
 179+ if(!This->cliplist)
151180 {
152181 memfail = false;
153 - maxsize = lpClipList->rdh.nCount;
154 - cliplist = (RECT*)malloc(maxsize*sizeof(RECT));
155 - if(!cliplist) memfail = true;
156 - if(!memfail) vertices = (BltVertex*)malloc(maxsize*4*sizeof(BltVertex));
157 - if(!vertices) memfail = true;
158 - if(!memfail) indices = (WORD*)malloc(maxsize*6*sizeof(WORD));
159 - if(!indices) memfail = true;
 182+ This->maxsize = lpClipList->rdh.nCount;
 183+ This->cliplist = (RECT*)malloc(This->maxsize*sizeof(RECT));
 184+ if(!This->cliplist) memfail = true;
 185+ if(!memfail) This->vertices = (BltVertex*)malloc(This->maxsize*4*sizeof(BltVertex));
 186+ if(!This->vertices) memfail = true;
 187+ if(!memfail) This->indices = (WORD*)malloc(This->maxsize*6*sizeof(WORD));
 188+ if(!This->indices) memfail = true;
160189 if(memfail)
161190 {
162 - if(vertices)
 191+ if(This->vertices)
163192 {
164 - free(vertices);
165 - vertices = NULL;
 193+ free(This->vertices);
 194+ This->vertices = NULL;
166195 }
167 - if(cliplist)
 196+ if(This->cliplist)
168197 {
169 - free(cliplist);
170 - cliplist = NULL;
 198+ free(This->cliplist);
 199+ This->cliplist = NULL;
171200 }
172 - maxsize = 0;
 201+ This->maxsize = 0;
173202 TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
174203 }
175204 }
176 - if(lpClipList->rdh.nCount > maxsize)
 205+ if(lpClipList->rdh.nCount > This->maxsize)
177206 {
178207 memfail = false;
179208 RECT *newcliplist = NULL;
180209 BltVertex *newvertices = NULL;
181210 WORD *newindices = NULL;
182 - newcliplist = (RECT*)realloc(cliplist,lpClipList->rdh.nCount*sizeof(RECT));
 211+ newcliplist = (RECT*)realloc(This->cliplist,lpClipList->rdh.nCount*sizeof(RECT));
183212 if(!newcliplist) memfail = true;
184 - else cliplist = newcliplist;
185 - if(!memfail) newvertices = (BltVertex*)realloc(vertices,lpClipList->rdh.nCount*4*sizeof(BltVertex));
 213+ else This->cliplist = newcliplist;
 214+ if(!memfail) newvertices = (BltVertex*)realloc(This->vertices,lpClipList->rdh.nCount*4*sizeof(BltVertex));
186215 if(!newvertices) memfail = true;
187 - else vertices = newvertices;
188 - if(!memfail) newindices = (WORD*)realloc(indices,lpClipList->rdh.nCount*6*sizeof(WORD));
 216+ else This->vertices = newvertices;
 217+ if(!memfail) newindices = (WORD*)realloc(This->indices,lpClipList->rdh.nCount*6*sizeof(WORD));
189218 if(!newindices) memfail = true;
190 - else indices = newindices;
 219+ else This->indices = newindices;
191220 if(memfail) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
192 - maxsize = lpClipList->rdh.nCount;
 221+ This->maxsize = lpClipList->rdh.nCount;
193222 }
194 - clipsize = lpClipList->rdh.nCount;
195 - memcpy(cliplist,lpClipList->Buffer,lpClipList->rdh.nCount*sizeof(RECT));
 223+ This->clipsize = lpClipList->rdh.nCount;
 224+ memcpy(This->cliplist,lpClipList->Buffer,lpClipList->rdh.nCount*sizeof(RECT));
196225 for(int i = 0; i < lpClipList->rdh.nCount; i++)
197226 {
198 - vertices[(i*4)+1].y = vertices[(i*4)+3].y = cliplist[i].left;
199 - vertices[i*4].x = vertices[(i*4)+2].x = cliplist[i].right;
200 - vertices[i*4].y = vertices[(i*4)+1].y = cliplist[i].top;
201 - vertices[(i*4)+2].y = vertices[(i*4)+3].y = cliplist[i].bottom;
 227+ This->vertices[(i*4)+1].y = This->vertices[(i*4)+3].y = This->cliplist[i].left;
 228+ This->vertices[i*4].x = This->vertices[(i*4)+2].x = This->cliplist[i].right;
 229+ This->vertices[i*4].y = This->vertices[(i*4)+1].y = This->cliplist[i].top;
 230+ This->vertices[(i*4)+2].y = This->vertices[(i*4)+3].y = This->cliplist[i].bottom;
202231 // 0 1 2 2 1 3
203 - indices[i*6] = i*4;
204 - indices[(i*6)+1] = indices[(i*6)+4] = (i*4)+1;
205 - indices[(i*6)+2] = indices[(i*6)+3] = (i*4)+2;
206 - indices[(i*6)+5] = (i*4)+3;
 232+ This->indices[i*6] = i*4;
 233+ This->indices[(i*6)+1] = This->indices[(i*6)+4] = (i*4)+1;
 234+ This->indices[(i*6)+2] = This->indices[(i*6)+3] = (i*4)+2;
 235+ This->indices[(i*6)+5] = (i*4)+3;
207236 }
208237 for(int i = 0; i < (4*lpClipList->rdh.nCount); i++)
209238 {
210 - vertices[i].r = 255;
211 - vertices[i].g = vertices[i].b = vertices[i].a = 0;
212 - vertices[i].s = vertices[i].t = 0.0f;
 239+ This->vertices[i].r = 255;
 240+ This->vertices[i].g = This->vertices[i].b = This->vertices[i].a = 0;
 241+ This->vertices[i].s = This->vertices[i].t = 0.0f;
213242 }
214243 }
215 - else clipsize = 0;
 244+ else This->clipsize = 0;
 245+ This->dirty = true;
216246 TRACE_EXIT(23,DD_OK);
217247 return DD_OK;
218248 }
219 -HRESULT WINAPI glDirectDrawClipper::SetHWnd(DWORD dwFlags, HWND hWnd)
 249+HRESULT WINAPI glDirectDrawClipper_SetHWnd(glDirectDrawClipper *This, DWORD dwFlags, HWND hWnd)
220250 {
221 - TRACE_ENTER(3,14,this,9,dwFlags,13,hWnd);
222 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
223 - this->hWnd = hWnd;
 251+ TRACE_ENTER(3,14,This,9,dwFlags,13,hWnd);
 252+ if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 253+ This->hWnd = hWnd;
224254 TRACE_EXIT(23,DD_OK);
225255 return DD_OK;
226256 }
Index: ddraw/glDirectDrawClipper.h
@@ -21,23 +21,11 @@
2222
2323 class glDirectDraw7;
2424
25 -class glDirectDrawClipper : public IDirectDrawClipper
 25+struct glDirectDrawClipperVtbl;
 26+
 27+typedef struct glDirectDrawClipper
2628 {
27 -public:
28 - glDirectDrawClipper();
29 - glDirectDrawClipper(DWORD dwFlags, glDirectDraw7 *parent);
30 - ~glDirectDrawClipper();
31 - // ddraw api
32 - HRESULT WINAPI QueryInterface(REFIID riid, LPVOID* obp);
33 - ULONG WINAPI AddRef();
34 - ULONG WINAPI Release();
35 - HRESULT WINAPI GetClipList(LPRECT lpRect, LPRGNDATA lpClipList, LPDWORD lpdwSize);
36 - HRESULT WINAPI GetHWnd(HWND FAR *lphWnd);
37 - HRESULT WINAPI Initialize(LPDIRECTDRAW lpDD, DWORD dwFlags);
38 - HRESULT WINAPI IsClipListChanged(BOOL FAR *lpbChanged);
39 - HRESULT WINAPI SetClipList(LPRGNDATA lpClipList, DWORD dwFlags);
40 - HRESULT WINAPI SetHWnd(DWORD dwFlags, HWND hWnd);
41 -private:
 29+ struct glDirectDrawClipperVtbl *lpVtbl;
4230 ULONG refcount;
4331 glDirectDraw7 *glDD7;
4432 bool hasparent;
@@ -49,5 +37,32 @@
5038 int clipsize;
5139 int maxsize;
5240 bool hascliplist;
53 -};
 41+} glDirectDrawClipper;
 42+
 43+typedef struct glDirectDrawClipperVtbl
 44+{
 45+ HRESULT(WINAPI *QueryInterface)(glDirectDrawClipper *This, REFIID riid, LPVOID* obp);
 46+ ULONG(WINAPI *AddRef)(glDirectDrawClipper *This);
 47+ ULONG(WINAPI *Release)(glDirectDrawClipper *This);
 48+ // ddraw api
 49+ HRESULT(WINAPI *GetClipList)(glDirectDrawClipper *This, LPRECT lpRect, LPRGNDATA lpClipList, LPDWORD lpdwSize);
 50+ HRESULT(WINAPI *GetHWnd)(glDirectDrawClipper *This, HWND FAR *lphWnd);
 51+ HRESULT(WINAPI *Initialize)(glDirectDrawClipper *This, LPDIRECTDRAW lpDD, DWORD dwFlags);
 52+ HRESULT(WINAPI *IsClipListChanged)(glDirectDrawClipper *This, BOOL FAR *lpbChanged);
 53+ HRESULT(WINAPI *SetClipList)(glDirectDrawClipper *This, LPRGNDATA lpClipList, DWORD dwFlags);
 54+ HRESULT(WINAPI *SetHWnd)(glDirectDrawClipper *This, DWORD dwFlags, HWND hWnd);
 55+} glDirectDrawClipperVtbl;
 56+
 57+HRESULT glDirectDrawClipper_CreateNoInit(LPDIRECTDRAWCLIPPER *lplpDDClipper);
 58+HRESULT glDirectDrawClipper_Create(DWORD dwFlags, glDirectDraw7 *parent, LPDIRECTDRAWCLIPPER *lplpDDClipper);
 59+// ddraw api
 60+HRESULT WINAPI glDirectDrawClipper_QueryInterface(glDirectDrawClipper *This, REFIID riid, LPVOID* obp);
 61+ULONG WINAPI glDirectDrawClipper_AddRef(glDirectDrawClipper *This);
 62+ULONG WINAPI glDirectDrawClipper_Release(glDirectDrawClipper *This);
 63+HRESULT WINAPI glDirectDrawClipper_GetClipList(glDirectDrawClipper *This, LPRECT lpRect, LPRGNDATA lpClipList, LPDWORD lpdwSize);
 64+HRESULT WINAPI glDirectDrawClipper_GetHWnd(glDirectDrawClipper *This, HWND FAR *lphWnd);
 65+HRESULT WINAPI glDirectDrawClipper_Initialize(glDirectDrawClipper *This, LPDIRECTDRAW lpDD, DWORD dwFlags);
 66+HRESULT WINAPI glDirectDrawClipper_IsClipListChanged(glDirectDrawClipper *This, BOOL FAR *lpbChanged);
 67+HRESULT WINAPI glDirectDrawClipper_SetClipList(glDirectDrawClipper *This, LPRGNDATA lpClipList, DWORD dwFlags);
 68+HRESULT WINAPI glDirectDrawClipper_SetHWnd(glDirectDrawClipper *This, DWORD dwFlags, HWND hWnd);
5469 #endif //_GLDIRECTDRAWCLIPPER_H
\ No newline at end of file
Index: ddraw/glDirectDrawPalette.c
@@ -204,9 +204,9 @@
205205 {
206206 glDirectDrawPalette *newpal;
207207 TRACE_ENTER(3,9,dwFlags,14,lpDDColorArray,14,lplpDDPalette);
 208+ if (!lplpDDPalette) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
208209 newpal = (glDirectDrawPalette*)malloc(sizeof(glDirectDrawPalette));
209 - if (!lplpDDPalette) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
210 - if (!newpal) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
 210+ if (!newpal) TRACE_RET(HRESULT, 23, DDERR_OUTOFMEMORY);
211211 ZeroMemory(newpal, sizeof(glDirectDrawPalette));
212212 newpal->refcount = 1;
213213 newpal->flags = dwFlags;
Index: ddraw/glDirectDrawSurface.cpp
@@ -374,7 +374,7 @@
375375 if(bitmapinfo) free(bitmapinfo);
376376 if(palette) glDirectDrawPalette_Release(palette);
377377 if(backbuffer) backbuffer->Release();
378 - if(clipper) clipper->Release();
 378+ if(clipper) glDirectDrawClipper_Release(clipper);
379379 if(buffer) free(buffer);
380380 if(bigbuffer) free(bigbuffer);
381381 if(zbuffer) zbuffer->Release();
@@ -1170,9 +1170,9 @@
11711171 {
11721172 TRACE_ENTER(2,14,this,14,lpDDClipper);
11731173 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
1174 - if(clipper) clipper->Release();
 1174+ if(clipper) glDirectDrawClipper_Release(clipper);
11751175 clipper = (glDirectDrawClipper *)lpDDClipper;
1176 - if(clipper)clipper->AddRef();
 1176+ if(clipper) glDirectDrawClipper_AddRef(clipper);
11771177 TRACE_EXIT(23,DD_OK);
11781178 return DD_OK;
11791179 }
Index: ddraw/glDirectDrawSurface.h
@@ -27,7 +27,7 @@
2828 } CKEY;
2929
3030 class glDirectDraw7;
31 -class glDirectDrawClipper;
 31+struct glDirectDrawClipper;
3232 struct glDirectDrawPalette;
3333 class glDirectDrawSurface1;
3434 class glDirectDrawSurface2;