diff options
author | Zack Rusin <zackr@vmware.com> | 2009-08-27 18:06:15 -0400 |
---|---|---|
committer | Zack Rusin <zackr@vmware.com> | 2009-08-27 18:06:15 -0400 |
commit | 2048182e868a759c3198b3cbaf2dd1d366fe0a21 (patch) | |
tree | 12382028b76f93c2ae1300d7c5db77c3812e110e | |
parent | f9a3fce09044fbfe9a9b973d33b31cfe826d1386 (diff) |
st/xorg: set blend state for exa
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_composite.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index 642be3b726..c566d2d75a 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -14,6 +14,7 @@ struct xorg_composite_blend { unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ }; +#define BLEND_OP_OVER 3 static const struct xorg_composite_blend xorg_blends[] = { { PictOpClear, PIPE_BLENDFACTOR_CONST_COLOR, PIPE_BLENDFACTOR_CONST_ALPHA, @@ -58,6 +59,20 @@ static const struct acceleration_info accelerated_ops[] = { {PictOpSaturate, 1, 0}, }; +static struct xorg_composite_blend +blend_for_op(int op) +{ + const int num_blends = + sizeof(xorg_blends)/sizeof(struct xorg_composite_blend); + int i; + + for (i = 0; i < num_blends; ++i) { + if (xorg_blends[i].op == op) + return xorg_blends[i]; + } + return xorg_blends[BLEND_OP_OVER]; +} + static void draw_texture(struct exa_context *exa) { @@ -175,8 +190,31 @@ bind_viewport_state(struct exa_context *exa, PicturePtr pDstPicture) } static void -bind_blend_state() +bind_blend_state(struct exa_context *exa, int op, + PicturePtr pSrcPicture, PicturePtr pMaskPicture) { + boolean component_alpha = pSrcPicture->componentAlpha; + struct xorg_composite_blend blend_opt; + struct pipe_blend_state blend; + + if (component_alpha) { + op = PictOpOver; + } + blend_opt = blend_for_op(op); + + memset(&blend, 0, sizeof(struct pipe_blend_state)); + blend.blend_enable = 1; + blend.colormask |= PIPE_MASK_R; + blend.colormask |= PIPE_MASK_G; + blend.colormask |= PIPE_MASK_B; + blend.colormask |= PIPE_MASK_A; + + blend.rgb_src_factor = blend_opt.rgb_src_factor; + blend.alpha_src_factor = blend_opt.alpha_src_factor; + blend.rgb_dst_factor = blend_opt.rgb_dst_factor; + blend.alpha_dst_factor = blend_opt.alpha_dst_factor; + + cso_set_blend(exa->cso, &blend); } static void @@ -201,7 +239,7 @@ boolean xorg_composite_bind_state(struct exa_context *exa, { bind_framebuffer_state(exa, pDstPicture, pDst); bind_viewport_state(exa, pDstPicture); - bind_blend_state(); + bind_blend_state(exa, op, pSrcPicture, pMaskPicture); bind_rasterizer_state(); bind_shaders(); |