asset_corner_box.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. * Copyright (c) 2009-2021 Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. /*============================ INCLUDES ======================================*/
  19. #include "asset_corner_box.h"
  20. #include "arm_2d.h"
  21. #include "arm_2d_helper.h"
  22. #include "Arm2D_common.h"
  23. #include <math.h>
  24. #if defined(__clang__)
  25. # pragma clang diagnostic push
  26. # pragma clang diagnostic ignored "-Wsign-conversion"
  27. # pragma clang diagnostic ignored "-Wpadded"
  28. # pragma clang diagnostic ignored "-Wcast-qual"
  29. # pragma clang diagnostic ignored "-Wcast-align"
  30. # pragma clang diagnostic ignored "-Wmissing-field-initializers"
  31. # pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
  32. # pragma clang diagnostic ignored "-Wmissing-braces"
  33. # pragma clang diagnostic ignored "-Wunused-const-variable"
  34. # pragma clang diagnostic ignored "-Wmissing-declarations"
  35. # pragma clang diagnostic ignored "-Wmissing-variable-declarations"
  36. # pragma clang diagnostic ignored "-Winitializer-overrides"
  37. #endif
  38. /*============================ MACROS ========================================*/
  39. /*============================ MACROFIED FUNCTIONS ===========================*/
  40. /*============================ TYPES =========================================*/
  41. /*============================ GLOBAL VARIABLES ==============================*/
  42. extern
  43. const arm_2d_tile_t c_tileWhiteDotAlphaQuarter;
  44. /*============================ PROTOTYPES ====================================*/
  45. /*============================ LOCAL VARIABLES ===============================*/
  46. impl_fb(s_tCorner, 7, 7, uint8_t,
  47. .tInfo = {
  48. .bIsRoot = true,
  49. .bHasEnforcedColour = true,
  50. .tColourInfo = {
  51. .chScheme = ARM_2D_COLOUR_8BIT,
  52. },
  53. },
  54. )
  55. /*============================ IMPLEMENTATION ================================*/
  56. void draw_round_corner_box( const arm_2d_tile_t *ptTarget,
  57. const arm_2d_region_t *ptRegion,
  58. uint16_t hwColour,
  59. uint8_t chAlpha,
  60. bool bIsNewFrame)
  61. {
  62. ARM_2D_UNUSED(bIsNewFrame);
  63. if (NULL == ptRegion) {
  64. ptRegion = (const arm_2d_region_t *)&(ptTarget->tRegion);
  65. }
  66. arm_2d_region_t tRegion = *ptRegion;
  67. //! copy the top left corner
  68. arm_2d_c8bit_tile_copy( &c_tileWhiteDotAlphaQuarter,
  69. &s_tCorner,
  70. NULL,
  71. ARM_2D_CP_MODE_COPY |
  72. ARM_2D_CP_MODE_X_MIRROR |
  73. ARM_2D_CP_MODE_Y_MIRROR);
  74. arm_2d_fill_colour_with_mask_and_opacity(
  75. ptTarget,
  76. &tRegion,
  77. &s_tCorner,
  78. (arm_2d_color_rgb565_t){hwColour},
  79. chAlpha);
  80. arm_2d_op_wait_async(NULL);
  81. //! copy the top right corner
  82. tRegion.tLocation.iX += ptRegion->tSize.iWidth - s_tCorner.tRegion.tSize.iWidth;
  83. arm_2d_c8bit_tile_copy( &c_tileWhiteDotAlphaQuarter,
  84. &s_tCorner,
  85. NULL,
  86. ARM_2D_CP_MODE_COPY |
  87. ARM_2D_CP_MODE_Y_MIRROR);
  88. arm_2d_fill_colour_with_mask_and_opacity(
  89. ptTarget,
  90. &tRegion,
  91. &s_tCorner,
  92. (arm_2d_color_rgb565_t){hwColour},
  93. chAlpha);
  94. arm_2d_op_wait_async(NULL);
  95. arm_2dp_fill_colour_with_opacity(
  96. NULL,
  97. ptTarget,
  98. &(arm_2d_region_t) {
  99. .tSize = {
  100. .iHeight = s_tCorner.tRegion.tSize.iHeight,
  101. .iWidth = tRegion.tSize.iWidth - s_tCorner.tRegion.tSize.iWidth * 2,
  102. },
  103. .tLocation = {
  104. .iX = ptRegion->tLocation.iX + s_tCorner.tRegion.tSize.iWidth,
  105. .iY = ptRegion->tLocation.iY,
  106. },
  107. },
  108. (arm_2d_color_rgb565_t){hwColour},
  109. chAlpha);
  110. arm_2d_op_wait_async(NULL);
  111. arm_2dp_fill_colour_with_opacity(
  112. NULL,
  113. ptTarget,
  114. &(arm_2d_region_t) {
  115. .tSize = {
  116. .iHeight = tRegion.tSize.iHeight - s_tCorner.tRegion.tSize.iHeight * 2,
  117. .iWidth = tRegion.tSize.iWidth,
  118. },
  119. .tLocation = {
  120. .iX = ptRegion->tLocation.iX,
  121. .iY = ptRegion->tLocation.iY + s_tCorner.tRegion.tSize.iHeight,
  122. },
  123. },
  124. (arm_2d_color_rgb565_t){hwColour},
  125. chAlpha);
  126. arm_2d_op_wait_async(NULL);
  127. //! copy the bottom right corner
  128. tRegion.tLocation.iY += ptRegion->tSize.iHeight - s_tCorner.tRegion.tSize.iHeight;
  129. arm_2d_c8bit_tile_copy( &c_tileWhiteDotAlphaQuarter,
  130. &s_tCorner,
  131. NULL,
  132. ARM_2D_CP_MODE_COPY);
  133. arm_2d_fill_colour_with_mask_and_opacity(
  134. ptTarget,
  135. &tRegion,
  136. &s_tCorner,
  137. (arm_2d_color_rgb565_t){hwColour},
  138. chAlpha);
  139. arm_2d_op_wait_async(NULL);
  140. //! copy the bottom left corner
  141. tRegion.tLocation.iX = ptRegion->tLocation.iX;
  142. arm_2d_c8bit_tile_copy( &c_tileWhiteDotAlphaQuarter,
  143. &s_tCorner,
  144. NULL,
  145. ARM_2D_CP_MODE_COPY |
  146. ARM_2D_CP_MODE_X_MIRROR );
  147. arm_2d_fill_colour_with_mask_and_opacity(
  148. ptTarget,
  149. &tRegion,
  150. &s_tCorner,
  151. (arm_2d_color_rgb565_t){hwColour},
  152. chAlpha);
  153. arm_2d_op_wait_async(NULL);
  154. arm_2dp_fill_colour_with_opacity(
  155. NULL,
  156. ptTarget,
  157. &(arm_2d_region_t) {
  158. .tSize = {
  159. .iHeight = s_tCorner.tRegion.tSize.iHeight,
  160. .iWidth = tRegion.tSize.iWidth - s_tCorner.tRegion.tSize.iWidth * 2,
  161. },
  162. .tLocation = {
  163. .iX = tRegion.tLocation.iX + s_tCorner.tRegion.tSize.iWidth,
  164. .iY = tRegion.tLocation.iY,
  165. },
  166. },
  167. (arm_2d_color_rgb565_t){hwColour},
  168. chAlpha);
  169. arm_2d_op_wait_async(NULL);
  170. }
  171. #if defined(__clang__)
  172. # pragma clang diagnostic pop
  173. #endif