Subversion Repositories Kolibri OS

Rev

Rev 4359 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #ifndef SNA_RENDER_H
  2. #define SNA_RENDER_H
  3.  
  4. #include "compiler.h"
  5.  
  6. #include <stdbool.h>
  7. #include <stdint.h>
  8.  
  9. #define GRADIENT_CACHE_SIZE 16
  10.  
  11. #define GXinvalid 0xff
  12.  
  13. #define HW_BIT_BLIT         (1<<0)      /* BGRX blitter             */
  14. #define HW_TEX_BLIT         (1<<1)      /* stretch blit             */
  15. #define HW_VID_BLIT         (1<<2)      /* planar and packed video  */
  16.  
  17. struct sna;
  18. struct sna_glyph;
  19. struct sna_video;
  20. struct sna_video_frame;
  21. struct brw_compile;
  22.  
  23. struct sna_composite_rectangles {
  24.         struct sna_coordinate {
  25.                 int16_t x, y;
  26.         } src, mask, dst;
  27.         int16_t width, height;
  28. };
  29.  
  30. struct sna_composite_op {
  31.     fastcall void (*blt)(struct sna *sna, const struct sna_composite_op *op,
  32.                  const struct sna_composite_rectangles *r);
  33.  
  34.     void (*done)(struct sna *sna, const struct sna_composite_op *op);
  35.  
  36.     struct sna_damage **damage;
  37.  
  38.     uint32_t op;
  39.  
  40.     struct {
  41.                 PixmapPtr pixmap;
  42.         CARD32    format;
  43.         struct kgem_bo *bo;
  44.         int16_t   x, y;
  45.         uint16_t  width, height;
  46.     } dst;
  47.  
  48.     struct sna_composite_channel {
  49.         struct kgem_bo *bo;
  50.         PictTransform *transform;
  51.         uint16_t width;
  52.         uint16_t height;
  53.         uint32_t pict_format;
  54.         uint32_t card_format;
  55.         uint32_t filter;
  56.         uint32_t repeat;
  57.         uint32_t is_affine : 1;
  58.         uint32_t is_solid : 1;
  59.         uint32_t is_linear : 1;
  60.         uint32_t is_opaque : 1;
  61.         uint32_t alpha_fixup : 1;
  62.         uint32_t rb_reversed : 1;
  63.         int16_t offset[2];
  64.         float scale[2];
  65.  
  66. //        pixman_transform_t embedded_transform;
  67.  
  68.         union {
  69.             struct {
  70.                                 float dx, dy, offset;
  71.                         } linear;
  72.                         struct {
  73.                 uint32_t pixel;
  74.             } gen2;
  75.             struct gen3_shader_channel {
  76.                 int type;
  77.                 uint32_t mode;
  78.                 uint32_t constants;
  79.             } gen3;
  80.         } u;
  81.     } src, mask;
  82.     uint32_t is_affine : 1;
  83.     uint32_t has_component_alpha : 1;
  84.     uint32_t need_magic_ca_pass : 1;
  85.     uint32_t rb_reversed : 1;
  86.  
  87.     int16_t floats_per_vertex;
  88.     int16_t floats_per_rect;
  89.     fastcall void (*prim_emit)(struct sna *sna,
  90.                    const struct sna_composite_op *op,
  91.                    const struct sna_composite_rectangles *r);
  92.  
  93.     struct sna_composite_redirect {
  94.         struct kgem_bo *real_bo;
  95.         struct sna_damage **real_damage, *damage;
  96.         BoxRec box;
  97.     } redirect;
  98.  
  99.     union {
  100.         struct sna_blt_state {
  101.                         PixmapPtr src_pixmap;
  102.             int16_t sx, sy;
  103.  
  104.             uint32_t inplace :1;
  105.             uint32_t overwrites:1;
  106.             uint32_t bpp : 6;
  107.                         uint32_t alu : 4;
  108.  
  109.             uint32_t cmd;
  110.             uint32_t br13;
  111.             uint32_t pitch[2];
  112.             uint32_t pixel;
  113.             struct kgem_bo *bo[2];
  114.         } blt;
  115.  
  116.         struct {
  117.             float constants[8];
  118.             uint32_t num_constants;
  119.         } gen3;
  120.  
  121.         struct {
  122.             int wm_kernel;
  123.             int ve_id;
  124.         } gen4;
  125.  
  126.         struct {
  127.                         int16_t wm_kernel;
  128.                         int16_t ve_id;
  129.         } gen5;
  130.  
  131.         struct {
  132.                         uint32_t flags;
  133.         } gen6;
  134.  
  135.         struct {
  136.                         uint32_t flags;
  137.         } gen7;
  138.         } u;
  139.  
  140.         void *priv;
  141. };
  142.  
  143. struct sna_copy_op {
  144.         struct sna_composite_op base;
  145.  
  146.         void (*blt)(struct sna *sna, const struct sna_copy_op *op,
  147.                     int16_t sx, int16_t sy,
  148.                     int16_t w, int16_t h,
  149.                     int16_t dx, int16_t dy);
  150.         void (*done)(struct sna *sna, const struct sna_copy_op *op);
  151. };
  152.  
  153. struct sna_render {
  154.         int active;
  155.  
  156.         int caps;
  157.  
  158.         int max_3d_size;
  159.         int max_3d_pitch;
  160.  
  161.         unsigned prefer_gpu;
  162. #define PREFER_GPU_BLT 0x1
  163. #define PREFER_GPU_RENDER 0x2
  164. #define PREFER_GPU_SPANS 0x4
  165.  
  166.         bool (*composite)(struct sna *sna, uint8_t op,
  167.                           PicturePtr dst, PicturePtr src, PicturePtr mask,
  168.                           int16_t src_x, int16_t src_y,
  169.                           int16_t msk_x, int16_t msk_y,
  170.                           int16_t dst_x, int16_t dst_y,
  171.                           int16_t w, int16_t h,
  172.                           struct sna_composite_op *tmp);
  173.  
  174. #if 0
  175.         bool (*check_composite_spans)(struct sna *sna, uint8_t op,
  176.                                       PicturePtr dst, PicturePtr src,
  177.                                       int16_t w, int16_t h, unsigned flags);
  178.         bool (*composite_spans)(struct sna *sna, uint8_t op,
  179.                                 PicturePtr dst, PicturePtr src,
  180.                                 int16_t src_x, int16_t src_y,
  181.                                 int16_t dst_x, int16_t dst_y,
  182.                                 int16_t w, int16_t h,
  183.                                 unsigned flags,
  184.                                 struct sna_composite_spans_op *tmp);
  185. #define COMPOSITE_SPANS_RECTILINEAR 0x1
  186. #define COMPOSITE_SPANS_INPLACE_HINT 0x2
  187.  
  188.         bool (*video)(struct sna *sna,
  189.                       struct sna_video *video,
  190.                       struct sna_video_frame *frame,
  191.                       RegionPtr dstRegion,
  192.                       PixmapPtr pixmap);
  193.  
  194.         bool (*fill_boxes)(struct sna *sna,
  195.                            CARD8 op,
  196.                            PictFormat format,
  197.                            const xRenderColor *color,
  198.                            PixmapPtr dst, struct kgem_bo *dst_bo,
  199.                            const BoxRec *box, int n);
  200.         bool (*fill)(struct sna *sna, uint8_t alu,
  201.                      PixmapPtr dst, struct kgem_bo *dst_bo,
  202.                      uint32_t color,
  203.                      struct sna_fill_op *tmp);
  204.         bool (*fill_one)(struct sna *sna, PixmapPtr dst, struct kgem_bo *dst_bo,
  205.                          uint32_t color,
  206.                          int16_t x1, int16_t y1, int16_t x2, int16_t y2,
  207.                          uint8_t alu);
  208.         bool (*clear)(struct sna *sna, PixmapPtr dst, struct kgem_bo *dst_bo);
  209.  
  210.         bool (*copy_boxes)(struct sna *sna, uint8_t alu,
  211.                            PixmapPtr src, struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
  212.                            PixmapPtr dst, struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
  213.                            const BoxRec *box, int n, unsigned flags);
  214. #define COPY_LAST 0x1
  215. #define COPY_SYNC 0x2
  216.  
  217. #endif
  218.  
  219.     bool (*blit_tex)(struct sna *sna,
  220.               uint8_t op, bool scale,
  221.               PixmapPtr src, struct kgem_bo *src_bo,
  222.               PixmapPtr mask,struct kgem_bo *mask_bo,
  223.               PixmapPtr dst, struct kgem_bo *dst_bo,
  224.               int32_t src_x, int32_t src_y,
  225.               int32_t msk_x, int32_t msk_y,
  226.               int32_t dst_x, int32_t dst_y,
  227.               int32_t width, int32_t height,
  228.               struct sna_composite_op *tmp);
  229.  
  230.         bool (*copy)(struct sna *sna, uint8_t alu,
  231.                      PixmapPtr src, struct kgem_bo *src_bo,
  232.                      PixmapPtr dst, struct kgem_bo *dst_bo,
  233.                      struct sna_copy_op *op);
  234.  
  235.         void (*flush)(struct sna *sna);
  236.         void (*reset)(struct sna *sna);
  237.         void (*fini)(struct sna *sna);
  238.  
  239. #if 0
  240.  
  241.         struct sna_alpha_cache {
  242.                 struct kgem_bo *cache_bo;
  243.                 struct kgem_bo *bo[256+7];
  244.         } alpha_cache;
  245.  
  246.     struct sna_solid_cache {
  247.          struct kgem_bo *cache_bo;
  248.          struct kgem_bo *bo[1024];
  249.                 uint32_t color[1024];
  250.          int last;
  251.          int size;
  252.          int dirty;
  253.     } solid_cache;
  254.  
  255.         struct {
  256.                 struct sna_gradient_cache {
  257.                         struct kgem_bo *bo;
  258.                         int nstops;
  259.                         PictGradientStop *stops;
  260.                 } cache[GRADIENT_CACHE_SIZE];
  261.                 int size;
  262.         } gradient_cache;
  263.  
  264.         struct sna_glyph_cache{
  265.                 PicturePtr picture;
  266.                 struct sna_glyph **glyphs;
  267.                 uint16_t count;
  268.                 uint16_t evict;
  269.         } glyph[2];
  270.         pixman_image_t *white_image;
  271.         PicturePtr white_picture;
  272. #if HAS_PIXMAN_GLYPHS
  273.         pixman_glyph_cache_t *glyph_cache;
  274. #endif
  275.  
  276. #endif
  277.  
  278.         uint16_t vb_id;
  279.         uint16_t vertex_offset;
  280.         uint16_t vertex_start;
  281.         uint16_t vertex_index;
  282.         uint16_t vertex_used;
  283.         uint16_t vertex_size;
  284.         uint16_t vertex_reloc[16];
  285.         int nvertex_reloc;
  286.  
  287.     struct kgem_bo *vbo;
  288.         float *vertices;
  289.  
  290.         float vertex_data[1024];
  291. };
  292.  
  293. struct gen2_render_state {
  294.         uint32_t target;
  295.         bool need_invariant;
  296.         uint32_t logic_op_enabled;
  297.         uint32_t ls1, ls2, vft;
  298.         uint32_t diffuse;
  299.         uint32_t specular;
  300. };
  301.  
  302. struct gen3_render_state {
  303.         uint32_t current_dst;
  304.         bool need_invariant;
  305.         uint32_t tex_count;
  306.         uint32_t last_drawrect_limit;
  307.         uint32_t last_target;
  308.         uint32_t last_blend;
  309.         uint32_t last_constants;
  310.         uint32_t last_sampler;
  311.         uint32_t last_shader;
  312.         uint32_t last_diffuse;
  313.         uint32_t last_specular;
  314.  
  315.         uint16_t last_vertex_offset;
  316.         uint16_t floats_per_vertex;
  317.         uint16_t last_floats_per_vertex;
  318.  
  319.         uint32_t tex_map[4];
  320.         uint32_t tex_handle[2];
  321.         uint32_t tex_delta[2];
  322. };
  323.  
  324. struct gen4_render_state {
  325.         struct kgem_bo *general_bo;
  326.  
  327.         uint32_t vs;
  328.         uint32_t sf;
  329.         uint32_t wm;
  330.         uint32_t cc;
  331.  
  332.         int ve_id;
  333.         uint32_t drawrect_offset;
  334.         uint32_t drawrect_limit;
  335.         uint32_t last_pipelined_pointers;
  336.         uint16_t last_primitive;
  337.         int16_t floats_per_vertex;
  338.         uint16_t surface_table;
  339.  
  340.         bool needs_invariant;
  341.         bool needs_urb;
  342. };
  343.  
  344. struct gen5_render_state {
  345.         struct kgem_bo *general_bo;
  346.  
  347.         uint32_t vs;
  348.         uint32_t sf[2];
  349.         uint32_t wm;
  350.         uint32_t cc;
  351.  
  352.         int ve_id;
  353.         uint32_t drawrect_offset;
  354.         uint32_t drawrect_limit;
  355.         uint32_t last_pipelined_pointers;
  356.         uint16_t last_primitive;
  357.         int16_t floats_per_vertex;
  358.         uint16_t surface_table;
  359.  
  360.         bool needs_invariant;
  361. };
  362.  
  363. enum {
  364.         GEN6_WM_KERNEL_NOMASK = 0,
  365.         GEN6_WM_KERNEL_NOMASK_P,
  366.  
  367.     GEN6_WM_KERNEL_MASK,
  368.         GEN6_WM_KERNEL_MASK_P,
  369.  
  370.         GEN6_WM_KERNEL_MASKCA,
  371.         GEN6_WM_KERNEL_MASKCA_P,
  372.  
  373.         GEN6_WM_KERNEL_MASKSA,
  374.         GEN6_WM_KERNEL_MASKSA_P,
  375.  
  376.         GEN6_WM_KERNEL_OPACITY,
  377.         GEN6_WM_KERNEL_OPACITY_P,
  378.  
  379.         GEN6_WM_KERNEL_VIDEO_PLANAR,
  380.         GEN6_WM_KERNEL_VIDEO_PACKED,
  381.     GEN6_KERNEL_COUNT
  382. };
  383.  
  384. struct gen6_render_state {
  385.         unsigned gt;
  386.         const struct gt_info *info;
  387.     struct kgem_bo *general_bo;
  388.  
  389.         uint32_t vs_state;
  390.         uint32_t sf_state;
  391.         uint32_t sf_mask_state;
  392.         uint32_t wm_state;
  393.         uint32_t wm_kernel[GEN6_KERNEL_COUNT][3];
  394.  
  395.         uint32_t cc_blend;
  396.  
  397.         uint32_t drawrect_offset;
  398.         uint32_t drawrect_limit;
  399.         uint32_t blend;
  400.         uint32_t samplers;
  401.         uint32_t kernel;
  402.  
  403.         uint16_t num_sf_outputs;
  404.         uint16_t ve_id;
  405.         uint16_t last_primitive;
  406.         int16_t floats_per_vertex;
  407.         uint16_t surface_table;
  408.  
  409.         bool needs_invariant;
  410.         bool first_state_packet;
  411. };
  412.  
  413. enum {
  414.         GEN7_WM_KERNEL_NOMASK = 0,
  415.         GEN7_WM_KERNEL_NOMASK_P,
  416.  
  417.         GEN7_WM_KERNEL_MASK,
  418.         GEN7_WM_KERNEL_MASK_P,
  419.  
  420.         GEN7_WM_KERNEL_MASKCA,
  421.         GEN7_WM_KERNEL_MASKCA_P,
  422.  
  423.         GEN7_WM_KERNEL_MASKSA,
  424.         GEN7_WM_KERNEL_MASKSA_P,
  425.  
  426.         GEN7_WM_KERNEL_OPACITY,
  427.         GEN7_WM_KERNEL_OPACITY_P,
  428.  
  429.         GEN7_WM_KERNEL_VIDEO_PLANAR,
  430.         GEN7_WM_KERNEL_VIDEO_PACKED,
  431.         GEN7_WM_KERNEL_COUNT
  432. };
  433.  
  434. struct gen7_render_state {
  435.         unsigned gt;
  436.         const struct gt_info *info;
  437.         struct kgem_bo *general_bo;
  438.  
  439.         uint32_t vs_state;
  440.         uint32_t sf_state;
  441.         uint32_t sf_mask_state;
  442.         uint32_t wm_state;
  443.         uint32_t wm_kernel[GEN7_WM_KERNEL_COUNT][3];
  444.  
  445.         uint32_t cc_blend;
  446.  
  447.         uint32_t drawrect_offset;
  448.         uint32_t drawrect_limit;
  449.         uint32_t blend;
  450.         uint32_t samplers;
  451.         uint32_t kernel;
  452.  
  453.         uint16_t num_sf_outputs;
  454.         uint16_t ve_id;
  455.         uint16_t last_primitive;
  456.         int16_t floats_per_vertex;
  457.         uint16_t surface_table;
  458.  
  459.         bool needs_invariant;
  460.         bool emit_flush;
  461. };
  462.  
  463. struct sna_static_stream {
  464.         uint32_t size, used;
  465.         uint8_t *data;
  466. };
  467.  
  468. int sna_static_stream_init(struct sna_static_stream *stream);
  469. uint32_t sna_static_stream_add(struct sna_static_stream *stream,
  470.                                const void *data, uint32_t len, uint32_t align);
  471. void *sna_static_stream_map(struct sna_static_stream *stream,
  472.                             uint32_t len, uint32_t align);
  473. uint32_t sna_static_stream_offsetof(struct sna_static_stream *stream,
  474.                                     void *ptr);
  475. unsigned sna_static_stream_compile_sf(struct sna *sna,
  476.                                       struct sna_static_stream *stream,
  477.                                       bool (*compile)(struct brw_compile *));
  478.  
  479. unsigned sna_static_stream_compile_wm(struct sna *sna,
  480.                                       struct sna_static_stream *stream,
  481.                                       bool (*compile)(struct brw_compile *, int),
  482.                                       int width);
  483. struct kgem_bo *sna_static_stream_fini(struct sna *sna,
  484.                                        struct sna_static_stream *stream);
  485.  
  486. struct kgem_bo *
  487. sna_render_get_solid(struct sna *sna,
  488.                      uint32_t color);
  489.  
  490. void
  491. sna_render_flush_solid(struct sna *sna);
  492.  
  493.  
  494. uint32_t sna_rgba_for_color(uint32_t color, int depth);
  495. uint32_t sna_rgba_to_color(uint32_t rgba, uint32_t format);
  496. bool sna_get_rgba_from_pixel(uint32_t pixel,
  497.                              uint16_t *red,
  498.                              uint16_t *green,
  499.                              uint16_t *blue,
  500.                              uint16_t *alpha,
  501.                              uint32_t format);
  502. bool sna_picture_is_solid(PicturePtr picture, uint32_t *color);
  503.  
  504. const char *no_render_init(struct sna *sna);
  505. const char *gen2_render_init(struct sna *sna, const char *backend);
  506. const char *gen3_render_init(struct sna *sna, const char *backend);
  507. const char *gen4_render_init(struct sna *sna, const char *backend);
  508. const char *gen5_render_init(struct sna *sna, const char *backend);
  509. const char *gen6_render_init(struct sna *sna, const char *backend);
  510. const char *gen7_render_init(struct sna *sna, const char *backend);
  511.  
  512. #if 0
  513. bool sna_tiling_composite(uint32_t op,
  514.                           PicturePtr src,
  515.                           PicturePtr mask,
  516.                           PicturePtr dst,
  517.                           int16_t src_x, int16_t src_y,
  518.                           int16_t mask_x, int16_t mask_y,
  519.                           int16_t dst_x, int16_t dst_y,
  520.                           int16_t width, int16_t height,
  521.                           struct sna_composite_op *tmp);
  522. bool sna_tiling_fill_boxes(struct sna *sna,
  523.                            CARD8 op,
  524.                            PictFormat format,
  525.                            const xRenderColor *color,
  526.                            PixmapPtr dst, struct kgem_bo *dst_bo,
  527.                            const BoxRec *box, int n);
  528.  
  529. bool sna_tiling_copy_boxes(struct sna *sna, uint8_t alu,
  530.                            PixmapPtr src, struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
  531.                            PixmapPtr dst, struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
  532.                            const BoxRec *box, int n);
  533.  
  534. bool sna_tiling_blt_copy_boxes(struct sna *sna, uint8_t alu,
  535.                                struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
  536.                                struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
  537.                                int bpp, const BoxRec *box, int nbox);
  538.  
  539. bool sna_blt_composite(struct sna *sna,
  540.                        uint32_t op,
  541.                        PicturePtr src,
  542.                        PicturePtr dst,
  543.                        int16_t src_x, int16_t src_y,
  544.                        int16_t dst_x, int16_t dst_y,
  545.                        int16_t width, int16_t height,
  546.                        struct sna_composite_op *tmp,
  547.                        bool fallback);
  548. bool sna_blt_composite__convert(struct sna *sna,
  549.                                 int x, int y,
  550.                                 int width, int height,
  551.                        struct sna_composite_op *tmp);
  552.  
  553. bool sna_blt_fill(struct sna *sna, uint8_t alu,
  554.                   struct kgem_bo *bo,
  555.                   int bpp,
  556.                   uint32_t pixel,
  557.                   struct sna_fill_op *fill);
  558.  
  559. bool sna_blt_copy(struct sna *sna, uint8_t alu,
  560.                   struct kgem_bo *src,
  561.                   struct kgem_bo *dst,
  562.                   int bpp,
  563.                   struct sna_copy_op *copy);
  564.  
  565. bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu,
  566.                         struct kgem_bo *bo,
  567.                         int bpp,
  568.                         uint32_t pixel,
  569.                         const BoxRec *box, int n);
  570.  
  571. bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu,
  572.                         struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
  573.                         struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
  574.                         int bpp,
  575.                         const BoxRec *box, int n);
  576. bool sna_blt_copy_boxes_fallback(struct sna *sna, uint8_t alu,
  577.                                  PixmapPtr src, struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
  578.                                  PixmapPtr dst, struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
  579.                                  const BoxRec *box, int nbox);
  580.  
  581. bool _sna_get_pixel_from_rgba(uint32_t *pixel,
  582.                              uint16_t red,
  583.                              uint16_t green,
  584.                              uint16_t blue,
  585.                              uint16_t alpha,
  586.                              uint32_t format);
  587.  
  588. static inline bool
  589. sna_get_pixel_from_rgba(uint32_t * pixel,
  590.                         uint16_t red,
  591.                         uint16_t green,
  592.                         uint16_t blue,
  593.                         uint16_t alpha,
  594.                         uint32_t format)
  595. {
  596.         switch (format) {
  597.         case PICT_x8r8g8b8:
  598.                 alpha = 0xffff;
  599.                 /* fall through to re-use a8r8g8b8 expansion */
  600.         case PICT_a8r8g8b8:
  601.                 *pixel = ((alpha >> 8 << 24) |
  602.                           (red >> 8 << 16) |
  603.                           (green & 0xff00) |
  604.                           (blue >> 8));
  605.                 return TRUE;
  606.         case PICT_a8:
  607.                 *pixel = alpha >> 8;
  608.                 return TRUE;
  609.         }
  610.  
  611.         return _sna_get_pixel_from_rgba(pixel, red, green, blue, alpha, format);
  612. }
  613.  
  614. struct kgem_bo *
  615. __sna_render_pixmap_bo(struct sna *sna,
  616.                        PixmapPtr pixmap,
  617.                        const BoxRec *box,
  618.                        bool blt);
  619.  
  620. int
  621. sna_render_pixmap_bo(struct sna *sna,
  622.                      struct sna_composite_channel *channel,
  623.                      PixmapPtr pixmap,
  624.                      int16_t x, int16_t y,
  625.                      int16_t w, int16_t h,
  626.                      int16_t dst_x, int16_t dst_y);
  627.  
  628. bool
  629. sna_render_pixmap_partial(struct sna *sna,
  630.                           PixmapPtr pixmap,
  631.                           struct kgem_bo *bo,
  632.                           struct sna_composite_channel *channel,
  633.                           int16_t x, int16_t y,
  634.                           int16_t w, int16_t h);
  635.  
  636. int
  637. sna_render_picture_extract(struct sna *sna,
  638.                            PicturePtr picture,
  639.                            struct sna_composite_channel *channel,
  640.                            int16_t x, int16_t y,
  641.                            int16_t w, int16_t h,
  642.                            int16_t dst_x, int16_t dst_y);
  643.  
  644. int
  645. sna_render_picture_approximate_gradient(struct sna *sna,
  646.                                         PicturePtr picture,
  647.                                         struct sna_composite_channel *channel,
  648.                                         int16_t x, int16_t y,
  649.                                         int16_t w, int16_t h,
  650.                                         int16_t dst_x, int16_t dst_y);
  651.  
  652. int
  653. sna_render_picture_fixup(struct sna *sna,
  654.                          PicturePtr picture,
  655.                          struct sna_composite_channel *channel,
  656.                          int16_t x, int16_t y,
  657.                          int16_t w, int16_t h,
  658.                          int16_t dst_x, int16_t dst_y);
  659.  
  660. int
  661. sna_render_picture_convert(struct sna *sna,
  662.                            PicturePtr picture,
  663.                            struct sna_composite_channel *channel,
  664.                            PixmapPtr pixmap,
  665.                            int16_t x, int16_t y,
  666.                            int16_t w, int16_t h,
  667.                            int16_t dst_x, int16_t dst_y,
  668.                            bool fixup_alpha);
  669.  
  670. inline static void sna_render_composite_redirect_init(struct sna_composite_op *op)
  671. {
  672.         struct sna_composite_redirect *t = &op->redirect;
  673.         t->real_bo = NULL;
  674.         t->damage = NULL;
  675. }
  676.  
  677. bool
  678. sna_render_composite_redirect(struct sna *sna,
  679.                               struct sna_composite_op *op,
  680.                               int x, int y, int width, int height,
  681.                               bool partial);
  682.  
  683. void
  684. sna_render_composite_redirect_done(struct sna *sna,
  685.                                    const struct sna_composite_op *op);
  686.  
  687. bool
  688. sna_composite_mask_is_opaque(PicturePtr mask);
  689. #endif
  690.  
  691. void sna_vertex_init(struct sna *sna);
  692.  
  693. static inline void sna_vertex_lock(struct sna_render *r)
  694. {
  695. //      pthread_mutex_lock(&r->lock);
  696. }
  697.  
  698. static inline void sna_vertex_acquire__locked(struct sna_render *r)
  699. {
  700.         r->active++;
  701. }
  702.  
  703. static inline void sna_vertex_unlock(struct sna_render *r)
  704. {
  705. //      pthread_mutex_unlock(&r->lock);
  706. }
  707.  
  708. static inline void sna_vertex_release__locked(struct sna_render *r)
  709. {
  710.         assert(r->active > 0);
  711.         --r->active;
  712. //      if (--r->active == 0)
  713. //              pthread_cond_signal(&r->wait);
  714. }
  715.  
  716. static inline bool sna_vertex_wait__locked(struct sna_render *r)
  717. {
  718.         bool was_active = r->active;
  719. //      while (r->active)
  720. //              pthread_cond_wait(&r->wait, &r->lock);
  721.         return was_active;
  722. }
  723.  
  724. #define alphaless(format) PICT_FORMAT(PICT_FORMAT_BPP(format),          \
  725.                                       PICT_FORMAT_TYPE(format),         \
  726.                                       0,                                \
  727.                                       PICT_FORMAT_R(format),            \
  728.                                       PICT_FORMAT_G(format),            \
  729.                                       PICT_FORMAT_B(format))
  730. static bool
  731. gen3_blit_tex(struct sna *sna,
  732.               uint8_t op, bool scale,
  733.                       PixmapPtr src, struct kgem_bo *src_bo,
  734.                       PixmapPtr mask,struct kgem_bo *mask_bo,
  735.                       PixmapPtr dst, struct kgem_bo *dst_bo,
  736.               int32_t src_x, int32_t src_y,
  737.               int32_t msk_x, int32_t msk_y,
  738.               int32_t dst_x, int32_t dst_y,
  739.               int32_t width, int32_t height,
  740.               struct sna_composite_op *tmp);
  741. static bool
  742. gen4_blit_tex(struct sna *sna,
  743.               uint8_t op, bool scale,
  744.                       PixmapPtr src, struct kgem_bo *src_bo,
  745.                       PixmapPtr mask,struct kgem_bo *mask_bo,
  746.                       PixmapPtr dst, struct kgem_bo *dst_bo,
  747.               int32_t src_x, int32_t src_y,
  748.               int32_t msk_x, int32_t msk_y,
  749.               int32_t dst_x, int32_t dst_y,
  750.               int32_t width, int32_t height,
  751.               struct sna_composite_op *tmp);
  752.  
  753. static bool
  754. gen5_blit_tex(struct sna *sna,
  755.               uint8_t op, bool scale,
  756.                       PixmapPtr src, struct kgem_bo *src_bo,
  757.                       PixmapPtr mask,struct kgem_bo *mask_bo,
  758.                       PixmapPtr dst, struct kgem_bo *dst_bo,
  759.               int32_t src_x, int32_t src_y,
  760.               int32_t msk_x, int32_t msk_y,
  761.               int32_t dst_x, int32_t dst_y,
  762.               int32_t width, int32_t height,
  763.               struct sna_composite_op *tmp);
  764.  
  765. static bool
  766. gen6_blit_tex(struct sna *sna,
  767.               uint8_t op, bool scale,
  768.                       PixmapPtr src, struct kgem_bo *src_bo,
  769.                       PixmapPtr mask,struct kgem_bo *mask_bo,
  770.                       PixmapPtr dst, struct kgem_bo *dst_bo,
  771.               int32_t src_x, int32_t src_y,
  772.               int32_t msk_x, int32_t msk_y,
  773.               int32_t dst_x, int32_t dst_y,
  774.               int32_t width, int32_t height,
  775.               struct sna_composite_op *tmp);
  776.  
  777. static bool
  778. gen7_blit_tex(struct sna *sna,
  779.               uint8_t op, bool scale,
  780.                       PixmapPtr src, struct kgem_bo *src_bo,
  781.                       PixmapPtr mask,struct kgem_bo *mask_bo,
  782.                       PixmapPtr dst, struct kgem_bo *dst_bo,
  783.               int32_t src_x, int32_t src_y,
  784.               int32_t msk_x, int32_t msk_y,
  785.               int32_t dst_x, int32_t dst_y,
  786.               int32_t width, int32_t height,
  787.               struct sna_composite_op *tmp);
  788.  
  789. #endif /* SNA_RENDER_H */
  790.