DXGL r351 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r350‎ | r351 | r352 >
Date:23:20, 17 March 2013
Author:admin
Status:new
Tags:
Comment:
Trace glDirect3DMaterial.cpp
Modified paths:
  • /ddraw/glDirect3DMaterial.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DMaterial.cpp
@@ -23,6 +23,7 @@
2424
2525 glDirect3DMaterial3::glDirect3DMaterial3()
2626 {
 27+ TRACE_ENTER(1,14,this);
2728 device = NULL;
2829 current = FALSE;
2930 refcount = 1;
@@ -36,27 +37,35 @@
3738 handle = 0;
3839 glD3DM2 = NULL;
3940 glD3DM1 = NULL;
 41+ TRACE_EXIT(-1,0);
4042 }
4143
4244 glDirect3DMaterial3::~glDirect3DMaterial3()
4345 {
 46+ TRACE_ENTER(1,14,this);
4447 if(device) device->Release();
 48+ TRACE_EXIT(-1,0);
4549 }
4650
4751 HRESULT WINAPI glDirect3DMaterial3::QueryInterface(REFIID riid, void** ppvObj)
4852 {
49 - if(!this) return DDERR_INVALIDOBJECT;
 53+ TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
 54+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
5055 if(riid == IID_IUnknown)
5156 {
5257 this->AddRef();
5358 *ppvObj = this;
54 - return DD_OK;
 59+ TRACE_VAR("*ppvObj",14,*ppvObj);
 60+ TRACE_EXIT(23,D3D_OK);
 61+ return D3D_OK;
5562 }
5663 if(riid == IID_IDirect3DMaterial3)
5764 {
5865 this->AddRef();
5966 *ppvObj = this;
60 - return DD_OK;
 67+ TRACE_VAR("*ppvObj",14,*ppvObj);
 68+ TRACE_EXIT(23,D3D_OK);
 69+ return D3D_OK;
6170 }
6271 if(riid == IID_IDirect3DMaterial2)
6372 {
@@ -64,6 +73,8 @@
6574 {
6675 *ppvObj = glD3DM2;
6776 glD3DM2->AddRef();
 77+ TRACE_VAR("*ppvObj",14,*ppvObj);
 78+ TRACE_EXIT(23,D3D_OK);
6879 return D3D_OK;
6980 }
7081 else
@@ -71,6 +82,8 @@
7283 this->AddRef();
7384 *ppvObj = new glDirect3DMaterial2(this);
7485 glD3DM2 = (glDirect3DMaterial2*)*ppvObj;
 86+ TRACE_VAR("*ppvObj",14,*ppvObj);
 87+ TRACE_EXIT(23,D3D_OK);
7588 return D3D_OK;
7689 }
7790 }
@@ -80,6 +93,8 @@
8194 {
8295 *ppvObj = glD3DM1;
8396 glD3DM1->AddRef();
 97+ TRACE_VAR("*ppvObj",14,*ppvObj);
 98+ TRACE_EXIT(23,D3D_OK);
8499 return D3D_OK;
85100 }
86101 else
@@ -87,80 +102,104 @@
88103 this->AddRef();
89104 *ppvObj = new glDirect3DMaterial1(this);
90105 glD3DM1 = (glDirect3DMaterial1*)*ppvObj;
 106+ TRACE_VAR("*ppvObj",14,*ppvObj);
 107+ TRACE_EXIT(23,D3D_OK);
91108 return D3D_OK;
92109 }
93110 }
 111+ TRACE_EXIT(23,E_NOINTERFACE);
94112 return E_NOINTERFACE;
95113 }
96114
97115 ULONG WINAPI glDirect3DMaterial3::AddRef()
98116 {
99 - if(!this) return 0;
 117+ TRACE_ENTER(1,14,this);
 118+ if(!this) TRACE_RET(8,0);
100119 refcount++;
 120+ TRACE_EXIT(8,refcount);
101121 return refcount;
102122 }
103123
104124 ULONG WINAPI glDirect3DMaterial3::Release()
105125 {
106 - if(!this) return 0;
 126+ if(!this) TRACE_RET(8,0);
107127 ULONG ret;
108128 refcount--;
109129 ret = refcount;
110130 if(refcount == 0) delete this;
 131+ TRACE_EXIT(8,ret);
111132 return ret;
112133 }
113134
114135 HRESULT WINAPI glDirect3DMaterial3::GetHandle(LPDIRECT3DDEVICE3 lpDirect3DDevice, LPD3DMATERIALHANDLE lpHandle)
115136 {
116 - if(!this) return DDERR_INVALIDOBJECT;
117 - if(!lpDirect3DDevice) return DDERR_INVALIDPARAMS;
 137+ TRACE_ENTER(3,14,this,14,lpDirect3DDevice,14,lpHandle);
 138+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 139+ if(!lpDirect3DDevice) TRACE_RET(23,DDERR_INVALIDPARAMS);
118140 glDirect3DDevice3 *dev3 = (glDirect3DDevice3*)lpDirect3DDevice;
119141 if(handle)
120142 {
121 - if(device != dev3->GetGLD3DDev7()) return DDERR_INVALIDOBJECT;
 143+ if(device != dev3->GetGLD3DDev7()) TRACE_RET(23,DDERR_INVALIDOBJECT);
122144 *lpHandle = handle;
 145+ TRACE_VAR("*lpHandle",9,*lpHandle);
 146+ TRACE_EXIT(23,D3D_OK);
123147 return D3D_OK;
124148 }
125149 device = dev3->GetGLD3DDev7();
126150 handle = device->AddMaterial(this);
127 - if(handle == -1) return DDERR_OUTOFMEMORY;
 151+ if(handle == -1) TRACE_RET(23,DDERR_OUTOFMEMORY);
128152 *lpHandle = handle;
 153+ TRACE_VAR("*lpHandle",9,*lpHandle);
 154+ TRACE_EXIT(23,D3D_OK);
129155 return D3D_OK;
130156 }
131157
132158 HRESULT WINAPI glDirect3DMaterial3::GetMaterial(LPD3DMATERIAL lpMat)
133159 {
134 - if(!this) return DDERR_INVALIDOBJECT;
135 - if(lpMat->dwSize < sizeof(D3DMATERIAL)) return DDERR_INVALIDPARAMS;
 160+ TRACE_ENTER(2,14,this,14,lpMat);
 161+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 162+ if(lpMat->dwSize < sizeof(D3DMATERIAL)) TRACE_RET(23,DDERR_INVALIDPARAMS);
136163 memcpy(lpMat,&material,sizeof(D3DMATERIAL));
 164+ TRACE_EXIT(23,D3D_OK);
137165 return D3D_OK;
138166 }
139167
140168 HRESULT WINAPI glDirect3DMaterial3::SetMaterial(LPD3DMATERIAL lpMat)
141169 {
142 - if(!this) return DDERR_INVALIDOBJECT;
143 - if(lpMat->dwSize != sizeof(D3DMATERIAL)) return DDERR_INVALIDPARAMS;
 170+ TRACE_ENTER(2,14,this,14,lpMat);
 171+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 172+ if(lpMat->dwSize != sizeof(D3DMATERIAL)) TRACE_RET(23,DDERR_INVALIDPARAMS);
144173 memcpy(&material,lpMat,sizeof(D3DMATERIAL));
145174 if(device && current) Sync();
 175+ TRACE_EXIT(23,D3D_OK);
146176 return D3D_OK;
147177 }
148178
149179 void glDirect3DMaterial3::unbind()
150180 {
 181+ TRACE_ENTER(1,14,this);
151182 device = NULL;
152183 current = false;
153184 handle = 0;
 185+ TRACE_EXIT(0,0);
154186 }
155187
156188 void glDirect3DMaterial3::SetCurrent(bool current)
157189 {
158 - if(this->current == current) return;
 190+ TRACE_ENTER(2,14,this,21,current);
 191+ if(this->current == current)
 192+ {
 193+ TRACE_EXIT(0,0);
 194+ return;
 195+ }
159196 this->current = current;
160197 if(current) Sync();
 198+ TRACE_EXIT(0,0);
161199 }
162200
163201 void glDirect3DMaterial3::Sync()
164202 {
 203+ TRACE_ENTER(1,14,this);
165204 D3DMATERIAL7 mat7;
166205 mat7.diffuse = material.diffuse;
167206 mat7.ambient = material.ambient;
@@ -168,151 +207,188 @@
169208 mat7.emissive = material.emissive;
170209 mat7.power = material.power;
171210 device->SetMaterial(&mat7);
 211+ TRACE_EXIT(0,0);
172212 }
173213
174214 glDirect3DMaterial2::glDirect3DMaterial2(glDirect3DMaterial3 *glD3DM3)
175215 {
 216+ TRACE_ENTER(2,14,this,14,glD3DM3);
176217 refcount = 1;
177218 this->glD3DM3 = glD3DM3;
 219+ TRACE_EXIT(-1,0);
178220 }
179221
180222 glDirect3DMaterial2::~glDirect3DMaterial2()
181223 {
 224+ TRACE_ENTER(1,14,this);
182225 glD3DM3->glD3DM2 = NULL;
183226 glD3DM3->Release();
 227+ TRACE_EXIT(-1,0);
184228 }
185229
186230 ULONG WINAPI glDirect3DMaterial2::AddRef()
187231 {
188 - if(!this) return 0;
 232+ TRACE_ENTER(1,14,this);
 233+ if(!this) TRACE_RET(8,0);
189234 refcount++;
 235+ TRACE_EXIT(8,refcount);
190236 return refcount;
191237 }
192238
193239 ULONG WINAPI glDirect3DMaterial2::Release()
194240 {
195 - if(!this) return 0;
 241+ TRACE_ENTER(1,14,this);
 242+ if(!this) TRACE_RET(8,0);
196243 ULONG ret;
197244 refcount--;
198245 ret = refcount;
199246 if(refcount == 0) delete this;
 247+ TRACE_EXIT(8,ret);
200248 return ret;
201249 }
202250
203251 HRESULT WINAPI glDirect3DMaterial2::QueryInterface(REFIID riid, void** ppvObj)
204252 {
205 - if(!this) return DDERR_INVALIDOBJECT;
 253+ TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
 254+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
206255 if(riid == IID_IUnknown)
207256 {
208257 this->AddRef();
209258 *ppvObj = this;
 259+ TRACE_VAR("*ppvObj",14,*ppvObj);
 260+ TRACE_EXIT(23,D3D_OK);
210261 return D3D_OK;
211262 }
212 - return glD3DM3->QueryInterface(riid,ppvObj);
 263+ TRACE_RET(23,glD3DM3->QueryInterface(riid,ppvObj));
213264 }
214265
215266 HRESULT WINAPI glDirect3DMaterial2::GetHandle(LPDIRECT3DDEVICE2 lpDirect3DDevice, LPD3DMATERIALHANDLE lpHandle)
216267 {
217 - if(!this) return DDERR_INVALIDOBJECT;
218 - if(!lpDirect3DDevice) return DDERR_INVALIDPARAMS;
 268+ TRACE_ENTER(3,14,this,14,lpDirect3DDevice,14,lpHandle);
 269+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 270+ if(!lpDirect3DDevice) TRACE_RET(23,DDERR_INVALIDPARAMS);
219271 glDirect3DDevice2 *glD3DDev2 = (glDirect3DDevice2*)lpDirect3DDevice;
220272 glDirect3DDevice3 *glD3DDev3;
221273 glD3DDev2->QueryInterface(IID_IDirect3DDevice3,(void**)&glD3DDev3);
222274 HRESULT ret = glD3DM3->GetHandle(glD3DDev3,lpHandle);
223275 glD3DDev3->Release();
 276+ TRACE_EXIT(23,ret);
224277 return ret;
225278 }
226279
227280 HRESULT WINAPI glDirect3DMaterial2::GetMaterial(LPD3DMATERIAL lpMat)
228281 {
229 - if(!this) return DDERR_INVALIDOBJECT;
230 - return glD3DM3->GetMaterial(lpMat);
 282+ TRACE_ENTER(2,14,this,14,lpMat);
 283+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 284+ TRACE_RET(23,glD3DM3->GetMaterial(lpMat));
231285 }
232286 HRESULT WINAPI glDirect3DMaterial2::SetMaterial(LPD3DMATERIAL lpMat)
233287 {
234 - if(!this) return DDERR_INVALIDOBJECT;
235 - return glD3DM3->SetMaterial(lpMat);
 288+ TRACE_ENTER(2,14,this,14,lpMat);
 289+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 290+ TRACE_RET(23,glD3DM3->SetMaterial(lpMat));
236291 }
237292
238293 glDirect3DMaterial1::glDirect3DMaterial1(glDirect3DMaterial3 *glD3DM3)
239294 {
 295+ TRACE_ENTER(2,14,this,14,glD3DM3);
240296 refcount = 1;
241297 this->glD3DM3 = glD3DM3;
 298+ TRACE_EXIT(-1,0);
242299 }
243300
244301 glDirect3DMaterial1::~glDirect3DMaterial1()
245302 {
 303+ TRACE_ENTER(1,14,this);
246304 glD3DM3->glD3DM1 = NULL;
247305 glD3DM3->Release();
 306+ TRACE_EXIT(-1,0);
248307 }
249308
250309 ULONG WINAPI glDirect3DMaterial1::AddRef()
251310 {
252 - if(!this) return 0;
 311+ TRACE_ENTER(1,14,this);
 312+ if(!this) TRACE_RET(8,0);
253313 refcount++;
 314+ TRACE_EXIT(8,refcount);
254315 return refcount;
255316 }
256317
257318 ULONG WINAPI glDirect3DMaterial1::Release()
258319 {
259 - if(!this) return 0;
 320+ TRACE_ENTER(1,14,this);
 321+ if(!this) TRACE_RET(8,0);
260322 ULONG ret;
261323 refcount--;
262324 ret = refcount;
263325 if(refcount == 0) delete this;
 326+ TRACE_EXIT(8,ret);
264327 return ret;
265328 }
266329
267330 HRESULT WINAPI glDirect3DMaterial1::QueryInterface(REFIID riid, void** ppvObj)
268331 {
269 - if(!this) return DDERR_INVALIDOBJECT;
 332+ TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
 333+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
270334 if(riid == IID_IUnknown)
271335 {
272336 this->AddRef();
273337 *ppvObj = this;
 338+ TRACE_VAR("*ppvObj",14,*ppvObj);
 339+ TRACE_EXIT(23,D3D_OK);
274340 return D3D_OK;
275341 }
276 - return glD3DM3->QueryInterface(riid,ppvObj);
 342+ TRACE_RET(23,glD3DM3->QueryInterface(riid,ppvObj));
277343 }
278344
279345 HRESULT WINAPI glDirect3DMaterial1::GetHandle(LPDIRECT3DDEVICE lpDirect3DDevice, LPD3DMATERIALHANDLE lpHandle)
280346 {
281 - if(!this) return DDERR_INVALIDOBJECT;
282 - if(!lpDirect3DDevice) return DDERR_INVALIDPARAMS;
 347+ TRACE_ENTER(3,14,this,14,lpDirect3DDevice,14,lpHandle);
 348+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 349+ if(!lpDirect3DDevice) TRACE_RET(23,DDERR_INVALIDPARAMS);
283350 glDirect3DDevice1 *glD3DDev1 = (glDirect3DDevice1*)lpDirect3DDevice;
284351 glDirect3DDevice3 *glD3DDev3;
285352 glD3DDev1->QueryInterface(IID_IDirect3DDevice3,(void**)&glD3DDev3);
286353 HRESULT ret = glD3DM3->GetHandle(glD3DDev3,lpHandle);
287354 glD3DDev3->Release();
 355+ TRACE_EXIT(23,ret);
288356 return ret;
289357 }
290358
291359 HRESULT WINAPI glDirect3DMaterial1::GetMaterial(LPD3DMATERIAL lpMat)
292360 {
293 - if(!this) return DDERR_INVALIDOBJECT;
294 - return glD3DM3->GetMaterial(lpMat);
 361+ TRACE_ENTER(2,14,this,14,lpMat);
 362+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 363+ TRACE_RET(23,glD3DM3->GetMaterial(lpMat));
295364 }
296365
297366 HRESULT WINAPI glDirect3DMaterial1::Initialize(LPDIRECT3D lpDirect3D)
298367 {
299 - if(!this) return DDERR_INVALIDOBJECT;
 368+ TRACE_ENTER(2,14,this,14,lpDirect3D);
 369+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 370+ TRACE_EXIT(23,DDERR_ALREADYINITIALIZED);
300371 return DDERR_ALREADYINITIALIZED;
301372 }
302373
303374 HRESULT WINAPI glDirect3DMaterial1::Reserve()
304375 {
305 - if(!this) return DDERR_INVALIDPARAMS;
 376+ TRACE_ENTER(1,14,this);
 377+ if(!this) TRACE_RET(23,DDERR_INVALIDPARAMS);
 378+ TRACE_EXIT(23,DDERR_UNSUPPORTED);
306379 return DDERR_UNSUPPORTED;
307380 }
308381
309382 HRESULT WINAPI glDirect3DMaterial1::SetMaterial(LPD3DMATERIAL lpMat)
310383 {
311 - if(!this) return DDERR_INVALIDOBJECT;
312 - return glD3DM3->SetMaterial(lpMat);
 384+ TRACE_ENTER(2,14,this,14,lpMat);
 385+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 386+ TRACE_RET(23,glD3DM3->SetMaterial(lpMat));
313387 }
314388
315389 HRESULT WINAPI glDirect3DMaterial1::Unreserve()
316390 {
317 - if(!this) return DDERR_INVALIDPARAMS;
 391+ TRACE_ENTER(1,14,this);
 392+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 393+ TRACE_EXIT(23,DDERR_UNSUPPORTED);
318394 return DDERR_UNSUPPORTED;
319395 }