[waffle] New API call for Waffle
Juha-Pekka Heikkilä
juha-pekka.heikkila at linux.intel.com
Thu Jun 6 22:30:13 PDT 2013
Hi,
I've been porting retracer part of Apitrace for Waffle so I can use
retracer on Android. As a part of the process I notice I needed few
changes in Waffle. I was not certain what kind of API changes are
acceptable thus asking opinions.
Below is an addition to Waffle api which is implemented for Android, this
adds window resizing in a call 'waffle_window_resize'. I tried to go
around this with native interface at first but it started to feel silly
and I figure someone else might need window resizing too. On Android I did
not have possibility to merely destroy/recreate due to Android
limitations.
One thing I am still trying to find a good way to implement is to get
Waffle to do
'eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);'
I was thinking adding api call for such would feel a bit excessive thus I
currently do this through the native call in my retracer port. Would it be
best for this kind things be added as extra parameter to
waffle_make_current or create some extra/hidden behaviour for certain type
parameters?
/Juha-Pekka
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..742fc7a 100644
--- a/src/waffle/api/waffle_window.c
+++ b/src/waffle/api/waffle_window.c
@@ -93,6 +93,24 @@ 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;
+
+ return api_platform->vtbl->window.resize(wc_self, width, height);
+}
+
+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);
More information about the waffle
mailing list