[PATCH 4/5] wined3d: Get rid of the WINED3DVIEWPORT typedef.

Henri Verbeet hverbeet at codeweavers.com
Mon Nov 21 11:48:40 CST 2011


---
 dlls/d3d8/device.c             |    8 +++---
 dlls/d3d9/device.c             |    8 +++---
 dlls/ddraw/device.c            |    8 +++---
 dlls/wined3d/device.c          |   42 ++++++++++++++++++++--------------------
 dlls/wined3d/state.c           |   34 ++++++++++++++++----------------
 dlls/wined3d/stateblock.c      |   12 +++++-----
 dlls/wined3d/utils.c           |    4 +-
 dlls/wined3d/wined3d_private.h |    6 ++--
 include/wine/wined3d.h         |   20 +++++++++---------
 9 files changed, 71 insertions(+), 71 deletions(-)

diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 9bf350a..049c4e0 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -1279,9 +1279,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetViewport(IDirect3DDevice8 *iface,
 
     TRACE("iface %p, viewport %p.\n", iface, pViewport);
 
-    /* Note: D3DVIEWPORT8 is compatible with WINED3DVIEWPORT */
+    /* Note: D3DVIEWPORT8 is compatible with struct wined3d_viewport. */
     wined3d_mutex_lock();
-    hr = wined3d_device_set_viewport(This->wined3d_device, (const WINED3DVIEWPORT *)pViewport);
+    hr = wined3d_device_set_viewport(This->wined3d_device, (const struct wined3d_viewport *)pViewport);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1295,9 +1295,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetViewport(IDirect3DDevice8 *iface,
 
     TRACE("iface %p, viewport %p.\n", iface, pViewport);
 
-    /* Note: D3DVIEWPORT8 is compatible with WINED3DVIEWPORT */
+    /* Note: D3DVIEWPORT8 is compatible with struct wined3d_viewport. */
     wined3d_mutex_lock();
-    hr = wined3d_device_get_viewport(This->wined3d_device, (WINED3DVIEWPORT *)pViewport);
+    hr = wined3d_device_get_viewport(This->wined3d_device, (struct wined3d_viewport *)pViewport);
     wined3d_mutex_unlock();
 
     return hr;
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 08c503b..29dd180 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1297,9 +1297,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetViewport(IDirect3DDevice9Ex *iface
 
     TRACE("iface %p, viewport %p.\n", iface, pViewport);
 
-    /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
+    /* Note: D3DVIEWPORT9 is compatible with struct wined3d_viewport. */
     wined3d_mutex_lock();
-    hr = wined3d_device_set_viewport(This->wined3d_device, (const WINED3DVIEWPORT *)pViewport);
+    hr = wined3d_device_set_viewport(This->wined3d_device, (const struct wined3d_viewport *)pViewport);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1313,9 +1313,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(IDirect3DDevice9Ex *iface
 
     TRACE("iface %p, viewport %p.\n", iface, pViewport);
 
-    /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
+    /* Note: D3DVIEWPORT9 is compatible with struct wined3d_viewport. */
     wined3d_mutex_lock();
-    hr = wined3d_device_get_viewport(This->wined3d_device, (WINED3DVIEWPORT *)pViewport);
+    hr = wined3d_device_get_viewport(This->wined3d_device, (struct wined3d_viewport *)pViewport);
     wined3d_mutex_unlock();
 
     return hr;
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 966855e..c33ddbb 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -5151,9 +5151,9 @@ IDirect3DDeviceImpl_7_SetViewport(IDirect3DDevice7 *iface,
     if(!Data)
         return DDERR_INVALIDPARAMS;
 
-    /* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
+    /* Note: D3DVIEWPORT7 is compatible with struct wined3d_viewport. */
     wined3d_mutex_lock();
-    hr = wined3d_device_set_viewport(This->wined3d_device, (WINED3DVIEWPORT *)Data);
+    hr = wined3d_device_set_viewport(This->wined3d_device, (struct wined3d_viewport *)Data);
     wined3d_mutex_unlock();
 
     return hr;
@@ -5208,9 +5208,9 @@ IDirect3DDeviceImpl_7_GetViewport(IDirect3DDevice7 *iface,
     if(!Data)
         return DDERR_INVALIDPARAMS;
 
-    /* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
+    /* Note: D3DVIEWPORT7 is compatible with struct wined3d_viewport. */
     wined3d_mutex_lock();
-    hr = wined3d_device_get_viewport(This->wined3d_device, (WINED3DVIEWPORT *)Data);
+    hr = wined3d_device_get_viewport(This->wined3d_device, (struct wined3d_viewport *)Data);
     wined3d_mutex_unlock();
 
     return hr_ddraw_from_wined3d(hr);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 29c16b5..1ab205d 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2407,11 +2407,11 @@ INT CDECL wined3d_device_get_base_vertex_index(const struct wined3d_device *devi
     return device->stateBlock->state.base_vertex_index;
 }
 
-HRESULT CDECL wined3d_device_set_viewport(struct wined3d_device *device, const WINED3DVIEWPORT *viewport)
+HRESULT CDECL wined3d_device_set_viewport(struct wined3d_device *device, const struct wined3d_viewport *viewport)
 {
     TRACE("device %p, viewport %p.\n", device, viewport);
-    TRACE("x %u, y %u, w %u, h %u, minz %.8e, maxz %.8e.\n",
-          viewport->X, viewport->Y, viewport->Width, viewport->Height, viewport->MinZ, viewport->MaxZ);
+    TRACE("x %u, y %u, w %u, h %u, min_z %.8e, max_z %.8e.\n",
+          viewport->x, viewport->y, viewport->width, viewport->height, viewport->min_z, viewport->max_z);
 
     device->updateStateBlock->changed.viewport = TRUE;
     device->updateStateBlock->state.viewport = *viewport;
@@ -2428,7 +2428,7 @@ HRESULT CDECL wined3d_device_set_viewport(struct wined3d_device *device, const W
     return WINED3D_OK;
 }
 
-HRESULT CDECL wined3d_device_get_viewport(const struct wined3d_device *device, WINED3DVIEWPORT *viewport)
+HRESULT CDECL wined3d_device_get_viewport(const struct wined3d_device *device, struct wined3d_viewport *viewport)
 {
     TRACE("device %p, viewport %p.\n", device, viewport);
 
@@ -3202,8 +3202,8 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     char *dest_ptr, *dest_conv = NULL, *dest_conv_addr = NULL;
     struct wined3d_matrix mat, proj_mat, view_mat, world_mat;
+    struct wined3d_viewport vp;
     unsigned int i;
-    WINED3DVIEWPORT vp;
     BOOL doClip;
     DWORD numTextures;
 
@@ -3289,8 +3289,8 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
 
     /* Get the viewport */
     wined3d_device_get_viewport(device, &vp);
-    TRACE("Viewport: X=%d, Y=%d, Width=%d, Height=%d, MinZ=%f, MaxZ=%f\n",
-          vp.X, vp.Y, vp.Width, vp.Height, vp.MinZ, vp.MaxZ);
+    TRACE("viewport  x %u, y %u, width %u, height %u, min_z %.8e, max_z %.8e.\n",
+          vp.x, vp.y, vp.width, vp.height, vp.min_z, vp.max_z);
 
     multiply_matrix(&mat,&view_mat,&world_mat);
     multiply_matrix(&mat,&proj_mat,&mat);
@@ -3359,13 +3359,13 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
 
                 y *= -1;
 
-                x *= vp.Width / 2;
-                y *= vp.Height / 2;
-                z *= vp.MaxZ - vp.MinZ;
+                x *= vp.width / 2;
+                y *= vp.height / 2;
+                z *= vp.max_z - vp.min_z;
 
-                x += vp.Width / 2 + vp.X;
-                y += vp.Height / 2 + vp.Y;
-                z += vp.MinZ;
+                x += vp.width / 2 + vp.x;
+                y += vp.height / 2 + vp.y;
+                z += vp.min_z;
 
                 rhw = 1 / rhw;
             } else {
@@ -4912,18 +4912,18 @@ HRESULT CDECL wined3d_device_set_render_target(struct wined3d_device *device,
         /* Set the viewport and scissor rectangles, if requested. Tests show
          * that stateblock recording is ignored, the change goes directly
          * into the primary stateblock. */
-        device->stateBlock->state.viewport.Height = device->fb.render_targets[0]->resource.height;
-        device->stateBlock->state.viewport.Width  = device->fb.render_targets[0]->resource.width;
-        device->stateBlock->state.viewport.X      = 0;
-        device->stateBlock->state.viewport.Y      = 0;
-        device->stateBlock->state.viewport.MaxZ   = 1.0f;
-        device->stateBlock->state.viewport.MinZ   = 0.0f;
+        device->stateBlock->state.viewport.height = device->fb.render_targets[0]->resource.height;
+        device->stateBlock->state.viewport.width  = device->fb.render_targets[0]->resource.width;
+        device->stateBlock->state.viewport.x      = 0;
+        device->stateBlock->state.viewport.y      = 0;
+        device->stateBlock->state.viewport.max_z  = 1.0f;
+        device->stateBlock->state.viewport.min_z  = 0.0f;
         device_invalidate_state(device, STATE_VIEWPORT);
 
         device->stateBlock->state.scissor_rect.top = 0;
         device->stateBlock->state.scissor_rect.left = 0;
-        device->stateBlock->state.scissor_rect.right = device->stateBlock->state.viewport.Width;
-        device->stateBlock->state.scissor_rect.bottom = device->stateBlock->state.viewport.Height;
+        device->stateBlock->state.scissor_rect.right = device->stateBlock->state.viewport.width;
+        device->stateBlock->state.scissor_rect.bottom = device->stateBlock->state.viewport.height;
         device_invalidate_state(device, STATE_SCISSORRECT);
     }
 
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 7675cd2..b9a0dca 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -1444,8 +1444,8 @@ static void state_pscale(struct wined3d_context *context, const struct wined3d_s
 
     if (state->render_states[WINED3DRS_POINTSCALEENABLE])
     {
+        DWORD h = state->viewport.height;
         GLfloat scaleFactor;
-        DWORD h = state->viewport.Height;
 
         if (pointSize.f < gl_info->limits.pointsize_min)
         {
@@ -3909,10 +3909,10 @@ static void transform_projection(struct wined3d_context *context, const struct w
     if (context->last_was_rhw)
     {
         /* Transform D3D RHW coordinates to OpenGL clip coordinates. */
-        double x = state->viewport.X;
-        double y = state->viewport.Y;
-        double w = state->viewport.Width;
-        double h = state->viewport.Height;
+        double x = state->viewport.x;
+        double y = state->viewport.y;
+        double w = state->viewport.width;
+        double h = state->viewport.height;
         double x_scale = 2.0 / w;
         double x_offset = ((63.0 / 64.0) - (2.0 * x) - w) / w;
         double y_scale = context->render_offscreen ? 2.0 / h : 2.0 / -h;
@@ -3933,10 +3933,10 @@ static void transform_projection(struct wined3d_context *context, const struct w
     else
     {
         double y_scale = context->render_offscreen ? -1.0 : 1.0;
-        double x_offset = (63.0 / 64.0) / state->viewport.Width;
+        double x_offset = (63.0 / 64.0) / state->viewport.width;
         double y_offset = context->render_offscreen
-                ? (63.0 / 64.0) / state->viewport.Height
-                : -(63.0 / 64.0) / state->viewport.Height;
+                ? (63.0 / 64.0) / state->viewport.height
+                : -(63.0 / 64.0) / state->viewport.height;
         const GLdouble projection[] =
         {
                  1.0,      0.0,  0.0, 0.0,
@@ -4590,28 +4590,28 @@ static void vertexdeclaration(struct wined3d_context *context, const struct wine
 static void viewport_miscpart(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 {
     const struct wined3d_surface *target = state->fb->render_targets[0];
-    WINED3DVIEWPORT vp = state->viewport;
+    struct wined3d_viewport vp = state->viewport;
 
-    if (vp.Width > target->resource.width)
-        vp.Width = target->resource.width;
-    if (vp.Height > target->resource.height)
-        vp.Height = target->resource.height;
+    if (vp.width > target->resource.width)
+        vp.width = target->resource.width;
+    if (vp.height > target->resource.height)
+        vp.height = target->resource.height;
 
-    glDepthRange(vp.MinZ, vp.MaxZ);
+    glDepthRange(vp.min_z, vp.max_z);
     checkGLcall("glDepthRange");
     /* Note: GL requires lower left, DirectX supplies upper left. This is
      * reversed when using offscreen rendering. */
     if (context->render_offscreen)
     {
-        glViewport(vp.X, vp.Y, vp.Width, vp.Height);
+        glViewport(vp.x, vp.y, vp.width, vp.height);
     }
     else
     {
         UINT width, height;
 
         target->get_drawable_size(context, &width, &height);
-        glViewport(vp.X, (height - (vp.Y + vp.Height)),
-                vp.Width, vp.Height);
+        glViewport(vp.x, (height - (vp.y + vp.height)),
+                vp.width, vp.height);
     }
 
     checkGLcall("glViewport");
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index e122165..33b8ce2 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -1304,12 +1304,12 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
         }
 
         /* Set the default viewport */
-        state->viewport.X = 0;
-        state->viewport.Y = 0;
-        state->viewport.Width = swapchain->presentParms.BackBufferWidth;
-        state->viewport.Height = swapchain->presentParms.BackBufferHeight;
-        state->viewport.MinZ = 0.0f;
-        state->viewport.MaxZ = 1.0f;
+        state->viewport.x = 0;
+        state->viewport.y = 0;
+        state->viewport.width = swapchain->presentParms.BackBufferWidth;
+        state->viewport.height = swapchain->presentParms.BackBufferHeight;
+        state->viewport.min_z = 0.0f;
+        state->viewport.max_z = 1.0f;
 
         wined3d_swapchain_decref(swapchain);
     }
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index eacdf2f..34a9447 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3374,9 +3374,9 @@ const struct blit_shader *wined3d_select_blitter(const struct wined3d_gl_info *g
 
 void wined3d_get_draw_rect(const struct wined3d_state *state, RECT *rect)
 {
-    const WINED3DVIEWPORT *vp = &state->viewport;
+    const struct wined3d_viewport *vp = &state->viewport;
 
-    SetRect(rect, vp->X, vp->Y, vp->X + vp->Width, vp->Y + vp->Height);
+    SetRect(rect, vp->x, vp->y, vp->x + vp->width, vp->y + vp->height);
 
     if (state->render_states[WINED3DRS_SCISSORTESTENABLE])
         IntersectRect(rect, rect, &state->scissor_rect);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index ee29934..a43830e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2283,7 +2283,7 @@ struct wined3d_state
     struct wined3d_matrix transforms[HIGHEST_TRANSFORMSTATE + 1];
     double clip_planes[MAX_CLIPPLANES][4];
     struct wined3d_material material;
-    WINED3DVIEWPORT viewport;
+    struct wined3d_viewport viewport;
     RECT scissor_rect;
 
     /* Light hashmap . Collisions are handled using standard wine double linked lists */
@@ -2699,8 +2699,8 @@ static inline void shader_get_position_fixup(const struct wined3d_context *conte
 {
     position_fixup[0] = 1.0f;
     position_fixup[1] = 1.0f;
-    position_fixup[2] = (63.0f / 64.0f) / state->viewport.Width;
-    position_fixup[3] = -(63.0f / 64.0f) / state->viewport.Height;
+    position_fixup[2] = (63.0f / 64.0f) / state->viewport.width;
+    position_fixup[3] = -(63.0f / 64.0f) / state->viewport.height;
 
     if (context->render_offscreen)
     {
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 11b85f1..abf2c61 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -1573,15 +1573,15 @@ struct wined3d_material
     float power;
 };
 
-typedef struct _WINED3DVIEWPORT
+struct wined3d_viewport
 {
-    DWORD X;
-    DWORD Y;
-    DWORD Width;
-    DWORD Height;
-    float MinZ;
-    float MaxZ;
-} WINED3DVIEWPORT;
+    UINT x;
+    UINT y;
+    UINT width;
+    UINT height;
+    float min_z;
+    float max_z;
+};
 
 typedef struct _WINED3DGAMMARAMP
 {
@@ -2256,7 +2256,7 @@ HRESULT __cdecl wined3d_device_get_transform(const struct wined3d_device *device
 HRESULT __cdecl wined3d_device_get_vertex_declaration(const struct wined3d_device *device,
         struct wined3d_vertex_declaration **declaration);
 struct wined3d_shader * __cdecl wined3d_device_get_vertex_shader(const struct wined3d_device *device);
-HRESULT __cdecl wined3d_device_get_viewport(const struct wined3d_device *device, WINED3DVIEWPORT *viewport);
+HRESULT __cdecl wined3d_device_get_viewport(const struct wined3d_device *device, struct wined3d_viewport *viewport);
 HRESULT __cdecl wined3d_device_get_vs_consts_b(const struct wined3d_device *device,
         UINT start_register, BOOL *constants, UINT bool_count);
 HRESULT __cdecl wined3d_device_get_vs_consts_f(const struct wined3d_device *device,
@@ -2326,7 +2326,7 @@ HRESULT __cdecl wined3d_device_set_transform(struct wined3d_device *device,
 HRESULT __cdecl wined3d_device_set_vertex_declaration(struct wined3d_device *device,
         struct wined3d_vertex_declaration *declaration);
 HRESULT __cdecl wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader);
-HRESULT __cdecl wined3d_device_set_viewport(struct wined3d_device *device, const WINED3DVIEWPORT *viewport);
+HRESULT __cdecl wined3d_device_set_viewport(struct wined3d_device *device, const struct wined3d_viewport *viewport);
 HRESULT __cdecl wined3d_device_set_vs_consts_b(struct wined3d_device *device,
         UINT start_register, const BOOL *constants, UINT bool_count);
 HRESULT __cdecl wined3d_device_set_vs_consts_f(struct wined3d_device *device,
-- 
1.7.3.4




More information about the wine-patches mailing list