Home | History | Annotate | Download | only in xa
      1 /**********************************************************
      2  * Copyright 2009-2011 VMware, Inc. All rights reserved.
      3  *
      4  * Permission is hereby granted, free of charge, to any person
      5  * obtaining a copy of this software and associated documentation
      6  * files (the "Software"), to deal in the Software without
      7  * restriction, including without limitation the rights to use, copy,
      8  * modify, merge, publish, distribute, sublicense, and/or sell copies
      9  * of the Software, and to permit persons to whom the Software is
     10  * furnished to do so, subject to the following conditions:
     11  *
     12  * The above copyright notice and this permission notice shall be
     13  * included in all copies or substantial portions of the Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
     19  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
     20  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     22  * SOFTWARE.
     23  *
     24  *********************************************************
     25  * Authors:
     26  * Zack Rusin <zackr-at-vmware-dot-com>
     27  * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
     28  */
     29 
     30 #ifndef _XA_COMPOSITE_H_
     31 #define _XA_COMPOSITE_H_
     32 
     33 #include "xa_tracker.h"
     34 #include "xa_context.h"
     35 
     36 /*
     37  * Supported composite ops.
     38  */
     39 enum xa_composite_op {
     40     xa_op_clear,
     41     xa_op_src,
     42     xa_op_dst,
     43     xa_op_over,
     44     xa_op_over_reverse,
     45     xa_op_in,
     46     xa_op_in_reverse,
     47     xa_op_out,
     48     xa_op_out_reverse,
     49     xa_op_atop,
     50     xa_op_atop_reverse,
     51     xa_op_xor,
     52     xa_op_add
     53 };
     54 
     55 /*
     56  * Supported filters.
     57  */
     58 enum xa_composite_filter {
     59     xa_filter_nearest,
     60     xa_filter_linear
     61 };
     62 
     63 /*
     64  * Supported clamp methods.
     65  */
     66 enum xa_composite_wrap {
     67     xa_wrap_clamp_to_border,
     68     xa_wrap_repeat,
     69     xa_wrap_mirror_repeat,
     70     xa_wrap_clamp_to_edge
     71 };
     72 
     73 /*
     74  * Src picture types.
     75  */
     76 enum xa_composite_src_pict_type {
     77     xa_src_pict_solid_fill
     78 };
     79 
     80 struct xa_pict_solid_fill {
     81     enum xa_composite_src_pict_type type;
     82     unsigned int class;
     83     uint32_t color;
     84 };
     85 
     86 union xa_source_pict {
     87     unsigned int type;
     88     struct xa_pict_solid_fill solid_fill;
     89 };
     90 
     91 struct xa_picture {
     92     enum xa_formats pict_format;
     93     struct xa_surface *srf;
     94     struct xa_surface *alpha_map;
     95     float transform[9];
     96     int has_transform;
     97     int component_alpha;
     98     enum xa_composite_wrap wrap;
     99     enum xa_composite_filter filter;
    100     union xa_source_pict *src_pict;
    101 };
    102 
    103 struct xa_composite {
    104     struct xa_picture *src, *mask, *dst;
    105     int op;
    106     int no_solid;
    107 };
    108 
    109 struct xa_composite_allocation {
    110     unsigned int xa_composite_size;
    111     unsigned int xa_picture_size;
    112     unsigned int xa_source_pict_size;
    113 };
    114 
    115 /*
    116  * Get allocation sizes for minor bump compatibility.
    117  */
    118 
    119 extern const struct xa_composite_allocation *
    120 xa_composite_allocation(void);
    121 
    122 /*
    123  * This function checks most things except the format of the hardware
    124  * surfaces, since they are generally not available at the time this
    125  * function is called. Returns usual XA error codes.
    126  */
    127 extern int
    128 xa_composite_check_accelerated(const struct xa_composite *comp);
    129 
    130 extern int
    131 xa_composite_prepare(struct xa_context *ctx, const struct xa_composite *comp);
    132 
    133 extern void
    134 xa_composite_rect(struct xa_context *ctx,
    135 		  int srcX, int srcY, int maskX, int maskY,
    136 		  int dstX, int dstY, int width, int height);
    137 extern void
    138 xa_composite_done(struct xa_context *ctx);
    139 
    140 #endif
    141