Zebediah Figura : wined3d: Introduce wined3d_state_set_light() helper.

Alexandre Julliard julliard at winehq.org
Wed Feb 13 15:30:41 CST 2019


Module: wine
Branch: master
Commit: de8eb61d973e00dbcfcff3f3e9683e2e59b0be88
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=de8eb61d973e00dbcfcff3f3e9683e2e59b0be88

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Tue Feb 12 10:45:06 2019 -0600

wined3d: Introduce wined3d_state_set_light() helper.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/device.c          | 17 +++--------------
 dlls/wined3d/stateblock.c      | 27 +++++++++++++++++++++++++++
 dlls/wined3d/wined3d_private.h |  2 ++
 3 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 7c29380..3e03470 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1573,8 +1573,8 @@ void CDECL wined3d_device_multiply_transform(struct wined3d_device *device,
 HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
         UINT light_idx, const struct wined3d_light *light)
 {
-    UINT hash_idx = LIGHTMAP_HASHFUNC(light_idx);
     struct wined3d_light_info *object = NULL;
+    HRESULT hr;
     float rho;
 
     TRACE("device %p, light_idx %u, light %p.\n", device, light_idx, light);
@@ -1608,16 +1608,8 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
         return WINED3DERR_INVALIDCALL;
     }
 
-    if (!(object = wined3d_light_state_get_light(&device->update_state->light_state, light_idx)))
-    {
-        TRACE("Adding new light\n");
-        if (!(object = heap_alloc_zero(sizeof(*object))))
-            return E_OUTOFMEMORY;
-
-        list_add_head(&device->update_state->light_state.light_map[hash_idx], &object->entry);
-        object->glIndex = -1;
-        object->OriginalIndex = light_idx;
-    }
+    if (FAILED(hr = wined3d_light_state_set_light(&device->update_state->light_state, light_idx, light, &object)))
+        return hr;
 
     /* Initialize the object. */
     TRACE("Light %u setting to type %#x, diffuse %s, specular %s, ambient %s, "
@@ -1629,9 +1621,6 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
             light->direction.x, light->direction.y, light->direction.z,
             light->range, light->falloff, light->theta, light->phi);
 
-    /* Save away the information. */
-    object->OriginalParms = *light;
-
     switch (light->type)
     {
         case WINED3D_LIGHT_POINT:
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index afddd11..b5409ba 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -627,6 +627,33 @@ struct wined3d_light_info *wined3d_light_state_get_light(const struct wined3d_li
     return NULL;
 }
 
+HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD light_idx,
+        const struct wined3d_light *params, struct wined3d_light_info **light_info)
+{
+    struct wined3d_light_info *object;
+    unsigned int hash_idx;
+
+    if (!(object = wined3d_light_state_get_light(state, light_idx)))
+    {
+        TRACE("Adding new light.\n");
+        if (!(object = heap_alloc_zero(sizeof(*object))))
+        {
+            ERR("Failed to allocate light info.\n");
+            return E_OUTOFMEMORY;
+        }
+
+        hash_idx = LIGHTMAP_HASHFUNC(light_idx);
+        list_add_head(&state->light_map[hash_idx], &object->entry);
+        object->glIndex = -1;
+        object->OriginalIndex = light_idx;
+    }
+
+    object->OriginalParms = *params;
+
+    *light_info = object;
+    return WINED3D_OK;
+}
+
 void wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info,
         struct wined3d_light_info *light_info, BOOL enable)
 {
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index eece314..fbd7f41 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3639,6 +3639,8 @@ void wined3d_light_state_enable_light(struct wined3d_light_state *state, const s
         struct wined3d_light_info *light_info, BOOL enable) DECLSPEC_HIDDEN;
 struct wined3d_light_info *wined3d_light_state_get_light(const struct wined3d_light_state *state,
         unsigned int idx) DECLSPEC_HIDDEN;
+HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD light_idx,
+        const struct wined3d_light *params, struct wined3d_light_info **light_info) DECLSPEC_HIDDEN;
 
 void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN;
 void state_init(struct wined3d_state *state, struct wined3d_fb_state *fb,




More information about the wine-cvs mailing list