sw_rotate.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Copyright (c) 2020 Actions Technology Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file
  8. * @brief Utilities of sw rotation API
  9. */
  10. #ifndef ZEPHYR_FRAMEWORK_INCLUDE_DISPLAY_SW_ROTATE_H_
  11. #define ZEPHYR_FRAMEWORK_INCLUDE_DISPLAY_SW_ROTATE_H_
  12. #include "sw_math.h"
  13. /**
  14. * @defgroup display-util Display Utilities
  15. * @ingroup display_libraries
  16. * @{
  17. */
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. typedef struct sw_rotate_config {
  22. /* assistant variables */
  23. int32_t src_coord_x0; /* src X coord in .16 fixedpoint mapping to dest coord (0, 0) */
  24. int32_t src_coord_y0; /* src Y coord in .16 fixedpoint mapping to dest coord (0, 0) */
  25. int32_t src_coord_dx_ax; /* src X coord diff in .16 fixedpoint along the dest X-axis */
  26. int32_t src_coord_dy_ax; /* src Y coord diff in .16 fixedpoint along the dest X-axis */
  27. int32_t src_coord_dx_ay; /* src X coord diff in .16 fixedpoint along the dest Y-axis */
  28. int32_t src_coord_dy_ay; /* src Y coord diff in .16 fixedpoint along the dest Y-axis */
  29. } sw_rotate_config_t;
  30. /*
  31. * @brief generate a rotation configuration
  32. *
  33. * The pivot keep the same before and after rotation.
  34. *
  35. * @param draw_x x coord of top-left corner of draw area after rotation
  36. * @param draw_y y coord of top-left corner of draw area after rotation
  37. * @param img_x x coord of top-left corner of image area before rotation
  38. * @param img_y y coord of top-left corner of image area before rotation
  39. * @param pivot_x x coord of rotation pivot (the same pivot during rotation)
  40. * @param pivot_y y coord of rotation pivot (the same pivot during rotation)
  41. * @param angle rotation angle in 0.1 degree [0, 3600)
  42. * @param cfg rotation config generated in func sw_rotate_configure()
  43. *
  44. * @retval N/A
  45. */
  46. void sw_rotate_configure(int16_t draw_x, int16_t draw_y, int16_t img_x, int16_t img_y,
  47. int16_t pivot_x, int16_t pivot_y, uint16_t angle, sw_rotate_config_t *cfg);
  48. /*
  49. * @brief rotate an rgb565 image over rgb565 image
  50. *
  51. * @param dst address of dst image
  52. * @param src address of src image
  53. * @param dst_stride stride in pixels of dst image
  54. * @param src_w width in pixels of src image
  55. * @param src_h height in pixels of src image
  56. * @param x x offset from the top-left corner of original draw area in sw_rotate_configure()
  57. * @param y y offset from the top-left corner of original draw area in sw_rotate_configure()
  58. * @param w width in pixels of current draw area
  59. * @param h height in pixels of current draw area
  60. * @param cfg rotation config generated in func sw_rotate_configure()
  61. *
  62. * @retval N/A
  63. */
  64. void sw_rotate_rgb565_over_rgb565(void *dst, const void *src,
  65. uint16_t dst_stride, uint16_t src_w, uint16_t src_h,
  66. int16_t x, int16_t y, uint16_t w, uint16_t h,
  67. const sw_rotate_config_t *cfg);
  68. /*
  69. * @brief rotate an argb8565 image over rgb565 image
  70. *
  71. * @param dst address of dst image
  72. * @param src address of src image
  73. * @param dst_stride stride in pixels of dst image
  74. * @param src_w width in pixels of src image
  75. * @param src_h height in pixels of src image
  76. * @param x x offset from the top-left corner of original draw area in sw_rotate_configure()
  77. * @param y y offset from the top-left corner of original draw area in sw_rotate_configure()
  78. * @param w width in pixels of current draw area
  79. * @param h height in pixels of current draw area
  80. * @param cfg rotation config generated in func sw_rotate_configure()
  81. *
  82. * @retval N/A
  83. */
  84. void sw_rotate_argb8565_over_rgb565(void *dst, const void *src,
  85. uint16_t dst_stride, uint16_t src_w, uint16_t src_h,
  86. int16_t x, int16_t y, uint16_t w, uint16_t h,
  87. const sw_rotate_config_t *cfg);
  88. /*
  89. * @brief rotate an argb8888 image over rgb565 image
  90. *
  91. * @param dst address of dst image
  92. * @param src address of src image
  93. * @param dst_stride stride in pixels of dst image
  94. * @param src_w width in pixels of src image
  95. * @param src_h height in pixels of src image
  96. * @param x x offset from the top-left corner of original draw area in sw_rotate_configure()
  97. * @param y y offset from the top-left corner of original draw area in sw_rotate_configure()
  98. * @param w width in pixels of current draw area
  99. * @param h height in pixels of current draw area
  100. * @param cfg rotation config generated in func sw_rotate_configure()
  101. *
  102. * @retval N/A
  103. */
  104. void sw_rotate_argb8888_over_rgb565(void *dst, const void *src,
  105. uint16_t dst_stride, uint16_t src_w, uint16_t src_h,
  106. int16_t x, int16_t y, uint16_t w, uint16_t h,
  107. const sw_rotate_config_t *cfg);
  108. /*
  109. * @brief rotate an argb8888 image over argb8888 image
  110. *
  111. * @param dst address of dst image
  112. * @param src address of src image
  113. * @param dst_stride stride in pixels of dst image
  114. * @param src_w width in pixels of src image
  115. * @param src_h height in pixels of src image
  116. * @param x x offset from the top-left corner of original draw area in sw_rotate_configure()
  117. * @param y y offset from the top-left corner of original draw area in sw_rotate_configure()
  118. * @param w width in pixels of current draw area
  119. * @param h height in pixels of current draw area
  120. * @param cfg rotation config generated in func sw_rotate_configure()
  121. *
  122. * @retval N/A
  123. */
  124. void sw_rotate_argb8888_over_argb8888(void *dst, const void *src,
  125. uint16_t dst_stride, uint16_t src_w, uint16_t src_h,
  126. int16_t x, int16_t y, uint16_t w, uint16_t h,
  127. const sw_rotate_config_t *cfg);
  128. #ifdef __cplusplus
  129. }
  130. #endif
  131. /**
  132. * @}
  133. */
  134. #endif /* ZEPHYR_FRAMEWORK_INCLUDE_DISPLAY_SW_ROTATE_H_ */