static unsigned int picture_format_fixups(struct xa_picture *src_pic, int mask) { boolean set_alpha = FALSE; boolean swizzle = FALSE; unsigned ret = 0; struct xa_surface *src = src_pic->srf; enum xa_formats src_hw_format, src_pic_format; enum xa_surface_type src_hw_type, src_pic_type; if (!src) return 0; src_hw_format = xa_surface_format(src); src_pic_format = src_pic->pict_format; set_alpha = (xa_format_type_is_color(src_pic_format) && xa_format_a(src_pic_format) == 0); if (set_alpha) ret |= mask ? FS_MASK_SET_ALPHA : FS_SRC_SET_ALPHA; if (src_hw_format == src_pic_format) { if (src->tex->format == PIPE_FORMAT_L8_UNORM) return ((mask) ? FS_MASK_LUMINANCE : FS_SRC_LUMINANCE); return ret; } src_hw_type = xa_format_type(src_hw_format); src_pic_type = xa_format_type(src_pic_format); swizzle = ((src_hw_type == xa_type_argb && src_pic_type == xa_type_abgr) || ((src_hw_type == xa_type_abgr && src_pic_type == xa_type_argb))); if (!swizzle && (src_hw_type != src_pic_type)) return ret; if (swizzle) ret |= mask ? FS_MASK_SWIZZLE_RGB : FS_SRC_SWIZZLE_RGB; return ret; }
int xa_format_check_supported(struct xa_tracker *xa, enum xa_formats xa_format, unsigned int flags) { struct xa_format_descriptor fdesc = xa_get_pipe_format(xa_format); unsigned int bind; if (fdesc.xa_format == xa_format_unknown) return -XA_ERR_INVAL; bind = stype_bind[xa_format_type(fdesc.xa_format)]; if (flags & XA_FLAG_SHARED) bind |= PIPE_BIND_SHARED; if (flags & XA_FLAG_RENDER_TARGET) bind |= PIPE_BIND_RENDER_TARGET; if (!xa->screen->is_format_supported(xa->screen, fdesc.format, PIPE_TEXTURE_2D, 0, bind)) return -XA_ERR_INVAL; return XA_ERR_NONE; }
if (fdesc.xa_format == xa_format_unknown) return NULL; srf = calloc(1, sizeof(*srf)); if (!srf) return NULL; template = &srf->template; template->format = fdesc.format; template->target = PIPE_TEXTURE_2D; template->width0 = width; template->height0 = height; template->depth0 = 1; template->array_size = 1; template->last_level = 0; template->bind = stype_bind[xa_format_type(fdesc.xa_format)]; if (flags & XA_FLAG_SHARED) template->bind |= PIPE_BIND_SHARED; if (flags & XA_FLAG_RENDER_TARGET) template->bind |= PIPE_BIND_RENDER_TARGET; if (flags & XA_FLAG_SCANOUT) template->bind |= PIPE_BIND_SCANOUT; if (whandle) srf->tex = xa->screen->resource_from_handle(xa->screen, template, whandle); else srf->tex = xa->screen->resource_create(xa->screen, template); if (!srf->tex) goto out_no_tex;