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. 44
      libweston/renderer-gl/gl-renderer.c

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

Loading…
Cancel
Save