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