[PATCH 1/5] wined3d: Introduce a separate function for updating the viewport and scissor rects.

Henri Verbeet hverbeet at codeweavers.com
Mon Sep 23 03:26:44 CDT 2013


---
 dlls/wined3d/device.c     |   21 +++++++++++++++++++++
 dlls/wined3d/stateblock.c |   17 -----------------
 2 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 58c3db1..158305b 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -827,6 +827,23 @@ void CDECL wined3d_device_release_focus_window(struct wined3d_device *device)
     InterlockedExchangePointer((void **)&device->focus_window, NULL);
 }
 
+static void device_reset_viewport_scissor(struct wined3d_device *device, UINT width, UINT height)
+{
+    struct wined3d_state *state = &device->state;
+
+    state->viewport.x = 0;
+    state->viewport.y = 0;
+    state->viewport.width = width;
+    state->viewport.height = height;
+    state->viewport.min_z = 0.0f;
+    state->viewport.max_z = 1.0f;
+
+    state->scissor_rect.left = 0;
+    state->scissor_rect.top = 0;
+    state->scissor_rect.right = width;
+    state->scissor_rect.bottom = height;
+}
+
 HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
         struct wined3d_swapchain_desc *swapchain_desc)
 {
@@ -895,6 +912,8 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
 
     /* Setup all the devices defaults */
     state_init_default(&device->state, device);
+    device_reset_viewport_scissor(device, swapchain->desc.backbuffer_width,
+            swapchain->desc.backbuffer_height);
 
     context = context_acquire(device, swapchain->front_buffer);
 
@@ -4704,6 +4723,8 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
         if (FAILED(hr = state_init(&device->state, &device->adapter->d3d_info)))
             ERR("Failed to initialize device state, hr %#x.\n", hr);
         state_init_default(&device->state, device);
+        device_reset_viewport_scissor(device, swapchain->desc.backbuffer_width,
+                swapchain->desc.backbuffer_height);
         device->update_state = &device->state;
     }
     else
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index c2a5208..c593a63 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -1181,7 +1181,6 @@ void state_init_default(struct wined3d_state *state, struct wined3d_device *devi
         DWORD d;
     } tmpfloat;
     unsigned int i;
-    struct wined3d_swapchain_desc *swapchain_desc;
     static const struct wined3d_matrix identity =
     {{{
         1.0f, 0.0f, 0.0f, 0.0f,
@@ -1384,22 +1383,6 @@ void state_init_default(struct wined3d_state *state, struct wined3d_device *devi
     {
         state->textures[i] = NULL;
     }
-
-    swapchain_desc = &device->swapchains[0]->desc;
-
-    /* Set the default scissor rect values */
-    state->scissor_rect.left = 0;
-    state->scissor_rect.right = swapchain_desc->backbuffer_width;
-    state->scissor_rect.top = 0;
-    state->scissor_rect.bottom = swapchain_desc->backbuffer_height;
-
-    /* Set the default viewport */
-    state->viewport.x = 0;
-    state->viewport.y = 0;
-    state->viewport.width = swapchain_desc->backbuffer_width;
-    state->viewport.height = swapchain_desc->backbuffer_height;
-    state->viewport.min_z = 0.0f;
-    state->viewport.max_z = 1.0f;
 }
 
 static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
-- 
1.7.10.4




More information about the wine-patches mailing list