1
0
Fork 0

cogl/onscreen: Remove explicit 'resizable':ness

Mutter didn't use the APIs for resizeability of CoglOnscreens but
managed the size itself. For the native backend we don't ever resize
onscreens. Thus, remove this unused functionality.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
This commit is contained in:
Jonas Ådahl 2020-10-19 22:46:23 +02:00 committed by Robert Mader
parent e43b95cd11
commit 4ec0975e91
10 changed files with 1 additions and 399 deletions

View file

@ -70,9 +70,6 @@ _cogl_onscreen_notify_frame_sync (CoglOnscreen *onscreen, CoglFrameInfo *info);
COGL_EXPORT void
_cogl_onscreen_notify_complete (CoglOnscreen *onscreen, CoglFrameInfo *info);
void
_cogl_onscreen_notify_resize (CoglOnscreen *onscreen);
void
_cogl_onscreen_queue_dirty (CoglOnscreen *onscreen,
const CoglOnscreenDirtyInfo *info);

View file

@ -48,9 +48,6 @@ typedef struct _CoglOnscreenPrivate
{
CoglList frame_closures;
gboolean resizable;
CoglList resize_closures;
CoglList dirty_closures;
int64_t frame_counter;
@ -76,10 +73,6 @@ cogl_dummy_free (gpointer data)
COGL_GTYPE_DEFINE_BOXED (FrameClosure, frame_closure,
cogl_dummy_copy,
cogl_dummy_free);
COGL_GTYPE_DEFINE_BOXED (OnscreenResizeClosure,
onscreen_resize_closure,
cogl_dummy_copy,
cogl_dummy_free);
COGL_GTYPE_DEFINE_BOXED (OnscreenDirtyClosure,
onscreen_dirty_closure,
cogl_dummy_copy,
@ -118,7 +111,6 @@ cogl_onscreen_init_from_template (CoglOnscreen *onscreen,
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
_cogl_list_init (&priv->frame_closures);
_cogl_list_init (&priv->resize_closures);
_cogl_list_init (&priv->dirty_closures);
cogl_framebuffer_init_config (framebuffer, &onscreen_template->config);
@ -145,7 +137,6 @@ cogl_onscreen_dispose (GObject *object)
CoglOnscreenPrivate *priv = cogl_onscreen_get_instance_private (onscreen);
CoglFrameInfo *frame_info;
_cogl_closure_list_disconnect_all (&priv->resize_closures);
_cogl_closure_list_disconnect_all (&priv->frame_closures);
_cogl_closure_list_disconnect_all (&priv->dirty_closures);
@ -556,19 +547,6 @@ _cogl_onscreen_notify_complete (CoglOnscreen *onscreen, CoglFrameInfo *info)
notify_event (onscreen, COGL_FRAME_EVENT_COMPLETE, info);
}
void
_cogl_onscreen_notify_resize (CoglOnscreen *onscreen)
{
CoglOnscreenPrivate *priv = cogl_onscreen_get_instance_private (onscreen);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
_cogl_closure_list_invoke (&priv->resize_closures,
CoglOnscreenResizeCallback,
onscreen,
cogl_framebuffer_get_width (framebuffer),
cogl_framebuffer_get_height (framebuffer));
}
void
_cogl_framebuffer_winsys_update_size (CoglFramebuffer *framebuffer,
int width, int height)
@ -584,58 +562,6 @@ _cogl_framebuffer_winsys_update_size (CoglFramebuffer *framebuffer,
_cogl_onscreen_queue_full_dirty (COGL_ONSCREEN (framebuffer));
}
void
cogl_onscreen_set_resizable (CoglOnscreen *onscreen,
gboolean resizable)
{
CoglOnscreenPrivate *priv = cogl_onscreen_get_instance_private (onscreen);
CoglFramebuffer *framebuffer;
const CoglWinsysVtable *winsys;
if (priv->resizable == resizable)
return;
priv->resizable = resizable;
framebuffer = COGL_FRAMEBUFFER (onscreen);
if (cogl_framebuffer_is_allocated (framebuffer))
{
winsys = _cogl_framebuffer_get_winsys (COGL_FRAMEBUFFER (onscreen));
if (winsys->onscreen_set_resizable)
winsys->onscreen_set_resizable (onscreen, resizable);
}
}
gboolean
cogl_onscreen_get_resizable (CoglOnscreen *onscreen)
{
CoglOnscreenPrivate *priv = cogl_onscreen_get_instance_private (onscreen);
return priv->resizable;
}
CoglOnscreenResizeClosure *
cogl_onscreen_add_resize_callback (CoglOnscreen *onscreen,
CoglOnscreenResizeCallback callback,
void *user_data,
CoglUserDataDestroyCallback destroy)
{
CoglOnscreenPrivate *priv = cogl_onscreen_get_instance_private (onscreen);
return _cogl_closure_list_add (&priv->resize_closures,
callback,
user_data,
destroy);
}
void
cogl_onscreen_remove_resize_callback (CoglOnscreen *onscreen,
CoglOnscreenResizeClosure *closure)
{
_cogl_closure_disconnect (closure);
}
CoglOnscreenDirtyClosure *
cogl_onscreen_add_dirty_callback (CoglOnscreen *onscreen,
CoglOnscreenDirtyCallback callback,

View file

@ -493,168 +493,6 @@ COGL_EXPORT void
cogl_onscreen_remove_frame_callback (CoglOnscreen *onscreen,
CoglFrameClosure *closure);
/**
* cogl_onscreen_set_resizable:
* @onscreen: A #CoglOnscreen framebuffer
*
* Lets you request Cogl to mark an @onscreen framebuffer as
* resizable or not.
*
* By default, if possible, a @onscreen will be created by Cogl
* as non resizable, but it is not guaranteed that this is always
* possible for all window systems.
*
* <note>Cogl does not know whether marking the @onscreen framebuffer
* is truly meaningful for your current window system (consider
* applications being run fullscreen on a phone or TV) so this
* function may not have any useful effect. If you are running on a
* multi windowing system such as X11 or Win32 or OSX then Cogl will
* request to the window system that users be allowed to resize the
* @onscreen, although it's still possible that some other window
* management policy will block this possibility.</note>
*
* <note>Whenever an @onscreen framebuffer is resized the viewport
* will be automatically updated to match the new size of the
* framebuffer with an origin of (0,0). If your application needs more
* specialized control of the viewport it will need to register a
* resize handler using cogl_onscreen_add_resize_callback() so that it
* can track when the viewport has been changed automatically.</note>
*
* Since: 2.0
*/
COGL_EXPORT void
cogl_onscreen_set_resizable (CoglOnscreen *onscreen,
gboolean resizable);
/**
* cogl_onscreen_get_resizable:
* @onscreen: A #CoglOnscreen framebuffer
*
* Lets you query whether @onscreen has been marked as resizable via
* the cogl_onscreen_set_resizable() api.
*
* By default, if possible, a @onscreen will be created by Cogl
* as non resizable, but it is not guaranteed that this is always
* possible for all window systems.
*
* <note>If cogl_onscreen_set_resizable(@onscreen, %TRUE) has been
* previously called then this function will return %TRUE, but it's
* possible that the current windowing system being used does not
* support window resizing (consider fullscreen windows on a phone or
* a TV). This function is not aware of whether resizing is truly
* meaningful with your window system, only whether the @onscreen has
* been marked as resizable.</note>
*
* Return value: Returns whether @onscreen has been marked as
* resizable or not.
* Since: 2.0
*/
COGL_EXPORT gboolean
cogl_onscreen_get_resizable (CoglOnscreen *onscreen);
/**
* CoglOnscreenResizeCallback:
* @onscreen: A #CoglOnscreen framebuffer that was resized
* @width: The new width of @onscreen
* @height: The new height of @onscreen
* @user_data: The private passed to
* cogl_onscreen_add_resize_callback()
*
* Is a callback type used with the
* cogl_onscreen_add_resize_callback() allowing applications to be
* notified whenever an @onscreen framebuffer is resized.
*
* <note>Cogl automatically updates the viewport of an @onscreen
* framebuffer that is resized so this callback is also an indication
* that the viewport has been modified too</note>
*
* <note>A resize callback will only ever be called while dispatching
* Cogl events from the system mainloop; so for example during
* cogl_poll_renderer_dispatch(). This is so that callbacks shouldn't
* occur while an application might have arbitrary locks held for
* example.</note>
*
* Since: 2.0
*/
typedef void (*CoglOnscreenResizeCallback) (CoglOnscreen *onscreen,
int width,
int height,
void *user_data);
/**
* CoglOnscreenResizeClosure:
*
* An opaque type that tracks a #CoglOnscreenResizeCallback and
* associated user data. A #CoglOnscreenResizeClosure pointer will be
* returned from cogl_onscreen_add_resize_callback() and it allows you
* to remove a callback later using
* cogl_onscreen_remove_resize_callback().
*
* Since: 2.0
* Stability: unstable
*/
typedef struct _CoglClosure CoglOnscreenResizeClosure;
/**
* cogl_onscreen_resize_closure_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
COGL_EXPORT
GType cogl_onscreen_resize_closure_get_gtype (void);
/**
* cogl_onscreen_add_resize_callback:
* @onscreen: A #CoglOnscreen framebuffer
* @callback: (scope notified): A #CoglOnscreenResizeCallback to call when
* the @onscreen changes size.
* @user_data: (closure): Private data to be passed to @callback.
* @destroy: (allow-none): An optional callback to destroy @user_data
* when the @callback is removed or @onscreen is freed.
*
* Registers a @callback with @onscreen that will be called whenever
* the @onscreen framebuffer changes size.
*
* The @callback can be removed using
* cogl_onscreen_remove_resize_callback() passing the returned closure
* pointer.
*
* <note>Since Cogl automatically updates the viewport of an @onscreen
* framebuffer that is resized, a resize callback can also be used to
* track when the viewport has been changed automatically by Cogl in
* case your application needs more specialized control over the
* viewport.</note>
*
* <note>A resize callback will only ever be called while dispatching
* Cogl events from the system mainloop; so for example during
* cogl_poll_renderer_dispatch(). This is so that callbacks shouldn't
* occur while an application might have arbitrary locks held for
* example.</note>
*
* Return value: a #CoglOnscreenResizeClosure pointer that can be used to
* remove the callback and associated @user_data later.
* Since: 2.0
*/
COGL_EXPORT CoglOnscreenResizeClosure *
cogl_onscreen_add_resize_callback (CoglOnscreen *onscreen,
CoglOnscreenResizeCallback callback,
void *user_data,
CoglUserDataDestroyCallback destroy);
/**
* cogl_onscreen_remove_resize_callback:
* @onscreen: A #CoglOnscreen framebuffer
* @closure: An identifier returned from cogl_onscreen_add_resize_callback()
*
* Removes a resize @callback and @user_data pair that were previously
* associated with @onscreen via cogl_onscreen_add_resize_callback().
*
* Since: 2.0
*/
COGL_EXPORT void
cogl_onscreen_remove_resize_callback (CoglOnscreen *onscreen,
CoglOnscreenResizeClosure *closure);
/**
* CoglOnscreenDirtyInfo:
* @x: Left edge of the dirty rectangle

View file

@ -50,7 +50,6 @@ struct _CoglOnscreenGlx
uint32_t last_swap_vsync_counter;
uint32_t pending_sync_notify;
uint32_t pending_complete_notify;
uint32_t pending_resize_notify;
};
G_DEFINE_TYPE (CoglOnscreenGlx, cogl_onscreen_glx,
@ -552,8 +551,7 @@ cogl_onscreen_glx_flush_notification (CoglOnscreen *onscreen)
CoglOnscreenGlx *onscreen_glx = COGL_ONSCREEN_GLX (onscreen);
while (onscreen_glx->pending_sync_notify > 0 ||
onscreen_glx->pending_complete_notify > 0 ||
onscreen_glx->pending_resize_notify > 0)
onscreen_glx->pending_complete_notify > 0)
{
if (onscreen_glx->pending_sync_notify > 0)
{
@ -573,12 +571,6 @@ cogl_onscreen_glx_flush_notification (CoglOnscreen *onscreen)
cogl_object_unref (info);
onscreen_glx->pending_complete_notify--;
}
if (onscreen_glx->pending_resize_notify > 0)
{
_cogl_onscreen_notify_resize (onscreen);
onscreen_glx->pending_resize_notify--;
}
}
}
@ -958,44 +950,6 @@ _cogl_winsys_onscreen_glx_get_window_xid (CoglOnscreen *onscreen)
return onscreen_glx->xwin;
}
void
_cogl_winsys_onscreen_glx_set_resizable (CoglOnscreen *onscreen,
gboolean resizable)
{
CoglOnscreenGlx *onscreen_glx = COGL_ONSCREEN_GLX (onscreen);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglXlibRenderer *xlib_renderer =
_cogl_xlib_renderer_get_data (context->display->renderer);
XSizeHints *size_hints = XAllocSizeHints ();
if (resizable)
{
/* TODO: Add cogl_onscreen_request_minimum_size () */
size_hints->min_width = 1;
size_hints->min_height = 1;
size_hints->max_width = INT_MAX;
size_hints->max_height = INT_MAX;
}
else
{
int width = cogl_framebuffer_get_width (framebuffer);
int height = cogl_framebuffer_get_height (framebuffer);
size_hints->min_width = width;
size_hints->min_height = height;
size_hints->max_width = width;
size_hints->max_height = height;
}
XSetWMNormalHints (xlib_renderer->xdpy, onscreen_glx->xwin, size_hints);
XFree (size_hints);
}
void
cogl_onscreen_glx_notify_swap_buffers (CoglOnscreen *onscreen,
GLXBufferSwapComplete *swap_event)
@ -1079,8 +1033,6 @@ cogl_onscreen_glx_resize (CoglOnscreen *onscreen,
NULL);
}
onscreen_glx->pending_resize_notify++;
if (configure_event->send_event)
{
x = configure_event->x;

View file

@ -47,10 +47,6 @@ _cogl_winsys_onscreen_glx_get_buffer_age (CoglOnscreen *onscreen);
uint32_t
_cogl_winsys_onscreen_glx_get_window_xid (CoglOnscreen *onscreen);
void
_cogl_winsys_onscreen_glx_set_resizable (CoglOnscreen *onscreen,
gboolean resizable);
void
cogl_onscreen_glx_resize (CoglOnscreen *onscreen,
XConfigureEvent *configure_event);

View file

@ -39,8 +39,6 @@ struct _CoglOnscreenXlib
CoglOnscreenEgl parent;
Window xwin;
gboolean pending_resize_notify;
};
G_DEFINE_TYPE (CoglOnscreenXlib, cogl_onscreen_xlib,
@ -196,44 +194,6 @@ cogl_onscreen_xlib_dispose (GObject *object)
}
}
void
_cogl_winsys_onscreen_xlib_set_resizable (CoglOnscreen *onscreen,
gboolean resizable)
{
CoglOnscreenXlib *onscreen_xlib = COGL_ONSCREEN_XLIB (onscreen);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglXlibRenderer *xlib_renderer =
_cogl_xlib_renderer_get_data (context->display->renderer);
XSizeHints *size_hints = XAllocSizeHints ();
if (resizable)
{
/* TODO: Add cogl_onscreen_request_minimum_size () */
size_hints->min_width = 1;
size_hints->min_height = 1;
size_hints->max_width = INT_MAX;
size_hints->max_height = INT_MAX;
}
else
{
int width = cogl_framebuffer_get_width (framebuffer);
int height = cogl_framebuffer_get_height (framebuffer);
size_hints->min_width = width;
size_hints->min_height = height;
size_hints->max_width = width;
size_hints->max_height = height;
}
XSetWMNormalHints (xlib_renderer->xdpy, onscreen_xlib->xwin, size_hints);
XFree (size_hints);
}
uint32_t
_cogl_winsys_onscreen_xlib_get_window_xid (CoglOnscreen *onscreen)
{
@ -251,69 +211,14 @@ cogl_onscreen_xlib_is_for_window (CoglOnscreen *onscreen,
return onscreen_xlib->xwin == window;
}
static void
flush_pending_resize_notifications_cb (void *data,
void *user_data)
{
CoglFramebuffer *framebuffer = data;
if (COGL_IS_ONSCREEN (framebuffer))
{
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
CoglOnscreenXlib *onscreen_xlib = COGL_ONSCREEN_XLIB (onscreen);
if (onscreen_xlib->pending_resize_notify)
{
_cogl_onscreen_notify_resize (onscreen);
onscreen_xlib->pending_resize_notify = FALSE;
}
}
}
static void
flush_pending_resize_notifications_idle (void *user_data)
{
CoglContext *context = user_data;
CoglRenderer *renderer = context->display->renderer;
CoglRendererEGL *egl_renderer = renderer->winsys;
/* This needs to be disconnected before invoking the callbacks in
* case the callbacks cause it to be queued again */
_cogl_closure_disconnect (egl_renderer->resize_notify_idle);
egl_renderer->resize_notify_idle = NULL;
g_list_foreach (context->framebuffers,
flush_pending_resize_notifications_cb,
NULL);
}
void
cogl_onscreen_xlib_resize (CoglOnscreen *onscreen,
int width,
int height)
{
CoglOnscreenXlib *onscreen_xlib = COGL_ONSCREEN_XLIB (onscreen);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglRenderer *renderer = context->display->renderer;
CoglRendererEGL *egl_renderer = renderer->winsys;
_cogl_framebuffer_winsys_update_size (framebuffer, width, height);
/* We only want to notify that a resize happened when the
* application calls cogl_context_dispatch so instead of immediately
* notifying we queue an idle callback */
if (!egl_renderer->resize_notify_idle)
{
egl_renderer->resize_notify_idle =
_cogl_poll_renderer_add_idle (renderer,
flush_pending_resize_notifications_idle,
context,
NULL);
}
onscreen_xlib->pending_resize_notify = TRUE;
}
CoglOnscreenXlib *

View file

@ -49,10 +49,6 @@ cogl_onscreen_xlib_new (CoglContext *context,
void
_cogl_winsys_egl_onscreen_xlib_deinit (CoglOnscreen *onscreen);
void
_cogl_winsys_onscreen_xlib_set_resizable (CoglOnscreen *onscreen,
gboolean resizable);
uint32_t
_cogl_winsys_onscreen_xlib_get_window_xid (CoglOnscreen *onscreen);

View file

@ -590,9 +590,6 @@ _cogl_winsys_egl_xlib_get_vtable (void)
vtable.renderer_connect = _cogl_winsys_renderer_connect;
vtable.renderer_disconnect = _cogl_winsys_renderer_disconnect;
vtable.onscreen_set_resizable =
_cogl_winsys_onscreen_xlib_set_resizable;
vtable.onscreen_x11_get_window_xid =
_cogl_winsys_onscreen_xlib_get_window_xid;

View file

@ -1472,8 +1472,6 @@ static CoglWinsysVtable _cogl_winsys_vtable =
.onscreen_get_buffer_age = _cogl_winsys_onscreen_glx_get_buffer_age,
.onscreen_x11_get_window_xid =
_cogl_winsys_onscreen_glx_get_window_xid,
.onscreen_set_resizable =
_cogl_winsys_onscreen_glx_set_resizable,
/* X11 tfp support... */
/* XXX: instead of having a rather monolithic winsys vtable we could

View file

@ -109,9 +109,6 @@ typedef struct _CoglWinsysVtable
int64_t
(*context_get_clock_time) (CoglContext *context);
void
(*onscreen_set_resizable) (CoglOnscreen *onscreen, gboolean resizable);
int
(*onscreen_get_buffer_age) (CoglOnscreen *onscreen);