Subversion Repositories Kolibri OS

Rev

Rev 4304 | Rev 4359 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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