No longer leak FDs on VT switch.
[xserver.git] / glamor / glamor_program.h
blob72bf1fc3fec33318f04a5e2d34005cc6e5b0a72d
1 /*
2 * Copyright © 2014 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
23 #ifndef _GLAMOR_PROGRAM_H_
24 #define _GLAMOR_PROGRAM_H_
26 typedef enum {
27 glamor_program_location_none = 0,
28 glamor_program_location_fg = 1,
29 glamor_program_location_bg = 2,
30 glamor_program_location_fillsamp = 4,
31 glamor_program_location_fillpos = 8,
32 glamor_program_location_font = 16,
33 glamor_program_location_bitplane = 32,
34 glamor_program_location_dash = 64,
35 glamor_program_location_atlas = 128,
36 } glamor_program_location;
38 typedef enum {
39 glamor_program_flag_none = 0,
40 } glamor_program_flag;
42 typedef enum {
43 glamor_program_alpha_normal,
44 glamor_program_alpha_ca_first,
45 glamor_program_alpha_ca_second,
46 glamor_program_alpha_dual_blend,
47 glamor_program_alpha_dual_blend_gles2,
48 glamor_program_alpha_count
49 } glamor_program_alpha;
51 typedef struct _glamor_program glamor_program;
53 typedef Bool (*glamor_use) (DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg);
55 typedef Bool (*glamor_use_render) (CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog);
57 typedef struct {
58 const char *name;
59 const int version;
60 char *vs_extensions;
61 const char *fs_extensions;
62 const char *vs_vars;
63 const char *vs_exec;
64 const char *fs_vars;
65 const char *fs_exec;
66 const glamor_program_location locations;
67 const glamor_program_flag flags;
68 const char *source_name;
69 glamor_use use;
70 glamor_use_render use_render;
71 } glamor_facet;
73 struct _glamor_program {
74 GLint prog;
75 GLint failed;
76 GLint matrix_uniform;
77 GLint fg_uniform;
78 GLint bg_uniform;
79 GLint fill_size_inv_uniform;
80 GLint fill_offset_uniform;
81 GLint font_uniform;
82 GLint bitplane_uniform;
83 GLint bitmul_uniform;
84 GLint dash_uniform;
85 GLint dash_length_uniform;
86 GLint atlas_uniform;
87 glamor_program_location locations;
88 glamor_program_flag flags;
89 glamor_use prim_use;
90 glamor_use fill_use;
91 glamor_program_alpha alpha;
92 glamor_use_render prim_use_render;
93 glamor_use_render fill_use_render;
96 typedef struct {
97 glamor_program progs[4];
98 } glamor_program_fill;
100 extern const glamor_facet glamor_fill_solid;
102 Bool
103 glamor_build_program(ScreenPtr screen,
104 glamor_program *prog,
105 const glamor_facet *prim,
106 const glamor_facet *fill,
107 const char *combine,
108 const char *defines);
110 Bool
111 glamor_use_program(DrawablePtr drawable,
112 GCPtr gc,
113 glamor_program *prog,
114 void *arg);
116 glamor_program *
117 glamor_use_program_fill(DrawablePtr drawable,
118 GCPtr gc,
119 glamor_program_fill *program_fill,
120 const glamor_facet *prim);
122 typedef enum {
123 glamor_program_source_solid,
124 glamor_program_source_picture,
125 glamor_program_source_1x1_picture,
126 glamor_program_source_count,
127 } glamor_program_source;
129 typedef struct {
130 glamor_program progs[glamor_program_source_count][glamor_program_alpha_count];
131 } glamor_program_render;
133 static inline Bool
134 glamor_is_component_alpha(PicturePtr mask) {
135 if (mask && mask->componentAlpha && PICT_FORMAT_RGB(mask->format))
136 return TRUE;
137 return FALSE;
140 glamor_program *
141 glamor_setup_program_render(CARD8 op,
142 PicturePtr src,
143 PicturePtr mask,
144 PicturePtr dst,
145 glamor_program_render *program_render,
146 const glamor_facet *prim,
147 const char *defines);
149 Bool
150 glamor_use_program_render(glamor_program *prog,
151 CARD8 op,
152 PicturePtr src,
153 PicturePtr dst);
155 #endif /* _GLAMOR_PROGRAM_H_ */