mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 20:28:04 +02:00
st/egl: add premultiplied alpha support to wayland
Return true for NATIVE_PARAM_PREMULTIPLIED_ALPHA when all formats with
alpha support premultiplied alpha.
(Based on Chia-I Wu's patch)
[olv: remove the use of param_premultiplied_alpha from the original
patch]
This commit is contained in:
parent
1191d20363
commit
7645c49e07
4 changed files with 24 additions and 4 deletions
|
|
@ -109,8 +109,8 @@ wayland_create_drm_buffer(struct wayland_display *display,
|
|||
|
||||
switch (surface->color_format) {
|
||||
case PIPE_FORMAT_B8G8R8A8_UNORM:
|
||||
/* assume premultiplied */
|
||||
format = WL_DRM_FORMAT_PREMULTIPLIED_ARGB32;
|
||||
format = (surface->premultiplied_alpha) ?
|
||||
WL_DRM_FORMAT_PREMULTIPLIED_ARGB32 : WL_DRM_FORMAT_ARGB32;
|
||||
break;
|
||||
case PIPE_FORMAT_B8G8R8X8_UNORM:
|
||||
format = WL_DRM_FORMAT_XRGB32;
|
||||
|
|
|
|||
|
|
@ -94,8 +94,8 @@ wayland_create_shm_buffer(struct wayland_display *display,
|
|||
|
||||
switch (surface->color_format) {
|
||||
case PIPE_FORMAT_B8G8R8A8_UNORM:
|
||||
/* assume premultiplied */
|
||||
format = WL_SHM_FORMAT_PREMULTIPLIED_ARGB32;
|
||||
format = (surface->premultiplied_alpha) ?
|
||||
WL_SHM_FORMAT_PREMULTIPLIED_ARGB32 : WL_SHM_FORMAT_ARGB32;
|
||||
break;
|
||||
case PIPE_FORMAT_B8G8R8X8_UNORM:
|
||||
format = WL_SHM_FORMAT_XRGB32;
|
||||
|
|
|
|||
|
|
@ -99,9 +99,14 @@ static int
|
|||
wayland_display_get_param(struct native_display *ndpy,
|
||||
enum native_param_type param)
|
||||
{
|
||||
struct wayland_display *display = wayland_display(ndpy);
|
||||
int val;
|
||||
|
||||
switch (param) {
|
||||
case NATIVE_PARAM_PREMULTIPLIED_ALPHA:
|
||||
val = ((display->formats & HAS_ARGB32) &&
|
||||
(display->formats & HAS_PREMUL_ARGB32));
|
||||
break;
|
||||
case NATIVE_PARAM_USE_NATIVE_BUFFER:
|
||||
case NATIVE_PARAM_PRESERVE_BUFFER:
|
||||
case NATIVE_PARAM_MAX_SWAP_INTERVAL:
|
||||
|
|
@ -322,6 +327,20 @@ wayland_surface_present(struct native_surface *nsurf,
|
|||
if (ctrl->preserve || ctrl->swap_interval)
|
||||
return FALSE;
|
||||
|
||||
/* force buffers to be re-created if they will be presented differently */
|
||||
if (surface->premultiplied_alpha != ctrl->premultiplied_alpha) {
|
||||
enum wayland_buffer_type buffer;
|
||||
|
||||
for (buffer = 0; buffer < WL_BUFFER_COUNT; ++buffer) {
|
||||
if (surface->buffer[buffer]) {
|
||||
wl_buffer_destroy(surface->buffer[buffer]);
|
||||
surface->buffer[buffer] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
surface->premultiplied_alpha = ctrl->premultiplied_alpha;
|
||||
}
|
||||
|
||||
switch (ctrl->natt) {
|
||||
case NATIVE_ATTACHMENT_FRONT_LEFT:
|
||||
ret = TRUE;
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ struct wayland_surface {
|
|||
unsigned int attachment_mask;
|
||||
|
||||
boolean block_swap_buffers;
|
||||
boolean premultiplied_alpha;
|
||||
};
|
||||
|
||||
struct wayland_config {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue