DXGL r346 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r345‎ | r346 | r347 >
Date:21:51, 10 March 2013
Author:admin
Status:new
Tags:
Comment:
Trace glDirectDrawPalette.cpp and fix invalid object return values.
Fix IDirectDrawPalette::GetCaps
Modified paths:
  • /ddraw/glDirectDrawPalette.cpp (modified) (history)
  • /ddraw/glDirectDrawPalette.h (modified) (history)

Diff [purge]

Index: ddraw/glDirectDrawPalette.cpp
@@ -90,6 +90,7 @@
9191
9292 glDirectDrawPalette::glDirectDrawPalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette)
9393 {
 94+ TRACE_ENTER(4,14,this,9,dwFlags,14,lpDDColorArray,14,lplpDDPalette);
9495 refcount = 1;
9596 flags = dwFlags;
9697 if(lpDDColorArray == NULL) memcpy(palette,DefaultPalette,1024);
@@ -107,51 +108,67 @@
108109 else memcpy(palette,lpDDColorArray,256*sizeof(PALETTEENTRY));
109110 }
110111 if(lplpDDPalette) *lplpDDPalette = this;
 112+ TRACE_EXIT(-1,0);
111113 }
112114
113115 glDirectDrawPalette::~glDirectDrawPalette()
114116 {
 117+ TRACE_ENTER(1,14,this);
 118+ TRACE_EXIT(-1,0);
115119 }
116120
117121 HRESULT WINAPI glDirectDrawPalette::QueryInterface(REFIID riid, void** ppvObj)
118122 {
119 - if(!this) return DDERR_INVALIDPARAMS;
120 - if(!ppvObj) return DDERR_INVALIDPARAMS;
 123+ TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
 124+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 125+ if(!ppvObj) TRACE_RET(23,DDERR_INVALIDPARAMS);
121126 if(riid == IID_IUnknown)
122127 {
123128 this->AddRef();
124129 *ppvObj = this;
 130+ TRACE_VAR("*ppvObj",14,*ppvObj);
 131+ TRACE_EXIT(23,DD_OK);
125132 return DD_OK;
126133 }
 134+ TRACE_EXIT(23,E_NOINTERFACE);
127135 ERR(E_NOINTERFACE);
128136 }
129137
130138 ULONG WINAPI glDirectDrawPalette::AddRef()
131139 {
 140+ TRACE_ENTER(1,14,this);
132141 if(!this) return 0;
133142 refcount++;
 143+ TRACE_EXIT(8,refcount);
134144 return refcount;
135145 }
136146
137147 ULONG WINAPI glDirectDrawPalette::Release()
138148 {
 149+ TRACE_ENTER(1,14,this);
139150 if(!this) return 0;
140151 ULONG ret;
141152 refcount--;
142153 ret = refcount;
143154 if(refcount == 0) delete this;
 155+ TRACE_EXIT(8,ret);
144156 return ret;
145157 }
146158
147159 HRESULT WINAPI glDirectDrawPalette::GetCaps(LPDWORD lpdwCaps)
148160 {
149 - if(!this) return DDERR_INVALIDPARAMS;
150 - return flags;
 161+ TRACE_ENTER(2,14,this,14,lpdwCaps);
 162+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 163+ *lpdwCaps = flags;
 164+ TRACE_VAR("*lpdwCaps",9,*lpdwCaps);
 165+ TRACE_EXIT(23,DD_OK);
 166+ return DD_OK;
151167 }
152168
153169 HRESULT WINAPI glDirectDrawPalette::GetEntries(DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries)
154170 {
155 - if(!this) return DDERR_INVALIDPARAMS;
 171+ TRACE_ENTER(5,14,this,9,dwFlags,8,dwBase,8,dwNumEntries,14,lpEntries);
 172+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
156173 DWORD allentries = 256;
157174 DWORD entrysize;
158175 if(flags & DDPCAPS_1BIT) allentries=2;
@@ -160,18 +177,22 @@
161178 if(flags & DDPCAPS_8BIT) allentries=256;
162179 if(flags & DDPCAPS_8BITENTRIES) entrysize = 1;
163180 else entrysize = sizeof(PALETTEENTRY);
164 - if((dwBase + dwNumEntries) > allentries) ERR(DDERR_INVALIDPARAMS);
 181+ if((dwBase + dwNumEntries) > allentries) TRACE_RET(23,DDERR_INVALIDPARAMS);
165182 memcpy(lpEntries,((char *)palette)+(dwBase*entrysize),dwNumEntries*entrysize);
 183+ TRACE_EXIT(23,DD_OK);
166184 return DD_OK;
167185 }
168186 HRESULT WINAPI glDirectDrawPalette::Initialize(LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable)
169187 {
170 - if(!this) return DDERR_INVALIDPARAMS;
 188+ TRACE_ENTER(4,14,this,14,lpDD,9,dwFlags,14,lpDDColorTable);
 189+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 190+ TRACE_EXIT(23,DDERR_ALREADYINITIALIZED);
171191 return DDERR_ALREADYINITIALIZED;
172192 }
173193 HRESULT WINAPI glDirectDrawPalette::SetEntries(DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries)
174194 {
175 - if(!this) return DDERR_INVALIDPARAMS;
 195+ TRACE_ENTER(5,14,this,9,dwFlags,8,dwStartingEntry,8,dwCount,14,lpEntries);
 196+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
176197 DWORD allentries = 256;
177198 DWORD entrysize;
178199 if(flags & DDPCAPS_1BIT) allentries=2;
@@ -180,13 +201,20 @@
181202 if(flags & DDPCAPS_8BIT) allentries=256;
182203 if(flags & DDPCAPS_8BITENTRIES) entrysize = 1;
183204 else entrysize = sizeof(PALETTEENTRY);
184 - if((dwStartingEntry + dwCount) > allentries) ERR(DDERR_INVALIDPARAMS);
 205+ if((dwStartingEntry + dwCount) > allentries) TRACE_RET(23,DDERR_INVALIDPARAMS);
185206 memcpy(((char *)palette)+(dwStartingEntry*entrysize),lpEntries,dwCount*entrysize);
 207+ TRACE_EXIT(23,DD_OK);
186208 return DD_OK;
187209 }
188210
189211 LPPALETTEENTRY glDirectDrawPalette::GetPalette(DWORD *flags)
190212 {
191 - if(flags) *flags = this->flags;
 213+ TRACE_ENTER(2,14,this,14,flags);
 214+ if(flags)
 215+ {
 216+ *flags = this->flags;
 217+ TRACE_VAR("*flags",9,*flags);
 218+ }
 219+ TRACE_RET(14,palette);
192220 return palette;
193221 }
Index: ddraw/glDirectDrawPalette.h
@@ -34,7 +34,7 @@
3535 HRESULT WINAPI SetEntries(DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries);
3636
3737 // Internal function
38 - LPPALETTEENTRY GetPalette(DWORD *flags);
 38+ //LPPALETTEENTRY GetPalette(DWORD *flags);
3939 private:
4040 PALETTEENTRY palette[256];
4141 DWORD flags;

Follow-up revisions

RevisionCommit summaryAuthorDate
r347Revert accidentally commented out function in r346....admin14:55, 16 March 2013