examples/tinyds: Remove redundant referencing ds_buffer 74/278174/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:58:30 +0000 (14:58 +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: Ic1183d1517fb89711e0a53d3c3271ea2a1f598e9

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