135c4bbdfSmrg/*
235c4bbdfSmrg * Copyright © 2008 Intel Corporation
335c4bbdfSmrg *
435c4bbdfSmrg * Permission is hereby granted, free of charge, to any person obtaining a
535c4bbdfSmrg * copy of this software and associated documentation files (the "Software"),
635c4bbdfSmrg * to deal in the Software without restriction, including without limitation
735c4bbdfSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
835c4bbdfSmrg * and/or sell copies of the Software, and to permit persons to whom the
935c4bbdfSmrg * Software is furnished to do so, subject to the following conditions:
1035c4bbdfSmrg *
1135c4bbdfSmrg * The above copyright notice and this permission notice (including the next
1235c4bbdfSmrg * paragraph) shall be included in all copies or substantial portions of the
1335c4bbdfSmrg * Software.
1435c4bbdfSmrg *
1535c4bbdfSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1635c4bbdfSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1735c4bbdfSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1835c4bbdfSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1935c4bbdfSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2035c4bbdfSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2135c4bbdfSmrg * IN THE SOFTWARE.
2235c4bbdfSmrg *
2335c4bbdfSmrg * Authors:
2435c4bbdfSmrg *    Eric Anholt <eric@anholt.net>
2535c4bbdfSmrg *
2635c4bbdfSmrg */
2735c4bbdfSmrg#ifndef GLAMOR_PRIV_H
2835c4bbdfSmrg#define GLAMOR_PRIV_H
2935c4bbdfSmrg
3035c4bbdfSmrg#include "dix-config.h"
3135c4bbdfSmrg
3235c4bbdfSmrg#include "glamor.h"
3335c4bbdfSmrg#include "xvdix.h"
3435c4bbdfSmrg
3535c4bbdfSmrg#if XSYNC
3635c4bbdfSmrg#include "misyncshm.h"
3735c4bbdfSmrg#include "misyncstr.h"
3835c4bbdfSmrg#endif
3935c4bbdfSmrg
4035c4bbdfSmrg#include <epoxy/gl.h>
411b5d61b8Smrg#ifdef GLAMOR_HAS_GBM
4235c4bbdfSmrg#define MESA_EGL_NO_X11_HEADERS
4325da500fSmrg#define EGL_NO_X11
4435c4bbdfSmrg#include <epoxy/egl.h>
4535c4bbdfSmrg#endif
4635c4bbdfSmrg
4735c4bbdfSmrg#define GLAMOR_DEFAULT_PRECISION  \
4835c4bbdfSmrg    "#ifdef GL_ES\n"              \
4935c4bbdfSmrg    "precision mediump float;\n"  \
5035c4bbdfSmrg    "#endif\n"
5135c4bbdfSmrg
5235c4bbdfSmrg#include "glyphstr.h"
5335c4bbdfSmrg
5435c4bbdfSmrg#include "glamor_debug.h"
5535c4bbdfSmrg#include "glamor_context.h"
5635c4bbdfSmrg#include "glamor_program.h"
5735c4bbdfSmrg
5835c4bbdfSmrg#include <list.h>
5935c4bbdfSmrg
6035c4bbdfSmrgstruct glamor_pixmap_private;
6135c4bbdfSmrg
6235c4bbdfSmrgtypedef struct glamor_composite_shader {
6335c4bbdfSmrg    GLuint prog;
6435c4bbdfSmrg    GLint dest_to_dest_uniform_location;
6535c4bbdfSmrg    GLint dest_to_source_uniform_location;
6635c4bbdfSmrg    GLint dest_to_mask_uniform_location;
6735c4bbdfSmrg    GLint source_uniform_location;
6835c4bbdfSmrg    GLint mask_uniform_location;
6935c4bbdfSmrg    GLint source_wh;
7035c4bbdfSmrg    GLint mask_wh;
7135c4bbdfSmrg    GLint source_repeat_mode;
7235c4bbdfSmrg    GLint mask_repeat_mode;
7335c4bbdfSmrg    union {
7435c4bbdfSmrg        float source_solid_color[4];
7535c4bbdfSmrg        struct {
7635c4bbdfSmrg            PixmapPtr source_pixmap;
7735c4bbdfSmrg            PicturePtr source;
7835c4bbdfSmrg        };
7935c4bbdfSmrg    };
8035c4bbdfSmrg
8135c4bbdfSmrg    union {
8235c4bbdfSmrg        float mask_solid_color[4];
8335c4bbdfSmrg        struct {
8435c4bbdfSmrg            PixmapPtr mask_pixmap;
8535c4bbdfSmrg            PicturePtr mask;
8635c4bbdfSmrg        };
8735c4bbdfSmrg    };
8835c4bbdfSmrg} glamor_composite_shader;
8935c4bbdfSmrg
9035c4bbdfSmrgenum ca_state {
9135c4bbdfSmrg    CA_NONE,
9235c4bbdfSmrg    CA_TWO_PASS,
9335c4bbdfSmrg    CA_DUAL_BLEND,
9435c4bbdfSmrg};
9535c4bbdfSmrg
9635c4bbdfSmrgenum shader_source {
9735c4bbdfSmrg    SHADER_SOURCE_SOLID,
9835c4bbdfSmrg    SHADER_SOURCE_TEXTURE,
9935c4bbdfSmrg    SHADER_SOURCE_TEXTURE_ALPHA,
10035c4bbdfSmrg    SHADER_SOURCE_COUNT,
10135c4bbdfSmrg};
10235c4bbdfSmrg
10335c4bbdfSmrgenum shader_mask {
10435c4bbdfSmrg    SHADER_MASK_NONE,
10535c4bbdfSmrg    SHADER_MASK_SOLID,
10635c4bbdfSmrg    SHADER_MASK_TEXTURE,
10735c4bbdfSmrg    SHADER_MASK_TEXTURE_ALPHA,
10835c4bbdfSmrg    SHADER_MASK_COUNT,
10935c4bbdfSmrg};
11035c4bbdfSmrg
11135c4bbdfSmrgenum shader_dest_swizzle {
11235c4bbdfSmrg    SHADER_DEST_SWIZZLE_DEFAULT,
11335c4bbdfSmrg    SHADER_DEST_SWIZZLE_ALPHA_TO_RED,
11435c4bbdfSmrg    SHADER_DEST_SWIZZLE_COUNT,
11535c4bbdfSmrg};
11635c4bbdfSmrg
11735c4bbdfSmrgstruct shader_key {
11835c4bbdfSmrg    enum shader_source source;
11935c4bbdfSmrg    enum shader_mask mask;
12035c4bbdfSmrg    glamor_program_alpha in;
12135c4bbdfSmrg    enum shader_dest_swizzle dest_swizzle;
12235c4bbdfSmrg};
12335c4bbdfSmrg
12435c4bbdfSmrgstruct blendinfo {
12535c4bbdfSmrg    Bool dest_alpha;
12635c4bbdfSmrg    Bool source_alpha;
12735c4bbdfSmrg    GLenum source_blend;
12835c4bbdfSmrg    GLenum dest_blend;
12935c4bbdfSmrg};
13035c4bbdfSmrg
13135c4bbdfSmrgtypedef struct {
13235c4bbdfSmrg    INT16 x_src;
13335c4bbdfSmrg    INT16 y_src;
13435c4bbdfSmrg    INT16 x_mask;
13535c4bbdfSmrg    INT16 y_mask;
13635c4bbdfSmrg    INT16 x_dst;
13735c4bbdfSmrg    INT16 y_dst;
13835c4bbdfSmrg    INT16 width;
13935c4bbdfSmrg    INT16 height;
14035c4bbdfSmrg} glamor_composite_rect_t;
14135c4bbdfSmrg
14235c4bbdfSmrgenum glamor_vertex_type {
14335c4bbdfSmrg    GLAMOR_VERTEX_POS,
14435c4bbdfSmrg    GLAMOR_VERTEX_SOURCE,
14535c4bbdfSmrg    GLAMOR_VERTEX_MASK
14635c4bbdfSmrg};
14735c4bbdfSmrg
14835c4bbdfSmrgenum gradient_shader {
14935c4bbdfSmrg    SHADER_GRADIENT_LINEAR,
15035c4bbdfSmrg    SHADER_GRADIENT_RADIAL,
15135c4bbdfSmrg    SHADER_GRADIENT_CONICAL,
15235c4bbdfSmrg    SHADER_GRADIENT_COUNT,
15335c4bbdfSmrg};
15435c4bbdfSmrg
15535c4bbdfSmrgstruct glamor_screen_private;
15635c4bbdfSmrgstruct glamor_pixmap_private;
15735c4bbdfSmrg
15835c4bbdfSmrg#define GLAMOR_COMPOSITE_VBO_VERT_CNT (64*1024)
15935c4bbdfSmrg
160ed6184dfSmrgstruct glamor_format {
161ed6184dfSmrg    /** X Server's "depth" value */
162ed6184dfSmrg    int depth;
163ed6184dfSmrg    /** GL internalformat for creating textures of this type */
164ed6184dfSmrg    GLenum internalformat;
165ed6184dfSmrg    /** GL format transferring pixels in/out of textures of this type. */
166ed6184dfSmrg    GLenum format;
167ed6184dfSmrg    /** GL type transferring pixels in/out of textures of this type. */
168ed6184dfSmrg    GLenum type;
169ed6184dfSmrg    /* Render PICT_* matching GL's channel layout for pixels
170ed6184dfSmrg     * transferred using format/type.
171ed6184dfSmrg     */
172ed6184dfSmrg    CARD32 render_format;
173ed6184dfSmrg    /**
174ed6184dfSmrg     * Whether rendering is supported in GL at all (i.e. without pixel data conversion
175ed6184dfSmrg     * just before upload)
176ed6184dfSmrg     */
177ed6184dfSmrg    Bool rendering_supported;
178ed6184dfSmrg};
179ed6184dfSmrg
18035c4bbdfSmrgstruct glamor_saved_procs {
18135c4bbdfSmrg    CloseScreenProcPtr close_screen;
18235c4bbdfSmrg    CreateGCProcPtr create_gc;
18335c4bbdfSmrg    CreatePixmapProcPtr create_pixmap;
18435c4bbdfSmrg    DestroyPixmapProcPtr destroy_pixmap;
18535c4bbdfSmrg    GetSpansProcPtr get_spans;
18635c4bbdfSmrg    GetImageProcPtr get_image;
18735c4bbdfSmrg    CompositeProcPtr composite;
18835c4bbdfSmrg    CompositeRectsProcPtr composite_rects;
18935c4bbdfSmrg    TrapezoidsProcPtr trapezoids;
19035c4bbdfSmrg    GlyphsProcPtr glyphs;
19135c4bbdfSmrg    ChangeWindowAttributesProcPtr change_window_attributes;
19235c4bbdfSmrg    CopyWindowProcPtr copy_window;
19335c4bbdfSmrg    BitmapToRegionProcPtr bitmap_to_region;
19435c4bbdfSmrg    TrianglesProcPtr triangles;
19535c4bbdfSmrg    AddTrapsProcPtr addtraps;
19635c4bbdfSmrg#if XSYNC
19735c4bbdfSmrg    SyncScreenFuncsRec sync_screen_funcs;
19835c4bbdfSmrg#endif
19935c4bbdfSmrg    ScreenBlockHandlerProcPtr block_handler;
20035c4bbdfSmrg};
20135c4bbdfSmrg
20235c4bbdfSmrgtypedef struct glamor_screen_private {
203ed6184dfSmrg    Bool is_gles;
20435c4bbdfSmrg    int glsl_version;
20535c4bbdfSmrg    Bool has_pack_invert;
20635c4bbdfSmrg    Bool has_fbo_blit;
20735c4bbdfSmrg    Bool has_map_buffer_range;
20835c4bbdfSmrg    Bool has_buffer_storage;
20935c4bbdfSmrg    Bool has_khr_debug;
2101b5d61b8Smrg    Bool has_mesa_tile_raster_order;
21135c4bbdfSmrg    Bool has_nv_texture_barrier;
21235c4bbdfSmrg    Bool has_pack_subimage;
21335c4bbdfSmrg    Bool has_unpack_subimage;
21435c4bbdfSmrg    Bool has_rw_pbo;
21535c4bbdfSmrg    Bool use_quads;
21635c4bbdfSmrg    Bool has_dual_blend;
217ed6184dfSmrg    Bool has_clear_texture;
2181b5d61b8Smrg    Bool has_texture_swizzle;
21935c4bbdfSmrg    Bool is_core_profile;
2201b5d61b8Smrg    Bool can_copyplane;
221ed6184dfSmrg    Bool use_gpu_shader4;
22235c4bbdfSmrg    int max_fbo_size;
22335c4bbdfSmrg
224ed6184dfSmrg    /**
225ed6184dfSmrg     * Stores information about supported formats. Note, that this list contains all
226ed6184dfSmrg     * supported pixel formats, including these that are not supported on GL side
227ed6184dfSmrg     * directly, but are converted to another format instead.
228ed6184dfSmrg     */
229ed6184dfSmrg    struct glamor_format formats[33];
230ed6184dfSmrg    struct glamor_format cbcr_format;
23135c4bbdfSmrg
23235c4bbdfSmrg    /* glamor point shader */
23335c4bbdfSmrg    glamor_program point_prog;
23435c4bbdfSmrg
23535c4bbdfSmrg    /* glamor spans shaders */
23635c4bbdfSmrg    glamor_program_fill fill_spans_program;
23735c4bbdfSmrg
23835c4bbdfSmrg    /* glamor rect shaders */
23935c4bbdfSmrg    glamor_program_fill poly_fill_rect_program;
24035c4bbdfSmrg
24135c4bbdfSmrg    /* glamor glyphblt shaders */
24235c4bbdfSmrg    glamor_program_fill poly_glyph_blt_progs;
24335c4bbdfSmrg
24435c4bbdfSmrg    /* glamor text shaders */
24535c4bbdfSmrg    glamor_program_fill poly_text_progs;
24635c4bbdfSmrg    glamor_program      te_text_prog;
24735c4bbdfSmrg    glamor_program      image_text_prog;
24835c4bbdfSmrg
24935c4bbdfSmrg    /* glamor copy shaders */
25035c4bbdfSmrg    glamor_program      copy_area_prog;
25135c4bbdfSmrg    glamor_program      copy_plane_prog;
25235c4bbdfSmrg
25335c4bbdfSmrg    /* glamor line shader */
25435c4bbdfSmrg    glamor_program_fill poly_line_program;
25535c4bbdfSmrg
25635c4bbdfSmrg    /* glamor segment shaders */
25735c4bbdfSmrg    glamor_program_fill poly_segment_program;
25835c4bbdfSmrg
25935c4bbdfSmrg    /*  glamor dash line shader */
26035c4bbdfSmrg    glamor_program_fill on_off_dash_line_progs;
26135c4bbdfSmrg    glamor_program      double_dash_line_prog;
26235c4bbdfSmrg
26335c4bbdfSmrg    /* glamor composite_glyphs shaders */
26435c4bbdfSmrg    glamor_program_render       glyphs_program;
26535c4bbdfSmrg    struct glamor_glyph_atlas   *glyph_atlas_a;
26635c4bbdfSmrg    struct glamor_glyph_atlas   *glyph_atlas_argb;
26735c4bbdfSmrg    int                         glyph_atlas_dim;
26835c4bbdfSmrg    int                         glyph_max_dim;
26935c4bbdfSmrg    char                        *glyph_defines;
27035c4bbdfSmrg
27135c4bbdfSmrg    /** Vertex buffer for all GPU rendering. */
27235c4bbdfSmrg    GLuint vao;
27335c4bbdfSmrg    GLuint vbo;
27435c4bbdfSmrg    /** Next offset within the VBO that glamor_get_vbo_space() will use. */
27535c4bbdfSmrg    int vbo_offset;
27635c4bbdfSmrg    int vbo_size;
27735c4bbdfSmrg    Bool vbo_mapped;
27835c4bbdfSmrg    /**
27935c4bbdfSmrg     * Pointer to glamor_get_vbo_space()'s current VBO mapping.
28035c4bbdfSmrg     *
28135c4bbdfSmrg     * Note that this is not necessarily equal to the pointer returned
28235c4bbdfSmrg     * by glamor_get_vbo_space(), so it can't be used in place of that.
28335c4bbdfSmrg     */
28435c4bbdfSmrg    char *vb;
28535c4bbdfSmrg    int vb_stride;
28635c4bbdfSmrg
28735c4bbdfSmrg    /** Cached index buffer for translating GL_QUADS to triangles. */
28835c4bbdfSmrg    GLuint ib;
28935c4bbdfSmrg    /** Index buffer type: GL_UNSIGNED_SHORT or GL_UNSIGNED_INT */
29035c4bbdfSmrg    GLenum ib_type;
29135c4bbdfSmrg    /** Number of quads the index buffer has indices for. */
29235c4bbdfSmrg    unsigned ib_size;
29335c4bbdfSmrg
29435c4bbdfSmrg    Bool has_source_coords, has_mask_coords;
29535c4bbdfSmrg    int render_nr_quads;
29635c4bbdfSmrg    glamor_composite_shader composite_shader[SHADER_SOURCE_COUNT]
29735c4bbdfSmrg        [SHADER_MASK_COUNT]
29835c4bbdfSmrg        [glamor_program_alpha_count]
29935c4bbdfSmrg        [SHADER_DEST_SWIZZLE_COUNT];
30035c4bbdfSmrg
30135c4bbdfSmrg    /* glamor gradient, 0 for small nstops, 1 for
30235c4bbdfSmrg       large nstops and 2 for dynamic generate. */
30335c4bbdfSmrg    GLint gradient_prog[SHADER_GRADIENT_COUNT][3];
30435c4bbdfSmrg    int linear_max_nstops;
30535c4bbdfSmrg    int radial_max_nstops;
30635c4bbdfSmrg
30735c4bbdfSmrg    struct glamor_saved_procs saved_procs;
3081b5d61b8Smrg    GetDrawableModifiersFuncPtr get_drawable_modifiers;
30935c4bbdfSmrg    int flags;
31035c4bbdfSmrg    ScreenPtr screen;
31135c4bbdfSmrg    int dri3_enabled;
31235c4bbdfSmrg
31335c4bbdfSmrg    Bool suppress_gl_out_of_memory_logging;
31435c4bbdfSmrg    Bool logged_any_fbo_allocation_failure;
3155a7dfde8Smrg    Bool logged_any_pbo_allocation_failure;
31635c4bbdfSmrg
31735c4bbdfSmrg    /* xv */
31835c4bbdfSmrg    glamor_program xv_prog;
31935c4bbdfSmrg
32035c4bbdfSmrg    struct glamor_context ctx;
32135c4bbdfSmrg} glamor_screen_private;
32235c4bbdfSmrg
32335c4bbdfSmrgtypedef enum glamor_access {
32435c4bbdfSmrg    GLAMOR_ACCESS_RO,
32535c4bbdfSmrg    GLAMOR_ACCESS_RW,
32635c4bbdfSmrg} glamor_access_t;
32735c4bbdfSmrg
32835c4bbdfSmrgenum glamor_fbo_state {
32935c4bbdfSmrg    /** There is no storage attached to the pixmap. */
33035c4bbdfSmrg    GLAMOR_FBO_UNATTACHED,
33135c4bbdfSmrg    /**
33235c4bbdfSmrg     * The pixmap has FBO storage attached, but devPrivate.ptr doesn't
33335c4bbdfSmrg     * point at anything.
33435c4bbdfSmrg     */
33535c4bbdfSmrg    GLAMOR_FBO_NORMAL,
33635c4bbdfSmrg};
33735c4bbdfSmrg
33835c4bbdfSmrgtypedef struct glamor_pixmap_fbo {
33935c4bbdfSmrg    GLuint tex; /**< GL texture name */
34035c4bbdfSmrg    GLuint fb; /**< GL FBO name */
34135c4bbdfSmrg    int width; /**< width in pixels */
34235c4bbdfSmrg    int height; /**< height in pixels */
343ed6184dfSmrg    Bool is_red;
34435c4bbdfSmrg} glamor_pixmap_fbo;
34535c4bbdfSmrg
34635c4bbdfSmrgtypedef struct glamor_pixmap_clipped_regions {
34735c4bbdfSmrg    int block_idx;
34835c4bbdfSmrg    RegionPtr region;
34935c4bbdfSmrg} glamor_pixmap_clipped_regions;
35035c4bbdfSmrg
35135c4bbdfSmrgtypedef struct glamor_pixmap_private {
35235c4bbdfSmrg    glamor_pixmap_type_t type;
35335c4bbdfSmrg    enum glamor_fbo_state gl_fbo;
35435c4bbdfSmrg    /**
35535c4bbdfSmrg     * If devPrivate.ptr is non-NULL (meaning we're within
35635c4bbdfSmrg     * glamor_prepare_access), determies whether we should re-upload
35735c4bbdfSmrg     * that data on glamor_finish_access().
35835c4bbdfSmrg     */
35935c4bbdfSmrg    glamor_access_t map_access;
36035c4bbdfSmrg    glamor_pixmap_fbo *fbo;
36135c4bbdfSmrg    /** current fbo's coords in the whole pixmap. */
36235c4bbdfSmrg    BoxRec box;
36335c4bbdfSmrg    GLuint pbo;
36435c4bbdfSmrg    RegionRec prepare_region;
36535c4bbdfSmrg    Bool prepared;
3661b5d61b8Smrg#ifdef GLAMOR_HAS_GBM
36735c4bbdfSmrg    EGLImageKHR image;
3681b5d61b8Smrg    Bool used_modifiers;
36935c4bbdfSmrg#endif
37035c4bbdfSmrg    /** block width of this large pixmap. */
37135c4bbdfSmrg    int block_w;
37235c4bbdfSmrg    /** block height of this large pixmap. */
37335c4bbdfSmrg    int block_h;
37435c4bbdfSmrg
37535c4bbdfSmrg    /** block_wcnt: block count in one block row. */
37635c4bbdfSmrg    int block_wcnt;
37735c4bbdfSmrg    /** block_hcnt: block count in one block column. */
37835c4bbdfSmrg    int block_hcnt;
37935c4bbdfSmrg
38035c4bbdfSmrg    /**
38135c4bbdfSmrg     * The list of boxes for the bounds of the FBOs making up the
38235c4bbdfSmrg     * pixmap.
38335c4bbdfSmrg     *
38435c4bbdfSmrg     * For a 2048x2048 pixmap with GL FBO size limits of 1024x1024:
38535c4bbdfSmrg     *
38635c4bbdfSmrg     * ******************
38735c4bbdfSmrg     * *  fbo0 * fbo1   *
38835c4bbdfSmrg     * *       *        *
38935c4bbdfSmrg     * ******************
39035c4bbdfSmrg     * *  fbo2 * fbo3   *
39135c4bbdfSmrg     * *       *        *
39235c4bbdfSmrg     * ******************
39335c4bbdfSmrg     *
39435c4bbdfSmrg     * box[0] = {0,0,1024,1024}
39535c4bbdfSmrg     * box[1] = {1024,0,2048,2048}
39635c4bbdfSmrg     * ...
39735c4bbdfSmrg     */
39835c4bbdfSmrg    BoxPtr box_array;
39935c4bbdfSmrg
40035c4bbdfSmrg    /**
40135c4bbdfSmrg     * Array of fbo structs containing the actual GL texture/fbo
40235c4bbdfSmrg     * names.
40335c4bbdfSmrg     */
40435c4bbdfSmrg    glamor_pixmap_fbo **fbo_array;
405ed6184dfSmrg
406ed6184dfSmrg    Bool is_cbcr;
40735c4bbdfSmrg} glamor_pixmap_private;
40835c4bbdfSmrg
40935c4bbdfSmrgextern DevPrivateKeyRec glamor_pixmap_private_key;
41035c4bbdfSmrg
41135c4bbdfSmrgstatic inline glamor_pixmap_private *
41235c4bbdfSmrgglamor_get_pixmap_private(PixmapPtr pixmap)
41335c4bbdfSmrg{
41435c4bbdfSmrg    if (pixmap == NULL)
41535c4bbdfSmrg        return NULL;
41635c4bbdfSmrg
41735c4bbdfSmrg    return dixLookupPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key);
41835c4bbdfSmrg}
41935c4bbdfSmrg
42035c4bbdfSmrg/*
42135c4bbdfSmrg * Returns TRUE if pixmap has no image object
42235c4bbdfSmrg */
42335c4bbdfSmrgstatic inline Bool
42435c4bbdfSmrgglamor_pixmap_drm_only(PixmapPtr pixmap)
42535c4bbdfSmrg{
42635c4bbdfSmrg    glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
42735c4bbdfSmrg
42835c4bbdfSmrg    return priv->type == GLAMOR_DRM_ONLY;
42935c4bbdfSmrg}
43035c4bbdfSmrg
43135c4bbdfSmrg/*
43235c4bbdfSmrg * Returns TRUE if pixmap is plain memory (not a GL object at all)
43335c4bbdfSmrg */
43435c4bbdfSmrgstatic inline Bool
43535c4bbdfSmrgglamor_pixmap_is_memory(PixmapPtr pixmap)
43635c4bbdfSmrg{
43735c4bbdfSmrg    glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
43835c4bbdfSmrg
43935c4bbdfSmrg    return priv->type == GLAMOR_MEMORY;
44035c4bbdfSmrg}
44135c4bbdfSmrg
44235c4bbdfSmrg/*
44335c4bbdfSmrg * Returns TRUE if pixmap requires multiple textures to hold it
44435c4bbdfSmrg */
44535c4bbdfSmrgstatic inline Bool
44635c4bbdfSmrgglamor_pixmap_priv_is_large(glamor_pixmap_private *priv)
44735c4bbdfSmrg{
44835c4bbdfSmrg    return priv->block_wcnt > 1 || priv->block_hcnt > 1;
44935c4bbdfSmrg}
45035c4bbdfSmrg
45135c4bbdfSmrgstatic inline Bool
45235c4bbdfSmrgglamor_pixmap_priv_is_small(glamor_pixmap_private *priv)
45335c4bbdfSmrg{
45435c4bbdfSmrg    return priv->block_wcnt <= 1 && priv->block_hcnt <= 1;
45535c4bbdfSmrg}
45635c4bbdfSmrg
45735c4bbdfSmrgstatic inline Bool
45835c4bbdfSmrgglamor_pixmap_is_large(PixmapPtr pixmap)
45935c4bbdfSmrg{
46035c4bbdfSmrg    glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
46135c4bbdfSmrg
46235c4bbdfSmrg    return glamor_pixmap_priv_is_large(priv);
46335c4bbdfSmrg}
46435c4bbdfSmrg/*
46535c4bbdfSmrg * Returns TRUE if pixmap has an FBO
46635c4bbdfSmrg */
46735c4bbdfSmrgstatic inline Bool
46835c4bbdfSmrgglamor_pixmap_has_fbo(PixmapPtr pixmap)
46935c4bbdfSmrg{
47035c4bbdfSmrg    glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
47135c4bbdfSmrg
47235c4bbdfSmrg    return priv->gl_fbo == GLAMOR_FBO_NORMAL;
47335c4bbdfSmrg}
47435c4bbdfSmrg
47535c4bbdfSmrgstatic inline void
47635c4bbdfSmrgglamor_set_pixmap_fbo_current(glamor_pixmap_private *priv, int idx)
47735c4bbdfSmrg{
47835c4bbdfSmrg    if (glamor_pixmap_priv_is_large(priv)) {
47935c4bbdfSmrg        priv->fbo = priv->fbo_array[idx];
48035c4bbdfSmrg        priv->box = priv->box_array[idx];
48135c4bbdfSmrg    }
48235c4bbdfSmrg}
48335c4bbdfSmrg
48435c4bbdfSmrgstatic inline glamor_pixmap_fbo *
48535c4bbdfSmrgglamor_pixmap_fbo_at(glamor_pixmap_private *priv, int box)
48635c4bbdfSmrg{
48735c4bbdfSmrg    assert(box < priv->block_wcnt * priv->block_hcnt);
48835c4bbdfSmrg    return priv->fbo_array[box];
48935c4bbdfSmrg}
49035c4bbdfSmrg
49135c4bbdfSmrgstatic inline BoxPtr
49235c4bbdfSmrgglamor_pixmap_box_at(glamor_pixmap_private *priv, int box)
49335c4bbdfSmrg{
49435c4bbdfSmrg    assert(box < priv->block_wcnt * priv->block_hcnt);
49535c4bbdfSmrg    return &priv->box_array[box];
49635c4bbdfSmrg}
49735c4bbdfSmrg
49835c4bbdfSmrgstatic inline int
49935c4bbdfSmrgglamor_pixmap_wcnt(glamor_pixmap_private *priv)
50035c4bbdfSmrg{
50135c4bbdfSmrg    return priv->block_wcnt;
50235c4bbdfSmrg}
50335c4bbdfSmrg
50435c4bbdfSmrgstatic inline int
50535c4bbdfSmrgglamor_pixmap_hcnt(glamor_pixmap_private *priv)
50635c4bbdfSmrg{
50735c4bbdfSmrg    return priv->block_hcnt;
50835c4bbdfSmrg}
50935c4bbdfSmrg
51035c4bbdfSmrg#define glamor_pixmap_loop(priv, box_index)                            \
51135c4bbdfSmrg    for (box_index = 0; box_index < glamor_pixmap_hcnt(priv) *         \
51235c4bbdfSmrg             glamor_pixmap_wcnt(priv); box_index++)                    \
51335c4bbdfSmrg
51435c4bbdfSmrg/* GC private structure. Currently holds only any computed dash pixmap */
51535c4bbdfSmrg
51635c4bbdfSmrgtypedef struct {
51735c4bbdfSmrg    PixmapPtr   dash;
51835c4bbdfSmrg    PixmapPtr   stipple;
51935c4bbdfSmrg    DamagePtr   stipple_damage;
52035c4bbdfSmrg} glamor_gc_private;
52135c4bbdfSmrg
52235c4bbdfSmrgextern DevPrivateKeyRec glamor_gc_private_key;
52335c4bbdfSmrgextern DevPrivateKeyRec glamor_screen_private_key;
52435c4bbdfSmrg
5251b5d61b8Smrgextern glamor_screen_private *
5261b5d61b8Smrgglamor_get_screen_private(ScreenPtr screen);
52735c4bbdfSmrg
5281b5d61b8Smrgextern void
5291b5d61b8Smrgglamor_set_screen_private(ScreenPtr screen, glamor_screen_private *priv);
53035c4bbdfSmrg
53135c4bbdfSmrgstatic inline glamor_gc_private *
53235c4bbdfSmrgglamor_get_gc_private(GCPtr gc)
53335c4bbdfSmrg{
53435c4bbdfSmrg    return dixLookupPrivate(&gc->devPrivates, &glamor_gc_private_key);
53535c4bbdfSmrg}
53635c4bbdfSmrg
53735c4bbdfSmrg/**
53835c4bbdfSmrg * Returns TRUE if the given planemask covers all the significant bits in the
53935c4bbdfSmrg * pixel values for pDrawable.
54035c4bbdfSmrg */
54135c4bbdfSmrgstatic inline Bool
54235c4bbdfSmrgglamor_pm_is_solid(int depth, unsigned long planemask)
54335c4bbdfSmrg{
54435c4bbdfSmrg    return (planemask & FbFullMask(depth)) ==
54535c4bbdfSmrg        FbFullMask(depth);
54635c4bbdfSmrg}
54735c4bbdfSmrg
54835c4bbdfSmrgextern int glamor_debug_level;
54935c4bbdfSmrg
55035c4bbdfSmrg/* glamor.c */
55135c4bbdfSmrgPixmapPtr glamor_get_drawable_pixmap(DrawablePtr drawable);
55235c4bbdfSmrg
55335c4bbdfSmrgglamor_pixmap_fbo *glamor_pixmap_detach_fbo(glamor_pixmap_private *
55435c4bbdfSmrg                                            pixmap_priv);
55535c4bbdfSmrgvoid glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo);
55635c4bbdfSmrgglamor_pixmap_fbo *glamor_create_fbo_from_tex(glamor_screen_private *
557ed6184dfSmrg                                              glamor_priv, PixmapPtr pixmap,
558ed6184dfSmrg                                              int w, int h, GLint tex,
55935c4bbdfSmrg                                              int flag);
560ed6184dfSmrgglamor_pixmap_fbo *glamor_create_fbo(glamor_screen_private *glamor_priv,
561ed6184dfSmrg                                     PixmapPtr pixmap, int w, int h, int flag);
56235c4bbdfSmrgvoid glamor_destroy_fbo(glamor_screen_private *glamor_priv,
56335c4bbdfSmrg                        glamor_pixmap_fbo *fbo);
56435c4bbdfSmrgvoid glamor_pixmap_destroy_fbo(PixmapPtr pixmap);
56535c4bbdfSmrgBool glamor_pixmap_fbo_fixup(ScreenPtr screen, PixmapPtr pixmap);
566ed6184dfSmrgvoid glamor_pixmap_clear_fbo(glamor_screen_private *glamor_priv, glamor_pixmap_fbo *fbo,
567ed6184dfSmrg                             const struct glamor_format *pixmap_format);
568ed6184dfSmrg
569ed6184dfSmrgconst struct glamor_format *glamor_format_for_pixmap(PixmapPtr pixmap);
57035c4bbdfSmrg
57135c4bbdfSmrg/* Return whether 'picture' is alpha-only */
57235c4bbdfSmrgstatic inline Bool glamor_picture_is_alpha(PicturePtr picture)
57335c4bbdfSmrg{
57435c4bbdfSmrg    return picture->format == PICT_a1 || picture->format == PICT_a8;
57535c4bbdfSmrg}
57635c4bbdfSmrg
57735c4bbdfSmrg/* Return whether 'picture' is storing alpha bits in the red channel */
57835c4bbdfSmrgstatic inline Bool
57935c4bbdfSmrgglamor_picture_red_is_alpha(PicturePtr picture)
58035c4bbdfSmrg{
58135c4bbdfSmrg    /* True when the picture is alpha only and the screen is using GL_RED for alpha pictures */
58235c4bbdfSmrg    return glamor_picture_is_alpha(picture) &&
583ed6184dfSmrg        glamor_get_screen_private(picture->pDrawable->pScreen)->formats[8].format == GL_RED;
58435c4bbdfSmrg}
58535c4bbdfSmrg
58635c4bbdfSmrgvoid glamor_bind_texture(glamor_screen_private *glamor_priv,
58735c4bbdfSmrg                         GLenum texture,
58835c4bbdfSmrg                         glamor_pixmap_fbo *fbo,
58935c4bbdfSmrg                         Bool destination_red);
59035c4bbdfSmrg
59135c4bbdfSmrgglamor_pixmap_fbo *glamor_create_fbo_array(glamor_screen_private *glamor_priv,
592ed6184dfSmrg                                           PixmapPtr pixmap,
59335c4bbdfSmrg                                           int flag, int block_w, int block_h,
59435c4bbdfSmrg                                           glamor_pixmap_private *);
59535c4bbdfSmrg
59635c4bbdfSmrgvoid glamor_gldrawarrays_quads_using_indices(glamor_screen_private *glamor_priv,
59735c4bbdfSmrg                                             unsigned count);
59835c4bbdfSmrg
59935c4bbdfSmrg/* glamor_core.c */
60035c4bbdfSmrgBool glamor_get_drawable_location(const DrawablePtr drawable);
60135c4bbdfSmrgvoid glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
60235c4bbdfSmrg                                int *x, int *y);
60335c4bbdfSmrgGLint glamor_compile_glsl_prog(GLenum type, const char *source);
60435c4bbdfSmrgvoid glamor_link_glsl_prog(ScreenPtr screen, GLint prog,
60535c4bbdfSmrg                           const char *format, ...) _X_ATTRIBUTE_PRINTF(3,4);
60635c4bbdfSmrgvoid glamor_get_color_4f_from_pixel(PixmapPtr pixmap,
60735c4bbdfSmrg                                    unsigned long fg_pixel, GLfloat *color);
60835c4bbdfSmrg
60935c4bbdfSmrgint glamor_set_destination_pixmap(PixmapPtr pixmap);
61035c4bbdfSmrgint glamor_set_destination_pixmap_priv(glamor_screen_private *glamor_priv, PixmapPtr pixmap, glamor_pixmap_private *pixmap_priv);
61135c4bbdfSmrgvoid glamor_set_destination_pixmap_fbo(glamor_screen_private *glamor_priv, glamor_pixmap_fbo *, int, int, int, int);
61235c4bbdfSmrg
61335c4bbdfSmrg/* nc means no check. caller must ensure this pixmap has valid fbo.
61435c4bbdfSmrg * usually use the GLAMOR_PIXMAP_PRIV_HAS_FBO firstly.
61535c4bbdfSmrg * */
61635c4bbdfSmrgvoid glamor_set_destination_pixmap_priv_nc(glamor_screen_private *glamor_priv, PixmapPtr pixmap, glamor_pixmap_private *pixmap_priv);
61735c4bbdfSmrg
61835c4bbdfSmrgBool glamor_set_alu(ScreenPtr screen, unsigned char alu);
61935c4bbdfSmrgBool glamor_set_planemask(int depth, unsigned long planemask);
62035c4bbdfSmrgRegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
62135c4bbdfSmrg
62235c4bbdfSmrgvoid
62335c4bbdfSmrgglamor_track_stipple(GCPtr gc);
62435c4bbdfSmrg
62535c4bbdfSmrg/* glamor_render.c */
62635c4bbdfSmrgBool glamor_composite_clipped_region(CARD8 op,
62735c4bbdfSmrg                                     PicturePtr source,
62835c4bbdfSmrg                                     PicturePtr mask,
62935c4bbdfSmrg                                     PicturePtr dest,
63035c4bbdfSmrg                                     PixmapPtr source_pixmap,
63135c4bbdfSmrg                                     PixmapPtr mask_pixmap,
63235c4bbdfSmrg                                     PixmapPtr dest_pixmap,
63335c4bbdfSmrg                                     RegionPtr region,
63435c4bbdfSmrg                                     int x_source,
63535c4bbdfSmrg                                     int y_source,
63635c4bbdfSmrg                                     int x_mask, int y_mask,
63735c4bbdfSmrg                                     int x_dest, int y_dest);
63835c4bbdfSmrg
63935c4bbdfSmrgvoid glamor_composite(CARD8 op,
64035c4bbdfSmrg                      PicturePtr pSrc,
64135c4bbdfSmrg                      PicturePtr pMask,
64235c4bbdfSmrg                      PicturePtr pDst,
64335c4bbdfSmrg                      INT16 xSrc,
64435c4bbdfSmrg                      INT16 ySrc,
64535c4bbdfSmrg                      INT16 xMask,
64635c4bbdfSmrg                      INT16 yMask,
64735c4bbdfSmrg                      INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
64835c4bbdfSmrg
64935c4bbdfSmrgvoid glamor_composite_rects(CARD8 op,
65035c4bbdfSmrg                            PicturePtr pDst,
65135c4bbdfSmrg                            xRenderColor *color, int nRect, xRectangle *rects);
65235c4bbdfSmrg
65335c4bbdfSmrg/* glamor_trapezoid.c */
65435c4bbdfSmrgvoid glamor_trapezoids(CARD8 op,
65535c4bbdfSmrg                       PicturePtr src, PicturePtr dst,
65635c4bbdfSmrg                       PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
65735c4bbdfSmrg                       int ntrap, xTrapezoid *traps);
65835c4bbdfSmrg
65935c4bbdfSmrg/* glamor_gradient.c */
66035c4bbdfSmrgvoid glamor_init_gradient_shader(ScreenPtr screen);
66135c4bbdfSmrgPicturePtr glamor_generate_linear_gradient_picture(ScreenPtr screen,
66235c4bbdfSmrg                                                   PicturePtr src_picture,
66335c4bbdfSmrg                                                   int x_source, int y_source,
66435c4bbdfSmrg                                                   int width, int height,
66535c4bbdfSmrg                                                   PictFormatShort format);
66635c4bbdfSmrgPicturePtr glamor_generate_radial_gradient_picture(ScreenPtr screen,
66735c4bbdfSmrg                                                   PicturePtr src_picture,
66835c4bbdfSmrg                                                   int x_source, int y_source,
66935c4bbdfSmrg                                                   int width, int height,
67035c4bbdfSmrg                                                   PictFormatShort format);
67135c4bbdfSmrg
67235c4bbdfSmrg/* glamor_triangles.c */
67335c4bbdfSmrgvoid glamor_triangles(CARD8 op,
67435c4bbdfSmrg                      PicturePtr pSrc,
67535c4bbdfSmrg                      PicturePtr pDst,
67635c4bbdfSmrg                      PictFormatPtr maskFormat,
67735c4bbdfSmrg                      INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris);
67835c4bbdfSmrg
67935c4bbdfSmrg/* glamor_pixmap.c */
68035c4bbdfSmrg
68135c4bbdfSmrgvoid glamor_pixmap_init(ScreenPtr screen);
68235c4bbdfSmrgvoid glamor_pixmap_fini(ScreenPtr screen);
68335c4bbdfSmrg
68435c4bbdfSmrg/* glamor_vbo.c */
68535c4bbdfSmrg
68635c4bbdfSmrgvoid glamor_init_vbo(ScreenPtr screen);
68735c4bbdfSmrgvoid glamor_fini_vbo(ScreenPtr screen);
68835c4bbdfSmrg
68935c4bbdfSmrgvoid *
69035c4bbdfSmrgglamor_get_vbo_space(ScreenPtr screen, unsigned size, char **vbo_offset);
69135c4bbdfSmrg
69235c4bbdfSmrgvoid
69335c4bbdfSmrgglamor_put_vbo_space(ScreenPtr screen);
69435c4bbdfSmrg
69535c4bbdfSmrg/**
69635c4bbdfSmrg * According to the flag,
69735c4bbdfSmrg * if the flag is GLAMOR_CREATE_FBO_NO_FBO then just ensure
69835c4bbdfSmrg * the fbo has a valid texture. Otherwise, it will ensure
69935c4bbdfSmrg * the fbo has valid texture and attach to a valid fb.
70035c4bbdfSmrg * If the fbo already has a valid glfbo then do nothing.
70135c4bbdfSmrg */
702ed6184dfSmrgBool glamor_pixmap_ensure_fbo(PixmapPtr pixmap, int flag);
70335c4bbdfSmrg
70435c4bbdfSmrgglamor_pixmap_clipped_regions *
70535c4bbdfSmrgglamor_compute_clipped_regions(PixmapPtr pixmap,
70635c4bbdfSmrg                               RegionPtr region, int *clipped_nbox,
70735c4bbdfSmrg                               int repeat_type, int reverse,
70835c4bbdfSmrg                               int upsidedown);
70935c4bbdfSmrg
71035c4bbdfSmrgglamor_pixmap_clipped_regions *
71135c4bbdfSmrgglamor_compute_clipped_regions_ext(PixmapPtr pixmap,
71235c4bbdfSmrg                                   RegionPtr region, int *n_region,
71335c4bbdfSmrg                                   int inner_block_w, int inner_block_h,
71435c4bbdfSmrg                                   int reverse, int upsidedown);
71535c4bbdfSmrg
71635c4bbdfSmrgBool glamor_composite_largepixmap_region(CARD8 op,
71735c4bbdfSmrg                                         PicturePtr source,
71835c4bbdfSmrg                                         PicturePtr mask,
71935c4bbdfSmrg                                         PicturePtr dest,
72035c4bbdfSmrg                                         PixmapPtr source_pixmap,
72135c4bbdfSmrg                                         PixmapPtr mask_pixmap,
72235c4bbdfSmrg                                         PixmapPtr dest_pixmap,
72335c4bbdfSmrg                                         RegionPtr region, Bool force_clip,
72435c4bbdfSmrg                                         INT16 x_source,
72535c4bbdfSmrg                                         INT16 y_source,
72635c4bbdfSmrg                                         INT16 x_mask,
72735c4bbdfSmrg                                         INT16 y_mask,
72835c4bbdfSmrg                                         INT16 x_dest, INT16 y_dest,
72935c4bbdfSmrg                                         CARD16 width, CARD16 height);
73035c4bbdfSmrg
73135c4bbdfSmrg/**
73235c4bbdfSmrg * Upload a picture to gl texture. Similar to the
73335c4bbdfSmrg * glamor_upload_pixmap_to_texture. Used in rendering.
73435c4bbdfSmrg **/
7351b5d61b8SmrgBool glamor_upload_picture_to_texture(PicturePtr picture);
73635c4bbdfSmrg
73735c4bbdfSmrgvoid glamor_add_traps(PicturePtr pPicture,
73835c4bbdfSmrg                      INT16 x_off, INT16 y_off, int ntrap, xTrap *traps);
73935c4bbdfSmrg
74035c4bbdfSmrg/* glamor_text.c */
74135c4bbdfSmrgint glamor_poly_text8(DrawablePtr pDrawable, GCPtr pGC,
74235c4bbdfSmrg                      int x, int y, int count, char *chars);
74335c4bbdfSmrg
74435c4bbdfSmrgint glamor_poly_text16(DrawablePtr pDrawable, GCPtr pGC,
74535c4bbdfSmrg                       int x, int y, int count, unsigned short *chars);
74635c4bbdfSmrg
74735c4bbdfSmrgvoid glamor_image_text8(DrawablePtr pDrawable, GCPtr pGC,
74835c4bbdfSmrg                        int x, int y, int count, char *chars);
74935c4bbdfSmrg
75035c4bbdfSmrgvoid glamor_image_text16(DrawablePtr pDrawable, GCPtr pGC,
75135c4bbdfSmrg                         int x, int y, int count, unsigned short *chars);
75235c4bbdfSmrg
75335c4bbdfSmrg/* glamor_spans.c */
75435c4bbdfSmrgvoid
75535c4bbdfSmrgglamor_fill_spans(DrawablePtr drawable,
75635c4bbdfSmrg                  GCPtr gc,
75735c4bbdfSmrg                  int n, DDXPointPtr points, int *widths, int sorted);
75835c4bbdfSmrg
75935c4bbdfSmrgvoid
76035c4bbdfSmrgglamor_get_spans(DrawablePtr drawable, int wmax,
76135c4bbdfSmrg                 DDXPointPtr points, int *widths, int count, char *dst);
76235c4bbdfSmrg
76335c4bbdfSmrgvoid
76435c4bbdfSmrgglamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
76535c4bbdfSmrg                 DDXPointPtr points, int *widths, int numPoints, int sorted);
76635c4bbdfSmrg
76735c4bbdfSmrg/* glamor_rects.c */
76835c4bbdfSmrgvoid
76935c4bbdfSmrgglamor_poly_fill_rect(DrawablePtr drawable,
77035c4bbdfSmrg                      GCPtr gc, int nrect, xRectangle *prect);
77135c4bbdfSmrg
77235c4bbdfSmrg/* glamor_image.c */
77335c4bbdfSmrgvoid
77435c4bbdfSmrgglamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
77535c4bbdfSmrg                 int w, int h, int leftPad, int format, char *bits);
77635c4bbdfSmrg
77735c4bbdfSmrgvoid
77835c4bbdfSmrgglamor_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
77935c4bbdfSmrg                 unsigned int format, unsigned long planeMask, char *d);
78035c4bbdfSmrg
78135c4bbdfSmrg/* glamor_dash.c */
78235c4bbdfSmrgBool
78335c4bbdfSmrgglamor_poly_lines_dash_gl(DrawablePtr drawable, GCPtr gc,
78435c4bbdfSmrg                          int mode, int n, DDXPointPtr points);
78535c4bbdfSmrg
78635c4bbdfSmrgBool
78735c4bbdfSmrgglamor_poly_segment_dash_gl(DrawablePtr drawable, GCPtr gc,
78835c4bbdfSmrg                            int nseg, xSegment *segs);
78935c4bbdfSmrg
79035c4bbdfSmrg/* glamor_lines.c */
79135c4bbdfSmrgvoid
79235c4bbdfSmrgglamor_poly_lines(DrawablePtr drawable, GCPtr gc,
79335c4bbdfSmrg                  int mode, int n, DDXPointPtr points);
79435c4bbdfSmrg
79535c4bbdfSmrg/*  glamor_segs.c */
79635c4bbdfSmrgvoid
79735c4bbdfSmrgglamor_poly_segment(DrawablePtr drawable, GCPtr gc,
79835c4bbdfSmrg                    int nseg, xSegment *segs);
79935c4bbdfSmrg
80035c4bbdfSmrg/* glamor_copy.c */
80135c4bbdfSmrgvoid
80235c4bbdfSmrgglamor_copy(DrawablePtr src,
80335c4bbdfSmrg            DrawablePtr dst,
80435c4bbdfSmrg            GCPtr gc,
80535c4bbdfSmrg            BoxPtr box,
80635c4bbdfSmrg            int nbox,
80735c4bbdfSmrg            int dx,
80835c4bbdfSmrg            int dy,
80935c4bbdfSmrg            Bool reverse,
81035c4bbdfSmrg            Bool upsidedown,
81135c4bbdfSmrg            Pixel bitplane,
81235c4bbdfSmrg            void *closure);
81335c4bbdfSmrg
81435c4bbdfSmrgRegionPtr
81535c4bbdfSmrgglamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
81635c4bbdfSmrg                 int srcx, int srcy, int width, int height, int dstx, int dsty);
81735c4bbdfSmrg
81835c4bbdfSmrgRegionPtr
81935c4bbdfSmrgglamor_copy_plane(DrawablePtr src, DrawablePtr dst, GCPtr gc,
82035c4bbdfSmrg                  int srcx, int srcy, int width, int height, int dstx, int dsty,
82135c4bbdfSmrg                  unsigned long bitplane);
82235c4bbdfSmrg
82335c4bbdfSmrg/* glamor_glyphblt.c */
82435c4bbdfSmrgvoid glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
82535c4bbdfSmrg                            int x, int y, unsigned int nglyph,
82635c4bbdfSmrg                            CharInfoPtr *ppci, void *pglyphBase);
82735c4bbdfSmrg
82835c4bbdfSmrgvoid glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
82935c4bbdfSmrg                           int x, int y, unsigned int nglyph,
83035c4bbdfSmrg                           CharInfoPtr *ppci, void *pglyphBase);
83135c4bbdfSmrg
83235c4bbdfSmrgvoid glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
83335c4bbdfSmrg                        DrawablePtr pDrawable, int w, int h, int x, int y);
83435c4bbdfSmrg
83535c4bbdfSmrgvoid glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
83635c4bbdfSmrg                       DDXPointPtr ppt);
83735c4bbdfSmrg
83835c4bbdfSmrgvoid glamor_composite_rectangles(CARD8 op,
83935c4bbdfSmrg                                 PicturePtr dst,
84035c4bbdfSmrg                                 xRenderColor *color,
84135c4bbdfSmrg                                 int num_rects, xRectangle *rects);
84235c4bbdfSmrg
84335c4bbdfSmrg/* glamor_composite_glyphs.c */
84435c4bbdfSmrgBool
84535c4bbdfSmrgglamor_composite_glyphs_init(ScreenPtr pScreen);
84635c4bbdfSmrg
84735c4bbdfSmrgvoid
84835c4bbdfSmrgglamor_composite_glyphs_fini(ScreenPtr pScreen);
84935c4bbdfSmrg
85035c4bbdfSmrgvoid
85135c4bbdfSmrgglamor_composite_glyphs(CARD8 op,
85235c4bbdfSmrg                        PicturePtr src,
85335c4bbdfSmrg                        PicturePtr dst,
85435c4bbdfSmrg                        PictFormatPtr mask_format,
85535c4bbdfSmrg                        INT16 x_src,
85635c4bbdfSmrg                        INT16 y_src, int nlist,
85735c4bbdfSmrg                        GlyphListPtr list, GlyphPtr *glyphs);
85835c4bbdfSmrg
85935c4bbdfSmrg/* glamor_sync.c */
86035c4bbdfSmrgBool
86135c4bbdfSmrgglamor_sync_init(ScreenPtr screen);
86235c4bbdfSmrg
86335c4bbdfSmrgvoid
86435c4bbdfSmrgglamor_sync_close(ScreenPtr screen);
86535c4bbdfSmrg
86635c4bbdfSmrg/* glamor_util.c */
86735c4bbdfSmrgvoid
86835c4bbdfSmrgglamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
86935c4bbdfSmrg             unsigned long fg_pixel);
87035c4bbdfSmrg
87135c4bbdfSmrgvoid
87235c4bbdfSmrgglamor_solid_boxes(PixmapPtr pixmap,
87335c4bbdfSmrg                   BoxPtr box, int nbox, unsigned long fg_pixel);
87435c4bbdfSmrg
87535c4bbdfSmrg
87635c4bbdfSmrg/* glamor_xv */
87735c4bbdfSmrgtypedef struct {
87835c4bbdfSmrg    uint32_t transform_index;
87935c4bbdfSmrg    uint32_t gamma;             /* gamma value x 1000 */
88035c4bbdfSmrg    int brightness;
88135c4bbdfSmrg    int saturation;
88235c4bbdfSmrg    int hue;
88335c4bbdfSmrg    int contrast;
88435c4bbdfSmrg
88535c4bbdfSmrg    DrawablePtr pDraw;
88635c4bbdfSmrg    PixmapPtr pPixmap;
88735c4bbdfSmrg    uint32_t src_pitch;
88835c4bbdfSmrg    uint8_t *src_addr;
88935c4bbdfSmrg    int src_w, src_h, dst_w, dst_h;
89035c4bbdfSmrg    int src_x, src_y, drw_x, drw_y;
89135c4bbdfSmrg    int w, h;
89235c4bbdfSmrg    RegionRec clip;
89335c4bbdfSmrg    PixmapPtr src_pix[3];       /* y, u, v for planar */
89435c4bbdfSmrg    int src_pix_w, src_pix_h;
89535c4bbdfSmrg} glamor_port_private;
89635c4bbdfSmrg
89735c4bbdfSmrgextern XvAttributeRec glamor_xv_attributes[];
89835c4bbdfSmrgextern int glamor_xv_num_attributes;
89935c4bbdfSmrgextern XvImageRec glamor_xv_images[];
90035c4bbdfSmrgextern int glamor_xv_num_images;
90135c4bbdfSmrg
90235c4bbdfSmrgvoid glamor_xv_init_port(glamor_port_private *port_priv);
90335c4bbdfSmrgvoid glamor_xv_stop_video(glamor_port_private *port_priv);
90435c4bbdfSmrgint glamor_xv_set_port_attribute(glamor_port_private *port_priv,
90535c4bbdfSmrg                                 Atom attribute, INT32 value);
90635c4bbdfSmrgint glamor_xv_get_port_attribute(glamor_port_private *port_priv,
90735c4bbdfSmrg                                 Atom attribute, INT32 *value);
90835c4bbdfSmrgint glamor_xv_query_image_attributes(int id,
90935c4bbdfSmrg                                     unsigned short *w, unsigned short *h,
91035c4bbdfSmrg                                     int *pitches, int *offsets);
91135c4bbdfSmrgint glamor_xv_put_image(glamor_port_private *port_priv,
91235c4bbdfSmrg                        DrawablePtr pDrawable,
91335c4bbdfSmrg                        short src_x, short src_y,
91435c4bbdfSmrg                        short drw_x, short drw_y,
91535c4bbdfSmrg                        short src_w, short src_h,
91635c4bbdfSmrg                        short drw_w, short drw_h,
91735c4bbdfSmrg                        int id,
91835c4bbdfSmrg                        unsigned char *buf,
91935c4bbdfSmrg                        short width,
92035c4bbdfSmrg                        short height,
92135c4bbdfSmrg                        Bool sync,
92235c4bbdfSmrg                        RegionPtr clipBoxes);
92335c4bbdfSmrgvoid glamor_xv_core_init(ScreenPtr screen);
924ed6184dfSmrgvoid glamor_xv_render(glamor_port_private *port_priv, int id);
92535c4bbdfSmrg
9261b5d61b8Smrg#include "glamor_utils.h"
92735c4bbdfSmrg
92835c4bbdfSmrg#if 0
92935c4bbdfSmrg#define MAX_FBO_SIZE 32         /* For test purpose only. */
93035c4bbdfSmrg#endif
93135c4bbdfSmrg
93235c4bbdfSmrg#include "glamor_font.h"
93335c4bbdfSmrg
93435c4bbdfSmrg#define GLAMOR_MIN_ALU_INSTRUCTIONS 128 /* Minimum required number of native ALU instructions */
93535c4bbdfSmrg
93635c4bbdfSmrg#endif                          /* GLAMOR_PRIV_H */
937