xref: /OK3568_Linux_fs/external/xserver/glamor/glamor_transform.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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_TRANSFORM_H_
24 #define _GLAMOR_TRANSFORM_H_
25 
26 Bool
27 glamor_set_destination_drawable(DrawablePtr     drawable,
28                                 int             box_index,
29                                 Bool            do_drawable_translate,
30                                 Bool            center_offset,
31                                 GLint           matrix_uniform_location,
32                                 int             *p_off_x,
33                                 int             *p_off_y);
34 
35 void
36 glamor_set_color_depth(ScreenPtr      pScreen,
37                        int            depth,
38                        CARD32         pixel,
39                        GLint          uniform);
40 
41 static inline void
glamor_set_color(PixmapPtr pixmap,CARD32 pixel,GLint uniform)42 glamor_set_color(PixmapPtr      pixmap,
43                  CARD32         pixel,
44                  GLint          uniform)
45 {
46     glamor_set_color_depth(pixmap->drawable.pScreen,
47                            pixmap->drawable.depth, pixel, uniform);
48 }
49 
50 Bool
51 glamor_set_texture_pixmap(PixmapPtr     texture,
52                           Bool          destination_red);
53 
54 Bool
55 glamor_set_texture(PixmapPtr    texture,
56                    Bool         destination_red,
57                    int          off_x,
58                    int          off_y,
59                    GLint        offset_uniform,
60                    GLint        size_uniform);
61 
62 Bool
63 glamor_set_solid(PixmapPtr      pixmap,
64                  GCPtr          gc,
65                  Bool           use_alu,
66                  GLint          uniform);
67 
68 Bool
69 glamor_set_tiled(PixmapPtr      pixmap,
70                  GCPtr          gc,
71                  GLint          offset_uniform,
72                  GLint          size_uniform);
73 
74 Bool
75 glamor_set_stippled(PixmapPtr      pixmap,
76                     GCPtr          gc,
77                     GLint          fg_uniform,
78                     GLint          offset_uniform,
79                     GLint          size_uniform);
80 
81 /*
82  * Vertex shader bits that transform X coordinates to pixmap
83  * coordinates using the matrix computed above
84  */
85 
86 #define GLAMOR_DECLARE_MATRIX   "uniform vec4 v_matrix;\n"
87 #define GLAMOR_X_POS(x) #x " *v_matrix.x + v_matrix.y"
88 #define GLAMOR_Y_POS(y) #y " *v_matrix.z + v_matrix.w"
89 #if 0
90 #define GLAMOR_POS(dst,src) \
91     "       " #dst ".x = " #src ".x * v_matrix.x + v_matrix.y;\n" \
92     "       " #dst ".y = " #src ".y * v_matrix.z + v_matrix.w;\n" \
93     "       " #dst ".z = 0.0;\n" \
94     "       " #dst ".w = 1.0;\n"
95 #endif
96 #define GLAMOR_POS(dst,src) \
97     "       " #dst ".xy = " #src ".xy * v_matrix.xz + v_matrix.yw;\n" \
98     "       " #dst ".zw = vec2(0.0,1.0);\n"
99 
100 #endif /* _GLAMOR_TRANSFORM_H_ */
101