wayland_egl: Added new APIs related with wl_surface_set_buffer_transform. 24/134224/1
authorjoonbum.ko <joonbum.ko@samsung.com>
Tue, 11 Apr 2017 07:07:37 +0000 (16:07 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Thu, 15 Jun 2017 08:51:23 +0000 (17:51 +0900)
 - If wayland_egl provides the following function, the client can set
  the correct transform value, and tpl_wayland_egl can pass the transform value
  to the server at the appropriate time (befor wl_surface_attach).

 - New wayland_egl API:
  void
  wl_egl_window_set_buffer_transform(struct wl_egl_window *egl_window,
     int wl_output_transform)
 - egl_window cannot be NULL.
 - wl_output_transform is a value of WL_OUTPUT_TRANSFORM enum.
   (See wayland.xml)

Change-Id: Ibf4d1b8eee90ee75f519a6ad6bb680299d780d26
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl.c
src/wayland-egl/wayland-egl-priv.h
src/wayland-egl/wayland-egl.c

index 3328f35..0404064 100644 (file)
@@ -60,8 +60,9 @@ struct _tpl_wayland_egl_buffer {
        tpl_wayland_egl_surface_t *wayland_egl_surface;
        int dx, dy;
        int width, height;
-       int rotation;
+       int transform;
        tbm_bo bo;
+       tpl_bool_t rotated; /* TRUE if need to call wl_surface_set_buffer_transform */
        tpl_bool_t reset; /* TRUE if queue reseted by external */
        tpl_bool_t is_new; /* for frontbuffer mode */
        struct wl_proxy *wl_proxy; /* wl_buffer proxy */
@@ -724,6 +725,7 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface,
        tpl_wayland_egl_surface_t *wayland_egl_surface =
                (tpl_wayland_egl_surface_t *) surface->backend.data;
        tdm_error tdm_err = 0;
+       uint32_t version;
 
        wayland_egl_buffer =
                __tpl_wayland_egl_get_wayland_buffer_from_tbm_surface(tbm_surface);
@@ -734,6 +736,13 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface,
 
        TPL_IMAGE_DUMP(tbm_surface, surface->width, surface->height);
 
+       version = wl_proxy_get_version((struct wl_proxy *)wl_egl_window->surface);
+
+       if (wayland_egl_buffer->rotated == TPL_TRUE) {
+               wl_surface_set_buffer_transform(wl_egl_window->surface,
+                                                                               wayland_egl_buffer->transform);
+       }
+
        wl_surface_attach(wl_egl_window->surface, (void *)wayland_egl_buffer->wl_proxy,
                                          wayland_egl_buffer->dx, wayland_egl_buffer->dy);
 
@@ -741,9 +750,19 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface,
        wl_egl_window->attached_height = wayland_egl_buffer->height;
 
        if (num_rects < 1 || rects == NULL) {
-               wl_surface_damage(wl_egl_window->surface,
-                                                 wayland_egl_buffer->dx, wayland_egl_buffer->dy,
-                                                 wayland_egl_buffer->width, wayland_egl_buffer->height);
+               if (version < 4) {
+                       wl_surface_damage(wl_egl_window->surface,
+                                                         wayland_egl_buffer->dx,
+                                                         wayland_egl_buffer->dy,
+                                                         wayland_egl_buffer->width,
+                                                         wayland_egl_buffer->height);
+               } else {
+                       wl_surface_damage_buffer(wl_egl_window->surface,
+                                                                        wayland_egl_buffer->dx,
+                                                                        wayland_egl_buffer->dy,
+                                                                        wayland_egl_buffer->width,
+                                                                        wayland_egl_buffer->height);
+               }
        } else {
                int i;
 
@@ -754,9 +773,15 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface,
                         * y = [WINDOW.HEIGHT] - (RECT.Y + RECT.HEIGHT) */
                        int inverted_y =
                                wayland_egl_buffer->height - (rects[i * 4 + 1] + rects[i * 4 + 3]);
-                       wl_surface_damage(wl_egl_window->surface,
-                                                         rects[i * 4 + 0], inverted_y,
-                                                         rects[i * 4 + 2], rects[i * 4 + 3]);
+                       if (version < 4) {
+                               wl_surface_damage(wl_egl_window->surface,
+                                                                 rects[i * 4 + 0], inverted_y,
+                                                                 rects[i * 4 + 2], rects[i * 4 + 3]);
+                       } else {
+                               wl_surface_damage_buffer(wl_egl_window->surface,
+                                                                                rects[i * 4 + 0], inverted_y,
+                                                                                rects[i * 4 + 2], rects[i * 4 + 3]);
+                       }
                }
        }
 
@@ -1133,7 +1158,12 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou
                wayland_egl_buffer->dy = wl_egl_window->dy;
                wayland_egl_buffer->width = wl_egl_window->width;
                wayland_egl_buffer->height = wl_egl_window->height;
-               wayland_egl_buffer->rotation = wl_egl_window->rotation;
+               if (wayland_egl_buffer->transform != wl_egl_window->transform) {
+                       wayland_egl_buffer->transform = wl_egl_window->transform;
+                       wayland_egl_buffer->rotated = TPL_TRUE;
+               } else {
+                       wayland_egl_buffer->rotated = TPL_FALSE;
+               }
                wayland_egl_buffer->reset = TPL_FALSE;
 
                if (wayland_egl_surface->is_activated != is_activated)
@@ -1180,7 +1210,8 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou
        wayland_egl_buffer->dy = wl_egl_window->dy;
        wayland_egl_buffer->width = wl_egl_window->width;
        wayland_egl_buffer->height = wl_egl_window->height;
-       wayland_egl_buffer->rotation = wl_egl_window->rotation;
+       wayland_egl_buffer->transform = wl_egl_window->transform;
+       wayland_egl_buffer->rotated = TPL_FALSE;
        wayland_egl_buffer->display = wayland_egl_display;
        wayland_egl_buffer->wl_proxy = wl_proxy;
        wayland_egl_buffer->bo = tbm_surface_internal_get_bo(tbm_surface, 0);
index 619fa99..f2b2d05 100644 (file)
@@ -27,8 +27,8 @@ struct wl_egl_window {
        int attached_height;
 
        wl_egl_window_rotation rotation;
-
        int frontbuffer_mode;
+       int transform;
 
        void *private;
        void (*resize_callback)(struct wl_egl_window *, void *);
index 8c03f04..37e81d5 100644 (file)
@@ -159,6 +159,25 @@ wl_egl_window_set_rotation(struct wl_egl_window *egl_window,
                egl_window->rotate_callback(egl_window, egl_window->private);
 }
 
+WL_EGL_EXPORT void
+wl_egl_window_set_buffer_transform(struct wl_egl_window *egl_window,
+                                                                  int wl_output_transform)
+{
+       if (egl_window == NULL) {
+               WL_EGL_ERR("egl_window is NULL");
+               return;
+       }
+
+       if (egl_window->transform == wl_output_transform) {
+               WL_EGL_LOG(2,
+                                  "wl_output_transform(%d) egl_window->transform(%d) already rotated",
+                                  wl_output_transform, egl_window->transform);
+               return;
+       }
+
+       egl_window->transform = wl_output_transform;
+}
+
 WL_EGL_EXPORT int
 wl_egl_window_get_capabilities(struct wl_egl_window *egl_window)
 {