render/pixman: implement preferred_read_format
This commit is contained in:
		
							parent
							
								
									0411dc0663
								
							
						
					
					
						commit
						30706b71fb
					
				|  | @ -46,6 +46,7 @@ struct wlr_pixman_texture { | |||
| }; | ||||
| 
 | ||||
| pixman_format_code_t get_pixman_format_from_drm(uint32_t fmt); | ||||
| uint32_t get_drm_format_from_pixman(pixman_format_code_t fmt); | ||||
| const uint32_t *get_pixman_drm_formats(size_t *len); | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
|  | @ -49,6 +49,17 @@ pixman_format_code_t get_pixman_format_from_drm(uint32_t fmt) { | |||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| uint32_t get_drm_format_from_pixman(pixman_format_code_t fmt) { | ||||
| 	for (size_t i = 0; i < sizeof(formats) / sizeof(*formats); ++i) { | ||||
| 		if (formats[i].pixman_format == fmt) { | ||||
| 			return formats[i].drm_format; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	wlr_log(WLR_ERROR, "pixman format 0x%"PRIX32" has no drm equivalent", fmt); | ||||
| 	return DRM_FORMAT_INVALID; | ||||
| } | ||||
| 
 | ||||
| const uint32_t *get_pixman_drm_formats(size_t *len) { | ||||
| 	static uint32_t drm_formats[sizeof(formats) / sizeof(formats[0])]; | ||||
| 	*len = sizeof(formats) / sizeof(formats[0]); | ||||
|  |  | |||
|  | @ -369,6 +369,17 @@ static void pixman_destroy(struct wlr_renderer *wlr_renderer) { | |||
| 	free(renderer); | ||||
| } | ||||
| 
 | ||||
| static uint32_t pixman_preferred_read_format( | ||||
| 		struct wlr_renderer *wlr_renderer) { | ||||
| 	struct wlr_pixman_renderer *renderer = get_renderer(wlr_renderer); | ||||
| 	struct wlr_pixman_buffer *buffer = renderer->current_buffer; | ||||
| 
 | ||||
| 	pixman_format_code_t pixman_format = pixman_image_get_format( | ||||
| 			buffer->image); | ||||
| 
 | ||||
| 	return get_drm_format_from_pixman(pixman_format); | ||||
| } | ||||
| 
 | ||||
| static const struct wlr_renderer_impl renderer_impl = { | ||||
| 	.begin = pixman_begin, | ||||
| 	.clear = pixman_clear, | ||||
|  | @ -380,6 +391,7 @@ static const struct wlr_renderer_impl renderer_impl = { | |||
| 	.texture_from_pixels = pixman_texture_from_pixels, | ||||
| 	.bind_buffer = pixman_bind_buffer, | ||||
| 	.destroy = pixman_destroy, | ||||
| 	.preferred_read_format = pixman_preferred_read_format, | ||||
| }; | ||||
| 
 | ||||
| struct wlr_renderer *wlr_pixman_renderer_create(void) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue