Rev 4501 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4501 | Rev 4866 | ||
---|---|---|---|
1 | /************************************************************************** |
1 | /************************************************************************** |
2 | 2 | ||
3 | Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. |
3 | Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. |
4 | Copyright © 2002 David Dawes |
4 | Copyright © 2002 David Dawes |
5 | 5 | ||
6 | All Rights Reserved. |
6 | All Rights Reserved. |
7 | 7 | ||
8 | Permission is hereby granted, free of charge, to any person obtaining a |
8 | Permission is hereby granted, free of charge, to any person obtaining a |
9 | copy of this software and associated documentation files (the |
9 | copy of this software and associated documentation files (the |
10 | "Software"), to deal in the Software without restriction, including |
10 | "Software"), to deal in the Software without restriction, including |
11 | without limitation the rights to use, copy, modify, merge, publish, |
11 | without limitation the rights to use, copy, modify, merge, publish, |
12 | distribute, sub license, and/or sell copies of the Software, and to |
12 | distribute, sub license, and/or sell copies of the Software, and to |
13 | permit persons to whom the Software is furnished to do so, subject to |
13 | permit persons to whom the Software is furnished to do so, subject to |
14 | the following conditions: |
14 | the following conditions: |
15 | 15 | ||
16 | The above copyright notice and this permission notice (including the |
16 | The above copyright notice and this permission notice (including the |
17 | next paragraph) shall be included in all copies or substantial portions |
17 | next paragraph) shall be included in all copies or substantial portions |
18 | of the Software. |
18 | of the Software. |
19 | 19 | ||
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
21 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
21 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
22 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
22 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
23 | IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR |
23 | IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR |
24 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
24 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
26 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
26 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
27 | 27 | ||
28 | **************************************************************************/ |
28 | **************************************************************************/ |
29 | 29 | ||
30 | /* |
30 | /* |
31 | * Authors: |
31 | * Authors: |
32 | * Keith Whitwell |
32 | * Keith Whitwell |
33 | * David Dawes |
33 | * David Dawes |
34 | * |
34 | * |
35 | */ |
35 | */ |
36 | 36 | ||
37 | #ifndef _SNA_H_ |
37 | #ifndef _SNA_H_ |
38 | #define _SNA_H_ |
38 | #define _SNA_H_ |
39 | 39 | ||
40 | #ifdef HAVE_CONFIG_H |
40 | #ifdef HAVE_CONFIG_H |
41 | #include "config.h" |
41 | #include "config.h" |
42 | #endif |
42 | #endif |
43 | 43 | ||
44 | #include |
44 | #include |
45 | 45 | ||
46 | #include "compiler.h" |
46 | #include "compiler.h" |
47 | 47 | ||
48 | 48 | ||
49 | #include |
49 | //#include |
50 | #include |
50 | #include |
51 | #include |
51 | #include |
52 | #include |
52 | #include |
53 | 53 | ||
54 | #include "pciaccess.h" |
54 | #include "pciaccess.h" |
55 | #include "intel_driver.h" |
55 | #include "intel_driver.h" |
56 | 56 | ||
57 | #include |
57 | #include |
58 | #include |
58 | #include |
59 | 59 | ||
60 | #ifdef HAVE_DRI2_H |
60 | #ifdef HAVE_DRI2_H |
61 | #include |
61 | #include |
62 | #endif |
62 | #endif |
63 | 63 | ||
64 | #if HAVE_UDEV |
64 | #if HAVE_UDEV |
65 | #include |
65 | #include |
66 | #endif |
66 | #endif |
67 | 67 | ||
68 | #if 0 |
68 | #if 0 |
69 | #include |
69 | #include |
70 | 70 | ||
71 | #include |
71 | #include |
72 | #if XF86_CRTC_VERSION >= 5 |
72 | #if XF86_CRTC_VERSION >= 5 |
73 | #define HAS_PIXMAP_SHARING 1 |
73 | #define HAS_PIXMAP_SHARING 1 |
74 | #endif |
74 | #endif |
75 | 75 | ||
76 | #include |
76 | #include |
77 | #include |
77 | #include |
78 | #include |
78 | #include |
79 | #include |
79 | #include |
80 | #include |
80 | #include |
81 | #include |
81 | #include |
82 | 82 | ||
83 | #include |
83 | #include |
84 | 84 | ||
85 | #include |
85 | #include |
86 | 86 | ||
87 | #include "../compat-api.h" |
87 | #include "../compat-api.h" |
88 | 88 | ||
89 | #endif |
89 | #endif |
90 | 90 | ||
91 | #include |
91 | #include |
92 | 92 | ||
93 | #define ErrorF printf |
93 | #define ErrorF printf |
94 | 94 | ||
95 | #if HAS_DEBUG_FULL |
95 | #if HAS_DEBUG_FULL |
96 | #define DBG(x) ErrorF x |
96 | #define DBG(x) ErrorF x |
97 | #else |
97 | #else |
98 | #define DBG(x) |
98 | #define DBG(x) |
99 | #endif |
99 | #endif |
100 | 100 | ||
101 | # define ENTER() printf("ENTER %s\n", __FUNCTION__) |
101 | # define ENTER() printf("ENTER %s\n", __FUNCTION__) |
102 | # define LEAVE() printf("LEAVE %s\n", __FUNCTION__) |
102 | # define LEAVE() printf("LEAVE %s\n", __FUNCTION__) |
103 | # define FAIL() printf("FAIL %s\n", __FUNCTION__) |
103 | # define FAIL() printf("FAIL %s\n", __FUNCTION__) |
104 | 104 | ||
105 | #define DEBUG_NO_BLT 0 |
105 | #define DEBUG_NO_BLT 0 |
106 | 106 | ||
107 | #define DEBUG_FLUSH_BATCH 0 |
107 | #define DEBUG_FLUSH_BATCH 0 |
108 | 108 | ||
109 | #define TEST_ALL 0 |
109 | #define TEST_ALL 0 |
110 | #define TEST_ACCEL (TEST_ALL || 0) |
110 | #define TEST_ACCEL (TEST_ALL || 0) |
111 | #define TEST_BATCH (TEST_ALL || 0) |
111 | #define TEST_BATCH (TEST_ALL || 0) |
112 | #define TEST_BLT (TEST_ALL || 0) |
112 | #define TEST_BLT (TEST_ALL || 0) |
113 | #define TEST_COMPOSITE (TEST_ALL || 0) |
113 | #define TEST_COMPOSITE (TEST_ALL || 0) |
114 | #define TEST_DAMAGE (TEST_ALL || 0) |
114 | #define TEST_DAMAGE (TEST_ALL || 0) |
115 | #define TEST_GRADIENT (TEST_ALL || 0) |
115 | #define TEST_GRADIENT (TEST_ALL || 0) |
116 | #define TEST_GLYPHS (TEST_ALL || 0) |
116 | #define TEST_GLYPHS (TEST_ALL || 0) |
117 | #define TEST_IO (TEST_ALL || 0) |
117 | #define TEST_IO (TEST_ALL || 0) |
118 | #define TEST_KGEM (TEST_ALL || 0) |
118 | #define TEST_KGEM (TEST_ALL || 0) |
119 | #define TEST_RENDER (TEST_ALL || 0) |
119 | #define TEST_RENDER (TEST_ALL || 0) |
120 | 120 | ||
121 | int drmIoctl(int fd, unsigned long request, void *arg); |
121 | int drmIoctl(int fd, unsigned long request, void *arg); |
122 | 122 | ||
123 | 123 | ||
124 | #define PIXMAN_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \ |
124 | #define PIXMAN_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \ |
125 | ((type) << 16) | \ |
125 | ((type) << 16) | \ |
126 | ((a) << 12) | \ |
126 | ((a) << 12) | \ |
127 | ((r) << 8) | \ |
127 | ((r) << 8) | \ |
128 | ((g) << 4) | \ |
128 | ((g) << 4) | \ |
129 | ((b))) |
129 | ((b))) |
130 | #define PIXMAN_TYPE_OTHER 0 |
130 | #define PIXMAN_TYPE_OTHER 0 |
131 | #define PIXMAN_TYPE_A 1 |
131 | #define PIXMAN_TYPE_A 1 |
132 | #define PIXMAN_TYPE_ARGB 2 |
132 | #define PIXMAN_TYPE_ARGB 2 |
133 | #define PIXMAN_TYPE_ABGR 3 |
133 | #define PIXMAN_TYPE_ABGR 3 |
134 | #define PIXMAN_TYPE_COLOR 4 |
134 | #define PIXMAN_TYPE_COLOR 4 |
135 | #define PIXMAN_TYPE_GRAY 5 |
135 | #define PIXMAN_TYPE_GRAY 5 |
136 | #define PIXMAN_TYPE_YUY2 6 |
136 | #define PIXMAN_TYPE_YUY2 6 |
137 | #define PIXMAN_TYPE_YV12 7 |
137 | #define PIXMAN_TYPE_YV12 7 |
138 | #define PIXMAN_TYPE_BGRA 8 |
138 | #define PIXMAN_TYPE_BGRA 8 |
139 | #define PIXMAN_TYPE_RGBA 9 |
139 | #define PIXMAN_TYPE_RGBA 9 |
140 | #define PIXMAN_TYPE_ARGB_SRGB 10 |
140 | #define PIXMAN_TYPE_ARGB_SRGB 10 |
141 | 141 | ||
142 | /* 32bpp formats */ |
142 | /* 32bpp formats */ |
143 | typedef enum { |
143 | typedef enum { |
144 | PIXMAN_a8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,8,8,8,8), |
144 | PIXMAN_a8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,8,8,8,8), |
145 | PIXMAN_x8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,8,8,8), |
145 | PIXMAN_x8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,8,8,8), |
146 | PIXMAN_a8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,8,8,8,8), |
146 | PIXMAN_a8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,8,8,8,8), |
147 | PIXMAN_x8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,8,8,8), |
147 | PIXMAN_x8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,8,8,8), |
148 | PIXMAN_b8g8r8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,8,8,8,8), |
148 | PIXMAN_b8g8r8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,8,8,8,8), |
149 | PIXMAN_b8g8r8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,0,8,8,8), |
149 | PIXMAN_b8g8r8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,0,8,8,8), |
150 | PIXMAN_r8g8b8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,8,8,8,8), |
150 | PIXMAN_r8g8b8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,8,8,8,8), |
151 | PIXMAN_r8g8b8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,0,8,8,8), |
151 | PIXMAN_r8g8b8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,0,8,8,8), |
152 | PIXMAN_x14r6g6b6 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,6,6,6), |
152 | PIXMAN_x14r6g6b6 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,6,6,6), |
153 | PIXMAN_x2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,10,10,10), |
153 | PIXMAN_x2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,10,10,10), |
154 | PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10), |
154 | PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10), |
155 | PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10), |
155 | PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10), |
156 | PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10), |
156 | PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10), |
157 | 157 | ||
158 | /* sRGB formats */ |
158 | /* sRGB formats */ |
159 | PIXMAN_a8r8g8b8_sRGB = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB_SRGB,8,8,8,8), |
159 | PIXMAN_a8r8g8b8_sRGB = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB_SRGB,8,8,8,8), |
160 | 160 | ||
161 | /* 24bpp formats */ |
161 | /* 24bpp formats */ |
162 | PIXMAN_r8g8b8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8), |
162 | PIXMAN_r8g8b8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8), |
163 | PIXMAN_b8g8r8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ABGR,0,8,8,8), |
163 | PIXMAN_b8g8r8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ABGR,0,8,8,8), |
164 | 164 | ||
165 | /* 16bpp formats */ |
165 | /* 16bpp formats */ |
166 | PIXMAN_r5g6b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,6,5), |
166 | PIXMAN_r5g6b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,6,5), |
167 | PIXMAN_b5g6r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,6,5), |
167 | PIXMAN_b5g6r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,6,5), |
168 | 168 | ||
169 | PIXMAN_a1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,1,5,5,5), |
169 | PIXMAN_a1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,1,5,5,5), |
170 | PIXMAN_x1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,5,5), |
170 | PIXMAN_x1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,5,5), |
171 | PIXMAN_a1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,1,5,5,5), |
171 | PIXMAN_a1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,1,5,5,5), |
172 | PIXMAN_x1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,5,5), |
172 | PIXMAN_x1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,5,5), |
173 | PIXMAN_a4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,4,4,4,4), |
173 | PIXMAN_a4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,4,4,4,4), |
174 | PIXMAN_x4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,4,4,4), |
174 | PIXMAN_x4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,4,4,4), |
175 | PIXMAN_a4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,4,4,4,4), |
175 | PIXMAN_a4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,4,4,4,4), |
176 | PIXMAN_x4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,4,4,4), |
176 | PIXMAN_x4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,4,4,4), |
177 | 177 | ||
178 | /* 8bpp formats */ |
178 | /* 8bpp formats */ |
179 | PIXMAN_a8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0), |
179 | PIXMAN_a8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0), |
180 | PIXMAN_r3g3b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,0,3,3,2), |
180 | PIXMAN_r3g3b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,0,3,3,2), |
181 | PIXMAN_b2g3r3 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,0,3,3,2), |
181 | PIXMAN_b2g3r3 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,0,3,3,2), |
182 | PIXMAN_a2r2g2b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,2,2,2,2), |
182 | PIXMAN_a2r2g2b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,2,2,2,2), |
183 | PIXMAN_a2b2g2r2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,2,2,2,2), |
183 | PIXMAN_a2b2g2r2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,2,2,2,2), |
184 | 184 | ||
185 | PIXMAN_c8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0), |
185 | PIXMAN_c8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0), |
186 | PIXMAN_g8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0), |
186 | PIXMAN_g8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0), |
187 | 187 | ||
188 | PIXMAN_x4a4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,4,0,0,0), |
188 | PIXMAN_x4a4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,4,0,0,0), |
189 | 189 | ||
190 | PIXMAN_x4c4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0), |
190 | PIXMAN_x4c4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0), |
191 | PIXMAN_x4g4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0), |
191 | PIXMAN_x4g4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0), |
192 | 192 | ||
193 | /* 4bpp formats */ |
193 | /* 4bpp formats */ |
194 | PIXMAN_a4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_A,4,0,0,0), |
194 | PIXMAN_a4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_A,4,0,0,0), |
195 | PIXMAN_r1g2b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,0,1,2,1), |
195 | PIXMAN_r1g2b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,0,1,2,1), |
196 | PIXMAN_b1g2r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,0,1,2,1), |
196 | PIXMAN_b1g2r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,0,1,2,1), |
197 | PIXMAN_a1r1g1b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,1,1,1,1), |
197 | PIXMAN_a1r1g1b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,1,1,1,1), |
198 | PIXMAN_a1b1g1r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,1,1,1,1), |
198 | PIXMAN_a1b1g1r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,1,1,1,1), |
199 | 199 | ||
200 | PIXMAN_c4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_COLOR,0,0,0,0), |
200 | PIXMAN_c4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_COLOR,0,0,0,0), |
201 | PIXMAN_g4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_GRAY,0,0,0,0), |
201 | PIXMAN_g4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_GRAY,0,0,0,0), |
202 | 202 | ||
203 | /* 1bpp formats */ |
203 | /* 1bpp formats */ |
204 | PIXMAN_a1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0), |
204 | PIXMAN_a1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0), |
205 | 205 | ||
206 | PIXMAN_g1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0), |
206 | PIXMAN_g1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0), |
207 | 207 | ||
208 | /* YUV formats */ |
208 | /* YUV formats */ |
209 | PIXMAN_yuy2 = PIXMAN_FORMAT(16,PIXMAN_TYPE_YUY2,0,0,0,0), |
209 | PIXMAN_yuy2 = PIXMAN_FORMAT(16,PIXMAN_TYPE_YUY2,0,0,0,0), |
210 | PIXMAN_yv12 = PIXMAN_FORMAT(12,PIXMAN_TYPE_YV12,0,0,0,0) |
210 | PIXMAN_yv12 = PIXMAN_FORMAT(12,PIXMAN_TYPE_YV12,0,0,0,0) |
211 | 211 | ||
212 | } pixman_format_code_t; |
212 | } pixman_format_code_t; |
213 | 213 | ||
214 | typedef enum _PictFormatShort { |
214 | typedef enum _PictFormatShort { |
215 | 215 | ||
216 | PICT_a2r10g10b10 = PIXMAN_a2r10g10b10, |
216 | PICT_a2r10g10b10 = PIXMAN_a2r10g10b10, |
217 | PICT_x2r10g10b10 = PIXMAN_x2r10g10b10, |
217 | PICT_x2r10g10b10 = PIXMAN_x2r10g10b10, |
218 | PICT_a2b10g10r10 = PIXMAN_a2b10g10r10, |
218 | PICT_a2b10g10r10 = PIXMAN_a2b10g10r10, |
219 | PICT_x2b10g10r10 = PIXMAN_x2b10g10r10, |
219 | PICT_x2b10g10r10 = PIXMAN_x2b10g10r10, |
220 | 220 | ||
221 | PICT_a8r8g8b8 = PIXMAN_a8r8g8b8, |
221 | PICT_a8r8g8b8 = PIXMAN_a8r8g8b8, |
222 | PICT_x8r8g8b8 = PIXMAN_x8r8g8b8, |
222 | PICT_x8r8g8b8 = PIXMAN_x8r8g8b8, |
223 | PICT_a8b8g8r8 = PIXMAN_a8b8g8r8, |
223 | PICT_a8b8g8r8 = PIXMAN_a8b8g8r8, |
224 | PICT_x8b8g8r8 = PIXMAN_x8b8g8r8, |
224 | PICT_x8b8g8r8 = PIXMAN_x8b8g8r8, |
225 | PICT_b8g8r8a8 = PIXMAN_b8g8r8a8, |
225 | PICT_b8g8r8a8 = PIXMAN_b8g8r8a8, |
226 | PICT_b8g8r8x8 = PIXMAN_b8g8r8x8, |
226 | PICT_b8g8r8x8 = PIXMAN_b8g8r8x8, |
227 | 227 | ||
228 | /* 24bpp formats */ |
228 | /* 24bpp formats */ |
229 | PICT_r8g8b8 = PIXMAN_r8g8b8, |
229 | PICT_r8g8b8 = PIXMAN_r8g8b8, |
230 | PICT_b8g8r8 = PIXMAN_b8g8r8, |
230 | PICT_b8g8r8 = PIXMAN_b8g8r8, |
231 | 231 | ||
232 | /* 16bpp formats */ |
232 | /* 16bpp formats */ |
233 | PICT_r5g6b5 = PIXMAN_r5g6b5, |
233 | PICT_r5g6b5 = PIXMAN_r5g6b5, |
234 | PICT_b5g6r5 = PIXMAN_b5g6r5, |
234 | PICT_b5g6r5 = PIXMAN_b5g6r5, |
235 | 235 | ||
236 | PICT_a1r5g5b5 = PIXMAN_a1r5g5b5, |
236 | PICT_a1r5g5b5 = PIXMAN_a1r5g5b5, |
237 | PICT_x1r5g5b5 = PIXMAN_x1r5g5b5, |
237 | PICT_x1r5g5b5 = PIXMAN_x1r5g5b5, |
238 | PICT_a1b5g5r5 = PIXMAN_a1b5g5r5, |
238 | PICT_a1b5g5r5 = PIXMAN_a1b5g5r5, |
239 | PICT_x1b5g5r5 = PIXMAN_x1b5g5r5, |
239 | PICT_x1b5g5r5 = PIXMAN_x1b5g5r5, |
240 | PICT_a4r4g4b4 = PIXMAN_a4r4g4b4, |
240 | PICT_a4r4g4b4 = PIXMAN_a4r4g4b4, |
241 | PICT_x4r4g4b4 = PIXMAN_x4r4g4b4, |
241 | PICT_x4r4g4b4 = PIXMAN_x4r4g4b4, |
242 | PICT_a4b4g4r4 = PIXMAN_a4b4g4r4, |
242 | PICT_a4b4g4r4 = PIXMAN_a4b4g4r4, |
243 | PICT_x4b4g4r4 = PIXMAN_x4b4g4r4, |
243 | PICT_x4b4g4r4 = PIXMAN_x4b4g4r4, |
244 | 244 | ||
245 | /* 8bpp formats */ |
245 | /* 8bpp formats */ |
246 | PICT_a8 = PIXMAN_a8, |
246 | PICT_a8 = PIXMAN_a8, |
247 | PICT_r3g3b2 = PIXMAN_r3g3b2, |
247 | PICT_r3g3b2 = PIXMAN_r3g3b2, |
248 | PICT_b2g3r3 = PIXMAN_b2g3r3, |
248 | PICT_b2g3r3 = PIXMAN_b2g3r3, |
249 | PICT_a2r2g2b2 = PIXMAN_a2r2g2b2, |
249 | PICT_a2r2g2b2 = PIXMAN_a2r2g2b2, |
250 | PICT_a2b2g2r2 = PIXMAN_a2b2g2r2, |
250 | PICT_a2b2g2r2 = PIXMAN_a2b2g2r2, |
251 | 251 | ||
252 | PICT_c8 = PIXMAN_c8, |
252 | PICT_c8 = PIXMAN_c8, |
253 | PICT_g8 = PIXMAN_g8, |
253 | PICT_g8 = PIXMAN_g8, |
254 | 254 | ||
255 | PICT_x4a4 = PIXMAN_x4a4, |
255 | PICT_x4a4 = PIXMAN_x4a4, |
256 | 256 | ||
257 | PICT_x4c4 = PIXMAN_x4c4, |
257 | PICT_x4c4 = PIXMAN_x4c4, |
258 | PICT_x4g4 = PIXMAN_x4g4, |
258 | PICT_x4g4 = PIXMAN_x4g4, |
259 | 259 | ||
260 | /* 4bpp formats */ |
260 | /* 4bpp formats */ |
261 | PICT_a4 = PIXMAN_a4, |
261 | PICT_a4 = PIXMAN_a4, |
262 | PICT_r1g2b1 = PIXMAN_r1g2b1, |
262 | PICT_r1g2b1 = PIXMAN_r1g2b1, |
263 | PICT_b1g2r1 = PIXMAN_b1g2r1, |
263 | PICT_b1g2r1 = PIXMAN_b1g2r1, |
264 | PICT_a1r1g1b1 = PIXMAN_a1r1g1b1, |
264 | PICT_a1r1g1b1 = PIXMAN_a1r1g1b1, |
265 | PICT_a1b1g1r1 = PIXMAN_a1b1g1r1, |
265 | PICT_a1b1g1r1 = PIXMAN_a1b1g1r1, |
266 | 266 | ||
267 | PICT_c4 = PIXMAN_c4, |
267 | PICT_c4 = PIXMAN_c4, |
268 | PICT_g4 = PIXMAN_g4, |
268 | PICT_g4 = PIXMAN_g4, |
269 | 269 | ||
270 | /* 1bpp formats */ |
270 | /* 1bpp formats */ |
271 | PICT_a1 = PIXMAN_a1, |
271 | PICT_a1 = PIXMAN_a1, |
272 | 272 | ||
273 | PICT_g1 = PIXMAN_g1 |
273 | PICT_g1 = PIXMAN_g1 |
274 | } PictFormatShort; |
274 | } PictFormatShort; |
275 | 275 | ||
276 | #define PIXMAN_FORMAT_A(f) (((f) >> 12) & 0x0f) |
276 | #define PIXMAN_FORMAT_A(f) (((f) >> 12) & 0x0f) |
277 | #define PIXMAN_FORMAT_RGB(f) (((f) ) & 0xfff) |
277 | #define PIXMAN_FORMAT_RGB(f) (((f) ) & 0xfff) |
278 | 278 | ||
279 | #define PICT_FORMAT_A(f) PIXMAN_FORMAT_A(f) |
279 | #define PICT_FORMAT_A(f) PIXMAN_FORMAT_A(f) |
280 | 280 | ||
281 | #define RepeatNone 0 |
281 | #define RepeatNone 0 |
282 | #define RepeatNormal 1 |
282 | #define RepeatNormal 1 |
283 | #define RepeatPad 2 |
283 | #define RepeatPad 2 |
284 | #define RepeatReflect 3 |
284 | #define RepeatReflect 3 |
285 | 285 | ||
286 | #define PictFilterNearest 0 |
286 | #define PictFilterNearest 0 |
287 | #define PictFilterBilinear 1 |
287 | #define PictFilterBilinear 1 |
288 | 288 | ||
289 | #define PictFilterFast 2 |
289 | #define PictFilterFast 2 |
290 | #define PictFilterGood 3 |
290 | #define PictFilterGood 3 |
291 | #define PictFilterBest 4 |
291 | #define PictFilterBest 4 |
292 | 292 | ||
293 | #define PictFilterConvolution 5 |
293 | #define PictFilterConvolution 5 |
294 | 294 | ||
295 | typedef int32_t pixman_fixed_16_16_t; |
295 | typedef int32_t pixman_fixed_16_16_t; |
296 | typedef pixman_fixed_16_16_t pixman_fixed_t; |
296 | typedef pixman_fixed_16_16_t pixman_fixed_t; |
297 | 297 | ||
298 | struct pixman_transform |
298 | struct pixman_transform |
299 | { |
299 | { |
300 | pixman_fixed_t matrix[3][3]; |
300 | pixman_fixed_t matrix[3][3]; |
301 | }; |
301 | }; |
302 | 302 | ||
303 | typedef unsigned long Picture; |
303 | typedef unsigned long Picture; |
304 | typedef unsigned long PictFormat; |
304 | typedef unsigned long PictFormat; |
305 | 305 | ||
306 | typedef struct _Pixmap *PixmapPtr; |
306 | typedef struct _Pixmap *PixmapPtr; |
307 | typedef struct _Picture *PicturePtr; |
307 | typedef struct _Picture *PicturePtr; |
308 | typedef struct _Drawable *DrawablePtr; |
308 | typedef struct _Drawable *DrawablePtr; |
309 | typedef struct _PictFormat *PictFormatPtr; |
309 | typedef struct _PictFormat *PictFormatPtr; |
310 | 310 | ||
311 | typedef struct pixman_transform PictTransform, *PictTransformPtr; |
311 | typedef struct pixman_transform PictTransform, *PictTransformPtr; |
312 | 312 | ||
313 | 313 | ||
314 | 314 | ||
315 | typedef struct _Drawable { |
315 | typedef struct _Drawable { |
316 | unsigned char type; /* DRAWABLE_ |
316 | unsigned char type; /* DRAWABLE_ |
317 | unsigned char class; /* specific to type */ |
317 | unsigned char class; /* specific to type */ |
318 | unsigned char depth; |
318 | unsigned char depth; |
319 | unsigned char bitsPerPixel; |
319 | unsigned char bitsPerPixel; |
320 | unsigned int id; /* resource id */ |
320 | unsigned int id; /* resource id */ |
321 | short x; /* window: screen absolute, pixmap: 0 */ |
321 | short x; /* window: screen absolute, pixmap: 0 */ |
322 | short y; /* window: screen absolute, pixmap: 0 */ |
322 | short y; /* window: screen absolute, pixmap: 0 */ |
323 | unsigned short width; |
323 | unsigned short width; |
324 | unsigned short height; |
324 | unsigned short height; |
325 | } DrawableRec; |
325 | } DrawableRec; |
326 | 326 | ||
327 | /* |
327 | /* |
328 | * PIXMAP -- device dependent |
328 | * PIXMAP -- device dependent |
329 | */ |
329 | */ |
330 | 330 | ||
331 | typedef struct _Pixmap { |
331 | typedef struct _Pixmap { |
332 | DrawableRec drawable; |
332 | DrawableRec drawable; |
333 | // PrivateRec *devPrivates; |
333 | // PrivateRec *devPrivates; |
334 | int refcnt; |
334 | int refcnt; |
335 | int devKind; /* This is the pitch of the pixmap, typically width*bpp/8. */ |
335 | int devKind; /* This is the pitch of the pixmap, typically width*bpp/8. */ |
336 | // DevUnion devPrivate; /* When !NULL, devPrivate.ptr points to the raw pixel data. */ |
336 | // DevUnion devPrivate; /* When !NULL, devPrivate.ptr points to the raw pixel data. */ |
337 | #ifdef COMPOSITE |
337 | #ifdef COMPOSITE |
338 | short screen_x; |
338 | short screen_x; |
339 | short screen_y; |
339 | short screen_y; |
340 | #endif |
340 | #endif |
341 | unsigned usage_hint; /* see CREATE_PIXMAP_USAGE_* */ |
341 | unsigned usage_hint; /* see CREATE_PIXMAP_USAGE_* */ |
342 | 342 | ||
343 | PixmapPtr master_pixmap; /* pointer to master copy of pixmap for pixmap sharing */ |
343 | PixmapPtr master_pixmap; /* pointer to master copy of pixmap for pixmap sharing */ |
344 | } PixmapRec; |
344 | } PixmapRec; |
345 | 345 | ||
346 | typedef struct _PictFormat { |
346 | typedef struct _PictFormat { |
347 | uint32_t id; |
347 | uint32_t id; |
348 | uint32_t format; /* except bpp */ |
348 | uint32_t format; /* except bpp */ |
349 | unsigned char type; |
349 | unsigned char type; |
350 | unsigned char depth; |
350 | unsigned char depth; |
351 | // DirectFormatRec direct; |
351 | // DirectFormatRec direct; |
352 | // IndexFormatRec index; |
352 | // IndexFormatRec index; |
353 | } PictFormatRec; |
353 | } PictFormatRec; |
354 | 354 | ||
355 | typedef struct _Picture { |
355 | typedef struct _Picture { |
356 | DrawablePtr pDrawable; |
356 | DrawablePtr pDrawable; |
357 | // PictFormatPtr pFormat; |
357 | // PictFormatPtr pFormat; |
358 | PictFormatShort format; /* PICT_FORMAT */ |
358 | PictFormatShort format; /* PICT_FORMAT */ |
359 | int refcnt; |
359 | int refcnt; |
360 | uint32_t id; |
360 | uint32_t id; |
361 | unsigned int repeat:1; |
361 | unsigned int repeat:1; |
362 | unsigned int graphicsExposures:1; |
362 | unsigned int graphicsExposures:1; |
363 | unsigned int subWindowMode:1; |
363 | unsigned int subWindowMode:1; |
364 | unsigned int polyEdge:1; |
364 | unsigned int polyEdge:1; |
365 | unsigned int polyMode:1; |
365 | unsigned int polyMode:1; |
366 | unsigned int freeCompClip:1; |
366 | unsigned int freeCompClip:1; |
367 | unsigned int clientClipType:2; |
367 | unsigned int clientClipType:2; |
368 | unsigned int componentAlpha:1; |
368 | unsigned int componentAlpha:1; |
369 | unsigned int repeatType:2; |
369 | unsigned int repeatType:2; |
370 | unsigned int filter:3; |
370 | unsigned int filter:3; |
371 | // unsigned int stateChanges:CPLastBit; |
371 | // unsigned int stateChanges:CPLastBit; |
372 | // unsigned int unused:18 - CPLastBit; |
372 | // unsigned int unused:18 - CPLastBit; |
373 | 373 | ||
374 | // PicturePtr alphaMap; |
374 | // PicturePtr alphaMap; |
375 | 375 | ||
376 | // PictTransform *transform; |
376 | // PictTransform *transform; |
377 | 377 | ||
378 | // SourcePictPtr pSourcePict; |
378 | // SourcePictPtr pSourcePict; |
379 | // xFixed *filter_params; |
379 | // xFixed *filter_params; |
380 | // int filter_nparams; |
380 | // int filter_nparams; |
381 | } PictureRec; |
381 | } PictureRec; |
382 | 382 | ||
383 | #define PolyModePrecise 0 |
383 | #define PolyModePrecise 0 |
384 | #define PolyModeImprecise 1 |
384 | #define PolyModeImprecise 1 |
385 | 385 | ||
386 | 386 | ||
387 | struct sna_fb |
387 | struct sna_fb |
388 | { |
388 | { |
389 | uint32_t name; |
389 | uint32_t name; |
390 | uint32_t width; |
390 | uint32_t width; |
391 | uint32_t height; |
391 | uint32_t height; |
392 | uint32_t pitch; |
392 | uint32_t pitch; |
393 | uint32_t tiling; |
393 | uint32_t tiling; |
394 | uint32_t crtc; |
394 | uint32_t crtc; |
395 | uint32_t pipe; |
395 | uint32_t pipe; |
396 | 396 | ||
397 | struct kgem_bo *fb_bo; |
397 | struct kgem_bo *fb_bo; |
398 | }; |
398 | }; |
399 | 399 | ||
400 | struct pixman_box16 |
400 | struct pixman_box16 |
401 | { |
401 | { |
402 | int16_t x1, y1, x2, y2; |
402 | int16_t x1, y1, x2, y2; |
403 | }; |
403 | }; |
404 | 404 | ||
405 | typedef struct pixman_box16 BoxRec; |
405 | typedef struct pixman_box16 BoxRec; |
406 | typedef unsigned int CARD32; |
406 | typedef unsigned int CARD32; |
407 | typedef unsigned short CARD16; |
407 | typedef unsigned short CARD16; |
408 | 408 | ||
409 | #include "sna_render.h" |
409 | #include "sna_render.h" |
410 | #include "kgem.h" |
410 | #include "kgem.h" |
411 | 411 | ||
412 | #define GXclear 0x0 |
412 | #define GXclear 0x0 |
413 | #define GXcopy 0x3 |
413 | #define GXcopy 0x3 |
414 | 414 | ||
415 | #define PictOpClear 0 |
415 | #define PictOpClear 0 |
416 | #define PictOpSrc 1 |
416 | #define PictOpSrc 1 |
417 | #define PictOpDst 2 |
417 | #define PictOpDst 2 |
418 | #define PictOpOver 3 |
418 | #define PictOpOver 3 |
419 | #define PictOpOverReverse 4 |
419 | #define PictOpOverReverse 4 |
420 | #define PictOpIn 5 |
420 | #define PictOpIn 5 |
421 | #define PictOpInReverse 6 |
421 | #define PictOpInReverse 6 |
422 | #define PictOpOut 7 |
422 | #define PictOpOut 7 |
423 | #define PictOpOutReverse 8 |
423 | #define PictOpOutReverse 8 |
424 | #define PictOpAtop 9 |
424 | #define PictOpAtop 9 |
425 | #define PictOpAtopReverse 10 |
425 | #define PictOpAtopReverse 10 |
426 | #define PictOpXor 11 |
426 | #define PictOpXor 11 |
427 | #define PictOpAdd 12 |
427 | #define PictOpAdd 12 |
428 | #define PictOpSaturate 13 |
428 | #define PictOpSaturate 13 |
429 | #define PictOpMaximum 13 |
429 | #define PictOpMaximum 13 |
430 | 430 | ||
431 | 431 | ||
432 | #define SNA_CURSOR_X 64 |
432 | #define SNA_CURSOR_X 64 |
433 | #define SNA_CURSOR_Y SNA_CURSOR_X |
433 | #define SNA_CURSOR_Y SNA_CURSOR_X |
434 | 434 | ||
435 | struct sna_client { |
435 | struct sna_client { |
436 | int is_compositor; /* only 4 bits used */ |
436 | int is_compositor; /* only 4 bits used */ |
437 | }; |
437 | }; |
438 | 438 | ||
439 | 439 | ||
440 | //#define assert(x) |
440 | //#define assert(x) |
441 | 441 | ||
442 | 442 | ||
443 | struct sna { |
443 | struct sna { |
444 | struct kgem kgem; |
444 | struct kgem kgem; |
445 | 445 | ||
446 | unsigned scrn; |
446 | unsigned scrn; |
447 | 447 | ||
448 | unsigned flags; |
448 | unsigned flags; |
449 | #define SNA_NO_WAIT 0x1 |
449 | #define SNA_NO_WAIT 0x1 |
450 | #define SNA_NO_FLIP 0x2 |
450 | #define SNA_NO_FLIP 0x2 |
451 | #define SNA_NO_VSYNC 0x4 |
451 | #define SNA_NO_VSYNC 0x4 |
452 | #define SNA_TRIPLE_BUFFER 0x8 |
452 | #define SNA_TRIPLE_BUFFER 0x8 |
453 | #define SNA_TEAR_FREE 0x10 |
453 | #define SNA_TEAR_FREE 0x10 |
454 | #define SNA_FORCE_SHADOW 0x20 |
454 | #define SNA_FORCE_SHADOW 0x20 |
455 | #define SNA_FLUSH_GTT 0x40 |
455 | #define SNA_FLUSH_GTT 0x40 |
456 | #define SNA_IS_HOSTED 0x80 |
456 | #define SNA_IS_HOSTED 0x80 |
457 | #define SNA_PERFORMANCE 0x100 |
457 | #define SNA_PERFORMANCE 0x100 |
458 | #define SNA_POWERSAVE 0x200 |
458 | #define SNA_POWERSAVE 0x200 |
459 | #define SNA_REPROBE 0x80000000 |
459 | #define SNA_REPROBE 0x80000000 |
460 | 460 | ||
461 | unsigned cpu_features; |
461 | unsigned cpu_features; |
462 | #define MMX 0x1 |
462 | #define MMX 0x1 |
463 | #define SSE 0x2 |
463 | #define SSE 0x2 |
464 | #define SSE2 0x4 |
464 | #define SSE2 0x4 |
465 | #define SSE3 0x8 |
465 | #define SSE3 0x8 |
466 | #define SSSE3 0x10 |
466 | #define SSSE3 0x10 |
467 | #define SSE4_1 0x20 |
467 | #define SSE4_1 0x20 |
468 | #define SSE4_2 0x40 |
468 | #define SSE4_2 0x40 |
469 | #define AVX 0x80 |
469 | #define AVX 0x80 |
470 | #define AVX2 0x100 |
470 | #define AVX2 0x100 |
471 | 471 | ||
472 | struct list flush_pixmaps; |
472 | struct list flush_pixmaps; |
473 | struct list active_pixmaps; |
473 | struct list active_pixmaps; |
474 | 474 | ||
475 | 475 | ||
476 | 476 | ||
477 | 477 | ||
478 | 478 | ||
479 | unsigned int tiling; |
479 | unsigned int tiling; |
480 | #define SNA_TILING_FB 0x1 |
480 | #define SNA_TILING_FB 0x1 |
481 | #define SNA_TILING_2D 0x2 |
481 | #define SNA_TILING_2D 0x2 |
482 | #define SNA_TILING_ALL (~0) |
482 | #define SNA_TILING_ALL (~0) |
483 | 483 | ||
484 | struct pci_device *PciInfo; |
484 | struct pci_device *PciInfo; |
485 | const struct intel_device_info *info; |
485 | const struct intel_device_info *info; |
486 | 486 | ||
487 | // PicturePtr clear; |
487 | // PicturePtr clear; |
488 | struct { |
488 | struct { |
489 | uint32_t fill_bo; |
489 | uint32_t fill_bo; |
490 | uint32_t fill_pixel; |
490 | uint32_t fill_pixel; |
491 | uint32_t fill_alu; |
491 | uint32_t fill_alu; |
492 | } blt_state; |
492 | } blt_state; |
493 | union { |
493 | union { |
494 | unsigned gt; |
494 | unsigned gt; |
495 | struct gen3_render_state gen3; |
495 | struct gen3_render_state gen3; |
496 | struct gen4_render_state gen4; |
496 | struct gen4_render_state gen4; |
497 | struct gen5_render_state gen5; |
497 | struct gen5_render_state gen5; |
498 | struct gen6_render_state gen6; |
498 | struct gen6_render_state gen6; |
499 | struct gen7_render_state gen7; |
499 | struct gen7_render_state gen7; |
500 | } render_state; |
500 | } render_state; |
501 | 501 | ||
502 | bool dri_available; |
502 | bool dri_available; |
503 | bool dri_open; |
503 | bool dri_open; |
504 | 504 | ||
505 | /* Broken-out options. */ |
505 | /* Broken-out options. */ |
506 | // OptionInfoPtr Options; |
506 | // OptionInfoPtr Options; |
507 | 507 | ||
508 | /* Driver phase/state information */ |
508 | /* Driver phase/state information */ |
509 | // Bool suspended; |
509 | // Bool suspended; |
510 | 510 | ||
511 | struct sna_render render; |
511 | struct sna_render render; |
512 | 512 | ||
513 | #if DEBUG_MEMORY |
513 | #if DEBUG_MEMORY |
514 | struct { |
514 | struct { |
515 | int pixmap_allocs; |
515 | int pixmap_allocs; |
516 | int cpu_bo_allocs; |
516 | int cpu_bo_allocs; |
517 | size_t shadow_pixels_bytes; |
517 | size_t shadow_pixels_bytes; |
518 | size_t cpu_bo_bytes; |
518 | size_t cpu_bo_bytes; |
519 | } debug_memory; |
519 | } debug_memory; |
520 | #endif |
520 | #endif |
521 | }; |
521 | }; |
522 | 522 | ||
523 | static inline struct sna * |
523 | static inline struct sna * |
524 | to_sna_from_kgem(struct kgem *kgem) |
524 | to_sna_from_kgem(struct kgem *kgem) |
525 | { |
525 | { |
526 | return container_of(kgem, struct sna, kgem); |
526 | return container_of(kgem, struct sna, kgem); |
527 | } |
527 | } |
528 | 528 | ||
529 | #ifndef ARRAY_SIZE |
529 | #ifndef ARRAY_SIZE |
530 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) |
530 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) |
531 | #endif |
531 | #endif |
532 | 532 | ||
533 | #ifndef ALIGN |
533 | #ifndef ALIGN |
534 | #define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1)) |
534 | #define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1)) |
535 | #endif |
535 | #endif |
536 | 536 | ||
537 | #ifndef MIN |
537 | #ifndef MIN |
538 | #define MIN(a,b) ((a) <= (b) ? (a) : (b)) |
538 | #define MIN(a,b) ((a) <= (b) ? (a) : (b)) |
539 | #endif |
539 | #endif |
540 | 540 | ||
541 | #ifndef MAX |
541 | #ifndef MAX |
542 | #define MAX(a,b) ((a) >= (b) ? (a) : (b)) |
542 | #define MAX(a,b) ((a) >= (b) ? (a) : (b)) |
543 | #endif |
543 | #endif |
544 | static inline bool |
544 | static inline bool |
545 | _sna_transform_point(const PictTransform *transform, |
545 | _sna_transform_point(const PictTransform *transform, |
546 | int64_t x, int64_t y, int64_t result[3]) |
546 | int64_t x, int64_t y, int64_t result[3]) |
547 | { |
547 | { |
548 | int j; |
548 | int j; |
549 | 549 | ||
550 | for (j = 0; j < 3; j++) |
550 | for (j = 0; j < 3; j++) |
551 | result[j] = (transform->matrix[j][0] * x + |
551 | result[j] = (transform->matrix[j][0] * x + |
552 | transform->matrix[j][1] * y + |
552 | transform->matrix[j][1] * y + |
553 | transform->matrix[j][2]); |
553 | transform->matrix[j][2]); |
554 | 554 | ||
555 | return result[2] != 0; |
555 | return result[2] != 0; |
556 | } |
556 | } |
557 | 557 | ||
558 | static inline void |
558 | static inline void |
559 | _sna_get_transformed_coordinates(int x, int y, |
559 | _sna_get_transformed_coordinates(int x, int y, |
560 | const PictTransform *transform, |
560 | const PictTransform *transform, |
561 | float *x_out, float *y_out) |
561 | float *x_out, float *y_out) |
562 | { |
562 | { |
563 | 563 | ||
564 | int64_t result[3]; |
564 | int64_t result[3]; |
565 | 565 | ||
566 | _sna_transform_point(transform, x, y, result); |
566 | _sna_transform_point(transform, x, y, result); |
567 | *x_out = result[0] / (double)result[2]; |
567 | *x_out = result[0] / (double)result[2]; |
568 | *y_out = result[1] / (double)result[2]; |
568 | *y_out = result[1] / (double)result[2]; |
569 | } |
569 | } |
570 | 570 | ||
571 | static inline void |
571 | static inline void |
572 | _sna_get_transformed_scaled(int x, int y, |
572 | _sna_get_transformed_scaled(int x, int y, |
573 | const PictTransform *transform, const float *sf, |
573 | const PictTransform *transform, const float *sf, |
574 | float *x_out, float *y_out) |
574 | float *x_out, float *y_out) |
575 | { |
575 | { |
576 | *x_out = sf[0] * (transform->matrix[0][0] * x + |
576 | *x_out = sf[0] * (transform->matrix[0][0] * x + |
577 | transform->matrix[0][1] * y + |
577 | transform->matrix[0][1] * y + |
578 | transform->matrix[0][2]); |
578 | transform->matrix[0][2]); |
579 | 579 | ||
580 | *y_out = sf[1] * (transform->matrix[1][0] * x + |
580 | *y_out = sf[1] * (transform->matrix[1][0] * x + |
581 | transform->matrix[1][1] * y + |
581 | transform->matrix[1][1] * y + |
582 | transform->matrix[1][2]); |
582 | transform->matrix[1][2]); |
583 | } |
583 | } |
584 | 584 | ||
585 | void |
585 | void |
586 | sna_get_transformed_coordinates(int x, int y, |
586 | sna_get_transformed_coordinates(int x, int y, |
587 | const PictTransform *transform, |
587 | const PictTransform *transform, |
588 | float *x_out, float *y_out); |
588 | float *x_out, float *y_out); |
589 | 589 | ||
590 | void |
590 | void |
591 | sna_get_transformed_coordinates_3d(int x, int y, |
591 | sna_get_transformed_coordinates_3d(int x, int y, |
592 | const PictTransform *transform, |
592 | const PictTransform *transform, |
593 | float *x_out, float *y_out, float *z_out); |
593 | float *x_out, float *y_out, float *z_out); |
594 | 594 | ||
595 | bool sna_transform_is_affine(const PictTransform *t); |
595 | bool sna_transform_is_affine(const PictTransform *t); |
596 | bool sna_transform_is_integer_translation(const PictTransform *t, |
596 | bool sna_transform_is_integer_translation(const PictTransform *t, |
597 | int16_t *tx, int16_t *ty); |
597 | int16_t *tx, int16_t *ty); |
598 | bool sna_transform_is_translation(const PictTransform *t, |
598 | bool sna_transform_is_translation(const PictTransform *t, |
599 | pixman_fixed_t *tx, pixman_fixed_t *ty); |
599 | pixman_fixed_t *tx, pixman_fixed_t *ty); |
600 | static inline bool |
600 | static inline bool |
601 | sna_affine_transform_is_rotation(const PictTransform *t) |
601 | sna_affine_transform_is_rotation(const PictTransform *t) |
602 | { |
602 | { |
603 | assert(sna_transform_is_affine(t)); |
603 | assert(sna_transform_is_affine(t)); |
604 | return t->matrix[0][1] | t->matrix[1][0]; |
604 | return t->matrix[0][1] | t->matrix[1][0]; |
605 | } |
605 | } |
606 | 606 | ||
607 | static inline bool |
607 | static inline bool |
608 | sna_transform_equal(const PictTransform *a, const PictTransform *b) |
608 | sna_transform_equal(const PictTransform *a, const PictTransform *b) |
609 | { |
609 | { |
610 | if (a == b) |
610 | if (a == b) |
611 | return true; |
611 | return true; |
612 | 612 | ||
613 | if (a == NULL || b == NULL) |
613 | if (a == NULL || b == NULL) |
614 | return false; |
614 | return false; |
615 | 615 | ||
616 | return memcmp(a, b, sizeof(*a)) == 0; |
616 | return memcmp(a, b, sizeof(*a)) == 0; |
617 | } |
617 | } |
618 | 618 | ||
619 | int intel_get_device_id(struct sna *sna); |
619 | int intel_get_device_id(struct sna *sna); |
620 | 620 | ||
621 | #endif /* _SNA_H */>=>><>><>><>><>><> |
621 | #endif /* _SNA_H */>=>><>><>><>><>><> |