mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	backend/drm: extract linear format creation into function
Simplifies error handling.
This commit is contained in:
		
							parent
							
								
									c4635c68d2
								
							
						
					
					
						commit
						92a0fc0435
					
				
					 1 changed files with 13 additions and 6 deletions
				
			
		| 
						 | 
					@ -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,
 | 
					bool drm_plane_init_surface(struct wlr_drm_plane *plane,
 | 
				
			||||||
		struct wlr_drm_backend *drm, int32_t width, uint32_t height,
 | 
							struct wlr_drm_backend *drm, int32_t width, uint32_t height,
 | 
				
			||||||
		uint32_t format, bool force_linear, bool with_modifiers) {
 | 
							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);
 | 
							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) {
 | 
						if (drm_format_linear == NULL) {
 | 
				
			||||||
		free(drm_format);
 | 
							free(drm_format);
 | 
				
			||||||
		return false;
 | 
							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) {
 | 
						if (force_linear) {
 | 
				
			||||||
		free(drm_format);
 | 
							free(drm_format);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue