agg_pixfmt_transposer.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //----------------------------------------------------------------------------
  2. // Anti-Grain Geometry - Version 2.4
  3. // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
  4. //
  5. // Permission to copy, use, modify, sell and distribute this software
  6. // is granted provided this copyright notice appears in all copies.
  7. // This software is provided "as is" without express or implied
  8. // warranty, and with no claim as to its suitability for any purpose.
  9. //
  10. //----------------------------------------------------------------------------
  11. // Contact: mcseem@antigrain.com
  12. // mcseemagg@yahoo.com
  13. // http://www.antigrain.com
  14. //----------------------------------------------------------------------------
  15. #ifndef AGG_PIXFMT_TRANSPOSER_INCLUDED
  16. #define AGG_PIXFMT_TRANSPOSER_INCLUDED
  17. #include "agg_basics.h"
  18. namespace agg
  19. {
  20. //=======================================================pixfmt_transposer
  21. template<class PixFmt> class pixfmt_transposer
  22. {
  23. public:
  24. typedef PixFmt pixfmt_type;
  25. typedef typename pixfmt_type::color_type color_type;
  26. typedef typename pixfmt_type::row_data row_data;
  27. typedef typename color_type::value_type value_type;
  28. typedef typename color_type::calc_type calc_type;
  29. //--------------------------------------------------------------------
  30. pixfmt_transposer() : m_pixf(0) {}
  31. explicit pixfmt_transposer(pixfmt_type& pixf) : m_pixf(&pixf) {}
  32. void attach(pixfmt_type& pixf) { m_pixf = &pixf; }
  33. //--------------------------------------------------------------------
  34. AGG_INLINE unsigned width() const { return m_pixf->height(); }
  35. AGG_INLINE unsigned height() const { return m_pixf->width(); }
  36. //--------------------------------------------------------------------
  37. AGG_INLINE color_type pixel(int x, int y) const
  38. {
  39. return m_pixf->pixel(y, x);
  40. }
  41. //--------------------------------------------------------------------
  42. AGG_INLINE void copy_pixel(int x, int y, const color_type& c)
  43. {
  44. m_pixf->copy_pixel(y, x, c);
  45. }
  46. //--------------------------------------------------------------------
  47. AGG_INLINE void blend_pixel(int x, int y,
  48. const color_type& c,
  49. int8u cover)
  50. {
  51. m_pixf->blend_pixel(y, x, c, cover);
  52. }
  53. //--------------------------------------------------------------------
  54. AGG_INLINE void copy_hline(int x, int y,
  55. unsigned len,
  56. const color_type& c)
  57. {
  58. m_pixf->copy_vline(y, x, len, c);
  59. }
  60. //--------------------------------------------------------------------
  61. AGG_INLINE void copy_vline(int x, int y,
  62. unsigned len,
  63. const color_type& c)
  64. {
  65. m_pixf->copy_hline(y, x, len, c);
  66. }
  67. //--------------------------------------------------------------------
  68. AGG_INLINE void blend_hline(int x, int y,
  69. unsigned len,
  70. const color_type& c,
  71. int8u cover)
  72. {
  73. m_pixf->blend_vline(y, x, len, c, cover);
  74. }
  75. //--------------------------------------------------------------------
  76. AGG_INLINE void blend_vline(int x, int y,
  77. unsigned len,
  78. const color_type& c,
  79. int8u cover)
  80. {
  81. m_pixf->blend_hline(y, x, len, c, cover);
  82. }
  83. //--------------------------------------------------------------------
  84. AGG_INLINE void blend_solid_hspan(int x, int y,
  85. unsigned len,
  86. const color_type& c,
  87. const int8u* covers)
  88. {
  89. m_pixf->blend_solid_vspan(y, x, len, c, covers);
  90. }
  91. //--------------------------------------------------------------------
  92. AGG_INLINE void blend_solid_vspan(int x, int y,
  93. unsigned len,
  94. const color_type& c,
  95. const int8u* covers)
  96. {
  97. m_pixf->blend_solid_hspan(y, x, len, c, covers);
  98. }
  99. //--------------------------------------------------------------------
  100. AGG_INLINE void copy_color_hspan(int x, int y,
  101. unsigned len,
  102. const color_type* colors)
  103. {
  104. m_pixf->copy_color_vspan(y, x, len, colors);
  105. }
  106. //--------------------------------------------------------------------
  107. AGG_INLINE void copy_color_vspan(int x, int y,
  108. unsigned len,
  109. const color_type* colors)
  110. {
  111. m_pixf->copy_color_hspan(y, x, len, colors);
  112. }
  113. //--------------------------------------------------------------------
  114. AGG_INLINE void blend_color_hspan(int x, int y,
  115. unsigned len,
  116. const color_type* colors,
  117. const int8u* covers,
  118. int8u cover)
  119. {
  120. m_pixf->blend_color_vspan(y, x, len, colors, covers, cover);
  121. }
  122. //--------------------------------------------------------------------
  123. AGG_INLINE void blend_color_vspan(int x, int y,
  124. unsigned len,
  125. const color_type* colors,
  126. const int8u* covers,
  127. int8u cover)
  128. {
  129. m_pixf->blend_color_hspan(y, x, len, colors, covers, cover);
  130. }
  131. private:
  132. pixfmt_type* m_pixf;
  133. };
  134. }
  135. #endif