gl-renderer: Make attach_shm return early on cache hit

If we can reuse the textures we already have, just return early, rather
than putting all the work in a large indented body.

Signed-off-by: Daniel Stone <daniels@collabora.com>
dev
Daniel Stone 3 years ago
parent 1a65c1b8b1
commit 70874428d6
  1. 18
      libweston/renderer-gl/gl-renderer.c

@ -2158,13 +2158,16 @@ unsupported:
/* Only allocate a texture if it doesn't match existing one.
* If a switch from DRM allocated buffer to a SHM buffer is
* happening, we need to allocate a new texture buffer. */
if (pitch != gb->pitch ||
buffer->height != gb->height ||
gl_format[0] != gb->gl_format[0] ||
gl_format[1] != gb->gl_format[1] ||
gl_format[2] != gb->gl_format[2] ||
gl_pixel_type != gb->gl_pixel_type ||
gb->buffer_type != BUFFER_TYPE_SHM) {
if (pitch == gb->pitch &&
buffer->height == gb->height &&
gl_format[0] == gb->gl_format[0] &&
gl_format[1] == gb->gl_format[1] &&
gl_format[2] == gb->gl_format[2] &&
gl_pixel_type == gb->gl_pixel_type &&
gb->buffer_type == BUFFER_TYPE_SHM) {
return true;
}
gb->pitch = pitch;
gb->height = buffer->height;
gb->gl_format[0] = gl_format[0];
@ -2179,7 +2182,6 @@ unsupported:
gs->surface = es;
ensure_textures(gs, GL_TEXTURE_2D, num_planes);
}
return true;
}

Loading…
Cancel
Save