VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.18.0/glamor_priv.h

最後變更 在這個檔案是 58634,由 vboxsync 提交於 9 年 前

Additions/x11: added header files for building X.Org video driver against X.Org Server 1.18.

  • 屬性 svn:eol-style 設為 native
檔案大小: 28.8 KB
 
1/*
2 * Copyright © 2008 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Eric Anholt <[email protected]>
25 *
26 */
27#ifndef GLAMOR_PRIV_H
28#define GLAMOR_PRIV_H
29
30#include "dix-config.h"
31
32#include "glamor.h"
33#include "xvdix.h"
34
35#if XSYNC
36#include "misyncshm.h"
37#include "misyncstr.h"
38#endif
39
40#include <epoxy/gl.h>
41#if GLAMOR_HAS_GBM
42#define MESA_EGL_NO_X11_HEADERS
43#include <epoxy/egl.h>
44#endif
45
46#define GLAMOR_DEFAULT_PRECISION \
47 "#ifdef GL_ES\n" \
48 "precision mediump float;\n" \
49 "#endif\n"
50
51#include "glyphstr.h"
52
53#include "glamor_debug.h"
54#include "glamor_context.h"
55#include "glamor_program.h"
56
57#include <list.h>
58
59struct glamor_pixmap_private;
60
61typedef struct glamor_composite_shader {
62 GLuint prog;
63 GLint dest_to_dest_uniform_location;
64 GLint dest_to_source_uniform_location;
65 GLint dest_to_mask_uniform_location;
66 GLint source_uniform_location;
67 GLint mask_uniform_location;
68 GLint source_wh;
69 GLint mask_wh;
70 GLint source_repeat_mode;
71 GLint mask_repeat_mode;
72 union {
73 float source_solid_color[4];
74 struct {
75 PixmapPtr source_pixmap;
76 PicturePtr source;
77 };
78 };
79
80 union {
81 float mask_solid_color[4];
82 struct {
83 PixmapPtr mask_pixmap;
84 PicturePtr mask;
85 };
86 };
87} glamor_composite_shader;
88
89enum shader_source {
90 SHADER_SOURCE_SOLID,
91 SHADER_SOURCE_TEXTURE,
92 SHADER_SOURCE_TEXTURE_ALPHA,
93 SHADER_SOURCE_COUNT,
94};
95
96enum shader_mask {
97 SHADER_MASK_NONE,
98 SHADER_MASK_SOLID,
99 SHADER_MASK_TEXTURE,
100 SHADER_MASK_TEXTURE_ALPHA,
101 SHADER_MASK_COUNT,
102};
103
104enum shader_in {
105 SHADER_IN_SOURCE_ONLY,
106 SHADER_IN_NORMAL,
107 SHADER_IN_CA_SOURCE,
108 SHADER_IN_CA_ALPHA,
109 SHADER_IN_COUNT,
110};
111
112struct shader_key {
113 enum shader_source source;
114 enum shader_mask mask;
115 enum shader_in in;
116};
117
118struct blendinfo {
119 Bool dest_alpha;
120 Bool source_alpha;
121 GLenum source_blend;
122 GLenum dest_blend;
123};
124
125typedef struct {
126 INT16 x_src;
127 INT16 y_src;
128 INT16 x_mask;
129 INT16 y_mask;
130 INT16 x_dst;
131 INT16 y_dst;
132 INT16 width;
133 INT16 height;
134} glamor_composite_rect_t;
135
136enum glamor_vertex_type {
137 GLAMOR_VERTEX_POS,
138 GLAMOR_VERTEX_SOURCE,
139 GLAMOR_VERTEX_MASK
140};
141
142enum gradient_shader {
143 SHADER_GRADIENT_LINEAR,
144 SHADER_GRADIENT_RADIAL,
145 SHADER_GRADIENT_CONICAL,
146 SHADER_GRADIENT_COUNT,
147};
148
149struct glamor_screen_private;
150struct glamor_pixmap_private;
151
152enum glamor_gl_flavor {
153 GLAMOR_GL_DESKTOP, // OPENGL API
154 GLAMOR_GL_ES2 // OPENGL ES2.0 API
155};
156
157#define GLAMOR_COMPOSITE_VBO_VERT_CNT (64*1024)
158
159struct glamor_saved_procs {
160 CloseScreenProcPtr close_screen;
161 CreateScreenResourcesProcPtr create_screen_resources;
162 CreateGCProcPtr create_gc;
163 CreatePixmapProcPtr create_pixmap;
164 DestroyPixmapProcPtr destroy_pixmap;
165 GetSpansProcPtr get_spans;
166 GetImageProcPtr get_image;
167 CompositeProcPtr composite;
168 CompositeRectsProcPtr composite_rects;
169 TrapezoidsProcPtr trapezoids;
170 GlyphsProcPtr glyphs;
171 ChangeWindowAttributesProcPtr change_window_attributes;
172 CopyWindowProcPtr copy_window;
173 BitmapToRegionProcPtr bitmap_to_region;
174 TrianglesProcPtr triangles;
175 AddTrapsProcPtr addtraps;
176#if XSYNC
177 SyncScreenFuncsRec sync_screen_funcs;
178#endif
179 ScreenBlockHandlerProcPtr block_handler;
180};
181
182#define CACHE_FORMAT_COUNT 3
183
184#define CACHE_BUCKET_WCOUNT 4
185#define CACHE_BUCKET_HCOUNT 4
186
187#define GLAMOR_TICK_AFTER(t0, t1) \
188 (((int)(t1) - (int)(t0)) < 0)
189
190typedef struct glamor_screen_private {
191 unsigned int tick;
192 enum glamor_gl_flavor gl_flavor;
193 int glsl_version;
194 Bool has_pack_invert;
195 Bool has_fbo_blit;
196 Bool has_map_buffer_range;
197 Bool has_buffer_storage;
198 Bool has_khr_debug;
199 Bool has_nv_texture_barrier;
200 Bool has_pack_subimage;
201 Bool has_unpack_subimage;
202 Bool has_rw_pbo;
203 Bool use_quads;
204 int max_fbo_size;
205
206 struct xorg_list
207 fbo_cache[CACHE_FORMAT_COUNT][CACHE_BUCKET_WCOUNT][CACHE_BUCKET_HCOUNT];
208 unsigned long fbo_cache_watermark;
209
210 /* glamor point shader */
211 glamor_program point_prog;
212
213 /* glamor spans shaders */
214 glamor_program_fill fill_spans_program;
215
216 /* glamor rect shaders */
217 glamor_program_fill poly_fill_rect_program;
218
219 /* glamor glyphblt shaders */
220 glamor_program_fill poly_glyph_blt_progs;
221
222 /* glamor text shaders */
223 glamor_program_fill poly_text_progs;
224 glamor_program te_text_prog;
225 glamor_program image_text_prog;
226
227 /* glamor copy shaders */
228 glamor_program copy_area_prog;
229 glamor_program copy_plane_prog;
230
231 /* glamor line shader */
232 glamor_program_fill poly_line_program;
233
234 /* glamor segment shaders */
235 glamor_program_fill poly_segment_program;
236
237 /* glamor dash line shader */
238 glamor_program_fill on_off_dash_line_progs;
239 glamor_program double_dash_line_prog;
240
241 /* glamor composite_glyphs shaders */
242 glamor_program_render glyphs_program;
243 struct glamor_glyph_atlas *glyph_atlas_a;
244 struct glamor_glyph_atlas *glyph_atlas_argb;
245 int glyph_atlas_dim;
246 int glyph_max_dim;
247 char *glyph_defines;
248
249 /** Vertex buffer for all GPU rendering. */
250 GLuint vbo;
251 /** Next offset within the VBO that glamor_get_vbo_space() will use. */
252 int vbo_offset;
253 int vbo_size;
254 /**
255 * Pointer to glamor_get_vbo_space()'s current VBO mapping.
256 *
257 * Note that this is not necessarily equal to the pointer returned
258 * by glamor_get_vbo_space(), so it can't be used in place of that.
259 */
260 char *vb;
261 int vb_stride;
262
263 /** Cached index buffer for translating GL_QUADS to triangles. */
264 GLuint ib;
265 /** Index buffer type: GL_UNSIGNED_SHORT or GL_UNSIGNED_INT */
266 GLenum ib_type;
267 /** Number of quads the index buffer has indices for. */
268 unsigned ib_size;
269
270 Bool has_source_coords, has_mask_coords;
271 int render_nr_quads;
272 glamor_composite_shader composite_shader[SHADER_SOURCE_COUNT]
273 [SHADER_MASK_COUNT]
274 [SHADER_IN_COUNT];
275
276 /* shaders to restore a texture to another texture. */
277 GLint finish_access_prog[2];
278 GLint finish_access_revert[2];
279 GLint finish_access_swap_rb[2];
280
281 /* glamor gradient, 0 for small nstops, 1 for
282 large nstops and 2 for dynamic generate. */
283 GLint gradient_prog[SHADER_GRADIENT_COUNT][3];
284 int linear_max_nstops;
285 int radial_max_nstops;
286
287 int screen_fbo;
288 struct glamor_saved_procs saved_procs;
289 char delayed_fallback_string[GLAMOR_DELAYED_STRING_MAX + 1];
290 int delayed_fallback_pending;
291 int flags;
292 ScreenPtr screen;
293 int dri3_enabled;
294
295 /* xv */
296 GLint xv_prog;
297
298 struct glamor_context ctx;
299} glamor_screen_private;
300
301typedef enum glamor_access {
302 GLAMOR_ACCESS_RO,
303 GLAMOR_ACCESS_RW,
304} glamor_access_t;
305
306enum glamor_fbo_state {
307 /** There is no storage attached to the pixmap. */
308 GLAMOR_FBO_UNATTACHED,
309 /**
310 * The pixmap has FBO storage attached, but devPrivate.ptr doesn't
311 * point at anything.
312 */
313 GLAMOR_FBO_NORMAL,
314};
315
316typedef struct glamor_pixmap_fbo {
317 struct xorg_list list; /**< linked list pointers when in the fbo cache */
318 /** glamor_priv->tick number when this FBO will be expired from the cache. */
319 unsigned int expire;
320 GLuint tex; /**< GL texture name */
321 GLuint fb; /**< GL FBO name */
322 int width; /**< width in pixels */
323 int height; /**< height in pixels */
324 /**
325 * Flag for when texture contents might be shared with a
326 * non-glamor user.
327 *
328 * This is used to avoid putting textures used by other clients
329 * into the FBO cache.
330 */
331 Bool external;
332 GLenum format; /**< GL format used to create the texture. */
333 GLenum type; /**< GL type used to create the texture. */
334} glamor_pixmap_fbo;
335
336typedef struct glamor_pixmap_clipped_regions {
337 int block_idx;
338 RegionPtr region;
339} glamor_pixmap_clipped_regions;
340
341typedef struct glamor_pixmap_private {
342 glamor_pixmap_type_t type;
343 enum glamor_fbo_state gl_fbo;
344 /**
345 * If devPrivate.ptr is non-NULL (meaning we're within
346 * glamor_prepare_access), determies whether we should re-upload
347 * that data on glamor_finish_access().
348 */
349 glamor_access_t map_access;
350 glamor_pixmap_fbo *fbo;
351 /** current fbo's coords in the whole pixmap. */
352 BoxRec box;
353 GLuint pbo;
354 RegionRec prepare_region;
355 Bool prepared;
356#if GLAMOR_HAS_GBM
357 EGLImageKHR image;
358#endif
359 /** block width of this large pixmap. */
360 int block_w;
361 /** block height of this large pixmap. */
362 int block_h;
363
364 /** block_wcnt: block count in one block row. */
365 int block_wcnt;
366 /** block_hcnt: block count in one block column. */
367 int block_hcnt;
368
369 /**
370 * The list of boxes for the bounds of the FBOs making up the
371 * pixmap.
372 *
373 * For a 2048x2048 pixmap with GL FBO size limits of 1024x1024:
374 *
375 * ******************
376 * * fbo0 * fbo1 *
377 * * * *
378 * ******************
379 * * fbo2 * fbo3 *
380 * * * *
381 * ******************
382 *
383 * box[0] = {0,0,1024,1024}
384 * box[1] = {1024,0,2048,2048}
385 * ...
386 */
387 BoxPtr box_array;
388
389 /**
390 * Array of fbo structs containing the actual GL texture/fbo
391 * names.
392 */
393 glamor_pixmap_fbo **fbo_array;
394} glamor_pixmap_private;
395
396extern DevPrivateKeyRec glamor_pixmap_private_key;
397
398static inline glamor_pixmap_private *
399glamor_get_pixmap_private(PixmapPtr pixmap)
400{
401 if (pixmap == NULL)
402 return NULL;
403
404 return dixLookupPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key);
405}
406
407/*
408 * Returns TRUE if pixmap has no image object
409 */
410static inline Bool
411glamor_pixmap_drm_only(PixmapPtr pixmap)
412{
413 glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
414
415 return priv->type == GLAMOR_DRM_ONLY;
416}
417
418/*
419 * Returns TRUE if pixmap is plain memory (not a GL object at all)
420 */
421static inline Bool
422glamor_pixmap_is_memory(PixmapPtr pixmap)
423{
424 glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
425
426 return priv->type == GLAMOR_MEMORY;
427}
428
429/*
430 * Returns TRUE if pixmap requires multiple textures to hold it
431 */
432static inline Bool
433glamor_pixmap_priv_is_large(glamor_pixmap_private *priv)
434{
435 return priv->block_wcnt > 1 || priv->block_hcnt > 1;
436}
437
438static inline Bool
439glamor_pixmap_priv_is_small(glamor_pixmap_private *priv)
440{
441 return priv->block_wcnt <= 1 && priv->block_hcnt <= 1;
442}
443
444static inline Bool
445glamor_pixmap_is_large(PixmapPtr pixmap)
446{
447 glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
448
449 return glamor_pixmap_priv_is_large(priv);
450}
451/*
452 * Returns TRUE if pixmap has an FBO
453 */
454static inline Bool
455glamor_pixmap_has_fbo(PixmapPtr pixmap)
456{
457 glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
458
459 return priv->gl_fbo == GLAMOR_FBO_NORMAL;
460}
461
462static inline void
463glamor_set_pixmap_fbo_current(glamor_pixmap_private *priv, int idx)
464{
465 if (glamor_pixmap_priv_is_large(priv)) {
466 priv->fbo = priv->fbo_array[idx];
467 priv->box = priv->box_array[idx];
468 }
469}
470
471static inline glamor_pixmap_fbo *
472glamor_pixmap_fbo_at(glamor_pixmap_private *priv, int x, int y)
473{
474 assert(x < priv->block_wcnt);
475 assert(y < priv->block_hcnt);
476 return priv->fbo_array[y * priv->block_wcnt + x];
477}
478
479static inline BoxPtr
480glamor_pixmap_box_at(glamor_pixmap_private *priv, int x, int y)
481{
482 assert(x < priv->block_wcnt);
483 assert(y < priv->block_hcnt);
484 return &priv->box_array[y * priv->block_wcnt + x];
485}
486
487static inline int
488glamor_pixmap_wcnt(glamor_pixmap_private *priv)
489{
490 return priv->block_wcnt;
491}
492
493static inline int
494glamor_pixmap_hcnt(glamor_pixmap_private *priv)
495{
496 return priv->block_hcnt;
497}
498
499#define glamor_pixmap_loop(priv, x, y) \
500 for (y = 0; y < glamor_pixmap_hcnt(priv); y++) \
501 for (x = 0; x < glamor_pixmap_wcnt(priv); x++)
502
503/**
504 * Pixmap upload status, used by glamor_render.c's support for
505 * temporarily uploading pixmaps to GL textures to get a Composite
506 * operation done.
507 */
508typedef enum glamor_pixmap_status {
509 /** initial status, don't need to do anything. */
510 GLAMOR_NONE,
511 /** marked as need to be uploaded to gl texture. */
512 GLAMOR_UPLOAD_PENDING,
513 /** the pixmap has been uploaded successfully. */
514 GLAMOR_UPLOAD_DONE,
515 /** fail to upload the pixmap. */
516 GLAMOR_UPLOAD_FAILED
517} glamor_pixmap_status_t;
518
519/* GC private structure. Currently holds only any computed dash pixmap */
520
521typedef struct {
522 PixmapPtr dash;
523 PixmapPtr stipple;
524 DamagePtr stipple_damage;
525} glamor_gc_private;
526
527extern DevPrivateKeyRec glamor_gc_private_key;
528extern DevPrivateKeyRec glamor_screen_private_key;
529
530static inline glamor_screen_private *
531glamor_get_screen_private(ScreenPtr screen)
532{
533 return (glamor_screen_private *)
534 dixLookupPrivate(&screen->devPrivates, &glamor_screen_private_key);
535}
536
537static inline void
538glamor_set_screen_private(ScreenPtr screen, glamor_screen_private *priv)
539{
540 dixSetPrivate(&screen->devPrivates, &glamor_screen_private_key, priv);
541}
542
543static inline glamor_gc_private *
544glamor_get_gc_private(GCPtr gc)
545{
546 return dixLookupPrivate(&gc->devPrivates, &glamor_gc_private_key);
547}
548
549/**
550 * Returns TRUE if the given planemask covers all the significant bits in the
551 * pixel values for pDrawable.
552 */
553static inline Bool
554glamor_pm_is_solid(int depth, unsigned long planemask)
555{
556 return (planemask & FbFullMask(depth)) ==
557 FbFullMask(depth);
558}
559
560extern int glamor_debug_level;
561
562/* glamor.c */
563PixmapPtr glamor_get_drawable_pixmap(DrawablePtr drawable);
564
565glamor_pixmap_fbo *glamor_pixmap_detach_fbo(glamor_pixmap_private *
566 pixmap_priv);
567void glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo);
568glamor_pixmap_fbo *glamor_create_fbo_from_tex(glamor_screen_private *
569 glamor_priv, int w, int h,
570 GLenum format, GLint tex,
571 int flag);
572glamor_pixmap_fbo *glamor_create_fbo(glamor_screen_private *glamor_priv, int w,
573 int h, GLenum format, int flag);
574void glamor_destroy_fbo(glamor_screen_private *glamor_priv,
575 glamor_pixmap_fbo *fbo);
576void glamor_pixmap_destroy_fbo(PixmapPtr pixmap);
577void glamor_init_pixmap_fbo(ScreenPtr screen);
578void glamor_fini_pixmap_fbo(ScreenPtr screen);
579Bool glamor_pixmap_fbo_fixup(ScreenPtr screen, PixmapPtr pixmap);
580void glamor_fbo_expire(glamor_screen_private *glamor_priv);
581
582glamor_pixmap_fbo *glamor_create_fbo_array(glamor_screen_private *glamor_priv,
583 int w, int h, GLenum format,
584 int flag, int block_w, int block_h,
585 glamor_pixmap_private *);
586
587void glamor_gldrawarrays_quads_using_indices(glamor_screen_private *glamor_priv,
588 unsigned count);
589
590/* glamor_core.c */
591void glamor_init_finish_access_shaders(ScreenPtr screen);
592
593Bool glamor_get_drawable_location(const DrawablePtr drawable);
594void glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
595 int *x, int *y);
596GLint glamor_compile_glsl_prog(GLenum type, const char *source);
597void glamor_link_glsl_prog(ScreenPtr screen, GLint prog,
598 const char *format, ...) _X_ATTRIBUTE_PRINTF(3,4);
599void glamor_get_color_4f_from_pixel(PixmapPtr pixmap,
600 unsigned long fg_pixel, GLfloat *color);
601
602int glamor_set_destination_pixmap(PixmapPtr pixmap);
603int glamor_set_destination_pixmap_priv(glamor_screen_private *glamor_priv, PixmapPtr pixmap, glamor_pixmap_private *pixmap_priv);
604void glamor_set_destination_pixmap_fbo(glamor_screen_private *glamor_priv, glamor_pixmap_fbo *, int, int, int, int);
605
606/* nc means no check. caller must ensure this pixmap has valid fbo.
607 * usually use the GLAMOR_PIXMAP_PRIV_HAS_FBO firstly.
608 * */
609void glamor_set_destination_pixmap_priv_nc(glamor_screen_private *glamor_priv, PixmapPtr pixmap, glamor_pixmap_private *pixmap_priv);
610
611Bool glamor_set_alu(ScreenPtr screen, unsigned char alu);
612Bool glamor_set_planemask(int depth, unsigned long planemask);
613RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
614
615void
616glamor_track_stipple(GCPtr gc);
617
618/* glamor_render.c */
619Bool glamor_composite_clipped_region(CARD8 op,
620 PicturePtr source,
621 PicturePtr mask,
622 PicturePtr dest,
623 PixmapPtr source_pixmap,
624 PixmapPtr mask_pixmap,
625 PixmapPtr dest_pixmap,
626 RegionPtr region,
627 int x_source,
628 int y_source,
629 int x_mask, int y_mask,
630 int x_dest, int y_dest);
631
632void glamor_composite(CARD8 op,
633 PicturePtr pSrc,
634 PicturePtr pMask,
635 PicturePtr pDst,
636 INT16 xSrc,
637 INT16 ySrc,
638 INT16 xMask,
639 INT16 yMask,
640 INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
641
642void glamor_composite_rects(CARD8 op,
643 PicturePtr pDst,
644 xRenderColor *color, int nRect, xRectangle *rects);
645
646/* glamor_trapezoid.c */
647void glamor_trapezoids(CARD8 op,
648 PicturePtr src, PicturePtr dst,
649 PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
650 int ntrap, xTrapezoid *traps);
651
652/* glamor_gradient.c */
653void glamor_init_gradient_shader(ScreenPtr screen);
654PicturePtr glamor_generate_linear_gradient_picture(ScreenPtr screen,
655 PicturePtr src_picture,
656 int x_source, int y_source,
657 int width, int height,
658 PictFormatShort format);
659PicturePtr glamor_generate_radial_gradient_picture(ScreenPtr screen,
660 PicturePtr src_picture,
661 int x_source, int y_source,
662 int width, int height,
663 PictFormatShort format);
664
665/* glamor_triangles.c */
666void glamor_triangles(CARD8 op,
667 PicturePtr pSrc,
668 PicturePtr pDst,
669 PictFormatPtr maskFormat,
670 INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris);
671
672/* glamor_pixmap.c */
673
674void glamor_pixmap_init(ScreenPtr screen);
675void glamor_pixmap_fini(ScreenPtr screen);
676
677/* glamor_vbo.c */
678
679void glamor_init_vbo(ScreenPtr screen);
680void glamor_fini_vbo(ScreenPtr screen);
681
682void *
683glamor_get_vbo_space(ScreenPtr screen, unsigned size, char **vbo_offset);
684
685void
686glamor_put_vbo_space(ScreenPtr screen);
687
688/**
689 * According to the flag,
690 * if the flag is GLAMOR_CREATE_FBO_NO_FBO then just ensure
691 * the fbo has a valid texture. Otherwise, it will ensure
692 * the fbo has valid texture and attach to a valid fb.
693 * If the fbo already has a valid glfbo then do nothing.
694 */
695Bool glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag);
696
697glamor_pixmap_clipped_regions *
698glamor_compute_clipped_regions(PixmapPtr pixmap,
699 RegionPtr region, int *clipped_nbox,
700 int repeat_type, int reverse,
701 int upsidedown);
702
703glamor_pixmap_clipped_regions *
704glamor_compute_clipped_regions_ext(PixmapPtr pixmap,
705 RegionPtr region, int *n_region,
706 int inner_block_w, int inner_block_h,
707 int reverse, int upsidedown);
708
709Bool glamor_composite_largepixmap_region(CARD8 op,
710 PicturePtr source,
711 PicturePtr mask,
712 PicturePtr dest,
713 PixmapPtr source_pixmap,
714 PixmapPtr mask_pixmap,
715 PixmapPtr dest_pixmap,
716 RegionPtr region, Bool force_clip,
717 INT16 x_source,
718 INT16 y_source,
719 INT16 x_mask,
720 INT16 y_mask,
721 INT16 x_dest, INT16 y_dest,
722 CARD16 width, CARD16 height);
723
724/**
725 * Upload a picture to gl texture. Similar to the
726 * glamor_upload_pixmap_to_texture. Used in rendering.
727 **/
728enum glamor_pixmap_status glamor_upload_picture_to_texture(PicturePtr picture);
729
730void glamor_add_traps(PicturePtr pPicture,
731 INT16 x_off, INT16 y_off, int ntrap, xTrap *traps);
732
733/* glamor_text.c */
734int glamor_poly_text8(DrawablePtr pDrawable, GCPtr pGC,
735 int x, int y, int count, char *chars);
736
737int glamor_poly_text16(DrawablePtr pDrawable, GCPtr pGC,
738 int x, int y, int count, unsigned short *chars);
739
740void glamor_image_text8(DrawablePtr pDrawable, GCPtr pGC,
741 int x, int y, int count, char *chars);
742
743void glamor_image_text16(DrawablePtr pDrawable, GCPtr pGC,
744 int x, int y, int count, unsigned short *chars);
745
746/* glamor_spans.c */
747void
748glamor_fill_spans(DrawablePtr drawable,
749 GCPtr gc,
750 int n, DDXPointPtr points, int *widths, int sorted);
751
752void
753glamor_get_spans(DrawablePtr drawable, int wmax,
754 DDXPointPtr points, int *widths, int count, char *dst);
755
756void
757glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
758 DDXPointPtr points, int *widths, int numPoints, int sorted);
759
760/* glamor_rects.c */
761void
762glamor_poly_fill_rect(DrawablePtr drawable,
763 GCPtr gc, int nrect, xRectangle *prect);
764
765/* glamor_image.c */
766void
767glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
768 int w, int h, int leftPad, int format, char *bits);
769
770void
771glamor_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
772 unsigned int format, unsigned long planeMask, char *d);
773
774/* glamor_dash.c */
775Bool
776glamor_poly_lines_dash_gl(DrawablePtr drawable, GCPtr gc,
777 int mode, int n, DDXPointPtr points);
778
779Bool
780glamor_poly_segment_dash_gl(DrawablePtr drawable, GCPtr gc,
781 int nseg, xSegment *segs);
782
783/* glamor_lines.c */
784void
785glamor_poly_lines(DrawablePtr drawable, GCPtr gc,
786 int mode, int n, DDXPointPtr points);
787
788/* glamor_segs.c */
789void
790glamor_poly_segment(DrawablePtr drawable, GCPtr gc,
791 int nseg, xSegment *segs);
792
793/* glamor_copy.c */
794void
795glamor_copy(DrawablePtr src,
796 DrawablePtr dst,
797 GCPtr gc,
798 BoxPtr box,
799 int nbox,
800 int dx,
801 int dy,
802 Bool reverse,
803 Bool upsidedown,
804 Pixel bitplane,
805 void *closure);
806
807RegionPtr
808glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
809 int srcx, int srcy, int width, int height, int dstx, int dsty);
810
811RegionPtr
812glamor_copy_plane(DrawablePtr src, DrawablePtr dst, GCPtr gc,
813 int srcx, int srcy, int width, int height, int dstx, int dsty,
814 unsigned long bitplane);
815
816/* glamor_glyphblt.c */
817void glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
818 int x, int y, unsigned int nglyph,
819 CharInfoPtr *ppci, void *pglyphBase);
820
821void glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
822 int x, int y, unsigned int nglyph,
823 CharInfoPtr *ppci, void *pglyphBase);
824
825void glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
826 DrawablePtr pDrawable, int w, int h, int x, int y);
827
828void glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
829 DDXPointPtr ppt);
830
831void glamor_composite_rectangles(CARD8 op,
832 PicturePtr dst,
833 xRenderColor *color,
834 int num_rects, xRectangle *rects);
835
836/* glamor_composite_glyphs.c */
837Bool
838glamor_composite_glyphs_init(ScreenPtr pScreen);
839
840void
841glamor_composite_glyphs_fini(ScreenPtr pScreen);
842
843void
844glamor_composite_glyphs(CARD8 op,
845 PicturePtr src,
846 PicturePtr dst,
847 PictFormatPtr mask_format,
848 INT16 x_src,
849 INT16 y_src, int nlist,
850 GlyphListPtr list, GlyphPtr *glyphs);
851
852/* glamor_sync.c */
853Bool
854glamor_sync_init(ScreenPtr screen);
855
856void
857glamor_sync_close(ScreenPtr screen);
858
859/* glamor_util.c */
860void
861glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
862 unsigned long fg_pixel);
863
864void
865glamor_solid_boxes(PixmapPtr pixmap,
866 BoxPtr box, int nbox, unsigned long fg_pixel);
867
868
869/* glamor_xv */
870typedef struct {
871 uint32_t transform_index;
872 uint32_t gamma; /* gamma value x 1000 */
873 int brightness;
874 int saturation;
875 int hue;
876 int contrast;
877
878 DrawablePtr pDraw;
879 PixmapPtr pPixmap;
880 uint32_t src_pitch;
881 uint8_t *src_addr;
882 int src_w, src_h, dst_w, dst_h;
883 int src_x, src_y, drw_x, drw_y;
884 int w, h;
885 RegionRec clip;
886 PixmapPtr src_pix[3]; /* y, u, v for planar */
887 int src_pix_w, src_pix_h;
888} glamor_port_private;
889
890extern XvAttributeRec glamor_xv_attributes[];
891extern int glamor_xv_num_attributes;
892extern XvImageRec glamor_xv_images[];
893extern int glamor_xv_num_images;
894
895void glamor_xv_init_port(glamor_port_private *port_priv);
896void glamor_xv_stop_video(glamor_port_private *port_priv);
897int glamor_xv_set_port_attribute(glamor_port_private *port_priv,
898 Atom attribute, INT32 value);
899int glamor_xv_get_port_attribute(glamor_port_private *port_priv,
900 Atom attribute, INT32 *value);
901int glamor_xv_query_image_attributes(int id,
902 unsigned short *w, unsigned short *h,
903 int *pitches, int *offsets);
904int glamor_xv_put_image(glamor_port_private *port_priv,
905 DrawablePtr pDrawable,
906 short src_x, short src_y,
907 short drw_x, short drw_y,
908 short src_w, short src_h,
909 short drw_w, short drw_h,
910 int id,
911 unsigned char *buf,
912 short width,
913 short height,
914 Bool sync,
915 RegionPtr clipBoxes);
916void glamor_xv_core_init(ScreenPtr screen);
917void glamor_xv_render(glamor_port_private *port_priv);
918
919#include"glamor_utils.h"
920
921/* Dynamic pixmap upload to texture if needed.
922 * Sometimes, the target is a gl texture pixmap/picture,
923 * but the source or mask is in cpu memory. In that case,
924 * upload the source/mask to gl texture and then avoid
925 * fallback the whole process to cpu. Most of the time,
926 * this will increase performance obviously. */
927
928#define GLAMOR_PIXMAP_DYNAMIC_UPLOAD
929#define GLAMOR_GRADIENT_SHADER
930#define GLAMOR_TEXTURED_LARGE_PIXMAP 1
931#define WALKAROUND_LARGE_TEXTURE_MAP
932#if 0
933#define MAX_FBO_SIZE 32 /* For test purpose only. */
934#endif
935
936#include "glamor_font.h"
937
938#define GLAMOR_MIN_ALU_INSTRUCTIONS 128 /* Minimum required number of native ALU instructions */
939
940#endif /* GLAMOR_PRIV_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette