onscreen: Adds support for resizable windows

This adds api to be able to request that the window system allows a
given onscreen framebuffer to be resizable, and api to add and remove
resize handlers to be called whenever the framebuffer does actually
change size.

The new functions are:
  cogl_onscreen_{get,set}_resizable()
  cogl_onscreen_{add,remove}_resize_handler()

The examples cogl-hello and cogl-x11-foreign have been updated to use
the new api. To smoke test how Cogl updates the viewport automatically
in response to window resizes the cogl-hello test doesn't explicitly
respond to resize events by setting the viewport and cogl-x11-foreign
responds by setting a viewport that is offset by a quarter of the
window's width/height and half the width and height of the window.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit a1a8cc00bfa2cecaf1007aec5f3dd95dc07b1786)
This commit is contained in:
Robert Bragg
2012-06-20 16:22:36 +01:00
parent 72f992effe
commit df51574116
12 changed files with 563 additions and 38 deletions

View File

@@ -46,6 +46,19 @@ struct _CoglSwapBuffersNotifyEntry
unsigned int id;
};
typedef struct _CoglResizeNotifyEntry CoglResizeNotifyEntry;
COGL_TAILQ_HEAD (CoglResizeNotifyList, CoglResizeNotifyEntry);
struct _CoglResizeNotifyEntry
{
COGL_TAILQ_ENTRY (CoglResizeNotifyEntry) list_node;
CoglOnscreenResizeCallback callback;
void *user_data;
unsigned int id;
};
struct _CoglOnscreen
{
CoglFramebuffer _parent;
@@ -64,6 +77,9 @@ struct _CoglOnscreen
CoglSwapBuffersNotifyList swap_callbacks;
CoglBool resizable;
CoglResizeNotifyList resize_callbacks;
void *winsys;
};
@@ -77,4 +93,7 @@ _cogl_framebuffer_winsys_update_size (CoglFramebuffer *framebuffer,
void
_cogl_onscreen_notify_swap_buffers (CoglOnscreen *onscreen);
void
_cogl_onscreen_notify_resize (CoglOnscreen *onscreen);
#endif /* __COGL_ONSCREEN_PRIVATE_H */