st/xorg: fix text with component alpha rendering

This commit is contained in:
Zack Rusin 2009-10-23 09:35:36 -04:00
parent 49d402e275
commit b17c885a8a
3 changed files with 43 additions and 21 deletions

View file

@ -109,6 +109,7 @@ blend_for_op(struct xorg_composite_blend *blend,
blend->rgb_dst = PIPE_BLENDFACTOR_INV_SRC_COLOR;
}
}
return supported;
}
@ -257,8 +258,15 @@ bind_shaders(struct exa_context *exa, int op,
if (pMaskPicture) {
vs_traits |= VS_MASK;
fs_traits |= FS_MASK;
if (pMaskPicture->componentAlpha)
fs_traits |= FS_COMPONENT_ALPHA;
if (pMaskPicture->componentAlpha) {
struct xorg_composite_blend blend;
blend_for_op(&blend, op,
pSrcPicture, pMaskPicture, NULL);
if (blend.alpha_src) {
fs_traits |= FS_CA_SRCALPHA;
} else
fs_traits |= FS_CA_FULL;
}
}
shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits);
@ -289,21 +297,27 @@ bind_samplers(struct exa_context *exa, int op,
exa->pipe->flush(exa->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
if (pSrcPicture && pSrc) {
unsigned src_wrap = render_repeat_to_gallium(
pSrcPicture->repeatType);
int filter;
if (exa->has_solid_color) {
debug_assert(!"solid color with textures");
samplers[0] = NULL;
exa->bound_textures[0] = NULL;
} else {
unsigned src_wrap = render_repeat_to_gallium(
pSrcPicture->repeatType);
int filter;
render_filter_to_gallium(pSrcPicture->filter, &filter);
render_filter_to_gallium(pSrcPicture->filter, &filter);
src_sampler.wrap_s = src_wrap;
src_sampler.wrap_t = src_wrap;
src_sampler.min_img_filter = filter;
src_sampler.mag_img_filter = filter;
src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
src_sampler.normalized_coords = 1;
samplers[0] = &src_sampler;
exa->bound_textures[0] = pSrc->tex;
++exa->num_bound_samplers;
src_sampler.wrap_s = src_wrap;
src_sampler.wrap_t = src_wrap;
src_sampler.min_img_filter = filter;
src_sampler.mag_img_filter = filter;
src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
src_sampler.normalized_coords = 1;
samplers[0] = &src_sampler;
exa->bound_textures[0] = pSrc->tex;
exa->num_bound_samplers = 1;
}
}
if (pMaskPicture && pMask) {
@ -321,7 +335,7 @@ bind_samplers(struct exa_context *exa, int op,
mask_sampler.normalized_coords = 1;
samplers[1] = &mask_sampler;
exa->bound_textures[1] = pMask->tex;
++exa->num_bound_samplers;
exa->num_bound_samplers = 2;
}
cso_set_samplers(exa->renderer->cso, exa->num_bound_samplers,

View file

@ -55,10 +55,13 @@ src_in_mask(struct ureg_program *ureg,
struct ureg_dst dst,
struct ureg_src src,
struct ureg_src mask,
boolean component_alpha)
int component_alpha)
{
if (component_alpha) {
if (component_alpha == FS_CA_FULL) {
ureg_MUL(ureg, dst, src, mask);
} else if (component_alpha == FS_CA_SRCALPHA) {
ureg_MUL(ureg, dst,
ureg_scalar(src, TGSI_SWIZZLE_W), mask);
}
else {
ureg_MUL(ureg, dst, src,
@ -289,7 +292,7 @@ create_fs(struct pipe_context *pipe,
boolean is_solid = fs_traits & FS_SOLID_FILL;
boolean is_lingrad = fs_traits & FS_LINGRAD_FILL;
boolean is_radgrad = fs_traits & FS_RADGRAD_FILL;
boolean is_comp_alpha = fs_traits & FS_COMPONENT_ALPHA;
unsigned comp_alpha = fs_traits & FS_COMPONENT_ALPHA;
ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT);
if (ureg == NULL)
@ -386,7 +389,7 @@ create_fs(struct pipe_context *pipe,
ureg_TEX(ureg, mask,
TGSI_TEXTURE_2D, mask_pos, mask_sampler);
/* src IN mask */
src_in_mask(ureg, out, ureg_src(src), ureg_src(mask), is_comp_alpha);
src_in_mask(ureg, out, ureg_src(src), ureg_src(mask), comp_alpha);
ureg_release_temporary(ureg, mask);
}

View file

@ -24,7 +24,12 @@ enum xorg_fs_traits {
FS_FILL = (FS_SOLID_FILL |
FS_LINGRAD_FILL |
FS_RADGRAD_FILL),
FS_COMPONENT_ALPHA = 1 << 5
/* src.rgba * mask.rgba */
FS_CA_FULL = 1 << 5,
/* src.aaaa * mask.rgba */
FS_CA_SRCALPHA = 1 << 6,
FS_COMPONENT_ALPHA = (FS_CA_FULL |
FS_CA_SRCALPHA)
};
struct xorg_shader {