[waffle] [PATCH] API, Android: Add window resize call and implementation for Android

Juha-Pekka Heikkila juha-pekka.heikkila at linux.intel.com
Fri Jun 14 03:49:00 PDT 2013


Added waffle_window_resize(self, width, heigh) API call. Currently
implemented only on Android, other platforms return
WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM.

Signed-off-by: Juha-Pekka Heikkila <juha-pekka.heikkila at linux.intel.com>
---
 include/waffle/waffle.h                         |    6 ++++
 src/waffle/android/droid_platform.c             |    1 +
 src/waffle/android/droid_surfaceflingerlink.cpp |   35 +++++++++++++++++++++++
 src/waffle/android/droid_surfaceflingerlink.h   |    7 ++++
 src/waffle/android/droid_window.c               |   17 +++++++++++
 src/waffle/android/droid_window.h               |    5 +++
 src/waffle/api/waffle_window.c                  |   24 +++++++++++++++
 src/waffle/core/wcore_platform.h                |    5 +++
 8 files changed, 100 insertions(+), 0 deletions(-)

diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
index 00670fb..237b434 100644
--- a/include/waffle/waffle.h
+++ b/include/waffle/waffle.h
@@ -246,6 +246,12 @@ WAFFLE_API bool
 waffle_window_show(struct waffle_window *self);
 
 WAFFLE_API bool
+waffle_window_resize(
+        struct waffle_window *self,
+        int32_t width,
+        int32_t height);
+
+WAFFLE_API bool
 waffle_window_swap_buffers(struct waffle_window *self);
 
 WAFFLE_API union waffle_native_window*
diff --git a/src/waffle/android/droid_platform.c b/src/waffle/android/droid_platform.c
index f904685..bbf2b14 100644
--- a/src/waffle/android/droid_platform.c
+++ b/src/waffle/android/droid_platform.c
@@ -134,6 +134,7 @@ static const struct wcore_platform_vtbl droid_platform_vtbl = {
         .destroy = droid_window_destroy,
         .show = droid_window_show,
         .swap_buffers = wegl_window_swap_buffers,
+        .resize = droid_window_resize,
         .get_native = NULL,
     },
 };
diff --git a/src/waffle/android/droid_surfaceflingerlink.cpp b/src/waffle/android/droid_surfaceflingerlink.cpp
index 29f5757..f98d493 100644
--- a/src/waffle/android/droid_surfaceflingerlink.cpp
+++ b/src/waffle/android/droid_surfaceflingerlink.cpp
@@ -180,6 +180,27 @@ droid_show_surface(
     return true;
 }
 
+bool
+droid_resize_surface(
+    droid_surfaceflinger_container* pSFContainer,
+    droid_ANativeWindow_container* pANWContainer,
+    int width,
+    int height)
+{
+    int iRVal;
+
+    pSFContainer->composer_client->openGlobalTransaction();
+    iRVal = pANWContainer->surface_control->setSize(width, height);
+    pSFContainer->composer_client->closeGlobalTransaction();
+
+    if (iRVal != NO_ERROR) {
+        wcore_errorf(WAFFLE_ERROR_UNKNOWN,
+                     "Error in android::SurfaceControl->setSize");
+        return false;
+    }
+    return true;
+}
+
 void
 droid_destroy_surface(
     droid_surfaceflinger_container* pSFContainer,
@@ -249,6 +270,20 @@ droid_show_surface(
             (pANWContainer));
 }
 
+extern "C" bool
+droid_resize_surface(
+    droid_surfaceflinger_container* pSFContainer,
+    droid_ANativeWindow_container* pANWContainer,
+    int height,
+    int width)
+{
+    return waffle::droid_resize_surface(
+            reinterpret_cast<waffle::droid_surfaceflinger_container*>
+            (pSFContainer),
+            reinterpret_cast<waffle::droid_ANativeWindow_container*>
+            (pANWContainer), height, width);
+}
+
 extern "C" void
 droid_destroy_surface(
     droid_surfaceflinger_container* pSFContainer,
diff --git a/src/waffle/android/droid_surfaceflingerlink.h b/src/waffle/android/droid_surfaceflingerlink.h
index bf01c14..53aeb4f 100644
--- a/src/waffle/android/droid_surfaceflingerlink.h
+++ b/src/waffle/android/droid_surfaceflingerlink.h
@@ -40,6 +40,13 @@ droid_show_surface(
     struct droid_surfaceflinger_container* pSFContainer,
     struct droid_ANativeWindow_container* pANWContainer);
 
+bool
+droid_resize_surface(
+    struct droid_surfaceflinger_container* pSFContainer,
+    struct droid_ANativeWindow_container* pANWContainer,
+    int width,
+    int height);
+
 struct droid_ANativeWindow_container*
 droid_create_surface(
     int width,
diff --git a/src/waffle/android/droid_window.c b/src/waffle/android/droid_window.c
index 688b3de..b776b65 100644
--- a/src/waffle/android/droid_window.c
+++ b/src/waffle/android/droid_window.c
@@ -97,3 +97,20 @@ droid_window_show(struct wcore_window *wc_self)
 
     return droid_show_surface(dpy->pSFContainer, self->pANWContainer);
 }
+
+bool
+droid_window_resize(struct wcore_window *wc_self,
+                    int32_t width,
+                    int32_t height)
+{
+    struct droid_window *self = droid_window(wc_self);
+    struct droid_display *dpy;
+
+    if (!self)
+        return false;
+
+    dpy = droid_display(wc_self->display);
+
+    return droid_resize_surface(dpy->pSFContainer, self->pANWContainer,
+        width, height);
+}
diff --git a/src/waffle/android/droid_window.h b/src/waffle/android/droid_window.h
index 956ff41..85064cd 100644
--- a/src/waffle/android/droid_window.h
+++ b/src/waffle/android/droid_window.h
@@ -59,3 +59,8 @@ droid_window_destroy(struct wcore_window *wc_self);
 
 bool
 droid_window_show(struct wcore_window *wc_self);
+
+bool
+droid_window_resize(struct wcore_window *wc_self,
+                  int32_t width,
+                  int32_t height);
diff --git a/src/waffle/api/waffle_window.c b/src/waffle/api/waffle_window.c
index 85f29a2..f254607 100644
--- a/src/waffle/api/waffle_window.c
+++ b/src/waffle/api/waffle_window.c
@@ -93,6 +93,30 @@ waffle_window_show(struct waffle_window *self)
 }
 
 bool
+waffle_window_resize(
+                     struct waffle_window *self,
+                     int32_t width,
+                     int32_t height)
+{
+    struct wcore_window *wc_self = wcore_window(self);
+
+    const struct api_object *obj_list[] = {
+        wc_self ? &wc_self->api : NULL,
+    };
+
+    if (!api_check_entry(obj_list, 1))
+        return false;
+
+    if (api_platform->vtbl->window.resize) {
+        return api_platform->vtbl->window.resize(wc_self, width, height);
+    }
+    else {
+        wcore_error(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
+        return NULL;
+    }
+}
+
+bool
 waffle_window_swap_buffers(struct waffle_window *self)
 {
     struct wcore_window *wc_self = wcore_window(self);
diff --git a/src/waffle/core/wcore_platform.h b/src/waffle/core/wcore_platform.h
index ae602f5..65de879 100644
--- a/src/waffle/core/wcore_platform.h
+++ b/src/waffle/core/wcore_platform.h
@@ -124,6 +124,11 @@ struct wcore_platform_vtbl {
         bool
         (*swap_buffers)(struct wcore_window *window);
 
+        bool
+        (*resize)(struct wcore_window *window,
+                  int32_t height,
+                  int32_t width);
+
         /// May be null.
         union waffle_native_window*
         (*get_native)(struct wcore_window *window);
-- 
1.7.5.4



More information about the waffle mailing list