Subversion Repositories Kolibri OS

Rev

Rev 4359 | Rev 4377 | 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
 
4368 Serge 101
# define ENTER() printf("ENTER %s\n", __FUNCTION__)
102
# define LEAVE() printf("LEAVE %s\n", __FUNCTION__)
103
# define FAIL() printf("FAIL %s\n", __FUNCTION__)
104
 
4304 Serge 105
#define DEBUG_NO_BLT 0
106
 
107
#define DEBUG_FLUSH_BATCH 0
108
 
109
#define TEST_ALL 0
110
#define TEST_ACCEL (TEST_ALL || 0)
111
#define TEST_BATCH (TEST_ALL || 0)
112
#define TEST_BLT (TEST_ALL || 0)
113
#define TEST_COMPOSITE (TEST_ALL || 0)
114
#define TEST_DAMAGE (TEST_ALL || 0)
115
#define TEST_GRADIENT (TEST_ALL || 0)
116
#define TEST_GLYPHS (TEST_ALL || 0)
117
#define TEST_IO (TEST_ALL || 0)
118
#define TEST_KGEM (TEST_ALL || 0)
119
#define TEST_RENDER (TEST_ALL || 0)
120
 
121
int drmIoctl(int fd, unsigned long request, void *arg);
122
 
123
 
124
#define PIXMAN_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) |    \
125
                                        ((type) << 16) |    \
126
                                        ((a) << 12)    |    \
127
                                        ((r) << 8) |        \
128
                                        ((g) << 4) |        \
129
                                        ((b)))
130
#define PIXMAN_TYPE_OTHER	0
131
#define PIXMAN_TYPE_A		1
132
#define PIXMAN_TYPE_ARGB	2
133
#define PIXMAN_TYPE_ABGR	3
134
#define PIXMAN_TYPE_COLOR	4
135
#define PIXMAN_TYPE_GRAY	5
136
#define PIXMAN_TYPE_YUY2	6
137
#define PIXMAN_TYPE_YV12	7
138
#define PIXMAN_TYPE_BGRA	8
139
#define PIXMAN_TYPE_RGBA	9
140
#define PIXMAN_TYPE_ARGB_SRGB	10
141
 
142
/* 32bpp formats */
143
typedef enum {
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),
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),
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),
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),
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),
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),
156
    PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10),
157
 
158
/* sRGB formats */
159
    PIXMAN_a8r8g8b8_sRGB = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB_SRGB,8,8,8,8),
160
 
161
/* 24bpp formats */
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),
164
 
165
/* 16bpp formats */
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),
168
 
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),
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),
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),
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),
177
 
178
/* 8bpp formats */
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),
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),
183
    PIXMAN_a2b2g2r2 =	 PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,2,2,2,2),
184
 
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),
187
 
188
    PIXMAN_x4a4 =	 PIXMAN_FORMAT(8,PIXMAN_TYPE_A,4,0,0,0),
189
 
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),
192
 
193
/* 4bpp formats */
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),
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),
198
    PIXMAN_a1b1g1r1 =	 PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,1,1,1,1),
199
 
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),
202
 
203
/* 1bpp formats */
204
    PIXMAN_a1 =		 PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0),
205
 
206
    PIXMAN_g1 =		 PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0),
207
 
208
/* YUV formats */
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)
211
 
212
} pixman_format_code_t;
213
 
214
typedef enum _PictFormatShort {
215
 
216
    PICT_a2r10g10b10 = PIXMAN_a2r10g10b10,
217
    PICT_x2r10g10b10 = PIXMAN_x2r10g10b10,
218
    PICT_a2b10g10r10 = PIXMAN_a2b10g10r10,
219
    PICT_x2b10g10r10 = PIXMAN_x2b10g10r10,
220
 
221
    PICT_a8r8g8b8 = PIXMAN_a8r8g8b8,
222
    PICT_x8r8g8b8 = PIXMAN_x8r8g8b8,
223
    PICT_a8b8g8r8 = PIXMAN_a8b8g8r8,
224
    PICT_x8b8g8r8 = PIXMAN_x8b8g8r8,
225
    PICT_b8g8r8a8 = PIXMAN_b8g8r8a8,
226
    PICT_b8g8r8x8 = PIXMAN_b8g8r8x8,
227
 
228
/* 24bpp formats */
229
    PICT_r8g8b8 = PIXMAN_r8g8b8,
230
    PICT_b8g8r8 = PIXMAN_b8g8r8,
231
 
232
/* 16bpp formats */
233
    PICT_r5g6b5 = PIXMAN_r5g6b5,
234
    PICT_b5g6r5 = PIXMAN_b5g6r5,
235
 
236
    PICT_a1r5g5b5 = PIXMAN_a1r5g5b5,
237
    PICT_x1r5g5b5 = PIXMAN_x1r5g5b5,
238
    PICT_a1b5g5r5 = PIXMAN_a1b5g5r5,
239
    PICT_x1b5g5r5 = PIXMAN_x1b5g5r5,
240
    PICT_a4r4g4b4 = PIXMAN_a4r4g4b4,
241
    PICT_x4r4g4b4 = PIXMAN_x4r4g4b4,
242
    PICT_a4b4g4r4 = PIXMAN_a4b4g4r4,
243
    PICT_x4b4g4r4 = PIXMAN_x4b4g4r4,
244
 
245
/* 8bpp formats */
246
    PICT_a8 = PIXMAN_a8,
247
    PICT_r3g3b2 = PIXMAN_r3g3b2,
248
    PICT_b2g3r3 = PIXMAN_b2g3r3,
249
    PICT_a2r2g2b2 = PIXMAN_a2r2g2b2,
250
    PICT_a2b2g2r2 = PIXMAN_a2b2g2r2,
251
 
252
    PICT_c8 = PIXMAN_c8,
253
    PICT_g8 = PIXMAN_g8,
254
 
255
    PICT_x4a4 = PIXMAN_x4a4,
256
 
257
    PICT_x4c4 = PIXMAN_x4c4,
258
    PICT_x4g4 = PIXMAN_x4g4,
259
 
260
/* 4bpp formats */
261
    PICT_a4 = PIXMAN_a4,
262
    PICT_r1g2b1 = PIXMAN_r1g2b1,
263
    PICT_b1g2r1 = PIXMAN_b1g2r1,
264
    PICT_a1r1g1b1 = PIXMAN_a1r1g1b1,
265
    PICT_a1b1g1r1 = PIXMAN_a1b1g1r1,
266
 
267
    PICT_c4 = PIXMAN_c4,
268
    PICT_g4 = PIXMAN_g4,
269
 
270
/* 1bpp formats */
271
    PICT_a1 = PIXMAN_a1,
272
 
273
    PICT_g1 = PIXMAN_g1
274
} PictFormatShort;
275
 
276
#define PIXMAN_FORMAT_A(f)	(((f) >> 12) & 0x0f)
277
#define PIXMAN_FORMAT_RGB(f)	(((f)      ) & 0xfff)
278
 
279
#define PICT_FORMAT_A(f)	PIXMAN_FORMAT_A(f)
280
 
281
#define RepeatNone                          0
282
#define RepeatNormal                        1
283
#define RepeatPad                           2
284
#define RepeatReflect                       3
285
 
286
#define PictFilterNearest	0
287
#define PictFilterBilinear	1
288
 
289
#define PictFilterFast		2
290
#define PictFilterGood		3
291
#define PictFilterBest		4
292
 
293
#define PictFilterConvolution	5
294
 
295
typedef int32_t			pixman_fixed_16_16_t;
296
typedef pixman_fixed_16_16_t	pixman_fixed_t;
297
 
298
struct pixman_transform
299
{
300
    pixman_fixed_t	matrix[3][3];
301
};
302
 
303
typedef unsigned long   Picture;
304
typedef unsigned long   PictFormat;
305
 
306
typedef struct _Pixmap  *PixmapPtr;
307
typedef struct _Picture *PicturePtr;
308
typedef struct _Drawable *DrawablePtr;
309
typedef struct _PictFormat *PictFormatPtr;
310
 
311
typedef struct pixman_transform PictTransform, *PictTransformPtr;
312
 
313
 
314
 
315
typedef struct _Drawable {
316
    unsigned char type;         /* DRAWABLE_ */
317
    unsigned char class;        /* specific to type */
318
    unsigned char depth;
319
    unsigned char bitsPerPixel;
320
    unsigned int   id;           /* resource id */
321
    short x;                    /* window: screen absolute, pixmap: 0 */
322
    short y;                    /* window: screen absolute, pixmap: 0 */
323
    unsigned short width;
324
    unsigned short height;
325
} DrawableRec;
326
 
327
/*
328
 * PIXMAP -- device dependent
329
 */
330
 
331
typedef struct _Pixmap {
332
    DrawableRec drawable;
333
//    PrivateRec *devPrivates;
334
    int refcnt;
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. */
337
#ifdef COMPOSITE
338
    short screen_x;
339
    short screen_y;
340
#endif
341
    unsigned usage_hint;        /* see CREATE_PIXMAP_USAGE_* */
342
 
343
    PixmapPtr master_pixmap;    /* pointer to master copy of pixmap for pixmap sharing */
344
} PixmapRec;
345
 
346
typedef struct _PictFormat {
347
    uint32_t id;
348
    uint32_t format;              /* except bpp */
349
    unsigned char type;
350
    unsigned char depth;
351
//    DirectFormatRec direct;
352
//   IndexFormatRec index;
353
} PictFormatRec;
354
 
355
typedef struct _Picture {
356
    DrawablePtr pDrawable;
357
//    PictFormatPtr pFormat;
358
    PictFormatShort format;     /* PICT_FORMAT */
359
    int refcnt;
360
    uint32_t id;
361
    unsigned int repeat:1;
362
    unsigned int graphicsExposures:1;
363
    unsigned int subWindowMode:1;
364
    unsigned int polyEdge:1;
365
    unsigned int polyMode:1;
366
    unsigned int freeCompClip:1;
367
    unsigned int clientClipType:2;
368
    unsigned int componentAlpha:1;
369
    unsigned int repeatType:2;
370
    unsigned int filter:3;
371
//    unsigned int stateChanges:CPLastBit;
372
//    unsigned int unused:18 - CPLastBit;
373
 
374
//    PicturePtr alphaMap;
375
 
376
//    PictTransform *transform;
377
 
378
//    SourcePictPtr pSourcePict;
379
//    xFixed *filter_params;
380
//    int filter_nparams;
381
} PictureRec;
382
 
383
#define PolyModePrecise			    0
384
#define PolyModeImprecise		    1
385
 
386
 
387
struct sna_fb
388
{
4315 Serge 389
    uint32_t  name;
4304 Serge 390
    uint32_t  width;
391
    uint32_t  height;
392
    uint32_t  pitch;
393
    uint32_t  tiling;
394
 
395
    struct kgem_bo *fb_bo;
396
};
397
 
398
struct pixman_box16
399
{
400
    int16_t x1, y1, x2, y2;
401
};
402
 
403
typedef struct pixman_box16 BoxRec;
404
typedef unsigned int   CARD32;
405
typedef unsigned short CARD16;
406
 
407
#include "sna_render.h"
408
#include "kgem.h"
409
 
410
#define GXclear                 0x0
411
#define GXcopy                  0x3
412
 
413
#define PictOpClear             0
414
#define PictOpSrc               1
415
#define PictOpDst               2
416
#define PictOpOver              3
417
#define PictOpOverReverse       4
418
#define PictOpIn                5
419
#define PictOpInReverse         6
420
#define PictOpOut               7
421
#define PictOpOutReverse        8
422
#define PictOpAtop              9
423
#define PictOpAtopReverse       10
424
#define PictOpXor               11
425
#define PictOpAdd               12
426
#define PictOpSaturate          13
427
#define PictOpMaximum           13
428
 
429
 
430
#define SNA_CURSOR_X			64
431
#define SNA_CURSOR_Y			SNA_CURSOR_X
432
 
433
struct sna_client {
434
	int is_compositor; /* only 4 bits used */
435
};
436
 
437
 
438
//#define assert(x)
439
 
440
 
441
struct sna {
442
	struct kgem kgem;
443
 
444
	unsigned scrn;
445
 
446
    unsigned flags;
447
#define SNA_NO_WAIT		0x1
448
#define SNA_NO_FLIP		0x2
449
#define SNA_TRIPLE_BUFFER	0x4
450
#define SNA_TEAR_FREE		0x10
451
#define SNA_FORCE_SHADOW	0x20
452
#define SNA_FLUSH_GTT		0x40
453
#define SNA_IS_HOSTED		0x80
454
#define SNA_PERFORMANCE		0x100
455
#define SNA_POWERSAVE		0x200
456
#define SNA_REPROBE		0x80000000
457
 
458
	unsigned cpu_features;
459
#define MMX 0x1
460
#define SSE 0x2
461
#define SSE2 0x4
462
#define SSE3 0x8
463
#define SSSE3 0x10
464
#define SSE4_1 0x20
465
#define SSE4_2 0x40
466
#define AVX 0x80
467
#define AVX2 0x100
468
 
469
	struct list flush_pixmaps;
470
	struct list active_pixmaps;
471
 
472
 
473
 
474
 
475
 
476
    unsigned int tiling;
477
#define SNA_TILING_FB       0x1
478
#define SNA_TILING_2D       0x2
479
#define SNA_TILING_ALL     (~0)
480
 
481
	struct pci_device *PciInfo;
482
	const struct intel_device_info *info;
483
 
484
//    PicturePtr clear;
485
    struct {
486
        uint32_t fill_bo;
487
        uint32_t fill_pixel;
488
        uint32_t fill_alu;
489
    } blt_state;
490
    union {
491
        struct gen3_render_state gen3;
492
        struct gen4_render_state gen4;
493
        struct gen5_render_state gen5;
494
        struct gen6_render_state gen6;
495
		struct gen7_render_state gen7;
496
    } render_state;
497
 
498
 
499
    /* Broken-out options. */
500
//    OptionInfoPtr Options;
501
 
502
    /* Driver phase/state information */
503
//    Bool suspended;
504
 
505
    struct sna_render render;
506
 
507
#if DEBUG_MEMORY
508
	struct {
509
		int pixmap_allocs;
510
	       int cpu_bo_allocs;
511
	       size_t shadow_pixels_bytes;
512
	       size_t cpu_bo_bytes;
513
	} debug_memory;
514
#endif
515
};
516
 
517
static inline struct sna *
518
to_sna_from_kgem(struct kgem *kgem)
519
{
520
	return container_of(kgem, struct sna, kgem);
521
}
522
 
523
#ifndef ARRAY_SIZE
524
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
525
#endif
526
 
527
#ifndef ALIGN
528
#define ALIGN(i,m)	(((i) + (m) - 1) & ~((m) - 1))
529
#endif
530
 
531
#ifndef MIN
532
#define MIN(a,b)	((a) <= (b) ? (a) : (b))
533
#endif
534
 
535
#ifndef MAX
536
#define MAX(a,b)	((a) >= (b) ? (a) : (b))
537
#endif
538
static inline bool
539
_sna_transform_point(const PictTransform *transform,
540
		     int64_t x, int64_t y, int64_t result[3])
541
{
542
	int j;
543
 
544
	for (j = 0; j < 3; j++)
545
		result[j] = (transform->matrix[j][0] * x +
546
			     transform->matrix[j][1] * y +
547
			     transform->matrix[j][2]);
548
 
549
	return result[2] != 0;
550
}
551
 
552
static inline void
553
_sna_get_transformed_coordinates(int x, int y,
554
				 const PictTransform *transform,
555
				 float *x_out, float *y_out)
556
{
557
 
558
	int64_t result[3];
559
 
560
	_sna_transform_point(transform, x, y, result);
561
	*x_out = result[0] / (double)result[2];
562
	*y_out = result[1] / (double)result[2];
563
}
564
 
565
static inline void
566
_sna_get_transformed_scaled(int x, int y,
567
			    const PictTransform *transform, const float *sf,
568
			    float *x_out, float *y_out)
569
{
570
	*x_out = sf[0] * (transform->matrix[0][0] * x +
571
			  transform->matrix[0][1] * y +
572
			  transform->matrix[0][2]);
573
 
574
	*y_out = sf[1] * (transform->matrix[1][0] * x +
575
			  transform->matrix[1][1] * y +
576
			  transform->matrix[1][2]);
577
}
578
 
579
void
580
sna_get_transformed_coordinates(int x, int y,
581
				const PictTransform *transform,
582
				float *x_out, float *y_out);
583
 
584
void
585
sna_get_transformed_coordinates_3d(int x, int y,
586
				   const PictTransform *transform,
587
				   float *x_out, float *y_out, float *z_out);
588
 
589
bool sna_transform_is_affine(const PictTransform *t);
590
bool sna_transform_is_integer_translation(const PictTransform *t,
591
					  int16_t *tx, int16_t *ty);
592
bool sna_transform_is_translation(const PictTransform *t,
593
				  pixman_fixed_t *tx, pixman_fixed_t *ty);
594
static inline bool
595
sna_affine_transform_is_rotation(const PictTransform *t)
596
{
597
	assert(sna_transform_is_affine(t));
598
	return t->matrix[0][1] | t->matrix[1][0];
599
}
600
 
601
static inline bool
602
sna_transform_equal(const PictTransform *a, const PictTransform *b)
603
{
604
	if (a == b)
605
		return true;
606
 
607
	if (a == NULL || b == NULL)
608
		return false;
609
 
610
	return memcmp(a, b, sizeof(*a)) == 0;
611
}
612
#endif /* _SNA_H */