# lv_draw_sw_mask.h (/api/private/draw/sw/lv_draw_sw_mask_h)



<RelatedHeaders name="lv_draw_sw_mask_private.h" isPrivate="false" />

<ApiSummary functions="10" enums="3" typedefs="1" macros="2" />

Functions [#functions]

<ApiMember kind="function" name="lv_draw_sw_mask_init" file="private/draw/sw/lv_draw_sw_mask.h" line="68" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L68">
  lv_draw_sw_mask_init [#lv_draw_sw_mask_init]

  ```c title=" " lineNumbers=1
  void lv_draw_sw_mask_init(void)
  ```
</ApiMember>

<ApiMember kind="function" name="lv_draw_sw_mask_deinit" file="private/draw/sw/lv_draw_sw_mask.h" line="70" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L70">
  lv_draw_sw_mask_deinit [#lv_draw_sw_mask_deinit]

  ```c title=" " lineNumbers=1
  void lv_draw_sw_mask_deinit(void)
  ```
</ApiMember>

<ApiMember kind="function" name="lv_draw_sw_mask_apply" file="private/draw/sw/lv_draw_sw_mask.h" line="84" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L84">
  lv_draw_sw_mask_apply [#lv_draw_sw_mask_apply]

  Apply the added buffers on a line. Used internally by the library's drawing routines.

  ```c title=" " lineNumbers=1
  lv_draw_sw_mask_res_t lv_draw_sw_mask_apply(void *masks[], lv_opa_t *mask_buf, int32_t abs_x, int32_t abs_y, int32_t len)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name       | Type                                             | Description                                                                               |
  | ---------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------- |
  | `masks`    | `void *`                                         | the masks list to apply, must be ended with NULL pointer in array.                        |
  | `mask_buf` | <ApiLink name="lv_opa_t" display="lv_opa_t *" /> | store the result mask here. Has to be `len` byte long. Should be initialized with `0xFF`. |
  | `abs_x`    | `int32_t`                                        | absolute X coordinate where the line to calculate start                                   |
  | `abs_y`    | `int32_t`                                        | absolute Y coordinate where the line to calculate start                                   |
  | `len`      | `int32_t`                                        | length of the line to calculate (in pixel count)                                          |

  **Returns:** <ApiLink name="lv_draw_sw_mask_res_t" /> — One of these values:

  * `LV_DRAW_MASK_RES_FULL_TRANSP`: the whole line is transparent. `mask_buf` is not set to zero
  * `LV_DRAW_MASK_RES_FULL_COVER`: the whole line is fully visible. `mask_buf` is unchanged
  * `LV_DRAW_MASK_RES_CHANGED`: `mask_buf` has changed, it shows the desired opacity of each pixel in the given line
</ApiMember>

<ApiMember kind="function" name="lv_draw_sw_mask_free_param" file="private/draw/sw/lv_draw_sw_mask.h" line="96" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L96">
  lv_draw_sw_mask_free_param [#lv_draw_sw_mask_free_param]

  Free the data from the parameter. It's called inside `lv_draw_sw_mask_remove_id` and `lv_draw_sw_mask_remove_custom` Needs to be called only in special cases when the mask is not added by `lv_draw_mask_add` and not removed by `lv_draw_mask_remove_id` or `lv_draw_mask_remove_custom`

  ```c title=" " lineNumbers=1
  void lv_draw_sw_mask_free_param(void *p)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name | Type     | Description                 |
  | ---- | -------- | --------------------------- |
  | `p`  | `void *` | pointer to a mask parameter |
</ApiMember>

<ApiMember kind="function" name="lv_draw_sw_mask_line_points_init" file="private/draw/sw/lv_draw_sw_mask.h" line="109" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L109">
  lv_draw_sw_mask_line_points_init [#lv_draw_sw_mask_line_points_init]

  Initialize a line mask from two points.

  ```c title=" " lineNumbers=1
  void lv_draw_sw_mask_line_points_init(lv_draw_sw_mask_line_param_t *param, int32_t p1x, int32_t p1y, int32_t p2x, int32_t p2y, lv_draw_sw_mask_line_side_t side)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name    | Type                                                                                     | Description                                                                                                                                                                                                                               |
  | ------- | ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `param` | <ApiLink name="lv_draw_sw_mask_line_param_t" display="lv_draw_sw_mask_line_param_t *" /> | pointer to a `lv_draw_mask_param_t` to initialize                                                                                                                                                                                         |
  | `p1x`   | `int32_t`                                                                                | X coordinate of the first point of the line                                                                                                                                                                                               |
  | `p1y`   | `int32_t`                                                                                | Y coordinate of the first point of the line                                                                                                                                                                                               |
  | `p2x`   | `int32_t`                                                                                | X coordinate of the second point of the line                                                                                                                                                                                              |
  | `p2y`   | `int32_t`                                                                                | y coordinate of the second point of the line                                                                                                                                                                                              |
  | `side`  | <ApiLink name="lv_draw_sw_mask_line_side_t" />                                           | and element of `lv_draw_mask_line_side_t` to describe which side to keep. With `LV_DRAW_MASK_LINE_SIDE_LEFT/RIGHT` and horizontal line all pixels are kept With `LV_DRAW_MASK_LINE_SIDE_TOP/BOTTOM` and vertical line all pixels are kept |
</ApiMember>

<ApiMember kind="function" name="lv_draw_sw_mask_line_angle_init" file="private/draw/sw/lv_draw_sw_mask.h" line="123" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L123">
  lv_draw_sw_mask_line_angle_init [#lv_draw_sw_mask_line_angle_init]

  Initialize a line mask from a point and an angle.

  ```c title=" " lineNumbers=1
  void lv_draw_sw_mask_line_angle_init(lv_draw_sw_mask_line_param_t *param, int32_t px, int32_t py, int16_t angle, lv_draw_sw_mask_line_side_t side)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name    | Type                                                                                     | Description                                                                                                                                                                                                                              |
  | ------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `param` | <ApiLink name="lv_draw_sw_mask_line_param_t" display="lv_draw_sw_mask_line_param_t *" /> | pointer to a `lv_draw_mask_param_t` to initialize                                                                                                                                                                                        |
  | `px`    | `int32_t`                                                                                | X coordinate of a point of the line                                                                                                                                                                                                      |
  | `py`    | `int32_t`                                                                                | X coordinate of a point of the line                                                                                                                                                                                                      |
  | `angle` | `int16_t`                                                                                | right 0 deg, bottom: 90                                                                                                                                                                                                                  |
  | `side`  | <ApiLink name="lv_draw_sw_mask_line_side_t" />                                           | an element of `lv_draw_mask_line_side_t` to describe which side to keep. With `LV_DRAW_MASK_LINE_SIDE_LEFT/RIGHT` and horizontal line all pixels are kept With `LV_DRAW_MASK_LINE_SIDE_TOP/BOTTOM` and vertical line all pixels are kept |
</ApiMember>

<ApiMember kind="function" name="lv_draw_sw_mask_angle_init" file="private/draw/sw/lv_draw_sw_mask.h" line="134" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L134">
  lv_draw_sw_mask_angle_init [#lv_draw_sw_mask_angle_init]

  Initialize an angle mask.

  ```c title=" " lineNumbers=1
  void lv_draw_sw_mask_angle_init(lv_draw_sw_mask_angle_param_t *param, int32_t vertex_x, int32_t vertex_y, int32_t start_angle, int32_t end_angle)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name          | Type                                                                                       | Description                                                       |
  | ------------- | ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------- |
  | `param`       | <ApiLink name="lv_draw_sw_mask_angle_param_t" display="lv_draw_sw_mask_angle_param_t *" /> | pointer to a `lv_draw_mask_param_t` to initialize                 |
  | `vertex_x`    | `int32_t`                                                                                  | X coordinate of the angle vertex (absolute coordinates)           |
  | `vertex_y`    | `int32_t`                                                                                  | Y coordinate of the angle vertex (absolute coordinates)           |
  | `start_angle` | `int32_t`                                                                                  | start angle in degrees. 0 deg on the right, 90 deg, on the bottom |
  | `end_angle`   | `int32_t`                                                                                  | end angle                                                         |
</ApiMember>

<ApiMember kind="function" name="lv_draw_sw_mask_radius_init" file="private/draw/sw/lv_draw_sw_mask.h" line="145" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L145">
  lv_draw_sw_mask_radius_init [#lv_draw_sw_mask_radius_init]

  Initialize a fade mask.

  ```c title=" " lineNumbers=1
  lv_result_t lv_draw_sw_mask_radius_init(lv_draw_sw_mask_radius_param_t *param, const lv_area_t *rect, int32_t radius, bool inv)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type                                                                                         | Description                                                                          |
  | -------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
  | `param`  | <ApiLink name="lv_draw_sw_mask_radius_param_t" display="lv_draw_sw_mask_radius_param_t *" /> | pointer to an `lv_draw_mask_radius_param_t` to initialize                            |
  | `rect`   | <ApiLink name="lv_area_t" display="const lv_area_t *" />                                     | coordinates of the rectangle to affect (absolute coordinates)                        |
  | `radius` | `int32_t`                                                                                    | radius of the rectangle                                                              |
  | `inv`    | `bool`                                                                                       | true: keep the pixels inside the rectangle; keep the pixels outside of the rectangle |

  **Returns:** <ApiLink name="lv_result_t" /> — LV\_RESULT\_OK if the mask radius was initialized correctly else LV\_RESULT\_INVALID
</ApiMember>

<ApiMember kind="function" name="lv_draw_sw_mask_fade_init" file="private/draw/sw/lv_draw_sw_mask.h" line="157" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L157">
  lv_draw_sw_mask_fade_init [#lv_draw_sw_mask_fade_init]

  Initialize a fade mask.

  ```c title=" " lineNumbers=1
  void lv_draw_sw_mask_fade_init(lv_draw_sw_mask_fade_param_t *param, const lv_area_t *coords, lv_opa_t opa_top, int32_t y_top, lv_opa_t opa_bottom, int32_t y_bottom)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                                                     | Description                                                    |
  | ------------ | ---------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
  | `param`      | <ApiLink name="lv_draw_sw_mask_fade_param_t" display="lv_draw_sw_mask_fade_param_t *" /> | pointer to a `lv_draw_mask_param_t` to initialize              |
  | `coords`     | <ApiLink name="lv_area_t" display="const lv_area_t *" />                                 | coordinates of the area to affect (absolute coordinates)       |
  | `opa_top`    | <ApiLink name="lv_opa_t" />                                                              | opacity on the top                                             |
  | `y_top`      | `int32_t`                                                                                | at which coordinate start to change to opacity to `opa_bottom` |
  | `opa_bottom` | <ApiLink name="lv_opa_t" />                                                              | opacity at the bottom                                          |
  | `y_bottom`   | `int32_t`                                                                                | at which coordinate reach `opa_bottom`.                        |
</ApiMember>

<ApiMember kind="function" name="lv_draw_sw_mask_map_init" file="private/draw/sw/lv_draw_sw_mask.h" line="167" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L167">
  lv_draw_sw_mask_map_init [#lv_draw_sw_mask_map_init]

  Initialize a map mask.

  ```c title=" " lineNumbers=1
  void lv_draw_sw_mask_map_init(lv_draw_sw_mask_map_param_t *param, const lv_area_t *coords, const lv_opa_t *map)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name     | Type                                                                                   | Description                                       |
  | -------- | -------------------------------------------------------------------------------------- | ------------------------------------------------- |
  | `param`  | <ApiLink name="lv_draw_sw_mask_map_param_t" display="lv_draw_sw_mask_map_param_t *" /> | pointer to a `lv_draw_mask_param_t` to initialize |
  | `coords` | <ApiLink name="lv_area_t" display="const lv_area_t *" />                               | coordinates of the map (absolute coordinates)     |
  | `map`    | <ApiLink name="lv_opa_t" display="const lv_opa_t *" />                                 | array of bytes with the mask values               |
</ApiMember>

Enums [#enums]

<ApiMember kind="enum" name="lv_draw_sw_mask_res_t" file="private/draw/sw/lv_draw_sw_mask.h" line="32" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L32">
  lv_draw_sw_mask_res_t [#lv_draw_sw_mask_res_t]

  | Name                             |
  | -------------------------------- |
  | `LV_DRAW_SW_MASK_RES_TRANSP`     |
  | `LV_DRAW_SW_MASK_RES_FULL_COVER` |
  | `LV_DRAW_SW_MASK_RES_CHANGED`    |
  | `LV_DRAW_SW_MASK_RES_UNKNOWN`    |
</ApiMember>

<ApiMember kind="enum" name="lv_draw_sw_mask_type_t" file="private/draw/sw/lv_draw_sw_mask.h" line="41" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L41">
  lv_draw_sw_mask_type_t [#lv_draw_sw_mask_type_t]

  | Name                          |
  | ----------------------------- |
  | `LV_DRAW_SW_MASK_TYPE_LINE`   |
  | `LV_DRAW_SW_MASK_TYPE_ANGLE`  |
  | `LV_DRAW_SW_MASK_TYPE_RADIUS` |
  | `LV_DRAW_SW_MASK_TYPE_FADE`   |
  | `LV_DRAW_SW_MASK_TYPE_MAP`    |
</ApiMember>

<ApiMember kind="enum" name="lv_draw_sw_mask_line_side_t" file="private/draw/sw/lv_draw_sw_mask.h" line="49" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L49">
  lv_draw_sw_mask_line_side_t [#lv_draw_sw_mask_line_side_t]

  | Name                               | Value |
  | ---------------------------------- | ----- |
  | `LV_DRAW_SW_MASK_LINE_SIDE_LEFT`   | `0`   |
  | `LV_DRAW_SW_MASK_LINE_SIDE_RIGHT`  |       |
  | `LV_DRAW_SW_MASK_LINE_SIDE_TOP`    |       |
  | `LV_DRAW_SW_MASK_LINE_SIDE_BOTTOM` |       |
</ApiMember>

<TypeUsedBy name="lv_draw_sw_mask_line_side_t" count="2">
  * `lv_draw_sw_mask_line_points_init` — param `side`
  * `lv_draw_sw_mask_line_angle_init` — param `side`
</TypeUsedBy>

Typedefs [#typedefs]

<ApiMember kind="typedef" name="lv_draw_sw_mask_xcb_t" file="private/draw/sw/lv_draw_sw_mask.h" line="60" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L60">
  lv_draw_sw_mask_xcb_t [#lv_draw_sw_mask_xcb_t]

  ```c title=" " lineNumbers=1
  typedef lv_draw_sw_mask_res_t(* lv_draw_sw_mask_xcb_t) (lv_opa_t *mask_buf, int32_t abs_x, int32_t abs_y, int32_t len, void *p)
  ```

  A common callback type for every mask type. Used internally by the library.
</ApiMember>

Macros [#macros]

<ApiMember kind="macro" name="LV_MASK_ID_INV" file="private/draw/sw/lv_draw_sw_mask.h" line="21" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L21">
  LV_MASK_ID_INV [#lv_mask_id_inv]

  ```c title=" " lineNumbers=1
  #define LV_MASK_ID_INV (-1)
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_MASK_MAX_NUM" file="private/draw/sw/lv_draw_sw_mask.h" line="23" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/draw/sw/lv_draw_sw_mask.h#L23">
  LV_MASK_MAX_NUM [#lv_mask_max_num]

  ```c title=" " lineNumbers=1
  #define LV_MASK_MAX_NUM 16
  ```
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_draw_sw.h&#x22;]" includedBy="[&#x22;lv_draw_sw_blend_private.h&#x22;, &#x22;lv_draw_sw_mask_private.h&#x22;, &#x22;lvgl_private.h&#x22;]" transitiveIncludes="[&#x22;lv_blend_neon.h&#x22;, &#x22;lv_cache.h&#x22;, &#x22;lv_cache_class.h&#x22;, &#x22;lv_cache_entry.h&#x22;, &#x22;lv_cache_lru_ll.h&#x22;, &#x22;lv_cache_lru_rb.h&#x22;, &#x22;lv_cache_sc_da.h&#x22;, &#x22;lv_draw_private.h&#x22;, &#x22;lv_draw_sw_blend.h&#x22;, &#x22;lv_draw_sw_blend_neon_to_rgb565.h&#x22;, &#x22;lv_draw_sw_blend_neon_to_rgb888.h&#x22;, &#x22;lv_image_cache.h&#x22;, &#x22;lv_iter_private.h&#x22;, &#x22;lv_os_private.h&#x22;]" />
