1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright © 2014 Keith Packard
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * Permission to use, copy, modify, distribute, and sell this software and its
5*4882a593Smuzhiyun * documentation for any purpose is hereby granted without fee, provided that
6*4882a593Smuzhiyun * the above copyright notice appear in all copies and that both that copyright
7*4882a593Smuzhiyun * notice and this permission notice appear in supporting documentation, and
8*4882a593Smuzhiyun * that the name of the copyright holders not be used in advertising or
9*4882a593Smuzhiyun * publicity pertaining to distribution of the software without specific,
10*4882a593Smuzhiyun * written prior permission. The copyright holders make no representations
11*4882a593Smuzhiyun * about the suitability of this software for any purpose. It is provided "as
12*4882a593Smuzhiyun * is" without express or implied warranty.
13*4882a593Smuzhiyun *
14*4882a593Smuzhiyun * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15*4882a593Smuzhiyun * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16*4882a593Smuzhiyun * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17*4882a593Smuzhiyun * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18*4882a593Smuzhiyun * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19*4882a593Smuzhiyun * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20*4882a593Smuzhiyun * OF THIS SOFTWARE.
21*4882a593Smuzhiyun */
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun #ifndef _GLAMOR_TRANSFORM_H_
24*4882a593Smuzhiyun #define _GLAMOR_TRANSFORM_H_
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun Bool
27*4882a593Smuzhiyun glamor_set_destination_drawable(DrawablePtr drawable,
28*4882a593Smuzhiyun int box_index,
29*4882a593Smuzhiyun Bool do_drawable_translate,
30*4882a593Smuzhiyun Bool center_offset,
31*4882a593Smuzhiyun GLint matrix_uniform_location,
32*4882a593Smuzhiyun int *p_off_x,
33*4882a593Smuzhiyun int *p_off_y);
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun void
36*4882a593Smuzhiyun glamor_set_color_depth(ScreenPtr pScreen,
37*4882a593Smuzhiyun int depth,
38*4882a593Smuzhiyun CARD32 pixel,
39*4882a593Smuzhiyun GLint uniform);
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun static inline void
glamor_set_color(PixmapPtr pixmap,CARD32 pixel,GLint uniform)42*4882a593Smuzhiyun glamor_set_color(PixmapPtr pixmap,
43*4882a593Smuzhiyun CARD32 pixel,
44*4882a593Smuzhiyun GLint uniform)
45*4882a593Smuzhiyun {
46*4882a593Smuzhiyun glamor_set_color_depth(pixmap->drawable.pScreen,
47*4882a593Smuzhiyun pixmap->drawable.depth, pixel, uniform);
48*4882a593Smuzhiyun }
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun Bool
51*4882a593Smuzhiyun glamor_set_texture_pixmap(PixmapPtr texture,
52*4882a593Smuzhiyun Bool destination_red);
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun Bool
55*4882a593Smuzhiyun glamor_set_texture(PixmapPtr texture,
56*4882a593Smuzhiyun Bool destination_red,
57*4882a593Smuzhiyun int off_x,
58*4882a593Smuzhiyun int off_y,
59*4882a593Smuzhiyun GLint offset_uniform,
60*4882a593Smuzhiyun GLint size_uniform);
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun Bool
63*4882a593Smuzhiyun glamor_set_solid(PixmapPtr pixmap,
64*4882a593Smuzhiyun GCPtr gc,
65*4882a593Smuzhiyun Bool use_alu,
66*4882a593Smuzhiyun GLint uniform);
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun Bool
69*4882a593Smuzhiyun glamor_set_tiled(PixmapPtr pixmap,
70*4882a593Smuzhiyun GCPtr gc,
71*4882a593Smuzhiyun GLint offset_uniform,
72*4882a593Smuzhiyun GLint size_uniform);
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun Bool
75*4882a593Smuzhiyun glamor_set_stippled(PixmapPtr pixmap,
76*4882a593Smuzhiyun GCPtr gc,
77*4882a593Smuzhiyun GLint fg_uniform,
78*4882a593Smuzhiyun GLint offset_uniform,
79*4882a593Smuzhiyun GLint size_uniform);
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun /*
82*4882a593Smuzhiyun * Vertex shader bits that transform X coordinates to pixmap
83*4882a593Smuzhiyun * coordinates using the matrix computed above
84*4882a593Smuzhiyun */
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun #define GLAMOR_DECLARE_MATRIX "uniform vec4 v_matrix;\n"
87*4882a593Smuzhiyun #define GLAMOR_X_POS(x) #x " *v_matrix.x + v_matrix.y"
88*4882a593Smuzhiyun #define GLAMOR_Y_POS(y) #y " *v_matrix.z + v_matrix.w"
89*4882a593Smuzhiyun #if 0
90*4882a593Smuzhiyun #define GLAMOR_POS(dst,src) \
91*4882a593Smuzhiyun " " #dst ".x = " #src ".x * v_matrix.x + v_matrix.y;\n" \
92*4882a593Smuzhiyun " " #dst ".y = " #src ".y * v_matrix.z + v_matrix.w;\n" \
93*4882a593Smuzhiyun " " #dst ".z = 0.0;\n" \
94*4882a593Smuzhiyun " " #dst ".w = 1.0;\n"
95*4882a593Smuzhiyun #endif
96*4882a593Smuzhiyun #define GLAMOR_POS(dst,src) \
97*4882a593Smuzhiyun " " #dst ".xy = " #src ".xy * v_matrix.xz + v_matrix.yw;\n" \
98*4882a593Smuzhiyun " " #dst ".zw = vec2(0.0,1.0);\n"
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun #endif /* _GLAMOR_TRANSFORM_H_ */
101