examples/tinyds: Remove redundant referencing ds_buffer 60/278060/1
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 20 Apr 2022 09:10:04 +0000 (18:10 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 18 Jul 2022 05:08:19 +0000 (14:08 +0900)
ds_buffer is supposed to be referenced by ds_output while using it, so
tinyds doesn't have any reasons to reference a ds_buffer for the output.

Change-Id: I7f4aacd9263f4b70c57d269f118605b743d5b847

src/examples/tinyds.c

index 61366fb..ed3ed01 100644 (file)
@@ -54,7 +54,6 @@ struct tinyds_output
     struct ds_output *ds_output;
     struct ds_allocator *allocator;
     struct ds_swapchain *swapchain;
-    struct ds_buffer *front_buffer;
 
     struct wl_listener output_destroy;
     struct wl_listener output_frame;
@@ -325,7 +324,6 @@ init_output(struct tinyds_output *output, struct tinyds_server *server,
     output->server = server;
     output->width = width;
     output->height = height;
-    output->front_buffer = NULL;
     output->drawable = true;
     output->damaged = true;
 
@@ -365,8 +363,6 @@ static void
 fini_output(struct tinyds_output *output)
 {
     wl_list_remove(&output->link);
-    if (output->front_buffer)
-        ds_buffer_unlock(output->front_buffer);
     if (output->ds_output)
         ds_output_destroy(output->ds_output);
     ds_swapchain_destroy(output->swapchain);
@@ -411,10 +407,8 @@ draw_output(struct tinyds_output *output)
 
     output_image = pixman_image_from_buffer(output_buffer,
             DS_BUFFER_DATA_PTR_ACCESS_WRITE);
-    if (!output_image) {
-        ds_buffer_unlock(output_buffer);
-        return;
-    }
+    if (!output_image)
+        goto out;
 
     pixman_image_fill_color(output_image, 80, 80, 80);
 
@@ -428,12 +422,11 @@ draw_output(struct tinyds_output *output)
     ds_output_attach_buffer(output->ds_output, output_buffer);
     ds_output_commit(output->ds_output);
 
-    if (output->front_buffer)
-        ds_buffer_unlock(output->front_buffer);
-    output->front_buffer = output_buffer;
-
     output->drawable = false;
     output->damaged = false;
+
+out:
+    ds_buffer_unlock(output_buffer);
 }
 
 static void