wined3d: Const correctness fixes.

Henri Verbeet hverbeet at codeweavers.com
Mon Dec 1 08:32:15 CST 2008


---
 dlls/wined3d/device.c          |   11 +++++++++--
 dlls/wined3d/pixelshader.c     |    6 ++++--
 dlls/wined3d/stateblock.c      |    9 +++------
 dlls/wined3d/surface_gdi.c     |    4 ++--
 dlls/wined3d/swapchain_gdi.c   |    3 ++-
 dlls/wined3d/utils.c           |    6 +++---
 dlls/wined3d/vertexbuffer.c    |   12 +++++++-----
 dlls/wined3d/vertexshader.c    |   10 ++++------
 dlls/wined3d/wined3d_private.h |   17 +++++++----------
 include/wine/wined3d.idl       |    4 ++--
 10 files changed, 43 insertions(+), 39 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index e73a4f6..7c7f644 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5407,7 +5407,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided (IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, WineDirect3DVertexStridedData *DrawPrimStrideData) {
+static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided(IWineD3DDevice *iface,
+        WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount,
+        const WineDirect3DVertexStridedData *DrawPrimStrideData)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
 
     /* Mark the state dirty until we have nicer tracking
@@ -5423,7 +5426,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided (IWineD3DDevice *i
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, WineDirect3DVertexStridedData *DrawPrimStrideData, UINT NumVertices, CONST void *pIndexData, WINED3DFORMAT IndexDataFormat) {
+static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDevice *iface,
+        WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount,
+        const WineDirect3DVertexStridedData *DrawPrimStrideData, UINT NumVertices, const void *pIndexData,
+        WINED3DFORMAT IndexDataFormat)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     DWORD idxSize = (IndexDataFormat == WINED3DFMT_INDEX32 ? 4 : 2);
 
diff --git a/dlls/wined3d/pixelshader.c b/dlls/wined3d/pixelshader.c
index 7b2f639..153e72d 100644
--- a/dlls/wined3d/pixelshader.c
+++ b/dlls/wined3d/pixelshader.c
@@ -368,7 +368,8 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *i
     return WINED3D_OK;
 }
 
-GLuint pixelshader_compile(IWineD3DPixelShaderImpl *This, struct ps_compile_args *args) {
+static GLuint pixelshader_compile(IWineD3DPixelShaderImpl *This, const struct ps_compile_args *args)
+{
     CONST DWORD *function = This->baseShader.function;
     HRESULT hr;
     GLuint retval;
@@ -457,7 +458,8 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImp
     }
 }
 
-GLuint find_gl_pshader(IWineD3DPixelShaderImpl *shader, struct ps_compile_args *args) {
+GLuint find_gl_pshader(IWineD3DPixelShaderImpl *shader, const struct ps_compile_args *args)
+{
     UINT i;
     struct ps_compiled_shader *old_array;
 
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 0d99134..b260f68 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -63,11 +63,8 @@ HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) {
 }
 
 /** Copy all members of one stateblock to another */
-void stateblock_savedstates_copy(
-    IWineD3DStateBlock* iface,
-    SAVEDSTATES* dest,
-    SAVEDSTATES* source) {
-    
+void stateblock_savedstates_copy(IWineD3DStateBlock* iface, SAVEDSTATES *dest, const SAVEDSTATES *source)
+{
     IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
     unsigned bsize = sizeof(BOOL);
 
@@ -710,7 +707,7 @@ static inline void apply_lights(IWineD3DDevice *pDevice, IWineD3DStateBlockImpl
         struct list *e;
 
         LIST_FOR_EACH(e, &This->lightMap[i]) {
-            PLIGHTINFOEL *light = LIST_ENTRY(e, PLIGHTINFOEL, entry);
+            const PLIGHTINFOEL *light = LIST_ENTRY(e, PLIGHTINFOEL, entry);
 
             if(light->changed) {
                 IWineD3DDevice_SetLight(pDevice, light->OriginalIndex, &light->OriginalParms);
diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c
index 6266366..fbe881e 100644
--- a/dlls/wined3d/surface_gdi.c
+++ b/dlls/wined3d/surface_gdi.c
@@ -340,7 +340,7 @@ const char* filename)
         alpha_shift = get_shift(formatEntry->alphaMask);
 
         for (y = 0; y < This->pow2Height; y++) {
-            unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface));
+            const unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface));
             for (x = 0; x < This->pow2Width; x++) {	    
                 unsigned int color;
                 unsigned int comp;
@@ -405,7 +405,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
     if(This->resource.format == WINED3DFMT_P8 ||
        This->resource.format == WINED3DFMT_A8P8) {
         unsigned int n;
-        PALETTEENTRY *pal = NULL;
+        const PALETTEENTRY *pal = NULL;
 
         if(This->palette) {
             pal = This->palette->palents;
diff --git a/dlls/wined3d/swapchain_gdi.c b/dlls/wined3d/swapchain_gdi.c
index f634e50..63bbf60 100644
--- a/dlls/wined3d/swapchain_gdi.c
+++ b/dlls/wined3d/swapchain_gdi.c
@@ -80,7 +80,8 @@ static void WINAPI IWineGDISwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB
  *  rc: Rectangle to copy
  *
  *****************************************************************************/
-void x11_copy_to_screen(IWineD3DSwapChainImpl *This, LPRECT rc) {
+void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc)
+{
     IWineD3DSurfaceImpl *front = (IWineD3DSurfaceImpl *) This->frontBuffer;
 
     if(front->resource.usage & WINED3DUSAGE_RENDERTARGET) {
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 151e5ba..e2dd859 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -1623,7 +1623,7 @@ void hash_table_destroy(struct hash_table_t *table, void (*free_value)(void *val
     HeapFree(GetProcessHeap(), 0, table);
 }
 
-static inline struct hash_table_entry_t *hash_table_get_by_idx(struct hash_table_t *table, const void *key,
+static inline struct hash_table_entry_t *hash_table_get_by_idx(const struct hash_table_t *table, const void *key,
         unsigned int idx)
 {
     struct hash_table_entry_t *entry;
@@ -1772,7 +1772,7 @@ void hash_table_remove(struct hash_table_t *table, void *key)
     hash_table_put(table, key, NULL);
 }
 
-void *hash_table_get(struct hash_table_t *table, const void *key)
+void *hash_table_get(const struct hash_table_t *table, const void *key)
 {
     unsigned int idx;
     struct hash_table_entry_t *entry;
@@ -2004,7 +2004,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
 }
 #undef GLINFO_LOCATION
 
-const struct ffp_frag_desc *find_ffp_frag_shader(struct hash_table_t *fragment_shaders,
+const struct ffp_frag_desc *find_ffp_frag_shader(const struct hash_table_t *fragment_shaders,
         const struct ffp_frag_settings *settings)
 {
     return (const struct ffp_frag_desc *)hash_table_get(fragment_shaders, settings);
diff --git a/dlls/wined3d/vertexbuffer.c b/dlls/wined3d/vertexbuffer.c
index 5f687ff..1ce6e8d 100644
--- a/dlls/wined3d/vertexbuffer.c
+++ b/dlls/wined3d/vertexbuffer.c
@@ -143,7 +143,8 @@ static inline void fixup_transformed_pos(float *p) {
     p[3] = w;
 }
 
-DWORD *find_conversion_shift(IWineD3DVertexBufferImpl *This, WineDirect3DVertexStridedData *strided, DWORD stride) {
+DWORD *find_conversion_shift(IWineD3DVertexBufferImpl *This, const WineDirect3DVertexStridedData *strided, DWORD stride)
+{
     DWORD *ret, i, shift, j, type;
     DWORD orig_type_size;
 
@@ -622,7 +623,7 @@ static void     WINAPI IWineD3DVertexBufferImpl_PreLoad(IWineD3DVertexBuffer *if
                     case CONV_FLOAT16_2:
                     {
                         float *out = (float *) (&data[This->conv_stride * i + j + This->conv_shift[j]]);
-                        WORD *in = (WORD *) (&This->resource.allocatedMemory[i * This->stride + j]);
+                        const WORD *in = (WORD *) (&This->resource.allocatedMemory[i * This->stride + j]);
 
                         out[1] = float_16_to_32(in + 1);
                         out[0] = float_16_to_32(in + 0);
@@ -796,7 +797,8 @@ const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl =
     IWineD3DVertexBufferImpl_GetDesc
 };
 
-BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo) {
+const BYTE* IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo)
+{
     IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
 
     *vbo = This->vbo;
@@ -806,12 +808,12 @@ BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWO
             This->Flags &= ~VBFLAG_CREATEVBO;
             if(This->vbo) {
                 *vbo = This->vbo;
-                return (BYTE *) iOffset;
+                return (const BYTE *)iOffset;
             }
         }
         return This->resource.allocatedMemory + iOffset;
     } else {
-        return (BYTE *) iOffset;
+        return (const BYTE *)iOffset;
     }
 }
 
diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c
index 1098661..0f246f9 100644
--- a/dlls/wined3d/vertexshader.c
+++ b/dlls/wined3d/vertexshader.c
@@ -316,11 +316,9 @@ static inline void find_swizzled_attribs(IWineD3DVertexDeclaration *declaration,
 }
 /** Generate a vertex shader string using either GL_VERTEX_PROGRAM_ARB
     or GLSL and send it to the card */
-static VOID IWineD3DVertexShaderImpl_GenerateShader(
-    IWineD3DVertexShader *iface,
-    shader_reg_maps* reg_maps,
-    CONST DWORD *pFunction) {
-
+static void IWineD3DVertexShaderImpl_GenerateShader(IWineD3DVertexShader *iface,
+        const struct shader_reg_maps* reg_maps, const DWORD *pFunction)
+{
     IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
     IWineD3DVertexDeclaration *decl = ((IWineD3DDeviceImpl *) This->baseShader.device)->stateBlock->vertexDecl;
     SHADER_BUFFER buffer;
@@ -485,7 +483,7 @@ static void WINAPI IWineD3DVertexShaderImpl_FakeSemantics(IWineD3DVertexShader *
 
     int i;
     for (i = 0; i < vdecl->declarationWNumElements - 1; ++i) {
-        WINED3DVERTEXELEMENT* element = vdecl->pDeclarationWine + i;
+        const WINED3DVERTEXELEMENT *element = vdecl->pDeclarationWine + i;
         vshader_set_input(This, element->Reg, element->Usage, element->UsageIndex);
     }
 }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 276f2a9..2c3d7e0 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -69,7 +69,7 @@ struct hash_table_t {
 
 struct hash_table_t *hash_table_create(hash_function_t *hash_function, compare_function_t *compare_function);
 void hash_table_destroy(struct hash_table_t *table, void (*free_value)(void *value, void *cb), void *cb);
-void *hash_table_get(struct hash_table_t *table, const void *key);
+void *hash_table_get(const struct hash_table_t *table, const void *key);
 void hash_table_put(struct hash_table_t *table, void *key, void *value);
 void hash_table_remove(struct hash_table_t *table, void *key);
 
@@ -878,7 +878,7 @@ struct ffp_frag_desc
 };
 
 void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_settings *settings, BOOL ignore_textype);
-const struct ffp_frag_desc *find_ffp_frag_shader(struct hash_table_t *fragment_shaders,
+const struct ffp_frag_desc *find_ffp_frag_shader(const struct hash_table_t *fragment_shaders,
         const struct ffp_frag_settings *settings);
 void add_ffp_frag_shader(struct hash_table_t *shaders, struct ffp_frag_desc *desc);
 BOOL ffp_frag_program_key_compare(const void *keya, const void *keyb);
@@ -1039,7 +1039,7 @@ struct IWineD3DDeviceImpl
 
     /* Stream source management */
     WineDirect3DVertexStridedData strided_streams;
-    WineDirect3DVertexStridedData *up_strided;
+    const WineDirect3DVertexStridedData *up_strided;
     BOOL                      useDrawStridedSlow;
     BOOL                      instancedDraw;
 
@@ -1775,10 +1775,7 @@ extern void stateblock_savedstates_set(
     SAVEDSTATES* states,
     BOOL value);
 
-extern void stateblock_savedstates_copy(
-    IWineD3DStateBlock* iface,
-    SAVEDSTATES* dest,
-    SAVEDSTATES* source);
+extern void stateblock_savedstates_copy(IWineD3DStateBlock *iface, SAVEDSTATES *dest, const SAVEDSTATES *source);
 
 extern void stateblock_copy(
     IWineD3DStateBlock* destination,
@@ -1867,7 +1864,7 @@ typedef struct IWineD3DSwapChainImpl
 
 extern const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl;
 const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl;
-void x11_copy_to_screen(IWineD3DSwapChainImpl *This, LPRECT rc);
+void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc);
 
 HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface, REFIID riid, LPVOID *ppobj);
 ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface);
@@ -1984,7 +1981,7 @@ unsigned int count_bits(unsigned int mask);
     extern BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL);
     extern BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface);
 
-    extern BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo);
+    extern const BYTE *IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo);
     extern HRESULT WINAPI IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer* iface);
     extern HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface);
     extern void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface, const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1], const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]);
@@ -2386,7 +2383,7 @@ typedef struct IWineD3DPixelShaderImpl {
 
 extern const SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[];
 extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl;
-GLuint find_gl_pshader(IWineD3DPixelShaderImpl *shader, struct ps_compile_args *args);
+GLuint find_gl_pshader(IWineD3DPixelShaderImpl *shader, const struct ps_compile_args *args);
 void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImpl *stateblock, struct ps_compile_args *args);
 
 /* sRGB correction constants */
diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl
index 29f28c2..abb0d3b 100644
--- a/include/wine/wined3d.idl
+++ b/include/wine/wined3d.idl
@@ -3374,12 +3374,12 @@ interface IWineD3DDevice : IWineD3DBase
     HRESULT DrawPrimitiveStrided(
         [in] WINED3DPRIMITIVETYPE primitive_type,
         [in] UINT primitive_count,
-        [in] WineDirect3DVertexStridedData *strided_data
+        [in] const WineDirect3DVertexStridedData *strided_data
     );
     HRESULT DrawIndexedPrimitiveStrided(
         [in] WINED3DPRIMITIVETYPE primitive_type,
         [in] UINT primitive_count,
-        [in] WineDirect3DVertexStridedData *strided_data,
+        [in] const WineDirect3DVertexStridedData *strided_data,
         [in] UINT vertex_count,
         [in] const void *index_data,
         [in] WINED3DFORMAT index_data_format
-- 
1.5.6.4



--------------050507070704020600060101--



More information about the wine-patches mailing list