wgl: move screen-init to a helper
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Sun, 26 May 2019 08:42:51 +0000 (10:42 +0200)
committerMarge Bot <eric+marge@anholt.net>
Thu, 2 Apr 2020 09:51:58 +0000 (09:51 +0000)
This will be useful in the next commit.

Reviewed-by: Neha Bhende <bhenden@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4307>

src/gallium/state_trackers/wgl/stw_device.c

index 7c887194b5c73369e2df115c78c0329c17611f59..86906ececc06a3aab6ba344d3a19ed1c1861b9e8 100644 (file)
@@ -80,12 +80,28 @@ get_refresh_rate(void)
    }
 }
 
+static bool
+init_screen(const struct stw_winsys *stw_winsys)
+{
+   struct pipe_screen *screen = stw_winsys->create_screen();
+   if (!screen)
+      return false;
+
+   if (stw_winsys->get_adapter_luid)
+      stw_winsys->get_adapter_luid(screen, &stw_dev->AdapterLuid);
+
+   stw_dev->smapi->screen = screen;
+   stw_dev->screen = screen;
+
+   stw_dev->max_2d_length = screen->get_param(screen,
+                                              PIPE_CAP_MAX_TEXTURE_2D_SIZE);
+   return true;
+}
 
 boolean
 stw_init(const struct stw_winsys *stw_winsys)
 {
    static struct stw_device stw_dev_storage;
-   struct pipe_screen *screen;
 
    debug_disable_error_message_boxes();
 
@@ -107,19 +123,10 @@ stw_init(const struct stw_winsys *stw_winsys)
    if (!stw_dev->stapi || !stw_dev->smapi)
       goto error1;
 
-   screen = stw_winsys->create_screen();
-   if (!screen)
-      goto error1;
-
-   if (stw_winsys->get_adapter_luid)
-      stw_winsys->get_adapter_luid(screen, &stw_dev->AdapterLuid);
-
-   stw_dev->smapi->screen = screen;
    stw_dev->smapi->get_param = stw_get_param;
-   stw_dev->screen = screen;
 
-   stw_dev->max_2d_length = screen->get_param(screen,
-                                              PIPE_CAP_MAX_TEXTURE_2D_SIZE);
+   if (!init_screen(stw_winsys))
+      goto error1;
 
    InitializeCriticalSection(&stw_dev->ctx_mutex);
    InitializeCriticalSection(&stw_dev->fb_mutex);