aboutsummaryrefslogtreecommitdiff
path: root/render/gles2
diff options
context:
space:
mode:
authorAlexander Orzechowski <alex@ozal.ski>2023-05-22 16:20:26 -0400
committerAlexander Orzechowski <alex@ozal.ski>2023-05-28 14:53:34 -0400
commit45b2a8eee2f1ee30bd021cba7e918c758b8f4cea (patch)
tree69a8d786725b2449304358cefe54e32cdd2acd14 /render/gles2
parent6f67bfe5ab111881f2c066502b845d35c0c24a30 (diff)
renderer/gles2: Merge get_buffer and create_buffer
Diffstat (limited to 'render/gles2')
-rw-r--r--render/gles2/renderer.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index 6648fb65..67168fe9 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -85,19 +85,15 @@ static const struct wlr_addon_interface buffer_addon_impl = {
.destroy = handle_buffer_destroy,
};
-static struct wlr_gles2_buffer *get_buffer(struct wlr_gles2_renderer *renderer,
+static struct wlr_gles2_buffer *get_or_create_buffer(struct wlr_gles2_renderer *renderer,
struct wlr_buffer *wlr_buffer) {
struct wlr_addon *addon =
wlr_addon_find(&wlr_buffer->addons, renderer, &buffer_addon_impl);
- if (addon == NULL) {
- return NULL;
+ if (addon) {
+ struct wlr_gles2_buffer *buffer = wl_container_of(addon, buffer, addon);
+ return buffer;
}
- struct wlr_gles2_buffer *buffer = wl_container_of(addon, buffer, addon);
- return buffer;
-}
-static struct wlr_gles2_buffer *create_buffer(struct wlr_gles2_renderer *renderer,
- struct wlr_buffer *wlr_buffer) {
struct wlr_gles2_buffer *buffer = calloc(1, sizeof(*buffer));
if (buffer == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed");
@@ -180,10 +176,7 @@ static bool gles2_bind_buffer(struct wlr_renderer *wlr_renderer,
wlr_egl_make_current(renderer->egl);
- struct wlr_gles2_buffer *buffer = get_buffer(renderer, wlr_buffer);
- if (buffer == NULL) {
- buffer = create_buffer(renderer, wlr_buffer);
- }
+ struct wlr_gles2_buffer *buffer = get_or_create_buffer(renderer, wlr_buffer);
if (buffer == NULL) {
return false;
}