Subversion Repositories Kolibri OS

Rev

Rev 2351 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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