cogl: Don't allow creating sized textures with 0 pixels

A texture with no pixels isn't a useful thing to have, and breaks
assumptions elsewhere. For example, CoglFramebuffer assumes that after
a texture has been allocated, it will have width and height both greater
than 0.

In particular, this works around a crash when gnome-shell tries to blur a
background that hasn't yet had any space allocated for it - which it seems
is really an actor layout bug, but more robustness seems good to have.

Workaround for <https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2538>.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1172

Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
Simon McVittie 2020-04-02 19:30:14 +01:00
parent 7d2df52336
commit 37eda498f2

View File

@ -121,6 +121,9 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
{ {
CoglTextureLoader *loader; CoglTextureLoader *loader;
g_return_val_if_fail (width >= 1, NULL);
g_return_val_if_fail (height >= 1, NULL);
loader = _cogl_texture_create_loader (); loader = _cogl_texture_create_loader ();
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED; loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED;
loader->src.sized.width = width; loader->src.sized.width = width;