DXGL r531 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r530‎ | r531 | r532 >
Date:12:45, 13 September 2014
Author:admin
Status:new
Tags:
Comment:
Add IDirectDrawGammaControl interface and stub functions.
Modified paths:
  • /ddraw/ddraw.vcxproj (modified) (history)
  • /ddraw/ddraw.vcxproj.filters (modified) (history)
  • /ddraw/glDirectDrawGammaControl.cpp (added) (history)
  • /ddraw/glDirectDrawGammaControl.h (added) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.h (modified) (history)

Diff [purge]

Index: ddraw/ddraw.vcxproj
@@ -278,6 +278,7 @@
279279 <ClInclude Include="glDirect3DViewport.h" />
280280 <ClInclude Include="glDirectDraw.h" />
281281 <ClInclude Include="glDirectDrawClipper.h" />
 282+ <ClInclude Include="glDirectDrawGammaControl.h" />
282283 <ClInclude Include="glDirectDrawPalette.h" />
283284 <ClInclude Include="glDirectDrawSurface.h" />
284285 <ClInclude Include="glExtensions.h" />
@@ -344,6 +345,7 @@
345346 <ClCompile Include="glDirect3DViewport.cpp" />
346347 <ClCompile Include="glDirectDraw.cpp" />
347348 <ClCompile Include="glDirectDrawClipper.cpp" />
 349+ <ClCompile Include="glDirectDrawGammaControl.cpp" />
348350 <ClCompile Include="glDirectDrawPalette.c">
349351 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Trace|Win32'">NotUsing</PrecompiledHeader>
350352 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">NotUsing</PrecompiledHeader>
Index: ddraw/ddraw.vcxproj.filters
@@ -140,6 +140,9 @@
141141 <ClInclude Include="ShaderGen2D.h">
142142 <Filter>Header Files</Filter>
143143 </ClInclude>
 144+ <ClInclude Include="glDirectDrawGammaControl.h">
 145+ <Filter>Header Files</Filter>
 146+ </ClInclude>
144147 </ItemGroup>
145148 <ItemGroup>
146149 <ClCompile Include="ddraw.cpp">
@@ -235,6 +238,9 @@
236239 <ClCompile Include="scalers.c">
237240 <Filter>Source Files</Filter>
238241 </ClCompile>
 242+ <ClCompile Include="glDirectDrawGammaControl.cpp">
 243+ <Filter>Source Files</Filter>
 244+ </ClCompile>
239245 </ItemGroup>
240246 <ItemGroup>
241247 <ResourceCompile Include="ddraw.rc">
Index: ddraw/glDirectDrawGammaControl.cpp
@@ -0,0 +1,90 @@
 2+// DXGL
 3+// Copyright (C) 2011-2014 William Feely
 4+
 5+// This library is free software; you can redistribute it and/or
 6+// modify it under the terms of the GNU Lesser General Public
 7+// License as published by the Free Software Foundation; either
 8+// version 2.1 of the License, or (at your option) any later version.
 9+
 10+// This library is distributed in the hope that it will be useful,
 11+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13+// Lesser General Public License for more details.
 14+
 15+// You should have received a copy of the GNU Lesser General Public
 16+// License along with this library; if not, write to the Free Software
 17+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 18+
 19+#include "common.h"
 20+#include "TextureManager.h"
 21+#include "glUtil.h"
 22+#include "glDirectDrawSurface.h"
 23+#include "glDirectDrawGammaControl.h"
 24+
 25+extern "C" {
 26+
 27+glDirectDrawGammaControlVtbl glDirectDrawGammaControl_iface =
 28+{
 29+ glDirectDrawGammaControl_QueryInterface,
 30+ glDirectDrawGammaControl_AddRef,
 31+ glDirectDrawGammaControl_Release,
 32+ glDirectDrawGammaControl_GetGammaRamp,
 33+ glDirectDrawGammaControl_SetGammaRamp
 34+};
 35+
 36+HRESULT glDirectDrawGammaControl_Create(glDirectDrawSurface7 *glDDS7, LPDIRECTDRAWGAMMACONTROL *gamma)
 37+{
 38+ glDirectDrawGammaControl *newgamma;
 39+ TRACE_ENTER(2, 14, glDDS7, 14, gamma);
 40+ if (!glDDS7) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 41+ if (!gamma) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 42+ newgamma = (glDirectDrawGammaControl*)malloc(sizeof(glDirectDrawGammaControl));
 43+ if (!newgamma) TRACE_RET(HRESULT, 23, DDERR_OUTOFMEMORY);
 44+ ZeroMemory(newgamma, sizeof(glDirectDrawGammaControl));
 45+ newgamma->glDDS7 = glDDS7;
 46+ newgamma->lpVtbl = &glDirectDrawGammaControl_iface;
 47+ *gamma = (LPDIRECTDRAWGAMMACONTROL)newgamma;
 48+ TRACE_EXIT(23, DD_OK);
 49+ return DD_OK;
 50+}
 51+
 52+HRESULT WINAPI glDirectDrawGammaControl_QueryInterface(glDirectDrawGammaControl *This, REFIID riid, void** ppvObj)
 53+{
 54+ TRACE_ENTER(3, 14, This, 24, &riid, 14, ppvObj);
 55+ if (!This) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
 56+ if (riid == IID_IUnknown)
 57+ {
 58+ glDirectDrawGammaControl_AddRef(This);
 59+ *ppvObj = This;
 60+ TRACE_VAR("*ppvObj", 14, *ppvObj);
 61+ TRACE_EXIT(23, DD_OK);
 62+ return DD_OK;
 63+ }
 64+ TRACE_RET(HRESULT, 23, This->glDDS7->QueryInterface(riid, ppvObj));
 65+}
 66+ULONG WINAPI glDirectDrawGammaControl_AddRef(glDirectDrawGammaControl *This)
 67+{
 68+ TRACE_ENTER(1, 14, This);
 69+ if (!This) TRACE_RET(ULONG, 8, 0);
 70+ TRACE_RET(ULONG, 8, This->glDDS7->AddRefGamma());
 71+}
 72+ULONG WINAPI glDirectDrawGammaControl_Release(glDirectDrawGammaControl *This)
 73+{
 74+ TRACE_ENTER(1, 14, This);
 75+ if (!This) TRACE_RET(ULONG, 8, 0);
 76+ TRACE_RET(ULONG, 8, This->glDDS7->ReleaseGamma());
 77+}
 78+HRESULT WINAPI glDirectDrawGammaControl_GetGammaRamp(glDirectDrawGammaControl *This, DWORD dwFlags, LPDDGAMMARAMP lpRampData)
 79+{
 80+ TRACE_ENTER(3, 14, This, 9, dwFlags, 14, lpRampData);
 81+ if (!This) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
 82+ TRACE_RET(HRESULT, 23, This->glDDS7->GetGammaRamp(dwFlags, lpRampData));
 83+}
 84+HRESULT WINAPI glDirectDrawGammaControl_SetGammaRamp(glDirectDrawGammaControl *This, DWORD dwFlags, LPDDGAMMARAMP lpRampData)
 85+{
 86+ TRACE_ENTER(3, 14, This, 9, dwFlags, 14, lpRampData);
 87+ if (!This) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
 88+ TRACE_RET(HRESULT, 23, This->glDDS7->SetGammaRamp(dwFlags, lpRampData));
 89+}
 90+
 91+}
\ No newline at end of file
Index: ddraw/glDirectDrawGammaControl.h
@@ -0,0 +1,57 @@
 2+// DXGL
 3+// Copyright (C) 2014 William Feely
 4+
 5+// This library is free software; you can redistribute it and/or
 6+// modify it under the terms of the GNU Lesser General Public
 7+// License as published by the Free Software Foundation; either
 8+// version 2.1 of the License, or (at your option) any later version.
 9+
 10+// This library is distributed in the hope that it will be useful,
 11+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13+// Lesser General Public License for more details.
 14+
 15+// You should have received a copy of the GNU Lesser General Public
 16+// License along with this library; if not, write to the Free Software
 17+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 18+
 19+#pragma once
 20+#ifndef _GLDIRECTDRAWGAMMACONTROL_H
 21+#define _GLDIRECTDRAWGAMMACONTROL_H
 22+
 23+#ifdef __cplusplus
 24+extern "C" {
 25+#endif
 26+
 27+class glDirectDrawSurface7;
 28+struct glDirectDrawGammaControlVtbl;
 29+
 30+typedef struct glDirectDrawGammaControl
 31+{
 32+ glDirectDrawGammaControlVtbl *lpVtbl;
 33+ glDirectDrawSurface7 *glDDS7;
 34+} glDirectDrawGammaControl;
 35+
 36+typedef struct glDirectDrawGammaControlVtbl
 37+{
 38+ HRESULT(WINAPI *QueryInterface)(glDirectDrawGammaControl *This, REFIID riid, void** ppvObj);
 39+ ULONG(WINAPI *AddRef)(glDirectDrawGammaControl *This);
 40+ ULONG(WINAPI *Release)(glDirectDrawGammaControl *This);
 41+ HRESULT(WINAPI *GetGammaRamp)(glDirectDrawGammaControl *This, DWORD dwFlags, LPDDGAMMARAMP lpRampData);
 42+ HRESULT(WINAPI *SetGammaRamp)(glDirectDrawGammaControl *This, DWORD dwFlags, LPDDGAMMARAMP lpRampData);
 43+} glDirectDrawGammaControlVtbl;
 44+
 45+HRESULT glDirectDrawGammaControl_Create(glDirectDrawSurface7 *glDDS7, LPDIRECTDRAWGAMMACONTROL *gamma);
 46+
 47+HRESULT WINAPI glDirectDrawGammaControl_QueryInterface(glDirectDrawGammaControl *This, REFIID riid, void** ppvObj);
 48+ULONG WINAPI glDirectDrawGammaControl_AddRef(glDirectDrawGammaControl *This);
 49+ULONG WINAPI glDirectDrawGammaControl_Release(glDirectDrawGammaControl *This);
 50+HRESULT WINAPI glDirectDrawGammaControl_GetGammaRamp(glDirectDrawGammaControl *This, DWORD dwFlags, LPDDGAMMARAMP lpRampData);
 51+HRESULT WINAPI glDirectDrawGammaControl_SetGammaRamp(glDirectDrawGammaControl *This, DWORD dwFlags, LPDDGAMMARAMP lpRampData);
 52+
 53+
 54+#ifdef __cplusplus
 55+}
 56+#endif
 57+
 58+#endif //_GLDIRECTDRAWGAMMACONTROL_H
\ No newline at end of file
Index: ddraw/glDirectDrawSurface.cpp
@@ -29,6 +29,7 @@
3030 #include "glDirect3DTexture.h"
3131 #include "glDirectDrawPalette.h"
3232 #include "glDirectDrawClipper.h"
 33+#include "glDirectDrawGammaControl.h"
3334 #include "glRenderer.h"
3435 #include <string>
3536 using namespace std;
@@ -66,6 +67,7 @@
6768 dds4 = new glDirectDrawSurface4(this);
6869 d3dt2 = new glDirect3DTexture2(this);
6970 d3dt1 = new glDirect3DTexture1(this);
 71+ glDirectDrawGammaControl_Create(this, (LPDIRECTDRAWGAMMACONTROL*)&gammacontrol);
7072 buffer = gdibuffer = NULL;
7173 bigbuffer = NULL;
7274 zbuffer = NULL;
@@ -396,6 +398,7 @@
397399 if (dds4) delete dds4;
398400 if (d3dt1) delete d3dt1;
399401 if (d3dt2) delete d3dt2;
 402+ if (gammacontrol) free(gammacontrol);
400403 if(paltex)
401404 {
402405 glRenderer_DeleteTexture(ddInterface->renderer, paltex);
@@ -489,9 +492,11 @@
490493 }
491494 if (riid == IID_IDirectDrawGammaControl)
492495 {
493 - FIXME("Add gamma control\n");
494 - TRACE_EXIT(23, E_NOINTERFACE);
495 - ERR(E_NOINTERFACE);
 496+ this->AddRefGamma();
 497+ *ppvObj = gammacontrol;
 498+ TRACE_VAR("*ppvObj",14,*ppvObj);
 499+ TRACE_EXIT(23,DD_OK);
 500+ return DD_OK;
496501 }
497502 if (riid == IID_IDirectDrawColorControl)
498503 {
@@ -1726,7 +1731,24 @@
17271732 return D3D_OK;
17281733 }
17291734
 1735+HRESULT glDirectDrawSurface7::GetGammaRamp(DWORD dwFlags, LPDDGAMMARAMP lpRampData)
 1736+{
 1737+ TRACE_ENTER(3, 14, this, 9, dwFlags, 14, lpRampData);
 1738+ if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
 1739+ FIXME("glDirectDrawSurface7::GetGammaRamp: stub\n");
 1740+ TRACE_EXIT(23, DDERR_GENERIC);
 1741+ ERR(DDERR_GENERIC);
 1742+}
17301743
 1744+HRESULT glDirectDrawSurface7::SetGammaRamp(DWORD dwFlags, LPDDGAMMARAMP lpRampData)
 1745+{
 1746+ TRACE_ENTER(3, 14, this, 9, dwFlags, 14, lpRampData);
 1747+ if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
 1748+ FIXME("glDirectDrawSurface7::SetGammaRamp: stub\n");
 1749+ TRACE_EXIT(23, DDERR_GENERIC);
 1750+ ERR(DDERR_GENERIC);
 1751+}
 1752+
17311753 // DDRAW1 wrapper
17321754 glDirectDrawSurface1::glDirectDrawSurface1(glDirectDrawSurface7 *gl_DDS7)
17331755 {
Index: ddraw/glDirectDrawSurface.h
@@ -36,6 +36,7 @@
3737 class glDirect3DTexture2;
3838 class glDirect3DTexture1;
3939 class glDirect3DDevice7;
 40+struct glDirectDrawGammaControl;
4041 class glDirectDrawSurface7 : public IDirectDrawSurface7
4142 {
4243 public:
@@ -123,6 +124,8 @@
124125 HRESULT WINAPI Unlock2(LPVOID lpSurfaceData);
125126 HRESULT GetHandle(glDirect3DDevice7 *glD3DDev7, LPD3DTEXTUREHANDLE lpHandle);
126127 HRESULT Load(glDirectDrawSurface7 *src);
 128+ HRESULT GetGammaRamp(DWORD dwFlags, LPDDGAMMARAMP lpRampData);
 129+ HRESULT SetGammaRamp(DWORD dwFlags, LPDDGAMMARAMP lpRampData);
127130 glDirectDrawSurface1 *dds1;
128131 glDirectDrawSurface2 *dds2;
129132 glDirectDrawSurface3 *dds3;
@@ -129,6 +132,7 @@
130133 glDirectDrawSurface4 *dds4;
131134 glDirect3DTexture2 *d3dt2;
132135 glDirect3DTexture1 *d3dt1;
 136+ glDirectDrawGammaControl *gammacontrol;
133137 DWORD flipcount;
134138 DWORD fakex,fakey;
135139 float mulx, muly;