[Spice-devel] [PATCH spice-server 2/2] display: Simplify display_channel_create_surface

Pavel Grunt pgrunt at redhat.com
Tue Nov 24 23:58:26 PST 2015


From: Marc-André Lureau <marcandre.lureau at gmail.com>

---
removed extra spice_warn_if_fail
---
 server/display-channel.c | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index 45a63eb..10dbc8d 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1508,7 +1508,6 @@ void display_channel_create_surface(DisplayChannel *display, uint32_t surface_id
                                     void *line_0, int data_is_valid, int send_client)
 {
     RedSurface *surface = &display->surfaces[surface_id];
-    uint32_t i;
 
     spice_warn_if(surface->context.canvas);
 
@@ -1532,28 +1531,23 @@ void display_channel_create_surface(DisplayChannel *display, uint32_t surface_id
     ring_init(&surface->depend_on_me);
     region_init(&surface->draw_dirty_region);
     surface->refs = 1;
-    if (display->renderer != RED_RENDERER_INVALID) {
-        surface->context.canvas = create_canvas_for_surface(display, surface, display->renderer);
-        if (!surface->context.canvas) {
-            spice_critical("drawing canvas creating failed - can`t create same type canvas");
-        }
-
-        if (send_client)
-            send_create_surface(display, surface_id, data_is_valid);
-        return;
-    }
 
-    for (i = 0; i < display->num_renderers; i++) {
-        surface->context.canvas = create_canvas_for_surface(display, surface, display->renderers[i]);
-        if (surface->context.canvas) { //no need canvas check
-            display->renderer = display->renderers[i];
-            if (send_client)
-                send_create_surface(display, surface_id, data_is_valid);
-            return;
+    if (display->renderer == RED_RENDERER_INVALID) {
+        int i;
+        for (i = 0; i < display->num_renderers; i++) {
+            surface->context.canvas = create_canvas_for_surface(display, surface, display->renderers[i]);
+            if (surface->context.canvas) {
+                display->renderer = display->renderers[i];
+                break;
+            }
         }
+    } else {
+        surface->context.canvas = create_canvas_for_surface(display, surface, display->renderer);
     }
 
-    spice_critical("unable to create drawing canvas");
+    spice_return_if_fail(surface->context.canvas);
+    if (send_client)
+        send_create_surface(display, surface_id, data_is_valid);
 }
 
 static void on_disconnect(RedChannelClient *rcc)
-- 
2.5.0



More information about the Spice-devel mailing list