| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "lv_draw_pxp.h" |
| 17 |
|
| 18 |
#if LV_USE_PXP |
| 19 |
#if LV_USE_DRAW_PXP |
| 20 |
#include "lv_pxp_cfg.h" |
| 21 |
#include "lv_pxp_utils.h" |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
static void _pxp_fill(uint8_t * dest_buf, const lv_area_t * dest_area, int32_t dest_stride, |
| 36 |
lv_color_format_t dest_cf, const lv_draw_fill_dsc_t * dsc); |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
void lv_draw_pxp_fill(lv_draw_task_t * t) |
| 51 |
{ |
| 52 |
const lv_draw_fill_dsc_t * dsc = t->draw_dsc; |
| 53 |
const lv_area_t * coords = &t->area; |
| 54 |
|
| 55 |
if(dsc->opa <= (lv_opa_t)LV_OPA_MIN) |
| 56 |
return; |
| 57 |
|
| 58 |
lv_layer_t * layer = t->target_layer; |
| 59 |
lv_draw_buf_t * draw_buf = layer->draw_buf; |
| 60 |
|
| 61 |
lv_area_t rel_coords; |
| 62 |
lv_area_copy(&rel_coords, coords); |
| 63 |
lv_area_move(&rel_coords, -layer->buf_area.x1, -layer->buf_area.y1); |
| 64 |
|
| 65 |
lv_area_t rel_clip_area; |
| 66 |
lv_area_copy(&rel_clip_area, &t->clip_area); |
| 67 |
lv_area_move(&rel_clip_area, -layer->buf_area.x1, -layer->buf_area.y1); |
| 68 |
|
| 69 |
lv_area_t blend_area; |
| 70 |
if(!lv_area_intersect(&blend_area, &rel_coords, &rel_clip_area)) |
| 71 |
return; |
| 72 |
|
| 73 |
_pxp_fill(draw_buf->data, &blend_area, draw_buf->header.stride, draw_buf->header.cf, dsc); |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
static void _pxp_fill(uint8_t * dest_buf, const lv_area_t * dest_area, int32_t dest_stride, |
| 81 |
lv_color_format_t dest_cf, const lv_draw_fill_dsc_t * dsc) |
| 82 |
{ |
| 83 |
int32_t dest_w = lv_area_get_width(dest_area); |
| 84 |
int32_t dest_h = lv_area_get_height(dest_area); |
| 85 |
|
| 86 |
lv_pxp_reset(); |
| 87 |
|
| 88 |
uint8_t px_size = lv_color_format_get_size(dest_cf); |
| 89 |
|
| 90 |
|
| 91 |
pxp_output_buffer_config_t outputConfig = { |
| 92 |
.pixelFormat = pxp_get_out_px_format(dest_cf), |
| 93 |
.interlacedMode = kPXP_OutputProgressive, |
| 94 |
.buffer0Addr = (uint32_t)(dest_buf + dest_stride * dest_area->y1 + px_size * dest_area->x1), |
| 95 |
.buffer1Addr = (uint32_t)NULL, |
| 96 |
.pitchBytes = dest_stride, |
| 97 |
.width = dest_w, |
| 98 |
.height = dest_h |
| 99 |
}; |
| 100 |
|
| 101 |
PXP_SetOutputBufferConfig(PXP_ID, &outputConfig); |
| 102 |
|
| 103 |
if(dsc->opa >= (lv_opa_t)LV_OPA_MAX) { |
| 104 |
|
| 105 |
PXP_SetAlphaSurfacePosition(PXP_ID, 0xFFFFU, 0xFFFFU, 0U, 0U); |
| 106 |
|
| 107 |
} |
| 108 |
else { |
| 109 |
|
| 110 |
pxp_as_buffer_config_t asBufferConfig = { |
| 111 |
.pixelFormat = pxp_get_as_px_format(dest_cf), |
| 112 |
.bufferAddr = outputConfig.buffer0Addr, |
| 113 |
.pitchBytes = outputConfig.pitchBytes |
| 114 |
}; |
| 115 |
|
| 116 |
PXP_SetAlphaSurfaceBufferConfig(PXP_ID, &asBufferConfig); |
| 117 |
PXP_SetAlphaSurfacePosition(PXP_ID, 0U, 0U, dest_w - 1U, dest_h - 1U); |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
PXP_SetProcessSurfacePosition(PXP_ID, 0xFFFFU, 0xFFFFU, 0U, 0U); |
| 122 |
PXP_SetProcessSurfaceBackGroundColor(PXP_ID, lv_color_to_u32(dsc->color)); |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
pxp_porter_duff_config_t pdConfig = { |
| 132 |
.enable = 1, |
| 133 |
.dstColorMode = kPXP_PorterDuffColorNoAlpha, |
| 134 |
.srcColorMode = kPXP_PorterDuffColorNoAlpha, |
| 135 |
.dstGlobalAlphaMode = kPXP_PorterDuffGlobalAlpha, |
| 136 |
.srcGlobalAlphaMode = kPXP_PorterDuffGlobalAlpha, |
| 137 |
.dstFactorMode = kPXP_PorterDuffFactorStraight, |
| 138 |
.srcFactorMode = (dsc->opa >= (lv_opa_t)LV_OPA_MAX) ? kPXP_PorterDuffFactorStraight : kPXP_PorterDuffFactorInversed, |
| 139 |
.dstGlobalAlpha = dsc->opa, |
| 140 |
.srcGlobalAlpha = dsc->opa, |
| 141 |
.dstAlphaMode = kPXP_PorterDuffAlphaStraight, |
| 142 |
.srcAlphaMode = kPXP_PorterDuffAlphaStraight |
| 143 |
}; |
| 144 |
|
| 145 |
PXP_SetPorterDuffConfig(PXP_ID, &pdConfig); |
| 146 |
|
| 147 |
lv_pxp_run(); |
| 148 |
} |
| 149 |
|
| 150 |
#endif |
| 151 |
#endif |