st/xa: Various fixes for composite.
authorThomas Hellstrom <thellstrom@vmware.com>
Thu, 23 Jun 2011 09:15:59 +0000 (11:15 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Mon, 27 Jun 2011 08:14:34 +0000 (10:14 +0200)
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
src/gallium/state_trackers/xa/xa_composite.c
src/gallium/state_trackers/xa/xa_composite.h
src/gallium/state_trackers/xa/xa_symbols

index b30728423e86792fede485e0e7a8f5fff1e9de0c..5389af6f363919bcb6e1a7c3424bb3d65c198afc 100644 (file)
@@ -111,7 +111,7 @@ blend_for_op(struct xa_composite_blend *blend,
      */
 
     if (dst_pic &&
-       xa_format_a(xa_surface_format(dst_pic->srf)) == 0 &&
+       xa_format_a(dst_pic->pict_format) == 0 &&
        blend->alpha_dst) {
        if (blend->rgb_src == PIPE_BLENDFACTOR_DST_ALPHA)
            blend->rgb_src = PIPE_BLENDFACTOR_ONE;
@@ -125,7 +125,7 @@ blend_for_op(struct xa_composite_blend *blend,
      * channels multiplied by the source picture's alpha.
      */
     if (mask_pic && mask_pic->component_alpha &&
-       xa_format_rgb(xa_surface_format(mask_pic->srf)) &&
+       xa_format_rgb(mask_pic->pict_format) &&
        blend->alpha_src) {
        if (blend->rgb_dst == PIPE_BLENDFACTOR_SRC_ALPHA) {
            blend->rgb_dst = PIPE_BLENDFACTOR_SRC_COLOR;
@@ -184,34 +184,34 @@ xa_is_filter_accelerated(struct xa_picture *pic)
 }
 
 int
-xa_composite_is_accelerated(const struct xa_composite *comp)
+xa_composite_check_accelerated(const struct xa_composite *comp)
 {
     struct xa_composite_blend blend;
     struct xa_picture *src_pic = comp->src;
 
     if (!xa_is_filter_accelerated(src_pic) ||
        !xa_is_filter_accelerated(comp->mask)) {
-       return 0;
+       return XA_ERR_INVAL;
     }
 
 
     if (src_pic->src_pict) {
        if (src_pic->src_pict->type != xa_src_pict_solid_fill)
-           return 0;
+           return XA_ERR_INVAL;
     }
 
     if (blend_for_op(&blend, comp->op, comp->src, comp->mask, comp->dst)) {
        struct xa_picture *mask = comp->mask;
        if (mask && mask->component_alpha &&
-           xa_format_rgb(xa_surface_format(mask->srf))) {
+           xa_format_rgb(mask->pict_format)) {
            if (blend.alpha_src && blend.rgb_src != PIPE_BLENDFACTOR_ZERO) {
-               return 0;
+               return XA_ERR_INVAL;
            }
        }
 
-       return 1;
+       return XA_ERR_NONE;
     }
-    return 0;
+    return XA_ERR_INVAL;
 }
 
 static void
@@ -247,11 +247,14 @@ picture_format_fixups(struct xa_picture *src_pic,
     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;
 
-    if (src_hw_format == src_pic_format) {
-       if (src_pic->pict_format == xa_format_a8) {
+    if (!src || src_hw_format == src_pic_format) {
+       if (src_pic_format == xa_format_a8) {
            if (mask)
                return FS_MASK_LUMINANCE;
            else if (dst_pic->pict_format != xa_format_a8) {
@@ -279,8 +282,8 @@ picture_format_fixups(struct xa_picture *src_pic,
     if (!swizzle && (src_hw_type != src_pic_type))
        return 0;
 
-    set_alpha = (xa_format_type_is_color(src_hw_type) &&
-                xa_format_a(src_hw_type) == 0);
+    set_alpha = (xa_format_type_is_color(src_pic_format) &&
+                xa_format_a(src_pic_type) == 0);
 
     if (set_alpha)
        ret |= mask ? FS_MASK_SET_ALPHA : FS_SRC_SET_ALPHA;
@@ -442,6 +445,7 @@ xa_composite_prepare(struct xa_context *ctx,
        renderer_begin_solid(ctx);
     } else {
        renderer_begin_textures(ctx);
+       ctx->comp = comp;
     }
 
     xa_surface_psurf_destroy(dst_srf);
@@ -463,7 +467,7 @@ void xa_composite_rect(struct xa_context *ctx,
 
        if (comp->src->has_transform)
            src_matrix = comp->src->transform;
-       if (comp->mask->has_transform)
+       if (comp->mask && comp->mask->has_transform)
            mask_matrix = comp->mask->transform;
 
        renderer_texture(ctx, pos, width, height,
index 63174a41fb120985d41188b4a07cdbb020ef46be..d16ef89ebd80d57fbb644598a61be3dc1989ae46 100644 (file)
@@ -103,6 +103,7 @@ struct xa_picture {
 struct xa_composite {
     struct xa_picture *src, *mask, *dst;
     int op;
+    int no_solid;
 };
 
 struct xa_composite_allocation {
@@ -117,10 +118,18 @@ struct xa_composite_allocation {
 
 extern const struct xa_composite_allocation *
 xa_composite_allocation(void);
+
+/*
+ * This function checks most things except the format of the hardware
+ * surfaces, since they are generally not available at the time this
+ * function is called. Returns usual XA error codes.
+ */
 extern int
-xa_composite_is_accelerated(const struct xa_composite *comp);
+xa_composite_check_accelerated(const struct xa_composite *comp);
+
 extern int
 xa_composite_prepare(struct xa_context *ctx, const struct xa_composite *comp);
+
 extern void
 xa_composite_rect(struct xa_context *ctx,
                  int srcX, int srcY, int maskX, int maskY,
index 7fa6c94cfe806f7eb4e115ff13c4355bca707b03..f1eabea1cfb98ac74cc4bb9c4061260943d35a3b 100644 (file)
@@ -22,7 +22,7 @@ xa_solid_prepare
 xa_solid
 xa_solid_done
 xa_composite_allocation
-xa_composite_is_accelerated
+xa_composite_check_accelerated
 xa_composite_prepare
 xa_composite_rect
 xa_composite_done