st/xa: Solid fill (tested) and composite (yet untested)
[mesa.git] / src / gallium / state_trackers / xa / xa_composite.h
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 };
107
108 struct xa_composite_allocation {
109 unsigned int xa_composite_size;
110 unsigned int xa_picture_size;
111 unsigned int xa_source_pict_size;
112 };
113
114 /*
115 * Get allocation sizes for minor bump compatibility.
116 */
117
118 extern const struct xa_composite_allocation *
119 xa_composite_allocation(void);
120 extern int
121 xa_composite_is_accelerated(const struct xa_composite *comp);
122 extern int
123 xa_composite_prepare(struct xa_context *ctx, const struct xa_composite *comp);
124 extern void
125 xa_composite_rect(struct xa_context *ctx,
126 int srcX, int srcY, int maskX, int maskY,
127 int dstX, int dstY, int width, int height);
128 extern void
129 xa_composite_done(struct xa_context *ctx);
130
131 #endif