glamor_transform.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright © 2014 Keith Packard
  3. *
  4. * Permission to use, copy, modify, distribute, and sell this software and its
  5. * documentation for any purpose is hereby granted without fee, provided that
  6. * the above copyright notice appear in all copies and that both that copyright
  7. * notice and this permission notice appear in supporting documentation, and
  8. * that the name of the copyright holders not be used in advertising or
  9. * publicity pertaining to distribution of the software without specific,
  10. * written prior permission. The copyright holders make no representations
  11. * about the suitability of this software for any purpose. It is provided "as
  12. * is" without express or implied warranty.
  13. *
  14. * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  16. * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18. * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  19. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  20. * OF THIS SOFTWARE.
  21. */
  22. #ifndef _GLAMOR_TRANSFORM_H_
  23. #define _GLAMOR_TRANSFORM_H_
  24. void
  25. glamor_set_destination_drawable(DrawablePtr drawable,
  26. int box_x,
  27. int box_y,
  28. Bool do_drawable_translate,
  29. Bool center_offset,
  30. GLint matrix_uniform_location,
  31. int *p_off_x,
  32. int *p_off_y);
  33. void
  34. glamor_set_color(PixmapPtr pixmap,
  35. CARD32 pixel,
  36. GLint uniform);
  37. Bool
  38. glamor_set_texture(PixmapPtr pixmap,
  39. PixmapPtr texture,
  40. int off_x,
  41. int off_y,
  42. GLint offset_uniform,
  43. GLint size_uniform);
  44. Bool
  45. glamor_set_solid(PixmapPtr pixmap,
  46. GCPtr gc,
  47. Bool use_alu,
  48. GLint uniform);
  49. Bool
  50. glamor_set_tiled(PixmapPtr pixmap,
  51. GCPtr gc,
  52. GLint offset_uniform,
  53. GLint size_uniform);
  54. Bool
  55. glamor_set_stippled(PixmapPtr pixmap,
  56. GCPtr gc,
  57. GLint fg_uniform,
  58. GLint offset_uniform,
  59. GLint size_uniform);
  60. /*
  61. * Vertex shader bits that transform X coordinates to pixmap
  62. * coordinates using the matrix computed above
  63. */
  64. #define GLAMOR_DECLARE_MATRIX "uniform vec4 v_matrix;\n"
  65. #define GLAMOR_X_POS(x) #x " *v_matrix.x + v_matrix.y"
  66. #define GLAMOR_Y_POS(y) #y " *v_matrix.z + v_matrix.w"
  67. #if 0
  68. #define GLAMOR_POS(dst,src) \
  69. " " #dst ".x = " #src ".x * v_matrix.x + v_matrix.y;\n" \
  70. " " #dst ".y = " #src ".y * v_matrix.z + v_matrix.w;\n" \
  71. " " #dst ".z = 0.0;\n" \
  72. " " #dst ".w = 1.0;\n"
  73. #endif
  74. #define GLAMOR_POS(dst,src) \
  75. " " #dst ".xy = " #src ".xy * v_matrix.xz + v_matrix.yw;\n" \
  76. " " #dst ".zw = vec2(0.0,1.0);\n"
  77. #endif /* _GLAMOR_TRANSFORM_H_ */