e_comp_wl: convert the buffer damage to surface damage 36/127336/2
authorBoram Park <boram1288.park@samsung.com>
Sun, 23 Apr 2017 06:02:35 +0000 (15:02 +0900)
committerBoram Park <boram1288.park@samsung.com>
Thu, 27 Apr 2017 06:40:38 +0000 (15:40 +0900)
Change-Id: I1466ceecd5c8c18c65fbbe8f8eca8aa7fb333d3c

src/bin/e_comp_wl.c

index 77ef8c70f870e536d1788a4388f5d2a4ef023d2a..7111e101acc1a98610ecec9375b4846a844a59bf 100644 (file)
@@ -224,113 +224,6 @@ e_comp_wl_map_size_cal_from_viewport(E_Client *ec)
    ec->comp_data->height_from_viewport = height;
 }
 
-static void
-_e_comp_wl_map_transform(int width, int height, uint32_t transform, int32_t scale, int sx, int sy, int *dx, int *dy)
-{
-   switch (transform)
-     {
-      case WL_OUTPUT_TRANSFORM_FLIPPED:     *dx = width  - sx, *dy = sy;          break;
-      case WL_OUTPUT_TRANSFORM_90:          *dx = height - sy, *dy = sx;          break;
-      case WL_OUTPUT_TRANSFORM_FLIPPED_90:  *dx = height - sy, *dy = width  - sx; break;
-      case WL_OUTPUT_TRANSFORM_180:         *dx = width  - sx, *dy = height - sy; break;
-      case WL_OUTPUT_TRANSFORM_FLIPPED_180: *dx = sx,          *dy = height - sy; break;
-      case WL_OUTPUT_TRANSFORM_270:         *dx = sy,          *dy = width - sx;  break;
-      case WL_OUTPUT_TRANSFORM_FLIPPED_270: *dx = sy,          *dy = sx;          break;
-      case WL_OUTPUT_TRANSFORM_NORMAL:
-      default:                              *dx = sx,          *dy = sy;          break;
-     }
-
-   *dx *= scale;
-   *dy *= scale;
-}
-
-static void
-_e_comp_wl_map_transform_rect(int width, int height,
-                              uint32_t transform, int32_t scale,
-                              Eina_Rectangle *srect, Eina_Rectangle *drect)
-{
-   int x1, x2, y1, y2;
-
-   x1 = srect->x;
-   y1 = srect->y;
-   x2 = srect->x + srect->w;
-   y2 = srect->y + srect->h;
-
-   _e_comp_wl_map_transform(width, height, transform, scale, x1, y1, &x1, &y1);
-   _e_comp_wl_map_transform(width, height, transform, scale, x2, y2, &x2, &y2);
-
-   drect->x = MIN(x1, x2);
-   drect->y = MIN(y1, y2);
-   drect->w = MAX(x1, x2) - drect->x;
-   drect->h = MAX(y1, y2) - drect->y;
-}
-
-static void
-_e_comp_wl_map_scaler_surface_to_buffer(E_Client *ec, int sx, int sy, int *bx, int *by)
-{
-   E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
-   double src_width, src_height;
-   double src_x, src_y;
-
-   if (vp->buffer.src_width == wl_fixed_from_int(-1))
-     {
-        if (vp->surface.width == -1)
-          {
-             *bx = sx;
-             *by = sy;
-             return;
-          }
-
-        src_x = 0.0;
-        src_y = 0.0;
-        src_width = ec->comp_data->width_from_buffer;
-        src_height = ec->comp_data->height_from_buffer;
-     }
-   else
-     {
-        src_x = wl_fixed_to_double(vp->buffer.src_x);
-        src_y = wl_fixed_to_double(vp->buffer.src_y);
-        src_width = wl_fixed_to_double(vp->buffer.src_width);
-        src_height = wl_fixed_to_double(vp->buffer.src_height);
-     }
-
-   *bx = sx * src_width / ec->comp_data->width_from_viewport + src_x;
-   *by = sy * src_height / ec->comp_data->height_from_viewport + src_y;
-}
-
-static void
-_e_comp_wl_surface_to_buffer_rect(E_Client *ec, Eina_Rectangle *srect, Eina_Rectangle *drect)
-{
-   E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
-   int xf1, yf1, xf2, yf2;
-
-   if (!ec->comp_data->sub.data)
-     {
-        *drect = *srect;
-        return;
-     }
-
-   /* first transform box coordinates if the scaler is set */
-
-   xf1 = srect->x;
-   yf1 = srect->y;
-   xf2 = srect->x + srect->w;
-   yf2 = srect->y + srect->h;
-
-   _e_comp_wl_map_scaler_surface_to_buffer(ec, xf1, yf1, &xf1, &yf1);
-   _e_comp_wl_map_scaler_surface_to_buffer(ec, xf2, yf2, &xf2, &yf2);
-
-   srect->x = MIN(xf1, xf2);
-   srect->y = MIN(yf1, yf2);
-   srect->w = MAX(xf1, xf2) - srect->x;
-   srect->h = MAX(yf1, yf2) - srect->y;
-
-   _e_comp_wl_map_transform_rect(ec->comp_data->width_from_buffer,
-                                 ec->comp_data->height_from_buffer,
-                                 vp->buffer.transform, vp->buffer.scale,
-                                 srect, drect);
-}
-
 static E_Client*
 _e_comp_wl_topmost_parent_get(E_Client *ec)
 {
@@ -2635,25 +2528,22 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
 
              if (eina_list_count(state->buffer_damages))
                {
-                  damages = eina_list_clone(state->buffer_damages);
-                  state->buffer_damages = eina_list_free(state->buffer_damages);
-               }
+                  E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
 
-             EINA_LIST_FREE(state->damages, dmg)
-               {
-                  if (ec->comp_data->sub.data &&
-                      (ec->comp_data->scaler.buffer_viewport.surface.width != -1 ||
-                       ec->comp_data->scaler.buffer_viewport.buffer.src_width != wl_fixed_from_int(-1)))
+                  EINA_LIST_FREE(state->buffer_damages, dmg)
                     {
-                       Eina_Rectangle temp = {0,};
-                       /* change to the buffer cordinate if subsurface */
-                       _e_comp_wl_surface_to_buffer_rect(ec, dmg, &temp);
-                       *dmg = temp;
+                       if (buffer)
+                         e_comp_wl_rect_convert_inverse(buffer->w, buffer->h,
+                                                        vp->buffer.transform, vp->buffer.scale,
+                                                        dmg->x, dmg->y, dmg->w, dmg->h,
+                                                        &dmg->x, &dmg->y, &dmg->w, &dmg->h);
+                       damages = eina_list_append(damages, dmg);
                     }
-
-                  damages = eina_list_append(damages, dmg);
                }
 
+             EINA_LIST_FREE(state->damages, dmg)
+               damages = eina_list_append(damages, dmg);
+
              EINA_LIST_FREE(damages, dmg)
                {
                   /* not creating damage for ec that shows a underlay video */