aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-12-18 12:47:50 +0100
committerIlia Bozhinov <ammen99@gmail.com>2020-12-30 11:17:43 +0100
commit92a0fc0435a86396de4f9b010e22036a933cf9d0 (patch)
treebd3786d3610de42e409ae05efaf444fc4a7beccc
parentc4635c68d25b92564a4568f435526108448fa0ca (diff)
backend/drm: extract linear format creation into function
Simplifies error handling.
-rw-r--r--backend/drm/renderer.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index c3d7e638..c73fe73c 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -208,6 +208,18 @@ static uint32_t strip_alpha_channel(uint32_t format) {
}
}
+static struct wlr_drm_format *create_linear_format(uint32_t format) {
+ struct wlr_drm_format *fmt = wlr_drm_format_create(format);
+ if (fmt == NULL) {
+ return NULL;
+ }
+ if (!wlr_drm_format_add(&fmt, DRM_FORMAT_MOD_LINEAR)) {
+ free(fmt);
+ return NULL;
+ }
+ return fmt;
+}
+
bool drm_plane_init_surface(struct wlr_drm_plane *plane,
struct wlr_drm_backend *drm, int32_t width, uint32_t height,
uint32_t format, bool force_linear, bool with_modifiers) {
@@ -249,16 +261,11 @@ bool drm_plane_init_surface(struct wlr_drm_plane *plane,
drm_format = wlr_drm_format_create(format);
}
- struct wlr_drm_format *drm_format_linear = wlr_drm_format_create(format);
+ struct wlr_drm_format *drm_format_linear = create_linear_format(format);
if (drm_format_linear == NULL) {
free(drm_format);
return false;
}
- if (!wlr_drm_format_add(&drm_format_linear, DRM_FORMAT_MOD_LINEAR)) {
- free(drm_format_linear);
- free(drm_format);
- return false;
- }
if (force_linear) {
free(drm_format);