summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/xa/xa_composite.h
blob: d16ef89ebd80d57fbb644598a61be3dc1989ae46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/**********************************************************
 * Copyright 2009-2011 VMware, Inc. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy,
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 *********************************************************
 * Authors:
 * Zack Rusin <zackr-at-vmware-dot-com>
 * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
 */

#ifndef _XA_COMPOSITE_H_
#define _XA_COMPOSITE_H_

#include "xa_tracker.h"
#include "xa_context.h"

/*
 * Supported composite ops.
 */
enum xa_composite_op {
    xa_op_clear,
    xa_op_src,
    xa_op_dst,
    xa_op_over,
    xa_op_over_reverse,
    xa_op_in,
    xa_op_in_reverse,
    xa_op_out,
    xa_op_out_reverse,
    xa_op_atop,
    xa_op_atop_reverse,
    xa_op_xor,
    xa_op_add
};

/*
 * Supported filters.
 */
enum xa_composite_filter {
    xa_filter_nearest,
    xa_filter_linear
};

/*
 * Supported clamp methods.
 */
enum xa_composite_wrap {
    xa_wrap_clamp_to_border,
    xa_wrap_repeat,
    xa_wrap_mirror_repeat,
    xa_wrap_clamp_to_edge
};

/*
 * Src picture types.
 */
enum xa_composite_src_pict_type {
    xa_src_pict_solid_fill
};

struct xa_pict_solid_fill {
    enum xa_composite_src_pict_type type;
    unsigned int class;
    uint32_t color;
};

union xa_source_pict {
    unsigned int type;
    struct xa_pict_solid_fill solid_fill;
};

struct xa_picture {
    enum xa_formats pict_format;
    struct xa_surface *srf;
    struct xa_surface *alpha_map;
    float transform[9];
    int has_transform;
    int component_alpha;
    enum xa_composite_wrap wrap;
    enum xa_composite_filter filter;
    union xa_source_pict *src_pict;
};

struct xa_composite {
    struct xa_picture *src, *mask, *dst;
    int op;
    int no_solid;
};

struct xa_composite_allocation {
    unsigned int xa_composite_size;
    unsigned int xa_picture_size;
    unsigned int xa_source_pict_size;
};

/*
 * Get allocation sizes for minor bump compatibility.
 */

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_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,
		  int dstX, int dstY, int width, int height);
extern void
xa_composite_done(struct xa_context *ctx);

#endif