surface: Use DS_FLAG_* macros 91/283591/2
authorSeunghun Lee <shiin.lee@samsung.com>
Sun, 23 Oct 2022 23:51:33 +0000 (08:51 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 31 Oct 2022 05:05:44 +0000 (05:05 +0000)
Change-Id: I67d3134e36c70aa7b490dd7f7c4d23438789118e

src/surface/surface.c

index f4f86f6..a80c1ac 100644 (file)
@@ -168,7 +168,7 @@ ds_surface_viewport_set_source(struct ds_surface_viewport *vp_handle,
     DS_ASSERT(x >= 0 && y >= 0 && width > 0 && height > 0);
 
     surface = wl_container_of(vp_handle, surface, viewport_handle);
-    surface->pending.committed |= DS_SURFACE_STATE_VIEWPORT;
+    DS_FLAG_SET(surface->pending.committed, DS_SURFACE_STATE_VIEWPORT);
     surface->pending.viewport.has_src = true;
     surface->pending.viewport.src.x = x;
     surface->pending.viewport.src.y = y;
@@ -184,7 +184,7 @@ ds_surface_viewport_unset_source(struct ds_surface_viewport *vp_handle)
     DS_ASSERT(vp_handle->taken == true);
 
     surface = wl_container_of(vp_handle, surface, viewport_handle);
-    surface->pending.committed |= DS_SURFACE_STATE_VIEWPORT;
+    DS_FLAG_SET(surface->pending.committed, DS_SURFACE_STATE_VIEWPORT);
     surface->pending.viewport.has_src = false;
 }
 
@@ -198,7 +198,7 @@ ds_surface_viewport_set_destination(struct ds_surface_viewport *vp_handle,
     DS_ASSERT(width > 0 && height > 0);
 
     surface = wl_container_of(vp_handle, surface, viewport_handle);
-    surface->pending.committed |= DS_SURFACE_STATE_VIEWPORT;
+    DS_FLAG_SET(surface->pending.committed, DS_SURFACE_STATE_VIEWPORT);
     surface->pending.viewport.has_dst = true;
     surface->pending.viewport.dst_width = width;
     surface->pending.viewport.dst_height = height;
@@ -212,7 +212,7 @@ ds_surface_viewport_unset_destination(struct ds_surface_viewport *vp_handle)
     DS_ASSERT(vp_handle->taken == true);
 
     surface = wl_container_of(vp_handle, surface, viewport_handle);
-    surface->pending.committed |= DS_SURFACE_STATE_VIEWPORT;
+    DS_FLAG_SET(surface->pending.committed, DS_SURFACE_STATE_VIEWPORT);
     surface->pending.viewport.has_dst = false;
 }
 
@@ -331,7 +331,7 @@ surface_handle_attach(struct wl_client *client,
     }
 
     surface = wl_resource_get_user_data(resource);
-    surface->pending.committed |= DS_SURFACE_STATE_BUFFER;
+    DS_FLAG_SET(surface->pending.committed, DS_SURFACE_STATE_BUFFER);
     surface->pending.dx = dx;
     surface->pending.dy = dy;
 
@@ -358,7 +358,7 @@ surface_handle_damage(struct wl_client *client,
     if (width < 0 || height < 0)
         return;
 
-    surface->pending.committed |= DS_SURFACE_STATE_SURFACE_DAMAGE;
+    DS_FLAG_SET(surface->pending.committed, DS_SURFACE_STATE_SURFACE_DAMAGE);
     pixman_region32_union_rect(&surface->pending.surface_damage,
             &surface->pending.surface_damage,
             x, y, width, height);
@@ -394,7 +394,8 @@ surface_handle_frame(struct wl_client *client,
     wl_list_insert(surface->pending.frame_callback_list.prev,
             wl_resource_get_link(callback_resource));
 
-    surface->pending.committed |= DS_SURFACE_STATE_FRAME_CALLBACK_LIST;
+    DS_FLAG_SET(surface->pending.committed,
+            DS_SURFACE_STATE_FRAME_CALLBACK_LIST);
 }
 
 static void
@@ -408,7 +409,7 @@ surface_handle_set_opaque_region(struct wl_client *client,
 
     ds_dbg("ds_surface(%p) set opaque region", surface);
 
-    surface->pending.committed |= DS_SURFACE_STATE_OPAQUE_REGION;
+    DS_FLAG_SET(surface->pending.committed, DS_SURFACE_STATE_OPAQUE_REGION);
     if (region_resource) {
         region = ds_region_from_resource(region_resource);
         pixman_region32_copy(&surface->pending.opaque, region);
@@ -429,7 +430,7 @@ surface_handle_set_input_region(struct wl_client *client,
 
     ds_dbg("ds_surface(%p) set input region", surface);
 
-    surface->pending.committed |= DS_SURFACE_STATE_INPUT_REGION;
+    DS_FLAG_SET(surface->pending.committed, DS_SURFACE_STATE_INPUT_REGION);
     if (region_resource) {
         region = ds_region_from_resource(region_resource);
         pixman_region32_copy(&surface->pending.input, region);
@@ -478,7 +479,7 @@ surface_handle_set_buffer_transform(struct wl_client *client,
         return;
     }
 
-    surface->pending.committed |= DS_SURFACE_STATE_TRANSFORM;
+    DS_FLAG_SET(surface->pending.committed, DS_SURFACE_STATE_TRANSFORM);
     surface->pending.transform = transform;
 }
 
@@ -500,7 +501,7 @@ surface_handle_set_buffer_scale(struct wl_client *client,
         return;
     }
 
-    surface->pending.committed |= DS_SURFACE_STATE_SCALE;
+    DS_FLAG_SET(surface->pending.committed, DS_SURFACE_STATE_SCALE);
     surface->pending.scale = scale;
 }
 
@@ -522,7 +523,7 @@ surface_handle_damage_buffer(struct wl_client *client,
         return;
     }
 
-    surface->pending.committed |= DS_SURFACE_STATE_BUFFER_DAMAGE;
+    DS_FLAG_SET(surface->pending.committed, DS_SURFACE_STATE_BUFFER_DAMAGE);
     pixman_region32_union_rect(&surface->pending.buffer_damage,
             &surface->pending.buffer_damage,
             x, y, width, height);
@@ -609,13 +610,13 @@ surface_state_move(struct ds_surface_state *state, struct ds_surface_state *next
     state->buffer_width = next->buffer_width;
     state->buffer_height = next->buffer_height;
 
-    if (next->committed & DS_SURFACE_STATE_SCALE)
+    if (DS_FLAG_IS_SET(next->committed, DS_SURFACE_STATE_SCALE))
         state->scale = next->scale;
 
-    if (next->committed & DS_SURFACE_STATE_TRANSFORM)
+    if (DS_FLAG_IS_SET(next->committed, DS_SURFACE_STATE_TRANSFORM))
         state->transform = next->transform;
 
-    if (next->committed & DS_SURFACE_STATE_BUFFER) {
+    if (DS_FLAG_IS_SET(next->committed, DS_SURFACE_STATE_BUFFER)) {
         state->dx = next->dx;
         state->dy = next->dy;
         next->dx = next->dy = 0;
@@ -635,30 +636,30 @@ surface_state_move(struct ds_surface_state *state, struct ds_surface_state *next
         state->dx = state->dy = 0;
     }
 
-    if (next->committed & DS_SURFACE_STATE_SURFACE_DAMAGE) {
+    if (DS_FLAG_IS_SET(next->committed, DS_SURFACE_STATE_SURFACE_DAMAGE)) {
         pixman_region32_copy(&state->surface_damage, &next->surface_damage);
         pixman_region32_clear(&next->surface_damage);
     }
     else
         pixman_region32_clear(&state->surface_damage);
 
-    if (next->committed & DS_SURFACE_STATE_BUFFER_DAMAGE) {
+    if (DS_FLAG_IS_SET(next->committed, DS_SURFACE_STATE_BUFFER_DAMAGE)) {
         pixman_region32_copy(&state->buffer_damage, &next->buffer_damage);
         pixman_region32_clear(&next->buffer_damage);
     }
     else
         pixman_region32_clear(&state->buffer_damage);
 
-    if (next->committed & DS_SURFACE_STATE_OPAQUE_REGION)
+    if (DS_FLAG_IS_SET(next->committed, DS_SURFACE_STATE_OPAQUE_REGION))
         pixman_region32_copy(&state->opaque, &next->opaque);
 
-    if (next->committed & DS_SURFACE_STATE_INPUT_REGION)
+    if (DS_FLAG_IS_SET(next->committed, DS_SURFACE_STATE_INPUT_REGION))
         pixman_region32_copy(&state->input, &next->input);
 
-    if (next->committed & DS_SURFACE_STATE_VIEWPORT)
+    if (DS_FLAG_IS_SET(next->committed, DS_SURFACE_STATE_VIEWPORT))
         memcpy(&state->viewport, &next->viewport, sizeof(state->viewport));
 
-    if (next->committed & DS_SURFACE_STATE_FRAME_CALLBACK_LIST) {
+    if (DS_FLAG_IS_SET(next->committed, DS_SURFACE_STATE_FRAME_CALLBACK_LIST)) {
         wl_list_insert_list(&state->frame_callback_list,
                 &next->frame_callback_list);
         wl_list_init(&next->frame_callback_list);
@@ -705,7 +706,7 @@ surface_finalize_pending(struct ds_surface *surface)
 {
     struct ds_surface_state *pending = &surface->pending;
 
-    if ((pending->committed & DS_SURFACE_STATE_BUFFER)) {
+    if (DS_FLAG_IS_SET(pending->committed, DS_SURFACE_STATE_BUFFER)) {
         if (pending->buffer) {
             ds_buffer_get_size(pending->buffer,
                     &pending->buffer_width, &pending->buffer_height);
@@ -839,7 +840,7 @@ surface_commit_state(struct ds_surface *surface, struct ds_surface_state *next)
     surface_state_move(&surface->current, next);
 
     // FIXME no need?
-    if (surface->current.committed & DS_SURFACE_STATE_BUFFER)
+    if (DS_FLAG_IS_SET(surface->current.committed, DS_SURFACE_STATE_BUFFER))
         surface_update_buffer(surface);
 
     if (surface->role && surface->role->commit)