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