"Fossies" - the Fresh Open Source Software Archive

Member "xorg-server-1.20.8/glamor/glamor_priv.h" (29 Mar 2020, 28719 Bytes) of package /linux/misc/xorg-server-1.20.8.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "glamor_priv.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.20.7_vs_1.20.8.

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