mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-03-10 05:34:08 -04:00
types/wlr_buffer: add buffer_get_drm_format helper function
This commit is contained in:
parent
bb78861ca9
commit
ef88246642
4 changed files with 32 additions and 22 deletions
|
|
@ -109,14 +109,11 @@ bool wlr_buffer_get_shm(struct wlr_buffer *buffer,
|
|||
|
||||
bool wlr_buffer_is_opaque(struct wlr_buffer *buffer) {
|
||||
void *data;
|
||||
uint32_t format;
|
||||
uint32_t format = buffer_get_drm_format(buffer);
|
||||
size_t stride;
|
||||
struct wlr_dmabuf_attributes dmabuf;
|
||||
struct wlr_shm_attributes shm;
|
||||
if (wlr_buffer_get_dmabuf(buffer, &dmabuf)) {
|
||||
format = dmabuf.format;
|
||||
} else if (wlr_buffer_get_shm(buffer, &shm)) {
|
||||
format = shm.format;
|
||||
|
||||
if (format != DRM_FORMAT_INVALID) {
|
||||
// pass
|
||||
} else if (wlr_buffer_begin_data_ptr_access(buffer,
|
||||
WLR_BUFFER_DATA_PTR_ACCESS_READ, &data, &format, &stride)) {
|
||||
bool opaque = false;
|
||||
|
|
@ -135,3 +132,15 @@ bool wlr_buffer_is_opaque(struct wlr_buffer *buffer) {
|
|||
|
||||
return !pixel_format_has_alpha(format);
|
||||
}
|
||||
|
||||
uint32_t buffer_get_drm_format(struct wlr_buffer *buffer) {
|
||||
uint32_t format = DRM_FORMAT_INVALID;
|
||||
struct wlr_dmabuf_attributes dmabuf;
|
||||
struct wlr_shm_attributes shm;
|
||||
if (wlr_buffer_get_dmabuf(buffer, &dmabuf)) {
|
||||
format = dmabuf.format;
|
||||
} else if (wlr_buffer_get_shm(buffer, &shm)) {
|
||||
format = shm.format;
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "color-representation-v1-protocol.h"
|
||||
#include "render/pixel_format.h"
|
||||
#include "types/wlr_buffer.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
#define WP_COLOR_REPRESENTATION_VERSION 1
|
||||
|
|
@ -240,14 +241,14 @@ static void surface_synced_commit(struct wlr_surface_synced *synced) {
|
|||
return;
|
||||
}
|
||||
|
||||
struct wlr_dmabuf_attributes dmabuf;
|
||||
|
||||
if (!color_repr->surface->buffer ||
|
||||
!wlr_buffer_get_dmabuf(&color_repr->surface->buffer->base, &dmabuf)) {
|
||||
uint32_t drm_format = DRM_FORMAT_INVALID;
|
||||
if (!color_repr->surface->buffer){
|
||||
drm_format = buffer_get_drm_format(&color_repr->surface->buffer->base);
|
||||
}
|
||||
if (drm_format == DRM_FORMAT_INVALID) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool is_ycbcr = pixel_format_is_ycbcr(dmabuf.format);
|
||||
bool is_ycbcr = pixel_format_is_ycbcr(drm_format);
|
||||
|
||||
bool is_identity_full =
|
||||
color_repr->current.coefficients == WP_COLOR_REPRESENTATION_SURFACE_V1_COEFFICIENTS_IDENTITY &&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue