1 | /*
|
---|
2 | * Copyright © 2014 Keith Packard
|
---|
3 | *
|
---|
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.
|
---|
13 | *
|
---|
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.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef _GLAMOR_PROGRAM_H_
|
---|
24 | #define _GLAMOR_PROGRAM_H_
|
---|
25 |
|
---|
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;
|
---|
37 |
|
---|
38 | typedef enum {
|
---|
39 | glamor_program_flag_none = 0,
|
---|
40 | } glamor_program_flag;
|
---|
41 |
|
---|
42 | typedef enum {
|
---|
43 | glamor_program_alpha_normal,
|
---|
44 | glamor_program_alpha_ca_first,
|
---|
45 | glamor_program_alpha_ca_second,
|
---|
46 | glamor_program_alpha_count
|
---|
47 | } glamor_program_alpha;
|
---|
48 |
|
---|
49 | typedef struct _glamor_program glamor_program;
|
---|
50 |
|
---|
51 | typedef Bool (*glamor_use) (PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg);
|
---|
52 |
|
---|
53 | typedef Bool (*glamor_use_render) (CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog);
|
---|
54 |
|
---|
55 | typedef struct {
|
---|
56 | const char *name;
|
---|
57 | const int version;
|
---|
58 | char *vs_defines;
|
---|
59 | char *fs_defines;
|
---|
60 | const char *vs_vars;
|
---|
61 | const char *vs_exec;
|
---|
62 | const char *fs_vars;
|
---|
63 | const char *fs_exec;
|
---|
64 | const glamor_program_location locations;
|
---|
65 | const glamor_program_flag flags;
|
---|
66 | const char *source_name;
|
---|
67 | glamor_use use;
|
---|
68 | glamor_use_render use_render;
|
---|
69 | } glamor_facet;
|
---|
70 |
|
---|
71 | struct _glamor_program {
|
---|
72 | GLint prog;
|
---|
73 | GLint failed;
|
---|
74 | GLint matrix_uniform;
|
---|
75 | GLint fg_uniform;
|
---|
76 | GLint bg_uniform;
|
---|
77 | GLint fill_size_inv_uniform;
|
---|
78 | GLint fill_offset_uniform;
|
---|
79 | GLint font_uniform;
|
---|
80 | GLint bitplane_uniform;
|
---|
81 | GLint bitmul_uniform;
|
---|
82 | GLint dash_uniform;
|
---|
83 | GLint dash_length_uniform;
|
---|
84 | GLint atlas_uniform;
|
---|
85 | glamor_program_location locations;
|
---|
86 | glamor_program_flag flags;
|
---|
87 | glamor_use prim_use;
|
---|
88 | glamor_use fill_use;
|
---|
89 | glamor_program_alpha alpha;
|
---|
90 | glamor_use_render prim_use_render;
|
---|
91 | glamor_use_render fill_use_render;
|
---|
92 | };
|
---|
93 |
|
---|
94 | typedef struct {
|
---|
95 | glamor_program progs[4];
|
---|
96 | } glamor_program_fill;
|
---|
97 |
|
---|
98 | extern const glamor_facet glamor_fill_solid;
|
---|
99 |
|
---|
100 | Bool
|
---|
101 | glamor_build_program(ScreenPtr screen,
|
---|
102 | glamor_program *prog,
|
---|
103 | const glamor_facet *prim,
|
---|
104 | const glamor_facet *fill,
|
---|
105 | const char *combine,
|
---|
106 | const char *defines);
|
---|
107 |
|
---|
108 | Bool
|
---|
109 | glamor_use_program(PixmapPtr pixmap,
|
---|
110 | GCPtr gc,
|
---|
111 | glamor_program *prog,
|
---|
112 | void *arg);
|
---|
113 |
|
---|
114 | glamor_program *
|
---|
115 | glamor_use_program_fill(PixmapPtr pixmap,
|
---|
116 | GCPtr gc,
|
---|
117 | glamor_program_fill *program_fill,
|
---|
118 | const glamor_facet *prim);
|
---|
119 |
|
---|
120 | typedef enum {
|
---|
121 | glamor_program_source_solid,
|
---|
122 | glamor_program_source_picture,
|
---|
123 | glamor_program_source_1x1_picture,
|
---|
124 | glamor_program_source_count,
|
---|
125 | } glamor_program_source;
|
---|
126 |
|
---|
127 | typedef struct {
|
---|
128 | glamor_program progs[glamor_program_source_count][glamor_program_alpha_count];
|
---|
129 | } glamor_program_render;
|
---|
130 |
|
---|
131 | static inline Bool
|
---|
132 | glamor_is_component_alpha(PicturePtr mask) {
|
---|
133 | if (mask && mask->componentAlpha && PICT_FORMAT_RGB(mask->format))
|
---|
134 | return TRUE;
|
---|
135 | return FALSE;
|
---|
136 | }
|
---|
137 |
|
---|
138 | glamor_program *
|
---|
139 | glamor_setup_program_render(CARD8 op,
|
---|
140 | PicturePtr src,
|
---|
141 | PicturePtr mask,
|
---|
142 | PicturePtr dst,
|
---|
143 | glamor_program_render *program_render,
|
---|
144 | const glamor_facet *prim,
|
---|
145 | const char *defines);
|
---|
146 |
|
---|
147 | Bool
|
---|
148 | glamor_use_program_render(glamor_program *prog,
|
---|
149 | CARD8 op,
|
---|
150 | PicturePtr src,
|
---|
151 | PicturePtr dst);
|
---|
152 |
|
---|
153 | #endif /* _GLAMOR_PROGRAM_H_ */
|
---|