Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
2351 Serge 1
#ifndef SNA_RENDER_H
2
#define SNA_RENDER_H
3
 
4
typedef int Bool;
5
 
6
#define GRADIENT_CACHE_SIZE 16
7
 
8
struct sna;
9
 
10
struct sna_composite_rectangles {
11
	struct sna_coordinate {
12
		int16_t x, y;
13
	} src, mask, dst;
14
	int16_t width, height;
15
};
16
 
17
struct sna_composite_op {
18
    fastcall void (*blt)(struct sna *sna, const struct sna_composite_op *op,
19
                 const struct sna_composite_rectangles *r);
20
    fastcall void (*box)(struct sna *sna,
21
                 const struct sna_composite_op *op,
22
                 const BoxRec *box);
23
    void (*boxes)(struct sna *sna, const struct sna_composite_op *op,
24
              const BoxRec *box, int nbox);
25
    void (*done)(struct sna *sna, const struct sna_composite_op *op);
26
 
27
    struct sna_damage **damage;
28
 
29
    uint32_t op;
30
 
31
    struct {
32
        bitmap_t *pixmap;
33
        CARD32    format;
34
        struct kgem_bo *bo;
35
        int16_t   x, y;
36
        uint16_t  width, height;
37
    } dst;
38
 
39
    struct sna_composite_channel {
40
        struct kgem_bo *bo;
41
//        PictTransform *transform;
42
        uint16_t width;
43
        uint16_t height;
44
        uint32_t pict_format;
45
        uint32_t card_format;
46
        uint32_t filter;
47
        uint32_t repeat;
48
        uint32_t is_affine : 1;
49
        uint32_t is_solid : 1;
50
        uint32_t is_linear : 1;
51
        uint32_t is_opaque : 1;
52
        uint32_t alpha_fixup : 1;
53
        uint32_t rb_reversed : 1;
54
        int16_t offset[2];
55
        float scale[2];
56
 
57
//        pixman_transform_t embedded_transform;
58
 
59
        union {
60
            struct {
61
                uint32_t pixel;
62
                float linear_dx;
63
                float linear_dy;
64
                float linear_offset;
65
            } gen2;
66
            struct gen3_shader_channel {
67
                int type;
68
                uint32_t mode;
69
                uint32_t constants;
70
            } gen3;
71
        } u;
72
    } src, mask;
73
    uint32_t is_affine : 1;
74
    uint32_t has_component_alpha : 1;
75
    uint32_t need_magic_ca_pass : 1;
76
    uint32_t rb_reversed : 1;
77
 
78
    int16_t floats_per_vertex;
79
    int16_t floats_per_rect;
80
    fastcall void (*prim_emit)(struct sna *sna,
81
                   const struct sna_composite_op *op,
82
                   const struct sna_composite_rectangles *r);
83
 
84
    struct sna_composite_redirect {
85
        struct kgem_bo *real_bo;
86
        struct sna_damage **real_damage, *damage;
87
        BoxRec box;
88
    } redirect;
89
 
90
    union {
91
        struct sna_blt_state {
92
            bitmap_t *src_pixmap;
93
            int16_t sx, sy;
94
 
95
            uint32_t inplace :1;
96
            uint32_t overwrites:1;
97
            uint32_t bpp : 6;
98
 
99
            uint32_t cmd;
100
            uint32_t br13;
101
            uint32_t pitch[2];
102
            uint32_t pixel;
103
            struct kgem_bo *bo[2];
104
        } blt;
105
 
106
        struct {
107
            float constants[8];
108
            uint32_t num_constants;
109
        } gen3;
110
 
111
        struct {
112
            int wm_kernel;
113
            int ve_id;
114
        } gen4;
115
 
116
        struct {
117
            int wm_kernel;
118
            int ve_id;
119
        } gen5;
120
 
121
        struct {
122
            int wm_kernel;
123
            int nr_surfaces;
124
            int nr_inputs;
125
            int ve_id;
126
        } gen6;
127
 
128
        struct {
129
            int wm_kernel;
130
            int nr_surfaces;
131
            int nr_inputs;
132
            int ve_id;
133
        } gen7;
134
 
135
        void *priv;
136
    } u;
137
};
138
 
139
 
140
struct sna_render {
141
	int max_3d_size;
142
	int max_3d_pitch;
143
 
144
	Bool (*composite)(struct sna *sna, uint8_t op,
2361 Serge 145
              bitmap_t *src, struct kgem_bo *src_bo,
146
              bitmap_t *mask, struct kgem_bo *mask_bo,
147
              bitmap_t *dst,  struct kgem_bo *dst_bo,
2351 Serge 148
			  int16_t src_x, int16_t src_y,
149
			  int16_t msk_x, int16_t msk_y,
150
			  int16_t dst_x, int16_t dst_y,
151
			  int16_t w, int16_t h,
152
			  struct sna_composite_op *tmp);
2361 Serge 153
/*
2351 Serge 154
	Bool (*composite_spans)(struct sna *sna, uint8_t op,
155
				PicturePtr dst, PicturePtr src,
156
				int16_t src_x, int16_t src_y,
157
				int16_t dst_x, int16_t dst_y,
158
				int16_t w, int16_t h,
159
				unsigned flags,
160
				struct sna_composite_spans_op *tmp);
161
#define COMPOSITE_SPANS_RECTILINEAR 0x1
162
 
163
	Bool (*video)(struct sna *sna,
164
		      struct sna_video *video,
165
		      struct sna_video_frame *frame,
166
		      RegionPtr dstRegion,
167
		      short src_w, short src_h,
168
		      short drw_w, short drw_h,
169
		      PixmapPtr pixmap);
170
 
171
	Bool (*fill_boxes)(struct sna *sna,
172
			   CARD8 op,
173
			   PictFormat format,
174
			   const xRenderColor *color,
175
			   PixmapPtr dst, struct kgem_bo *dst_bo,
176
			   const BoxRec *box, int n);
177
	Bool (*fill)(struct sna *sna, uint8_t alu,
178
		     PixmapPtr dst, struct kgem_bo *dst_bo,
179
		     uint32_t color,
180
		     struct sna_fill_op *tmp);
181
	Bool (*fill_one)(struct sna *sna, PixmapPtr dst, struct kgem_bo *dst_bo,
182
			 uint32_t color,
183
			 int16_t x1, int16_t y1, int16_t x2, int16_t y2,
184
			 uint8_t alu);
185
*/
186
    Bool (*clear)(struct sna *sna, bitmap_t *dst, struct kgem_bo *dst_bo);
187
/*
188
	Bool (*copy_boxes)(struct sna *sna, uint8_t alu,
189
			   PixmapPtr src, struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
190
			   PixmapPtr dst, struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
191
			   const BoxRec *box, int n);
192
*/
193
	Bool (*copy)(struct sna *sna, uint8_t alu,
194
             bitmap_t *src, struct kgem_bo *src_bo,
195
             bitmap_t *dst, struct kgem_bo *dst_bo,
196
             int dst_x, int dst_y, int src_x, int src_y,
197
             int w, int h);
198
 
199
	void (*flush)(struct sna *sna);
200
	void (*reset)(struct sna *sna);
201
	void (*fini)(struct sna *sna);
202
 
203
//   struct sna_alpha_cache {
204
//       struct kgem_bo *cache_bo;
205
//       struct kgem_bo *bo[256];
206
//   } alpha_cache;
207
 
208
    struct sna_solid_cache {
209
         struct kgem_bo *cache_bo;
210
         uint32_t color[1024];
211
         struct kgem_bo *bo[1024];
212
         int last;
213
         int size;
214
         int dirty;
215
    } solid_cache;
216
 
217
//   struct {
218
//       struct sna_gradient_cache {
219
//           struct kgem_bo *bo;
220
//           int nstops;
221
//           PictGradientStop *stops;
222
//       } cache[GRADIENT_CACHE_SIZE];
223
//       int size;
224
//   } gradient_cache;
225
 
226
//   struct sna_glyph_cache{
227
//       PicturePtr picture;
228
//       struct sna_glyph **glyphs;
229
//       uint16_t count;
230
//       uint16_t evict;
231
//   } glyph[2];
232
 
233
	uint16_t vertex_start;
234
	uint16_t vertex_index;
235
	uint16_t vertex_used;
236
	uint16_t vertex_size;
237
	uint16_t vertex_reloc[8];
238
 
239
    struct kgem_bo *vbo;
240
	float *vertices;
241
 
242
	float vertex_data[1024];
243
};
244
 
245
enum {
246
	GEN6_WM_KERNEL_NOMASK = 0,
2360 Serge 247
    GEN6_WM_KERNEL_MASK,
2351 Serge 248
 
249
    GEN6_KERNEL_COUNT
250
};
251
 
252
struct gen6_render_state {
253
    struct kgem_bo *general_bo;
254
 
255
	uint32_t vs_state;
256
	uint32_t sf_state;
257
	uint32_t sf_mask_state;
258
	uint32_t wm_state;
259
	uint32_t wm_kernel[GEN6_KERNEL_COUNT];
260
 
261
	uint32_t cc_vp;
262
	uint32_t cc_blend;
263
 
264
	uint32_t drawrect_offset;
265
	uint32_t drawrect_limit;
266
	uint32_t blend;
267
	uint32_t samplers;
268
	uint32_t kernel;
269
 
270
	uint16_t num_sf_outputs;
271
	uint16_t vb_id;
272
	uint16_t ve_id;
273
	uint16_t vertex_offset;
274
	uint16_t last_primitive;
275
	int16_t floats_per_vertex;
276
	uint16_t surface_table;
277
 
278
	Bool needs_invariant;
279
};
280
 
281
 
282
 
283
struct sna_static_stream {
284
	uint32_t size, used;
285
	uint8_t *data;
286
};
287
 
288
int sna_static_stream_init(struct sna_static_stream *stream);
289
uint32_t sna_static_stream_add(struct sna_static_stream *stream,
290
			       const void *data, uint32_t len, uint32_t align);
291
void *sna_static_stream_map(struct sna_static_stream *stream,
292
			    uint32_t len, uint32_t align);
293
uint32_t sna_static_stream_offsetof(struct sna_static_stream *stream,
294
				    void *ptr);
295
struct kgem_bo *sna_static_stream_fini(struct sna *sna,
296
				       struct sna_static_stream *stream);
297
 
298
/*
299
struct kgem_bo *
300
sna_render_get_solid(struct sna *sna,
301
		     uint32_t color);
302
 
303
void
304
sna_render_flush_solid(struct sna *sna);
305
 
306
struct kgem_bo *
307
sna_render_get_gradient(struct sna *sna,
308
			PictGradient *pattern);
309
 
310
uint32_t sna_rgba_for_color(uint32_t color, int depth);
311
Bool sna_picture_is_solid(PicturePtr picture, uint32_t *color);
312
*/
313
void no_render_init(struct sna *sna);
314
 
315
Bool gen2_render_init(struct sna *sna);
316
Bool gen3_render_init(struct sna *sna);
317
Bool gen4_render_init(struct sna *sna);
318
Bool gen5_render_init(struct sna *sna);
319
Bool gen6_render_init(struct sna *sna);
320
Bool gen7_render_init(struct sna *sna);
321
/*
322
Bool sna_tiling_composite(uint32_t op,
323
			  PicturePtr src,
324
			  PicturePtr mask,
325
			  PicturePtr dst,
326
			  int16_t src_x, int16_t src_y,
327
			  int16_t mask_x, int16_t mask_y,
328
			  int16_t dst_x, int16_t dst_y,
329
			  int16_t width, int16_t height,
330
			  struct sna_composite_op *tmp);
331
Bool sna_tiling_fill_boxes(struct sna *sna,
332
			   CARD8 op,
333
			   PictFormat format,
334
			   const xRenderColor *color,
335
			   PixmapPtr dst, struct kgem_bo *dst_bo,
336
			   const BoxRec *box, int n);
337
 
338
Bool sna_tiling_copy_boxes(struct sna *sna, uint8_t alu,
339
			   PixmapPtr src, struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
340
			   PixmapPtr dst, struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
341
			   const BoxRec *box, int n);
342
 
343
Bool sna_tiling_blt_copy_boxes(struct sna *sna, uint8_t alu,
344
			       struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
345
			       struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
346
			       int bpp, const BoxRec *box, int nbox);
347
 
348
Bool sna_blt_composite(struct sna *sna,
349
		       uint32_t op,
350
		       PicturePtr src,
351
		       PicturePtr dst,
352
		       int16_t src_x, int16_t src_y,
353
		       int16_t dst_x, int16_t dst_y,
354
		       int16_t width, int16_t height,
355
		       struct sna_composite_op *tmp);
356
 
357
bool sna_blt_fill(struct sna *sna, uint8_t alu,
358
		  struct kgem_bo *bo,
359
		  int bpp,
360
		  uint32_t pixel,
361
		  struct sna_fill_op *fill);
362
 
363
bool sna_blt_copy(struct sna *sna, uint8_t alu,
364
		  struct kgem_bo *src,
365
		  struct kgem_bo *dst,
366
		  int bpp,
367
		  struct sna_copy_op *copy);
368
 
369
Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu,
370
			struct kgem_bo *bo,
371
			int bpp,
372
			uint32_t pixel,
373
			const BoxRec *box, int n);
374
 
375
Bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu,
376
			struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
377
			struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
378
			int bpp,
379
			const BoxRec *box, int n);
380
Bool sna_blt_copy_boxes_fallback(struct sna *sna, uint8_t alu,
381
				 PixmapPtr src, struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
382
				 PixmapPtr dst, struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
383
				 const BoxRec *box, int nbox);
384
 
385
Bool _sna_get_pixel_from_rgba(uint32_t *pixel,
386
			     uint16_t red,
387
			     uint16_t green,
388
			     uint16_t blue,
389
			     uint16_t alpha,
390
			     uint32_t format);
391
 
392
static inline Bool
393
sna_get_pixel_from_rgba(uint32_t * pixel,
394
			uint16_t red,
395
			uint16_t green,
396
			uint16_t blue,
397
			uint16_t alpha,
398
			uint32_t format)
399
{
400
	switch (format) {
401
	case PICT_x8r8g8b8:
402
		alpha = 0xffff;
403
	case PICT_a8r8g8b8:
404
		*pixel = ((alpha >> 8 << 24) |
405
			  (red >> 8 << 16) |
406
			  (green & 0xff00) |
407
			  (blue >> 8));
408
		return TRUE;
409
	case PICT_a8:
410
		*pixel = alpha >> 8;
411
		return TRUE;
412
	}
413
 
414
	return _sna_get_pixel_from_rgba(pixel, red, green, blue, alpha, format);
415
}
416
 
417
int
418
sna_render_pixmap_bo(struct sna *sna,
419
		     struct sna_composite_channel *channel,
420
		     PixmapPtr pixmap,
421
		     int16_t x, int16_t y,
422
		     int16_t w, int16_t h,
423
		     int16_t dst_x, int16_t dst_y);
424
 
425
bool
426
sna_render_pixmap_partial(struct sna *sna,
427
			  PixmapPtr pixmap,
428
			  struct kgem_bo *bo,
429
			  struct sna_composite_channel *channel,
430
			  int16_t x, int16_t y,
431
			  int16_t w, int16_t h);
432
 
433
int
434
sna_render_picture_extract(struct sna *sna,
435
			   PicturePtr picture,
436
			   struct sna_composite_channel *channel,
437
			   int16_t x, int16_t y,
438
			   int16_t w, int16_t h,
439
			   int16_t dst_x, int16_t dst_y);
440
 
441
int
442
sna_render_picture_fixup(struct sna *sna,
443
			 PicturePtr picture,
444
			 struct sna_composite_channel *channel,
445
			 int16_t x, int16_t y,
446
			 int16_t w, int16_t h,
447
			 int16_t dst_x, int16_t dst_y);
448
 
449
int
450
sna_render_picture_convert(struct sna *sna,
451
			   PicturePtr picture,
452
			   struct sna_composite_channel *channel,
453
			   PixmapPtr pixmap,
454
			   int16_t x, int16_t y,
455
			   int16_t w, int16_t h,
456
			   int16_t dst_x, int16_t dst_y);
457
 
458
inline static void sna_render_composite_redirect_init(struct sna_composite_op *op)
459
{
460
	struct sna_composite_redirect *t = &op->redirect;
461
	t->real_bo = NULL;
462
	t->damage = NULL;
463
}
464
 
465
Bool
466
sna_render_composite_redirect(struct sna *sna,
467
			      struct sna_composite_op *op,
468
			      int x, int y, int width, int height);
469
 
470
void
471
sna_render_composite_redirect_done(struct sna *sna,
472
				   const struct sna_composite_op *op);
473
 
474
bool
475
sna_composite_mask_is_opaque(PicturePtr mask);
476
*/
477
 
478
#endif /* SNA_RENDER_H */