chore(api): prevent API leaks (cache and thread) (#7220)

This commit is contained in:
Gabor Kiss-Vamosi 2024-11-13 12:37:37 +01:00 committed by GitHub
parent 81612fd153
commit 7bccca027a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
28 changed files with 711 additions and 593 deletions

View File

@ -13,6 +13,7 @@
#include "assets/spectrum_1.h"
#include "assets/spectrum_2.h"
#include "assets/spectrum_3.h"
#include "../../src/lvgl_private.h"
/*********************
* DEFINES

View File

@ -7,6 +7,7 @@
* INCLUDES
*********************/
#include "lv_demo_widgets.h"
#include "../../src/lvgl_private.h"
#if LV_USE_DEMO_WIDGETS

View File

@ -9,6 +9,7 @@
#include "../../lv_examples.h"
#if LV_BUILD_EXAMPLES
#include "../../../src/osal/lv_os.h"
/*********************
* DEFINES

View File

@ -1,4 +1,5 @@
#include "../../lv_examples.h"
#include "../../../src/lvgl_private.h"
#if LV_USE_CHART && LV_DRAW_SW_COMPLEX && LV_BUILD_EXAMPLES

6
lvgl.h
View File

@ -36,7 +36,8 @@ extern "C" {
#include "src/misc/lv_iter.h"
#include "src/misc/lv_circle_buf.h"
#include "src/misc/lv_tree.h"
#include "src/misc/cache/lv_image_cache.h"
#include "src/tick/lv_tick.h"
#include "src/core/lv_obj.h"
@ -113,10 +114,9 @@ extern "C" {
#include "src/layouts/lv_layout.h"
#include "src/draw/lv_draw.h"
#include "src/draw/lv_draw_buf.h"
#include "src/draw/lv_draw_vector.h"
#include "src/draw/sw/lv_draw_sw.h"
#include "src/draw/sw/lv_draw_sw_utils.h"
#include "src/themes/lv_theme.h"

View File

@ -17,7 +17,7 @@ extern "C" {
#include "../misc/lv_timer.h"
#include "../misc/lv_event.h"
#include "../misc/lv_color.h"
#include "../draw/lv_draw.h"
#include "../misc/lv_area.h"
/*********************
* DEFINES

View File

@ -25,7 +25,6 @@ extern "C" {
#include "../misc/lv_profiler.h"
#include "../misc/lv_matrix.h"
#include "lv_image_decoder.h"
#include "../osal/lv_os.h"
#include "lv_draw_buf.h"
/*********************

View File

@ -19,6 +19,8 @@ extern "C" {
*********************/
#include "lv_draw.h"
#include "../osal/lv_os.h"
#include "../misc/cache/lv_cache.h"
/*********************
* DEFINES

View File

@ -19,7 +19,6 @@ extern "C" {
#include "../misc/lv_fs.h"
#include "../misc/lv_types.h"
#include "../misc/lv_area.h"
#include "../misc/cache/lv_cache.h"
/*********************
* DEFINES

View File

@ -13,8 +13,8 @@ extern "C" {
/*********************
* INCLUDES
*********************/
#include "lv_image_decoder.h"
#include "../misc/cache/lv_cache.h"
/*********************
* DEFINES

View File

@ -38,58 +38,6 @@
*********************/
#define DRAW_UNIT_ID_SW 1
#ifndef LV_DRAW_SW_RGB565_SWAP
#define LV_DRAW_SW_RGB565_SWAP(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE90_ARGB8888
#define LV_DRAW_SW_ROTATE90_ARGB8888(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE180_ARGB8888
#define LV_DRAW_SW_ROTATE180_ARGB8888(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE270_ARGB8888
#define LV_DRAW_SW_ROTATE270_ARGB8888(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE90_RGB888
#define LV_DRAW_SW_ROTATE90_RGB888(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE180_RGB888
#define LV_DRAW_SW_ROTATE180_RGB888(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE270_RGB888
#define LV_DRAW_SW_ROTATE270_RGB888(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE90_RGB565
#define LV_DRAW_SW_ROTATE90_RGB565(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE180_RGB565
#define LV_DRAW_SW_ROTATE180_RGB565(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE270_RGB565
#define LV_DRAW_SW_ROTATE270_RGB565(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE90_L8
#define LV_DRAW_SW_ROTATE90_L8(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE180_L8
#define LV_DRAW_SW_ROTATE180_L8(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE270_L8
#define LV_DRAW_SW_ROTATE270_L8(...) LV_RESULT_INVALID
#endif
/**********************
* TYPEDEFS
**********************/
@ -107,47 +55,6 @@ static int32_t dispatch(lv_draw_unit_t * draw_unit, lv_layer_t * layer);
static int32_t evaluate(lv_draw_unit_t * draw_unit, lv_draw_task_t * task);
static int32_t lv_draw_sw_delete(lv_draw_unit_t * draw_unit);
#if LV_DRAW_SW_SUPPORT_ARGB8888
static void rotate90_argb8888(const uint32_t * src, uint32_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
static void rotate180_argb8888(const uint32_t * src, uint32_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride);
static void rotate270_argb8888(const uint32_t * src, uint32_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
#endif
#if LV_DRAW_SW_SUPPORT_RGB888
static void rotate90_rgb888(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
static void rotate180_rgb888(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride);
static void rotate270_rgb888(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dst_stride);
#endif
#if LV_DRAW_SW_SUPPORT_RGB565
static void rotate90_rgb565(const uint16_t * src, uint16_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
static void rotate180_rgb565(const uint16_t * src, uint16_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride);
static void rotate270_rgb565(const uint16_t * src, uint16_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
#endif
#if LV_DRAW_SW_SUPPORT_L8
static void rotate90_l8(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
static void rotate180_l8(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride);
static void rotate270_l8(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
#endif
/**********************
* STATIC VARIABLES
**********************/
@ -217,194 +124,6 @@ static int32_t lv_draw_sw_delete(lv_draw_unit_t * draw_unit)
#endif
}
void lv_draw_sw_rgb565_swap(void * buf, uint32_t buf_size_px)
{
if(LV_DRAW_SW_RGB565_SWAP(buf, buf_size_px) == LV_RESULT_OK) return;
uint32_t u32_cnt = buf_size_px / 2;
uint16_t * buf16 = buf;
uint32_t * buf32 = buf;
while(u32_cnt >= 8) {
buf32[0] = ((buf32[0] & 0xff00ff00) >> 8) | ((buf32[0] & 0x00ff00ff) << 8);
buf32[1] = ((buf32[1] & 0xff00ff00) >> 8) | ((buf32[1] & 0x00ff00ff) << 8);
buf32[2] = ((buf32[2] & 0xff00ff00) >> 8) | ((buf32[2] & 0x00ff00ff) << 8);
buf32[3] = ((buf32[3] & 0xff00ff00) >> 8) | ((buf32[3] & 0x00ff00ff) << 8);
buf32[4] = ((buf32[4] & 0xff00ff00) >> 8) | ((buf32[4] & 0x00ff00ff) << 8);
buf32[5] = ((buf32[5] & 0xff00ff00) >> 8) | ((buf32[5] & 0x00ff00ff) << 8);
buf32[6] = ((buf32[6] & 0xff00ff00) >> 8) | ((buf32[6] & 0x00ff00ff) << 8);
buf32[7] = ((buf32[7] & 0xff00ff00) >> 8) | ((buf32[7] & 0x00ff00ff) << 8);
buf32 += 8;
u32_cnt -= 8;
}
while(u32_cnt) {
*buf32 = ((*buf32 & 0xff00ff00) >> 8) | ((*buf32 & 0x00ff00ff) << 8);
buf32++;
u32_cnt--;
}
if(buf_size_px & 0x1) {
uint32_t e = buf_size_px - 1;
buf16[e] = ((buf16[e] & 0xff00) >> 8) | ((buf16[e] & 0x00ff) << 8);
}
}
void lv_draw_sw_i1_invert(void * buf, uint32_t buf_size)
{
if(buf == NULL) return;
uint8_t * byte_buf = (uint8_t *)buf;
uint32_t i;
/*Make the buffer aligned*/
while(((uintptr_t)(byte_buf) & (sizeof(int) - 1)) && buf_size > 0) {
*byte_buf = ~(*byte_buf);
byte_buf++;
buf_size--;
}
if(buf_size >= sizeof(uint32_t)) {
uint32_t * aligned_addr = (uint32_t *)byte_buf;
uint32_t word_count = buf_size / 4;
for(i = 0; i < word_count; ++i) {
aligned_addr[i] = ~aligned_addr[i];
}
byte_buf = (uint8_t *)(aligned_addr + word_count);
buf_size = buf_size % sizeof(uint32_t);
}
for(i = 0; i < buf_size; ++i) {
byte_buf[i] = ~byte_buf[i];
}
}
void lv_draw_sw_i1_convert_to_vtiled(const void * buf, uint32_t buf_size, uint32_t width, uint32_t height,
void * out_buf,
uint32_t out_buf_size, bool bit_order_lsb)
{
LV_ASSERT(buf && out_buf);
LV_ASSERT(width % 8 == 0 && height % 8 == 0);
LV_ASSERT(buf_size == (width / 8) * height);
LV_ASSERT(out_buf_size >= buf_size);
lv_memset(out_buf, 0, out_buf_size);
const uint8_t * src_buf = (uint8_t *)buf;
uint8_t * dst_buf = (uint8_t *)out_buf;
for(uint32_t y = 0; y < height; y++) {
for(uint32_t x = 0; x < width; x++) {
uint32_t src_index = y * width + x;
uint32_t dst_index = x * height + y;
uint8_t bit = (src_buf[src_index / 8] >> (7 - (src_index % 8))) & 0x01;
if(bit_order_lsb) {
dst_buf[dst_index / 8] |= (bit << (dst_index % 8));
}
else {
dst_buf[dst_index / 8] |= (bit << (7 - (dst_index % 8)));
}
}
}
}
void lv_draw_sw_rotate(const void * src, void * dest, int32_t src_width, int32_t src_height, int32_t src_stride,
int32_t dest_stride, lv_display_rotation_t rotation, lv_color_format_t color_format)
{
if(rotation == LV_DISPLAY_ROTATION_90) {
switch(color_format) {
#if LV_DRAW_SW_SUPPORT_L8
case LV_COLOR_FORMAT_L8:
rotate90_l8(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_RGB565
case LV_COLOR_FORMAT_RGB565:
rotate90_rgb565(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_RGB888
case LV_COLOR_FORMAT_RGB888:
rotate90_rgb888(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_ARGB8888 || LV_DRAW_SW_SUPPORT_XRGB8888
case LV_COLOR_FORMAT_XRGB8888:
case LV_COLOR_FORMAT_ARGB8888:
rotate90_argb8888(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
default:
break;
}
return;
}
if(rotation == LV_DISPLAY_ROTATION_180) {
switch(color_format) {
#if LV_DRAW_SW_SUPPORT_L8
case LV_COLOR_FORMAT_L8:
rotate180_l8(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_RGB565
case LV_COLOR_FORMAT_RGB565:
rotate180_rgb565(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_RGB888
case LV_COLOR_FORMAT_RGB888:
rotate180_rgb888(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_ARGB8888 || LV_DRAW_SW_SUPPORT_XRGB8888
case LV_COLOR_FORMAT_XRGB8888:
case LV_COLOR_FORMAT_ARGB8888:
rotate180_argb8888(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
default:
break;
}
return;
}
if(rotation == LV_DISPLAY_ROTATION_270) {
switch(color_format) {
#if LV_DRAW_SW_SUPPORT_L8
case LV_COLOR_FORMAT_L8:
rotate270_l8(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_RGB565
case LV_COLOR_FORMAT_RGB565:
rotate270_rgb565(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_RGB888
case LV_COLOR_FORMAT_RGB888:
rotate270_rgb888(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_ARGB8888 || LV_DRAW_SW_SUPPORT_XRGB8888
case LV_COLOR_FORMAT_XRGB8888:
case LV_COLOR_FORMAT_ARGB8888:
rotate270_argb8888(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
default:
break;
}
return;
}
}
/**********************
* STATIC FUNCTIONS
**********************/
@ -625,250 +344,4 @@ static void execute_drawing(lv_draw_sw_unit_t * u)
LV_PROFILER_DRAW_END;
}
#if LV_DRAW_SW_SUPPORT_ARGB8888
static void rotate270_argb8888(const uint32_t * src, uint32_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE90_ARGB8888(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
src_stride /= sizeof(uint32_t);
dst_stride /= sizeof(uint32_t);
for(int32_t x = 0; x < src_width; ++x) {
int32_t dstIndex = x * dst_stride;
int32_t srcIndex = x;
for(int32_t y = 0; y < src_height; ++y) {
dst[dstIndex + (src_height - y - 1)] = src[srcIndex];
srcIndex += src_stride;
}
}
}
static void rotate180_argb8888(const uint32_t * src, uint32_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride)
{
LV_UNUSED(dest_stride);
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE180_ARGB8888(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
src_stride /= sizeof(uint32_t);
dest_stride /= sizeof(uint32_t);
for(int32_t y = 0; y < height; ++y) {
int32_t dstIndex = (height - y - 1) * dest_stride;
int32_t srcIndex = y * src_stride;
for(int32_t x = 0; x < width; ++x) {
dst[dstIndex + width - x - 1] = src[srcIndex + x];
}
}
}
static void rotate90_argb8888(const uint32_t * src, uint32_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride, int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE270_ARGB8888(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
src_stride /= sizeof(uint32_t);
dst_stride /= sizeof(uint32_t);
for(int32_t x = 0; x < src_width; ++x) {
int32_t dstIndex = (src_width - x - 1);
int32_t srcIndex = x;
for(int32_t y = 0; y < src_height; ++y) {
dst[dstIndex * dst_stride + y] = src[srcIndex];
srcIndex += src_stride;
}
}
}
#endif
#if LV_DRAW_SW_SUPPORT_RGB888
static void rotate90_rgb888(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE90_RGB888(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
for(int32_t x = 0; x < src_width; ++x) {
for(int32_t y = 0; y < src_height; ++y) {
int32_t srcIndex = y * src_stride + x * 3;
int32_t dstIndex = (src_width - x - 1) * dst_stride + y * 3;
dst[dstIndex] = src[srcIndex]; /*Red*/
dst[dstIndex + 1] = src[srcIndex + 1]; /*Green*/
dst[dstIndex + 2] = src[srcIndex + 2]; /*Blue*/
}
}
}
static void rotate180_rgb888(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE180_RGB888(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
for(int32_t y = 0; y < height; ++y) {
for(int32_t x = 0; x < width; ++x) {
int32_t srcIndex = y * src_stride + x * 3;
int32_t dstIndex = (height - y - 1) * dest_stride + (width - x - 1) * 3;
dst[dstIndex] = src[srcIndex];
dst[dstIndex + 1] = src[srcIndex + 1];
dst[dstIndex + 2] = src[srcIndex + 2];
}
}
}
static void rotate270_rgb888(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE270_RGB888(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
for(int32_t x = 0; x < width; ++x) {
for(int32_t y = 0; y < height; ++y) {
int32_t srcIndex = y * src_stride + x * 3;
int32_t dstIndex = x * dst_stride + (height - y - 1) * 3;
dst[dstIndex] = src[srcIndex]; /*Red*/
dst[dstIndex + 1] = src[srcIndex + 1]; /*Green*/
dst[dstIndex + 2] = src[srcIndex + 2]; /*Blue*/
}
}
}
#endif
#if LV_DRAW_SW_SUPPORT_RGB565
static void rotate270_rgb565(const uint16_t * src, uint16_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE90_RGB565(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
src_stride /= sizeof(uint16_t);
dst_stride /= sizeof(uint16_t);
for(int32_t x = 0; x < src_width; ++x) {
int32_t dstIndex = x * dst_stride;
int32_t srcIndex = x;
for(int32_t y = 0; y < src_height; ++y) {
dst[dstIndex + (src_height - y - 1)] = src[srcIndex];
srcIndex += src_stride;
}
}
}
static void rotate180_rgb565(const uint16_t * src, uint16_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE180_RGB565(src, dst, width, height, src_stride)) {
return ;
}
src_stride /= sizeof(uint16_t);
dest_stride /= sizeof(uint16_t);
for(int32_t y = 0; y < height; ++y) {
int32_t dstIndex = (height - y - 1) * dest_stride;
int32_t srcIndex = y * src_stride;
for(int32_t x = 0; x < width; ++x) {
dst[dstIndex + width - x - 1] = src[srcIndex + x];
}
}
}
static void rotate90_rgb565(const uint16_t * src, uint16_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE270_RGB565(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
src_stride /= sizeof(uint16_t);
dst_stride /= sizeof(uint16_t);
for(int32_t x = 0; x < src_width; ++x) {
int32_t dstIndex = (src_width - x - 1);
int32_t srcIndex = x;
for(int32_t y = 0; y < src_height; ++y) {
dst[dstIndex * dst_stride + y] = src[srcIndex];
srcIndex += src_stride;
}
}
}
#endif
#if LV_DRAW_SW_SUPPORT_L8
static void rotate90_l8(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE270_L8(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
for(int32_t x = 0; x < src_width; ++x) {
int32_t dstIndex = (src_width - x - 1);
int32_t srcIndex = x;
for(int32_t y = 0; y < src_height; ++y) {
dst[dstIndex * dst_stride + y] = src[srcIndex];
srcIndex += src_stride;
}
}
}
static void rotate180_l8(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE180_L8(src, dst, width, height, src_stride)) {
return ;
}
for(int32_t y = 0; y < height; ++y) {
int32_t dstIndex = (height - y - 1) * dest_stride;
int32_t srcIndex = y * src_stride;
for(int32_t x = 0; x < width; ++x) {
dst[dstIndex + width - x - 1] = src[srcIndex + x];
}
}
}
static void rotate270_l8(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE90_L8(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
for(int32_t x = 0; x < src_width; ++x) {
int32_t dstIndex = x * dst_stride;
int32_t srcIndex = x;
for(int32_t y = 0; y < src_height; ++y) {
dst[dstIndex + (src_height - y - 1)] = src[srcIndex];
srcIndex += src_stride;
}
}
}
#endif
#endif /*LV_USE_DRAW_SW*/

View File

@ -27,6 +27,7 @@ extern "C" {
#include "../lv_draw_image.h"
#include "../lv_draw_line.h"
#include "../lv_draw_arc.h"
#include "lv_draw_sw_utils.h"
/*********************
* DEFINES
@ -152,56 +153,6 @@ void lv_draw_sw_transform(lv_draw_unit_t * draw_unit, const lv_area_t * dest_are
void lv_draw_sw_vector(lv_draw_unit_t * draw_unit, const lv_draw_vector_task_dsc_t * dsc);
#endif
/**
* Swap the upper and lower byte of an RGB565 buffer.
* Might be required if a 8bit parallel port or an SPI port send the bytes in the wrong order.
* The bytes will be swapped in place.
* @param buf pointer to buffer
* @param buf_size_px number of pixels in the buffer
*/
void lv_draw_sw_rgb565_swap(void * buf, uint32_t buf_size_px);
/**
* Invert a draw buffer in the I1 color format.
* Conventionally, a bit is set to 1 during blending if the luminance is greater than 127.
* Depending on the display controller used, you might want to have different behavior.
* The inversion will be performed in place.
* @param buf pointer to the buffer to be inverted
* @param buf_size size of the buffer in bytes
*/
void lv_draw_sw_i1_invert(void * buf, uint32_t buf_size);
/**
* Convert a draw buffer in I1 color format from htiled (row-wise)
* to vtiled (column-wise) buffer layout. The conversion assumes that the buffer width
* and height is rounded to a multiple of 8.
* @param buf pointer to the buffer to be converted
* @param buf_size size of the buffer in bytes
* @param width width of the buffer
* @param height height of the buffer
* @param out_buf pointer to the output buffer
* @param out_buf_size size of the output buffer in bytes
* @param bit_order_lsb bit order of the resulting vtiled buffer
*/
void lv_draw_sw_i1_convert_to_vtiled(const void * buf, uint32_t buf_size, uint32_t width, uint32_t height,
void * out_buf,
uint32_t out_buf_size, bool bit_order_lsb);
/**
* Rotate a buffer into another buffer
* @param src the source buffer
* @param dest the destination buffer
* @param src_width source width in pixels
* @param src_height source height in pixels
* @param src_stride source stride in bytes (number of bytes in a row)
* @param dest_stride destination stride in bytes (number of bytes in a row)
* @param rotation LV_DISPLAY_ROTATION_0/90/180/270
* @param color_format LV_COLOR_FORMAT_RGB565/RGB888/XRGB8888/ARGB8888
*/
void lv_draw_sw_rotate(const void * src, void * dest, int32_t src_width, int32_t src_height, int32_t src_stride,
int32_t dest_stride, lv_display_rotation_t rotation, lv_color_format_t color_format);
/***********************
* GLOBAL VARIABLES
***********************/

View File

@ -0,0 +1,567 @@
/**
* @file lv_draw_sw_utils.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_draw_sw_utils.h"
#if LV_USE_DRAW_SW
/*********************
* DEFINES
*********************/
#ifndef LV_DRAW_SW_RGB565_SWAP
#define LV_DRAW_SW_RGB565_SWAP(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE90_ARGB8888
#define LV_DRAW_SW_ROTATE90_ARGB8888(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE180_ARGB8888
#define LV_DRAW_SW_ROTATE180_ARGB8888(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE270_ARGB8888
#define LV_DRAW_SW_ROTATE270_ARGB8888(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE90_RGB888
#define LV_DRAW_SW_ROTATE90_RGB888(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE180_RGB888
#define LV_DRAW_SW_ROTATE180_RGB888(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE270_RGB888
#define LV_DRAW_SW_ROTATE270_RGB888(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE90_RGB565
#define LV_DRAW_SW_ROTATE90_RGB565(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE180_RGB565
#define LV_DRAW_SW_ROTATE180_RGB565(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE270_RGB565
#define LV_DRAW_SW_ROTATE270_RGB565(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE90_L8
#define LV_DRAW_SW_ROTATE90_L8(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE180_L8
#define LV_DRAW_SW_ROTATE180_L8(...) LV_RESULT_INVALID
#endif
#ifndef LV_DRAW_SW_ROTATE270_L8
#define LV_DRAW_SW_ROTATE270_L8(...) LV_RESULT_INVALID
#endif
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
#if LV_DRAW_SW_SUPPORT_ARGB8888
static void rotate90_argb8888(const uint32_t * src, uint32_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
static void rotate180_argb8888(const uint32_t * src, uint32_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride);
static void rotate270_argb8888(const uint32_t * src, uint32_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
#endif
#if LV_DRAW_SW_SUPPORT_RGB888
static void rotate90_rgb888(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
static void rotate180_rgb888(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride);
static void rotate270_rgb888(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dst_stride);
#endif
#if LV_DRAW_SW_SUPPORT_RGB565
static void rotate90_rgb565(const uint16_t * src, uint16_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
static void rotate180_rgb565(const uint16_t * src, uint16_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride);
static void rotate270_rgb565(const uint16_t * src, uint16_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
#endif
#if LV_DRAW_SW_SUPPORT_L8
static void rotate90_l8(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
static void rotate180_l8(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride);
static void rotate270_l8(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride);
#endif
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
void lv_draw_sw_rgb565_swap(void * buf, uint32_t buf_size_px)
{
if(LV_DRAW_SW_RGB565_SWAP(buf, buf_size_px) == LV_RESULT_OK) return;
uint32_t u32_cnt = buf_size_px / 2;
uint16_t * buf16 = buf;
uint32_t * buf32 = buf;
while(u32_cnt >= 8) {
buf32[0] = ((buf32[0] & 0xff00ff00) >> 8) | ((buf32[0] & 0x00ff00ff) << 8);
buf32[1] = ((buf32[1] & 0xff00ff00) >> 8) | ((buf32[1] & 0x00ff00ff) << 8);
buf32[2] = ((buf32[2] & 0xff00ff00) >> 8) | ((buf32[2] & 0x00ff00ff) << 8);
buf32[3] = ((buf32[3] & 0xff00ff00) >> 8) | ((buf32[3] & 0x00ff00ff) << 8);
buf32[4] = ((buf32[4] & 0xff00ff00) >> 8) | ((buf32[4] & 0x00ff00ff) << 8);
buf32[5] = ((buf32[5] & 0xff00ff00) >> 8) | ((buf32[5] & 0x00ff00ff) << 8);
buf32[6] = ((buf32[6] & 0xff00ff00) >> 8) | ((buf32[6] & 0x00ff00ff) << 8);
buf32[7] = ((buf32[7] & 0xff00ff00) >> 8) | ((buf32[7] & 0x00ff00ff) << 8);
buf32 += 8;
u32_cnt -= 8;
}
while(u32_cnt) {
*buf32 = ((*buf32 & 0xff00ff00) >> 8) | ((*buf32 & 0x00ff00ff) << 8);
buf32++;
u32_cnt--;
}
if(buf_size_px & 0x1) {
uint32_t e = buf_size_px - 1;
buf16[e] = ((buf16[e] & 0xff00) >> 8) | ((buf16[e] & 0x00ff) << 8);
}
}
void lv_draw_sw_i1_invert(void * buf, uint32_t buf_size)
{
if(buf == NULL) return;
uint8_t * byte_buf = (uint8_t *)buf;
uint32_t i;
/*Make the buffer aligned*/
while(((uintptr_t)(byte_buf) & (sizeof(int) - 1)) && buf_size > 0) {
*byte_buf = ~(*byte_buf);
byte_buf++;
buf_size--;
}
if(buf_size >= sizeof(uint32_t)) {
uint32_t * aligned_addr = (uint32_t *)byte_buf;
uint32_t word_count = buf_size / 4;
for(i = 0; i < word_count; ++i) {
aligned_addr[i] = ~aligned_addr[i];
}
byte_buf = (uint8_t *)(aligned_addr + word_count);
buf_size = buf_size % sizeof(uint32_t);
}
for(i = 0; i < buf_size; ++i) {
byte_buf[i] = ~byte_buf[i];
}
}
void lv_draw_sw_i1_convert_to_vtiled(const void * buf, uint32_t buf_size, uint32_t width, uint32_t height,
void * out_buf,
uint32_t out_buf_size, bool bit_order_lsb)
{
LV_ASSERT(buf && out_buf);
LV_ASSERT(width % 8 == 0 && height % 8 == 0);
LV_ASSERT(buf_size == (width / 8) * height);
LV_ASSERT(out_buf_size >= buf_size);
lv_memset(out_buf, 0, out_buf_size);
const uint8_t * src_buf = (uint8_t *)buf;
uint8_t * dst_buf = (uint8_t *)out_buf;
for(uint32_t y = 0; y < height; y++) {
for(uint32_t x = 0; x < width; x++) {
uint32_t src_index = y * width + x;
uint32_t dst_index = x * height + y;
uint8_t bit = (src_buf[src_index / 8] >> (7 - (src_index % 8))) & 0x01;
if(bit_order_lsb) {
dst_buf[dst_index / 8] |= (bit << (dst_index % 8));
}
else {
dst_buf[dst_index / 8] |= (bit << (7 - (dst_index % 8)));
}
}
}
}
void lv_draw_sw_rotate(const void * src, void * dest, int32_t src_width, int32_t src_height, int32_t src_stride,
int32_t dest_stride, lv_display_rotation_t rotation, lv_color_format_t color_format)
{
if(rotation == LV_DISPLAY_ROTATION_90) {
switch(color_format) {
#if LV_DRAW_SW_SUPPORT_L8
case LV_COLOR_FORMAT_L8:
rotate90_l8(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_RGB565
case LV_COLOR_FORMAT_RGB565:
rotate90_rgb565(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_RGB888
case LV_COLOR_FORMAT_RGB888:
rotate90_rgb888(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_ARGB8888 || LV_DRAW_SW_SUPPORT_XRGB8888
case LV_COLOR_FORMAT_XRGB8888:
case LV_COLOR_FORMAT_ARGB8888:
rotate90_argb8888(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
default:
break;
}
return;
}
if(rotation == LV_DISPLAY_ROTATION_180) {
switch(color_format) {
#if LV_DRAW_SW_SUPPORT_L8
case LV_COLOR_FORMAT_L8:
rotate180_l8(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_RGB565
case LV_COLOR_FORMAT_RGB565:
rotate180_rgb565(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_RGB888
case LV_COLOR_FORMAT_RGB888:
rotate180_rgb888(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_ARGB8888 || LV_DRAW_SW_SUPPORT_XRGB8888
case LV_COLOR_FORMAT_XRGB8888:
case LV_COLOR_FORMAT_ARGB8888:
rotate180_argb8888(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
default:
break;
}
return;
}
if(rotation == LV_DISPLAY_ROTATION_270) {
switch(color_format) {
#if LV_DRAW_SW_SUPPORT_L8
case LV_COLOR_FORMAT_L8:
rotate270_l8(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_RGB565
case LV_COLOR_FORMAT_RGB565:
rotate270_rgb565(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_RGB888
case LV_COLOR_FORMAT_RGB888:
rotate270_rgb888(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
#if LV_DRAW_SW_SUPPORT_ARGB8888 || LV_DRAW_SW_SUPPORT_XRGB8888
case LV_COLOR_FORMAT_XRGB8888:
case LV_COLOR_FORMAT_ARGB8888:
rotate270_argb8888(src, dest, src_width, src_height, src_stride, dest_stride);
break;
#endif
default:
break;
}
return;
}
}
/**********************
* STATIC FUNCTIONS
**********************/
#if LV_DRAW_SW_SUPPORT_ARGB8888
static void rotate270_argb8888(const uint32_t * src, uint32_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE90_ARGB8888(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
src_stride /= sizeof(uint32_t);
dst_stride /= sizeof(uint32_t);
for(int32_t x = 0; x < src_width; ++x) {
int32_t dstIndex = x * dst_stride;
int32_t srcIndex = x;
for(int32_t y = 0; y < src_height; ++y) {
dst[dstIndex + (src_height - y - 1)] = src[srcIndex];
srcIndex += src_stride;
}
}
}
static void rotate180_argb8888(const uint32_t * src, uint32_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride)
{
LV_UNUSED(dest_stride);
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE180_ARGB8888(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
src_stride /= sizeof(uint32_t);
dest_stride /= sizeof(uint32_t);
for(int32_t y = 0; y < height; ++y) {
int32_t dstIndex = (height - y - 1) * dest_stride;
int32_t srcIndex = y * src_stride;
for(int32_t x = 0; x < width; ++x) {
dst[dstIndex + width - x - 1] = src[srcIndex + x];
}
}
}
static void rotate90_argb8888(const uint32_t * src, uint32_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride, int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE270_ARGB8888(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
src_stride /= sizeof(uint32_t);
dst_stride /= sizeof(uint32_t);
for(int32_t x = 0; x < src_width; ++x) {
int32_t dstIndex = (src_width - x - 1);
int32_t srcIndex = x;
for(int32_t y = 0; y < src_height; ++y) {
dst[dstIndex * dst_stride + y] = src[srcIndex];
srcIndex += src_stride;
}
}
}
#endif
#if LV_DRAW_SW_SUPPORT_RGB888
static void rotate90_rgb888(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE90_RGB888(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
for(int32_t x = 0; x < src_width; ++x) {
for(int32_t y = 0; y < src_height; ++y) {
int32_t srcIndex = y * src_stride + x * 3;
int32_t dstIndex = (src_width - x - 1) * dst_stride + y * 3;
dst[dstIndex] = src[srcIndex]; /*Red*/
dst[dstIndex + 1] = src[srcIndex + 1]; /*Green*/
dst[dstIndex + 2] = src[srcIndex + 2]; /*Blue*/
}
}
}
static void rotate180_rgb888(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE180_RGB888(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
for(int32_t y = 0; y < height; ++y) {
for(int32_t x = 0; x < width; ++x) {
int32_t srcIndex = y * src_stride + x * 3;
int32_t dstIndex = (height - y - 1) * dest_stride + (width - x - 1) * 3;
dst[dstIndex] = src[srcIndex];
dst[dstIndex + 1] = src[srcIndex + 1];
dst[dstIndex + 2] = src[srcIndex + 2];
}
}
}
static void rotate270_rgb888(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE270_RGB888(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
for(int32_t x = 0; x < width; ++x) {
for(int32_t y = 0; y < height; ++y) {
int32_t srcIndex = y * src_stride + x * 3;
int32_t dstIndex = x * dst_stride + (height - y - 1) * 3;
dst[dstIndex] = src[srcIndex]; /*Red*/
dst[dstIndex + 1] = src[srcIndex + 1]; /*Green*/
dst[dstIndex + 2] = src[srcIndex + 2]; /*Blue*/
}
}
}
#endif
#if LV_DRAW_SW_SUPPORT_RGB565
static void rotate270_rgb565(const uint16_t * src, uint16_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE90_RGB565(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
src_stride /= sizeof(uint16_t);
dst_stride /= sizeof(uint16_t);
for(int32_t x = 0; x < src_width; ++x) {
int32_t dstIndex = x * dst_stride;
int32_t srcIndex = x;
for(int32_t y = 0; y < src_height; ++y) {
dst[dstIndex + (src_height - y - 1)] = src[srcIndex];
srcIndex += src_stride;
}
}
}
static void rotate180_rgb565(const uint16_t * src, uint16_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE180_RGB565(src, dst, width, height, src_stride)) {
return ;
}
src_stride /= sizeof(uint16_t);
dest_stride /= sizeof(uint16_t);
for(int32_t y = 0; y < height; ++y) {
int32_t dstIndex = (height - y - 1) * dest_stride;
int32_t srcIndex = y * src_stride;
for(int32_t x = 0; x < width; ++x) {
dst[dstIndex + width - x - 1] = src[srcIndex + x];
}
}
}
static void rotate90_rgb565(const uint16_t * src, uint16_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE270_RGB565(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
src_stride /= sizeof(uint16_t);
dst_stride /= sizeof(uint16_t);
for(int32_t x = 0; x < src_width; ++x) {
int32_t dstIndex = (src_width - x - 1);
int32_t srcIndex = x;
for(int32_t y = 0; y < src_height; ++y) {
dst[dstIndex * dst_stride + y] = src[srcIndex];
srcIndex += src_stride;
}
}
}
#endif
#if LV_DRAW_SW_SUPPORT_L8
static void rotate90_l8(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE270_L8(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
for(int32_t x = 0; x < src_width; ++x) {
int32_t dstIndex = (src_width - x - 1);
int32_t srcIndex = x;
for(int32_t y = 0; y < src_height; ++y) {
dst[dstIndex * dst_stride + y] = src[srcIndex];
srcIndex += src_stride;
}
}
}
static void rotate180_l8(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
int32_t dest_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE180_L8(src, dst, width, height, src_stride)) {
return ;
}
for(int32_t y = 0; y < height; ++y) {
int32_t dstIndex = (height - y - 1) * dest_stride;
int32_t srcIndex = y * src_stride;
for(int32_t x = 0; x < width; ++x) {
dst[dstIndex + width - x - 1] = src[srcIndex + x];
}
}
}
static void rotate270_l8(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
int32_t src_stride,
int32_t dst_stride)
{
if(LV_RESULT_OK == LV_DRAW_SW_ROTATE90_L8(src, dst, src_width, src_height, src_stride, dst_stride)) {
return ;
}
for(int32_t x = 0; x < src_width; ++x) {
int32_t dstIndex = x * dst_stride;
int32_t srcIndex = x;
for(int32_t y = 0; y < src_height; ++y) {
dst[dstIndex + (src_height - y - 1)] = src[srcIndex];
srcIndex += src_stride;
}
}
}
#endif
#endif /*LV_USE_DRAW_SW*/

View File

@ -0,0 +1,96 @@
/**
* @file lv_draw_sw_utils.h
*
*/
#ifndef LV_DRAW_SW_UTILS_H
#define LV_DRAW_SW_UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lv_conf_internal.h"
#if LV_USE_DRAW_SW
#include "../../misc/lv_area.h"
#include "../../misc/lv_color.h"
#include "../../display/lv_display.h"
/*********************
* DEFINES
*********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Swap the upper and lower byte of an RGB565 buffer.
* Might be required if a 8bit parallel port or an SPI port send the bytes in the wrong order.
* The bytes will be swapped in place.
* @param buf pointer to buffer
* @param buf_size_px number of pixels in the buffer
*/
void lv_draw_sw_rgb565_swap(void * buf, uint32_t buf_size_px);
/**
* Invert a draw buffer in the I1 color format.
* Conventionally, a bit is set to 1 during blending if the luminance is greater than 127.
* Depending on the display controller used, you might want to have different behavior.
* The inversion will be performed in place.
* @param buf pointer to the buffer to be inverted
* @param buf_size size of the buffer in bytes
*/
void lv_draw_sw_i1_invert(void * buf, uint32_t buf_size);
/**
* Convert a draw buffer in I1 color format from htiled (row-wise)
* to vtiled (column-wise) buffer layout. The conversion assumes that the buffer width
* and height is rounded to a multiple of 8.
* @param buf pointer to the buffer to be converted
* @param buf_size size of the buffer in bytes
* @param width width of the buffer
* @param height height of the buffer
* @param out_buf pointer to the output buffer
* @param out_buf_size size of the output buffer in bytes
* @param bit_order_lsb bit order of the resulting vtiled buffer
*/
void lv_draw_sw_i1_convert_to_vtiled(const void * buf, uint32_t buf_size, uint32_t width, uint32_t height,
void * out_buf,
uint32_t out_buf_size, bool bit_order_lsb);
/**
* Rotate a buffer into another buffer
* @param src the source buffer
* @param dest the destination buffer
* @param src_width source width in pixels
* @param src_height source height in pixels
* @param src_stride source stride in bytes (number of bytes in a row)
* @param dest_stride destination stride in bytes (number of bytes in a row)
* @param rotation LV_DISPLAY_ROTATION_0/90/180/270
* @param color_format LV_COLOR_FORMAT_RGB565/RGB888/XRGB8888/ARGB8888
*/
void lv_draw_sw_rotate(const void * src, void * dest, int32_t src_width, int32_t src_height, int32_t src_stride,
int32_t dest_stride, lv_display_rotation_t rotation, lv_color_format_t color_format);
/***********************
* GLOBAL VARIABLES
***********************/
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_SW*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_UTILS_H*/

View File

@ -22,6 +22,8 @@
#include <xf86drmMode.h>
#include <drm_fourcc.h>
#include "../../../stdlib/lv_sprintf.h"
/*********************
* DEFINES
*********************/

View File

@ -16,6 +16,7 @@
#include "lv_windows_display.h"
#include "lv_windows_input_private.h"
#include "../../osal/lv_os.h"
/*********************
* DEFINES

View File

@ -19,7 +19,6 @@ extern "C" {
#include "lv_symbol_def.h"
#include "../draw/lv_draw_buf.h"
#include "../misc/lv_area.h"
#include "../misc/cache/lv_cache.h"
/*********************
* DEFINES

View File

@ -6,10 +6,11 @@
/*********************
* INCLUDES
*********************/
#include "../../misc/lv_timer_private.h"
#include "../../core/lv_obj_class_private.h"
#include "lv_gif_private.h"
#if LV_USE_GIF
#include "../../misc/lv_timer_private.h"
#include "../../misc/cache/lv_image_cache.h"
#include "../../core/lv_obj_class_private.h"
#include "gifdec.h"

View File

@ -10,6 +10,7 @@
#include "../../stdlib/lv_sprintf.h"
#include "../lv_assert.h"
#include "lv_cache_entry_private.h"
#include "lv_cache_private.h"
/*********************
* DEFINES
@ -25,6 +26,7 @@
static void cache_drop_internal_no_lock(lv_cache_t * cache, const void * key, void * user_data);
static bool cache_evict_one_internal_no_lock(lv_cache_t * cache, void * user_data);
static lv_cache_entry_t * cache_add_internal_no_lock(lv_cache_t * cache, const void * key, void * user_data);
/**********************
* GLOBAL VARIABLES
**********************/

View File

@ -14,13 +14,13 @@ extern "C" {
* INCLUDES
*********************/
#include "lv_cache_entry.h"
#include "lv_cache_private.h"
#include "../lv_types.h"
#include "lv_cache_lru_rb.h"
#include "lv_image_cache.h"
#include "lv_image_header_cache.h"
/*********************
* DEFINES
*********************/

View File

@ -12,6 +12,7 @@
#include "lv_cache.h"
#include "lv_cache_entry_private.h"
#include "lv_cache_private.h"
/*********************
* DEFINES
*********************/
@ -51,11 +52,13 @@ void lv_cache_entry_reset_ref(lv_cache_entry_t * entry)
LV_ASSERT_NULL(entry);
entry->ref_cnt = 0;
}
void lv_cache_entry_inc_ref(lv_cache_entry_t * entry)
{
LV_ASSERT_NULL(entry);
entry->ref_cnt++;
}
void lv_cache_entry_dec_ref(lv_cache_entry_t * entry)
{
LV_ASSERT_NULL(entry);
@ -65,35 +68,42 @@ void lv_cache_entry_dec_ref(lv_cache_entry_t * entry)
entry->ref_cnt = 0;
}
}
int32_t lv_cache_entry_get_ref(lv_cache_entry_t * entry)
{
LV_ASSERT_NULL(entry);
return entry->ref_cnt;
}
uint32_t lv_cache_entry_get_node_size(lv_cache_entry_t * entry)
{
return entry->node_size;
}
void lv_cache_entry_set_node_size(lv_cache_entry_t * entry, uint32_t node_size)
{
LV_ASSERT_NULL(entry);
entry->node_size = node_size;
}
void lv_cache_entry_set_invalid(lv_cache_entry_t * entry, bool is_invalid)
{
LV_ASSERT_NULL(entry);
entry->is_invalid = is_invalid;
}
bool lv_cache_entry_is_invalid(lv_cache_entry_t * entry)
{
LV_ASSERT_NULL(entry);
return entry->is_invalid;
}
void * lv_cache_entry_get_data(lv_cache_entry_t * entry)
{
LV_ASSERT_NULL(entry);
return (uint8_t *)entry - entry->node_size;
}
void * lv_cache_entry_acquire_data(lv_cache_entry_t * entry)
{
LV_ASSERT_NULL(entry);
@ -101,6 +111,7 @@ void * lv_cache_entry_acquire_data(lv_cache_entry_t * entry)
lv_cache_entry_inc_ref(entry);
return lv_cache_entry_get_data(entry);
}
void lv_cache_entry_release_data(lv_cache_entry_t * entry, void * user_data)
{
LV_UNUSED(user_data);
@ -113,16 +124,19 @@ void lv_cache_entry_release_data(lv_cache_entry_t * entry, void * user_data)
lv_cache_entry_dec_ref(entry);
}
lv_cache_entry_t * lv_cache_entry_get_entry(void * data, const uint32_t node_size)
{
LV_ASSERT_NULL(data);
return (lv_cache_entry_t *)((uint8_t *)data + node_size);
}
void lv_cache_entry_set_cache(lv_cache_entry_t * entry, const lv_cache_t * cache)
{
LV_ASSERT_NULL(entry);
entry->cache = cache;
}
const lv_cache_t * lv_cache_entry_get_cache(const lv_cache_entry_t * entry)
{
LV_ASSERT_NULL(entry);
@ -133,6 +147,7 @@ uint32_t lv_cache_entry_get_size(const uint32_t node_size)
{
return node_size + sizeof(lv_cache_entry_t);
}
lv_cache_entry_t * lv_cache_entry_alloc(const uint32_t node_size, const lv_cache_t * cache)
{
void * res = lv_malloc_zeroed(lv_cache_entry_get_size(node_size));
@ -145,6 +160,7 @@ lv_cache_entry_t * lv_cache_entry_alloc(const uint32_t node_size, const lv_cache
lv_cache_entry_init(entry, cache, node_size);
return (lv_cache_entry_t *)((uint8_t *)entry + node_size);
}
void lv_cache_entry_init(lv_cache_entry_t * entry, const lv_cache_t * cache, const uint32_t node_size)
{
LV_ASSERT_NULL(entry);
@ -155,6 +171,7 @@ void lv_cache_entry_init(lv_cache_entry_t * entry, const lv_cache_t * cache, con
entry->ref_cnt = 0;
entry->is_invalid = false;
}
void lv_cache_entry_delete(lv_cache_entry_t * entry)
{
LV_ASSERT_NULL(entry);
@ -162,6 +179,7 @@ void lv_cache_entry_delete(lv_cache_entry_t * entry)
void * data = lv_cache_entry_get_data(entry);
lv_free(data);
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@ -13,9 +13,8 @@ extern "C" {
/*********************
* INCLUDES
*********************/
#include "../../osal/lv_os.h"
#include "../lv_types.h"
#include "lv_cache_private.h"
/*********************
* DEFINES
*********************/

View File

@ -16,6 +16,7 @@ extern "C" {
#include "../lv_types.h"
#include "../../osal/lv_os.h"
#include "../lv_profiler.h"
/*********************
* DEFINES
*********************/
@ -35,6 +36,7 @@ void lv_cache_entry_set_invalid(lv_cache_entry_t * entry, bool is_invalid);
void lv_cache_entry_set_cache(lv_cache_entry_t * entry, const lv_cache_t * cache);
void * lv_cache_entry_acquire_data(lv_cache_entry_t * entry);
void lv_cache_entry_release_data(lv_cache_entry_t * entry, void * user_data);
/*************************
* GLOBAL VARIABLES
*************************/

View File

@ -40,9 +40,7 @@ struct _lv_cache_class_t;
struct _lv_cache_entry_t;
typedef struct _lv_cache_ops_t lv_cache_ops_t;
typedef struct _lv_cache_t lv_cache_t;
typedef struct _lv_cache_class_t lv_cache_class_t;
typedef struct _lv_cache_entry_t lv_cache_entry_t;
typedef int8_t lv_cache_compare_res_t;
typedef bool (*lv_cache_create_cb_t)(void * node, void * user_data);

View File

@ -135,6 +135,10 @@ typedef struct _lv_color_filter_dsc_t lv_color_filter_dsc_t;
typedef struct _lv_event_dsc_t lv_event_dsc_t;
typedef struct _lv_cache_t lv_cache_t;
typedef struct _lv_cache_entry_t lv_cache_entry_t;
typedef struct _lv_fs_file_cache_t lv_fs_file_cache_t;
typedef struct _lv_fs_path_ex_t lv_fs_path_ex_t;

View File

@ -41,7 +41,6 @@
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "../../osal/lv_os.h"
#include "../../misc/lv_ll.h"
#include "../../misc/lv_types.h"

View File

@ -17,6 +17,7 @@ extern "C" {
*********************/
#include "lv_tlsf.h"
#include "../../osal/lv_os.h"
/*********************
* DEFINES

View File

@ -18,6 +18,7 @@
#include "../../misc/lv_timer.h"
#include "../../core/lv_obj_class_private.h"
#include "../../misc/cache/lv_image_cache.h"
/*********************
* DEFINES