int i;
boolean supported = FALSE;
- /*
- * No component alpha yet.
- */
- if (mask_pic && mask_pic->component_alpha)
- return FALSE;
-
/*
* our default in case something goes wrong
*/
}
}
+ /*
+ * No component alpha yet.
+ */
+ if (mask_pic && mask_pic->component_alpha && blend->alpha_src)
+ return FALSE;
+
if (!dst_pic->srf)
return supported;
XA_EXPORT int
xa_composite_check_accelerated(const struct xa_composite *comp)
{
- struct xa_composite_blend blend;
struct xa_picture *src_pic = comp->src;
struct xa_picture *mask_pic = comp->mask;
-
- /*
- * No component alpha yet.
- */
- if (mask_pic && mask_pic->component_alpha)
- return -XA_ERR_INVAL;
+ struct xa_composite_blend blend;
if (!xa_is_filter_accelerated(src_pic) ||
!xa_is_filter_accelerated(comp->mask)) {
if (!blend_for_op(&blend, comp->op, comp->src, comp->mask, comp->dst))
return -XA_ERR_INVAL;
+ /*
+ * No component alpha yet.
+ */
+ if (mask_pic && mask_pic->component_alpha && blend.alpha_src)
+ return -XA_ERR_INVAL;
+
return XA_ERR_NONE;
}
struct xa_shader shader;
struct xa_picture *src_pic = comp->src;
struct xa_picture *mask_pic = comp->mask;
+ struct xa_picture *dst_pic = comp->dst;
ctx->has_solid_src = FALSE;
ctx->has_solid_mask = FALSE;
+ if (dst_pic && xa_format_type(dst_pic->pict_format) !=
+ xa_format_type(xa_surface_format(dst_pic->srf)))
+ return -XA_ERR_INVAL;
+
if (src_pic) {
if (src_pic->wrap == xa_wrap_clamp_to_border && src_pic->has_transform)
fs_traits |= FS_SRC_REPEAT_NONE;
if (mask_pic) {
vs_traits |= VS_MASK;
fs_traits |= FS_MASK;
+ if (mask_pic->component_alpha)
+ fs_traits |= FS_CA;
if (mask_pic->src_pict) {
if (!xa_handle_src_pict(ctx, mask_pic->src_pict, true))
return -XA_ERR_INVAL;
"FS_SRC_LUMINANCE", /* = 1 << 11, */
"FS_MASK_LUMINANCE", /* = 1 << 12, */
"FS_DST_LUMINANCE", /* = 1 << 13, */
+ "FS_CA", /* = 1 << 14, */
};
int i, k;
struct ureg_dst dst,
struct ureg_src src,
struct ureg_src mask,
- unsigned mask_luminance)
+ unsigned mask_luminance, boolean component_alpha)
{
if (mask_luminance)
- ureg_MUL(ureg, dst, src, ureg_scalar(mask, TGSI_SWIZZLE_X));
- else
+ if (component_alpha) {
+ ureg_MOV(ureg, dst, src);
+ ureg_MUL(ureg, ureg_writemask(dst, TGSI_WRITEMASK_W),
+ src, ureg_scalar(mask, TGSI_SWIZZLE_X));
+ } else {
+ ureg_MUL(ureg, dst, src, ureg_scalar(mask, TGSI_SWIZZLE_X));
+ }
+ else if (!component_alpha)
ureg_MUL(ureg, dst, src, ureg_scalar(mask, TGSI_SWIZZLE_W));
+ else
+ ureg_MUL(ureg, dst, src, mask);
}
static struct ureg_src
unsigned dst_luminance = (fs_traits & FS_DST_LUMINANCE) != 0;
unsigned is_src_src = (fs_traits & FS_SRC_SRC) != 0;
unsigned is_mask_src = (fs_traits & FS_MASK_SRC) != 0;
+ boolean component_alpha = (fs_traits & FS_CA) != 0;
unsigned cur_sampler = 0;
unsigned cur_constant = 0;
&cur_sampler);
src_in_mask(ureg, (dst_luminance) ? src : out, ureg_src(src),
- ureg_src(mask), mask_luminance);
+ ureg_src(mask), mask_luminance, component_alpha);
ureg_release_temporary(ureg, mask);
}