sw_blend.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #include <display/sw_draw.h>
  2. #ifdef CONFIG_GUI_API_BROM
  3. #include <brom_interface.h>
  4. #endif
  5. void sw_blend_argb8565_over_rgb565(void *dst, const void *src,
  6. uint16_t dst_stride, uint16_t src_stride, uint16_t w, uint16_t h)
  7. {
  8. #ifdef CONFIG_GUI_API_BROM
  9. p_brom_libgui_api->p_sw_blend_argb8565_over_rgb565(
  10. dst, src, dst_stride, src_stride, w, h);
  11. #else
  12. const uint8_t *src8 = src;
  13. uint16_t *dst16 = dst;
  14. uint16_t src_y_step = src_stride * 3;
  15. uint16_t src_x_step = 3;
  16. for (int j = h; j > 0; j--) {
  17. const uint8_t *tmp_src8 = src8;
  18. uint16_t *tmp_dst = dst16;
  19. for (int i = w; i > 0; i--) {
  20. *tmp_dst = blend_rgb565_over_rgb565(*tmp_dst,
  21. ((uint16_t)tmp_src8[1] << 8) | tmp_src8[0], tmp_src8[2]);
  22. tmp_dst++;
  23. tmp_src8 += src_x_step;
  24. }
  25. dst16 += dst_stride;
  26. src8 += src_y_step;
  27. }
  28. #endif /* CONFIG_GUI_API_BROM */
  29. }
  30. void sw_blend_argb6666_over_rgb565(void *dst, const void *src,
  31. uint16_t dst_stride, uint16_t src_stride, uint16_t w, uint16_t h)
  32. {
  33. const uint8_t *src8 = src;
  34. uint16_t *dst16 = dst;
  35. uint16_t src_y_step = src_stride * 3;
  36. uint16_t src_x_step = 3;
  37. for (int j = h; j > 0; j--) {
  38. const uint8_t *tmp_src8 = src8;
  39. uint16_t *tmp_dst = dst16;
  40. for (int i = w; i > 0; i--) {
  41. *tmp_dst = blend_argb6666_over_rgb565(*tmp_dst, tmp_src8);
  42. tmp_dst++;
  43. tmp_src8 += src_x_step;
  44. }
  45. dst16 += dst_stride;
  46. src8 += src_y_step;
  47. }
  48. }
  49. void sw_blend_argb8888_over_rgb565(void *dst, const void *src,
  50. uint16_t dst_stride, uint16_t src_stride, uint16_t w, uint16_t h)
  51. {
  52. #ifdef CONFIG_GUI_API_BROM
  53. p_brom_libgui_api->p_sw_blend_argb8888_over_rgb565(
  54. dst, src, dst_stride, src_stride, w, h);
  55. #else
  56. const uint32_t *src32 = src;
  57. uint16_t *dst16 = dst;
  58. for (int j = h; j > 0; j--) {
  59. const uint32_t *tmp_src = src32;
  60. uint16_t *tmp_dst = dst16;
  61. for (int i = w; i > 0; i--) {
  62. *tmp_dst = blend_argb8888_over_rgb565(*tmp_dst, *tmp_src);
  63. tmp_dst++;
  64. tmp_src++;
  65. }
  66. src32 += src_stride;
  67. dst16 += dst_stride;
  68. }
  69. #endif /* CONFIG_GUI_API_BROM */
  70. }
  71. void sw_blend_argb8888_over_argb8888(void *dst, const void *src,
  72. uint16_t dst_stride, uint16_t src_stride, uint16_t w, uint16_t h)
  73. {
  74. #ifdef CONFIG_GUI_API_BROM
  75. p_brom_libgui_api->p_sw_blend_argb8888_over_argb8888(
  76. dst, src, dst_stride, src_stride, w, h);
  77. #else
  78. const uint32_t *src32 = src;
  79. uint32_t *dst32 = dst;
  80. for (int j = h; j > 0; j--) {
  81. const uint32_t *tmp_src = src32;
  82. uint32_t *tmp_dst = dst32;
  83. for (int i = w; i > 0; i--) {
  84. *tmp_dst = blend_argb8888_over_argb8888(*tmp_dst, *tmp_src);
  85. tmp_dst++;
  86. tmp_src++;
  87. }
  88. src32 += src_stride;
  89. dst32 += dst_stride;
  90. }
  91. #endif /* CONFIG_GUI_API_BROM */
  92. }