BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lvgl
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
lvgl
Commits
c3e9ce73
Commit
c3e9ce73
authored
Jun 16, 2017
by
Kiss-Vamosi Gabor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Draw: make ready to use hw. accelerator
parent
8fc7c26a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
131 deletions
+135
-131
lv_draw.c
lv_draw/lv_draw.c
+46
-59
lv_draw_vbasic.c
lv_draw/lv_draw_vbasic.c
+89
-72
No files found.
lv_draw/lv_draw.c
View file @
c3e9ce73
...
@@ -346,83 +346,70 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
...
@@ -346,83 +346,70 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
uint32_t
br
;
uint32_t
br
;
res
=
fs_read
(
&
file
,
&
header
,
sizeof
(
lv_img_raw_header_t
),
&
br
);
res
=
fs_read
(
&
file
,
&
header
,
sizeof
(
lv_img_raw_header_t
),
&
br
);
/*If the width is greater then
map
width then it is upscaled */
/*If the width is greater then
real img.
width then it is upscaled */
bool
upscale
=
false
;
bool
upscale
=
false
;
if
(
area_get_width
(
cords_p
)
>
header
.
w
)
upscale
=
true
;
if
(
area_get_width
(
cords_p
)
>
header
.
w
)
upscale
=
true
;
cord_t
row
;
area_t
mask_com
;
/*Common area of mask and cords*/
area_t
act_area
;
area_t
mask_sub
;
bool
union_ok
;
bool
union_ok
;
union_ok
=
area_union
(
&
mask_
sub
,
mask_p
,
cords_p
);
union_ok
=
area_union
(
&
mask_
com
,
mask_p
,
cords_p
);
if
(
union_ok
==
false
)
{
if
(
union_ok
==
false
)
{
fs_close
(
&
file
);
fs_close
(
&
file
);
return
;
return
;
}
}
uint8_t
ds_shift
=
0
;
uint8_t
ds_num
=
1
;
/*Set some values if upscale enabled*/
if
(
upscale
!=
false
)
{
ds_shift
=
1
;
ds_num
=
2
;
}
uint32_t
start_offset
=
sizeof
(
lv_img_raw_header_t
);
start_offset
+=
(
area_get_width
(
cords_p
)
>>
ds_shift
)
*
((
mask_sub
.
y1
-
cords_p
->
y1
)
>>
ds_shift
)
*
sizeof
(
color_t
);
/*First row*/
start_offset
+=
((
mask_sub
.
x1
-
cords_p
->
x1
)
>>
ds_shift
)
*
sizeof
(
color_t
);
/*First col*/
fs_seek
(
&
file
,
start_offset
);
uint32_t
useful_data
=
(
area_get_width
(
&
mask_sub
)
>>
ds_shift
)
*
sizeof
(
color_t
);
uint32_t
next_row
=
(
area_get_width
(
cords_p
)
>>
ds_shift
)
*
sizeof
(
color_t
)
-
useful_data
;
/*Round the coordinates with upscale*/
/*Round the coordinates with upscale*/
if
(
upscale
!=
false
)
{
if
(
upscale
!=
false
)
{
if
((
mask_
sub
.
x1
&
0x1
)
!=
0
)
mask_sub
.
x1
-=
1
;
/*Can be only even*/
if
((
mask_
com
.
x1
&
0x1
)
!=
0
)
mask_com
.
x1
-=
1
;
/*Can be only even*/
if
((
mask_
sub
.
x2
&
0x1
)
==
0
)
mask_sub
.
x2
-=
1
;
/*Can be only odd*/
if
((
mask_
com
.
x2
&
0x1
)
==
0
)
mask_com
.
x2
-=
1
;
/*Can be only odd*/
}
}
area_cpy
(
&
act_area
,
&
mask_sub
);
/*If the img. data is inside the MCU then do not use FS reading just a pointer*/
/* Round down the start coordinate, because the upscaled images
* can start only LV_DOWNSCALE 'y' coordinates */
act_area
.
y1
&=
~
(
cord_t
)(
ds_num
-
1
)
;
act_area
.
y2
=
act_area
.
y1
+
ds_num
-
1
;
uint32_t
act_pos
;
bool
const_data
=
false
;
if
(
fn
[
0
]
==
UFS_LETTER
)
{
if
(
fn
[
0
]
==
UFS_LETTER
)
{
if
(((
ufs_file_t
*
)
file
.
file_d
)
->
ent
->
const_data
!=
0
)
{
uint8_t
*
f_data
=
((
ufs_file_t
*
)
file
.
file_d
)
->
ent
->
data_d
;
const_data
=
true
;
f_data
+=
sizeof
(
lv_img_raw_header_t
)
;
}
map_fp
(
cords_p
,
&
mask_com
,
(
void
*
)
f_data
,
style
->
opa
,
header
.
transp
,
upscale
,
style
->
ccolor
,
style
->
img_recolor
);
}
}
/*Read the img. with the FS interface*/
for
(
row
=
mask_sub
.
y1
;
row
<=
mask_sub
.
y2
;
row
+=
ds_num
)
{
else
{
uint8_t
us_shift
=
0
;
/*Get and use the pointer of const data in program memory*/
uint8_t
us_val
=
1
;
if
(
const_data
!=
false
)
{
if
(
upscale
!=
false
)
{
uint8_t
*
f_data
=
((
ufs_file_t
*
)
file
.
file_d
)
->
ent
->
data_d
;
us_shift
=
1
;
f_data
+=
((
ufs_file_t
*
)
file
.
file_d
)
->
rwp
;
us_val
=
2
;
((
ufs_file_t
*
)
file
.
file_d
)
->
rwp
+=
useful_data
;
}
map_fp
(
&
act_area
,
&
mask_sub
,
(
void
*
)
f_data
,
style
->
opa
,
header
.
transp
,
upscale
,
style
->
ccolor
,
style
->
img_recolor
);
/* Move the file pointer to the start address according to mask
}
* But take care, the upscaled maps look greater*/
/*Or read the NOT const files normally*/
uint32_t
start_offset
=
sizeof
(
lv_img_raw_header_t
);
else
{
start_offset
+=
(
area_get_width
(
cords_p
)
>>
us_shift
)
*
color_t
buf
[
LV_HOR_RES
];
((
mask_com
.
y1
-
cords_p
->
y1
)
>>
us_shift
)
*
sizeof
(
color_t
);
/*First row*/
start_offset
+=
((
mask_com
.
x1
-
cords_p
->
x1
)
>>
us_shift
)
*
sizeof
(
color_t
);
/*First col*/
fs_seek
(
&
file
,
start_offset
);
uint32_t
useful_data
=
(
area_get_width
(
&
mask_com
)
>>
us_shift
)
*
sizeof
(
color_t
);
uint32_t
next_row
=
(
area_get_width
(
cords_p
)
>>
us_shift
)
*
sizeof
(
color_t
)
-
useful_data
;
area_t
line
;
area_cpy
(
&
line
,
&
mask_com
);
area_set_height
(
&
line
,
us_val
);
/*Create a line area. Hold 2 pixels if upscaled*/
cord_t
row
;
uint32_t
act_pos
;
color_t
buf
[
LV_HOR_RES
];
for
(
row
=
mask_com
.
y1
;
row
<=
mask_com
.
y2
;
row
+=
us_val
)
{
res
=
fs_read
(
&
file
,
buf
,
useful_data
,
&
br
);
res
=
fs_read
(
&
file
,
buf
,
useful_data
,
&
br
);
map_fp
(
&
act_area
,
&
mask_sub
,
buf
,
style
->
opa
,
header
.
transp
,
upscale
,
map_fp
(
&
line
,
&
mask_com
,
buf
,
style
->
opa
,
header
.
transp
,
upscale
,
style
->
ccolor
,
style
->
img_recolor
);
style
->
ccolor
,
style
->
img_recolor
);
fs_tell
(
&
file
,
&
act_pos
);
fs_seek
(
&
file
,
act_pos
+
next_row
);
line
.
y1
+=
us_val
;
/*Go down a line*/
line
.
y2
+=
us_val
;
}
}
fs_tell
(
&
file
,
&
act_pos
);
fs_seek
(
&
file
,
act_pos
+
next_row
);
act_area
.
y1
+=
ds_num
;
act_area
.
y2
+=
ds_num
;
}
}
}
}
fs_close
(
&
file
);
fs_close
(
&
file
);
if
(
res
!=
FS_RES_OK
)
{
if
(
res
!=
FS_RES_OK
)
{
...
...
lv_draw/lv_draw_vbasic.c
View file @
c3e9ce73
...
@@ -31,6 +31,8 @@
...
@@ -31,6 +31,8 @@
/**********************
/**********************
* STATIC PROTOTYPES
* STATIC PROTOTYPES
**********************/
**********************/
static
void
sw_render_fill
(
area_t
*
mem_area
,
color_t
*
mem
,
const
area_t
*
fill_area
,
color_t
color
,
opa_t
opa
);
static
inline
void
sw_render_map_line
(
color_t
*
mem
,
const
color_t
*
map
,
cord_t
map_len
,
opa_t
opa
);
/**********************
/**********************
* STATIC VARIABLES
* STATIC VARIABLES
...
@@ -99,55 +101,20 @@ void lv_vfill(const area_t * cords_p, const area_t * mask_p,
...
@@ -99,55 +101,20 @@ void lv_vfill(const area_t * cords_p, const area_t * mask_p,
union_ok
=
area_union
(
&
res_a
,
cords_p
,
mask_p
);
union_ok
=
area_union
(
&
res_a
,
cords_p
,
mask_p
);
/*If there are common part of the three area then draw to the vdb*/
/*If there are common part of the three area then draw to the vdb*/
if
(
union_ok
==
true
)
{
if
(
union_ok
==
false
)
return
;
area_t
vdb_rel_a
;
/*Stores relative coordinates on vdb*/
vdb_rel_a
.
x1
=
res_a
.
x1
-
vdb_p
->
area
.
x1
;
area_t
vdb_rel_a
;
/*Stores relative coordinates on vdb*/
vdb_rel_a
.
y1
=
res_a
.
y1
-
vdb_p
->
area
.
y1
;
vdb_rel_a
.
x1
=
res_a
.
x1
-
vdb_p
->
area
.
x1
;
vdb_rel_a
.
x2
=
res_a
.
x2
-
vdb_p
->
area
.
x1
;
vdb_rel_a
.
y1
=
res_a
.
y1
-
vdb_p
->
area
.
y1
;
vdb_rel_a
.
y2
=
res_a
.
y2
-
vdb_p
->
area
.
y1
;
vdb_rel_a
.
x2
=
res_a
.
x2
-
vdb_p
->
area
.
x1
;
vdb_rel_a
.
y2
=
res_a
.
y2
-
vdb_p
->
area
.
y1
;
color_t
*
vdb_buf_tmp
=
vdb_p
->
buf
;
uint32_t
vdb_width
=
area_get_width
(
&
vdb_p
->
area
);
color_t
*
vdb_buf_tmp
=
vdb_p
->
buf
;
/*Move the vdb_tmp to the first row*/
uint32_t
vdb_width
=
area_get_width
(
&
vdb_p
->
area
);
vdb_buf_tmp
+=
vdb_width
*
vdb_rel_a
.
y1
;
/*Move the vdb_tmp to the first row*/
vdb_buf_tmp
+=
vdb_width
*
vdb_rel_a
.
y1
;
/*Set all row in vdb to the given color*/
cord_t
row
;
sw_render_fill
(
&
vdb_p
->
area
,
vdb_buf_tmp
,
&
vdb_rel_a
,
color
,
opa
);
uint32_t
col
;
/*Run simpler function without opacity*/
if
(
opa
==
OPA_COVER
)
{
/*Fill the first row with 'color'*/
for
(
col
=
vdb_rel_a
.
x1
;
col
<=
vdb_rel_a
.
x2
;
col
++
)
{
vdb_buf_tmp
[
col
]
=
color
;
}
/*Copy the first row to all other rows*/
color_t
*
vdb_buf_first
=
&
vdb_buf_tmp
[
vdb_rel_a
.
x1
];
cord_t
copy_size
=
(
vdb_rel_a
.
x2
-
vdb_rel_a
.
x1
+
1
)
*
sizeof
(
color_t
);
vdb_buf_tmp
+=
vdb_width
;
for
(
row
=
vdb_rel_a
.
y1
+
1
;
row
<=
vdb_rel_a
.
y2
;
row
++
)
{
memcpy
(
&
vdb_buf_tmp
[
vdb_rel_a
.
x1
],
vdb_buf_first
,
copy_size
);
vdb_buf_tmp
+=
vdb_width
;
}
}
/*Calculate with alpha too*/
else
{
color_t
bg_tmp
=
COLOR_BLACK
;
color_t
opa_tmp
=
color_mix
(
color
,
bg_tmp
,
opa
);
for
(
row
=
vdb_rel_a
.
y1
;
row
<=
vdb_rel_a
.
y2
;
row
++
)
{
for
(
col
=
vdb_rel_a
.
x1
;
col
<=
vdb_rel_a
.
x2
;
col
++
)
{
/*If the bg color changed recalculate the result color*/
if
(
vdb_buf_tmp
[
col
].
full
!=
bg_tmp
.
full
)
{
bg_tmp
=
vdb_buf_tmp
[
col
];
opa_tmp
=
color_mix
(
color
,
bg_tmp
,
opa
);
}
vdb_buf_tmp
[
col
]
=
opa_tmp
;
}
vdb_buf_tmp
+=
vdb_width
;
}
}
}
}
}
/**
/**
...
@@ -322,38 +289,22 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
...
@@ -322,38 +289,22 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
color_t
*
vdb_buf_tmp
=
vdb_p
->
buf
;
color_t
*
vdb_buf_tmp
=
vdb_p
->
buf
;
vdb_buf_tmp
+=
(
uint32_t
)
vdb_width
*
masked_a
.
y1
;
/*Move to the first row*/
vdb_buf_tmp
+=
(
uint32_t
)
vdb_width
*
masked_a
.
y1
;
/*Move to the first row*/
map_p
-=
(
masked_a
.
x1
>>
ds_shift
);
map_p
-=
(
masked_a
.
x1
>>
ds_shift
);
/*Move back. It will be easier to index 'map_p' later*/
/*No upscalse*/
/*No upscalse*/
if
(
upscale
==
false
)
{
if
(
upscale
==
false
)
{
if
(
transp
==
false
)
{
/*Simply copy the pixels to the VDB*/
if
(
transp
==
false
)
{
/*Simply copy the pixels to the VDB*/
cord_t
row
;
cord_t
row
;
if
(
opa
==
OPA_COVER
)
{
/*no opa */
for
(
row
=
masked_a
.
y1
;
row
<=
masked_a
.
y2
;
row
++
)
{
for
(
row
=
masked_a
.
y1
;
row
<=
masked_a
.
y2
;
row
++
)
{
sw_render_map_line
(
&
vdb_buf_tmp
[
masked_a
.
x1
],
&
map_p
[
masked_a
.
x1
],
map_width
,
opa
);
memcpy
(
&
vdb_buf_tmp
[
masked_a
.
x1
],
map_p
+=
map_width
;
/*Next row on the map*/
&
map_p
[
masked_a
.
x1
],
vdb_buf_tmp
+=
vdb_width
;
/*Next row on the VDB*/
area_get_width
(
&
masked_a
)
*
sizeof
(
color_t
));
map_p
+=
map_width
;
/*Next row on the map*/
vdb_buf_tmp
+=
vdb_width
;
/*Next row on the VDB*/
}
}
else
{
/*with opacity*/
cord_t
col
;
for
(
row
=
masked_a
.
y1
;
row
<=
masked_a
.
y2
;
row
++
)
{
for
(
col
=
masked_a
.
x1
;
col
<=
masked_a
.
x2
;
col
++
)
{
vdb_buf_tmp
[
col
]
=
color_mix
(
map_p
[
col
],
vdb_buf_tmp
[
col
],
opa
);
}
map_p
+=
map_width
;
/*Next row on the map*/
vdb_buf_tmp
+=
vdb_width
;
/*Next row on the VDB*/
}
}
}
#if LV_VDB_SIZE != 0
/*To recolor draw simply a rectangle above the image*/
/*To recolor draw simply a rectangle above the image*/
if
(
recolor_opa
!=
OPA_TRANSP
)
{
if
(
recolor_opa
!=
OPA_TRANSP
)
{
lv_vfill
(
cords_p
,
mask_p
,
recolor
,
recolor_opa
);
lv_vfill
(
cords_p
,
mask_p
,
recolor
,
recolor_opa
);
}
}
#endif
}
else
{
/*transp == true: Check all pixels */
}
else
{
/*transp == true: Check all pixels */
cord_t
row
;
cord_t
row
;
cord_t
col
;
cord_t
col
;
...
@@ -473,10 +424,76 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
...
@@ -473,10 +424,76 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
}
}
}
}
/**********************
/**********************
* STATIC FUNCTIONS
* STATIC FUNCTIONS
**********************/
**********************/
/**
*
* @param mem_area coordinates of 'mem' memory area
* @param mem a memory address. Considered to a rectangual window according to 'mem_area'
* @param fill_area coordinates of an area to fill. Relative to 'mem_area'.
* @param color fill color
* @param opa opacity (0, OPA_TRANSP: transparent ... 255, OPA_COVER, fully cover)
*/
static
void
sw_render_fill
(
area_t
*
mem_area
,
color_t
*
mem
,
const
area_t
*
fill_area
,
color_t
color
,
opa_t
opa
)
{
/*Set all row in vdb to the given color*/
cord_t
row
;
uint32_t
col
;
cord_t
mem_width
=
area_get_width
(
mem_area
);
/*Run simpler function without opacity*/
if
(
opa
==
OPA_COVER
)
{
/*Fill the first row with 'color'*/
for
(
col
=
fill_area
->
x1
;
col
<=
fill_area
->
x2
;
col
++
)
{
mem
[
col
]
=
color
;
}
/*Copy the first row to all other rows*/
color_t
*
mem_first
=
&
mem
[
fill_area
->
x1
];
cord_t
copy_size
=
(
fill_area
->
x2
-
fill_area
->
x1
+
1
)
*
sizeof
(
color_t
);
mem
+=
mem_width
;
for
(
row
=
fill_area
->
y1
+
1
;
row
<=
fill_area
->
y2
;
row
++
)
{
memcpy
(
&
mem
[
fill_area
->
x1
],
mem_first
,
copy_size
);
mem
+=
mem_width
;
}
}
/*Calculate with alpha too*/
else
{
color_t
bg_tmp
=
COLOR_BLACK
;
color_t
opa_tmp
=
color_mix
(
color
,
bg_tmp
,
opa
);
for
(
row
=
fill_area
->
y1
;
row
<=
fill_area
->
y2
;
row
++
)
{
for
(
col
=
fill_area
->
x1
;
col
<=
fill_area
->
x2
;
col
++
)
{
/*If the bg color changed recalculate the result color*/
if
(
mem
[
col
].
full
!=
bg_tmp
.
full
)
{
bg_tmp
=
mem
[
col
];
opa_tmp
=
color_mix
(
color
,
bg_tmp
,
opa
);
}
mem
[
col
]
=
opa_tmp
;
}
mem
+=
mem_width
;
}
}
}
/**
* Copy one line of pixel map into a memory using opacity
* @param mem a memory address. Copy 'map' here.
* @param map pointer to pixel map. Copy it to 'mem'.
* @param map_len number of pixels in 'map'
* @param opa opacity (0, OPA_TRANSP: transparent ... 255, OPA_COVER, fully cover)
*/
static
inline
void
sw_render_map_line
(
color_t
*
mem
,
const
color_t
*
map
,
cord_t
map_len
,
opa_t
opa
)
{
if
(
opa
==
OPA_COVER
)
{
/*no opa */
memcpy
(
mem
,
map
,
map_len
*
sizeof
(
color_t
));
}
else
{
/*with opacity*/
cord_t
x
;
for
(
x
=
0
;
x
<=
map_len
;
x
++
)
{
mem
[
x
]
=
color_mix
(
map
[
x
],
mem
[
x
],
opa
);
}
}
}
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment