Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dos
flow3r firmware
Commits
b962cd96
Commit
b962cd96
authored
1 year ago
by
pippin
Browse files
Options
Downloads
Patches
Plain Diff
st3m_gfx: avoid some superfluous clips at 1x
Also, less hard-coding of display size.
parent
0dcccf12
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/st3m/st3m_gfx.c
+23
-21
23 additions, 21 deletions
components/st3m/st3m_gfx.c
with
23 additions
and
21 deletions
components/st3m/st3m_gfx.c
+
23
−
21
View file @
b962cd96
...
...
@@ -34,13 +34,15 @@ static st3m_gfx_mode default_mode = ST3M_GFX_DEFAULT_MODE;
// faster but it is not possible to enable wifi
#if CTX_ST3M_FB_INTERNAL_RAM
static
uint16_t
st3m_fb
[
240
*
240
];
static
uint16_t
st3m_fb
[
FLOW3R_BSP_DISPLAY_WIDTH
*
FLOW3R_BSP_DISPLAY_HEIGHT
];
uint8_t
st3m_pal
[
256
*
3
];
#else
EXT_RAM_BSS_ATTR
uint8_t
st3m_pal
[
256
*
3
];
EXT_RAM_BSS_ATTR
static
uint16_t
st3m_fb
[
240
*
240
];
EXT_RAM_BSS_ATTR
static
uint16_t
st3m_fb
[
FLOW3R_BSP_DISPLAY_WIDTH
*
FLOW3R_BSP_DISPLAY_HEIGHT
];
#endif
EXT_RAM_BSS_ATTR
static
uint8_t
st3m_fb2
[
240
*
240
*
4
];
EXT_RAM_BSS_ATTR
static
uint8_t
st3m_fb2
[
FLOW3R_BSP_DISPLAY_WIDTH
*
FLOW3R_BSP_DISPLAY_HEIGHT
*
4
];
// Get a free drawlist ctx to draw into.
//
...
...
@@ -123,7 +125,7 @@ static inline int _st3m_gfx_bpp(st3m_gfx_mode mode) {
else
return
16
;
}
int
bpp
=
(
mode
&
(
1
|
2
|
4
|
8
|
16
|
24
|
32
)
);
int
bpp
=
(
mode
&
63
);
if
(
bpp
>=
2
&&
bpp
<
4
)
bpp
=
2
;
if
(
bpp
>=
4
&&
bpp
<
8
)
bpp
=
4
;
if
(
bpp
>=
8
&&
bpp
<
16
)
bpp
=
8
;
...
...
@@ -170,7 +172,7 @@ void st3m_gfx_start_frame(Ctx *ctx) {
int
scale
=
st3m_gfx_scale
();
ctx_save
(
ctx
);
st3m_gfx_viewport_transform
(
ctx
);
if
(
scale
)
{
if
(
scale
>
1
)
{
ctx_rectangle
(
ctx
,
-
120
,
-
120
,
240
,
240
);
ctx_clip
(
ctx
);
}
...
...
@@ -348,29 +350,29 @@ st3m_gfx_mode st3m_gfx_get_mode(void) {
uint8_t
*
st3m_gfx_fb
(
st3m_gfx_mode
mode
,
int
*
width
,
int
*
height
,
int
*
stride
)
{
st3m_gfx_mode
set_mode
=
_st3m_gfx_mode
?
_st3m_gfx_mode
:
default_mode
;
int
bpp
=
_st3m_gfx_bpp
(
set_mode
);
int
scale
=
st3m_gfx_scale
();
if
(
mode
==
st3m_gfx_palette
)
{
if
(
stride
)
*
stride
=
3
;
if
(
width
)
*
width
=
1
;
if
(
height
)
*
height
=
256
;
return
st3m_pal
;
}
else
if
(
mode
==
st3m_gfx_default
)
{
if
(
stride
)
*
stride
=
240
*
bpp
/
8
;
if
(
width
)
*
width
=
240
;
if
(
height
)
*
height
=
240
;
if
(
stride
)
*
stride
=
FLOW3R_BSP_DISPLAY_WIDTH
*
bpp
/
8
;
if
(
width
)
*
width
=
FLOW3R_BSP_DISPLAY_WIDTH
;
if
(
height
)
*
height
=
FLOW3R_BSP_DISPLAY_HEIGHT
;
if
(
bpp
<=
16
)
return
(
uint8_t
*
)
st3m_fb
;
return
st3m_fb2
;
}
else
if
(
mode
==
st3m_gfx_osd
)
{
if
(
stride
)
*
stride
=
240
*
bpp
/
8
;
if
(
width
)
*
width
=
240
;
if
(
height
)
*
height
=
240
;
if
(
stride
)
*
stride
=
FLOW3R_BSP_DISPLAY_WIDTH
*
bpp
/
8
;
if
(
width
)
*
width
=
FLOW3R_BSP_DISPLAY_WIDTH
;
if
(
height
)
*
height
=
FLOW3R_BSP_DISPLAY_HEIGHT
;
if
(
_st3m_gfx_bpp
(
set_mode
)
<=
16
)
return
st3m_fb2
;
return
(
uint8_t
*
)
st3m_fb
;
}
if
(
stride
)
*
stride
=
240
*
bpp
/
8
;
if
(
width
)
*
width
=
240
/
scale
;
if
(
height
)
*
height
=
240
/
scale
;
int
scale
=
st3m_gfx_scale
();
if
(
stride
)
*
stride
=
FLOW3R_BSP_DISPLAY_WIDTH
*
bpp
/
8
;
if
(
width
)
*
width
=
FLOW3R_BSP_DISPLAY_WIDTH
/
scale
;
if
(
height
)
*
height
=
FLOW3R_BSP_DISPLAY_HEIGHT
/
scale
;
if
(
bpp
<=
16
)
return
(
uint8_t
*
)
st3m_fb
;
return
st3m_fb2
;
}
...
...
@@ -438,7 +440,7 @@ static void st3m_gfx_task(void *_arg) {
if
((
set_mode
&
st3m_gfx_direct_ctx
)
==
0
)
ctx_render_ctx
(
drawlist
->
user_ctx
,
user_target
);
if
(
scale
||
((
set_mode
&
st3m_gfx_osd
)
&&
if
(
(
scale
>
1
)
||
((
set_mode
&
st3m_gfx_osd
)
&&
(
drawlist
->
osd_y0
!=
drawlist
->
osd_y1
)))
{
if
(((
set_mode
&
st3m_gfx_osd
)
&&
(
drawlist
->
osd_y0
!=
drawlist
->
osd_y1
)))
{
...
...
@@ -850,14 +852,14 @@ void st3m_gfx_flush(int timeout_ms) {
void
st3m_gfx_overlay_clip
(
int
x0
,
int
y0
,
int
x1
,
int
y1
)
{
if
(
y1
<
0
)
y1
=
0
;
if
(
y1
>
240
)
y1
=
240
;
if
(
y1
>
FLOW3R_BSP_DISPLAY_HEIGHT
)
y1
=
FLOW3R_BSP_DISPLAY_HEIGHT
;
if
(
y0
<
0
)
y0
=
0
;
if
(
y0
>
240
)
y0
=
240
;
if
(
y0
>
FLOW3R_BSP_DISPLAY_HEIGHT
)
y0
=
FLOW3R_BSP_DISPLAY_HEIGHT
;
if
(
x1
<
0
)
x1
=
0
;
if
(
x1
>
240
)
x1
=
240
;
if
(
x1
>
FLOW3R_BSP_DISPLAY_WIDTH
)
x1
=
FLOW3R_BSP_DISPLAY_WIDTH
;
if
(
x0
<
0
)
x0
=
0
;
if
(
x0
>
240
)
x0
=
240
;
if
(
x0
>
FLOW3R_BSP_DISPLAY_WIDTH
)
x0
=
FLOW3R_BSP_DISPLAY_WIDTH
;
st3m_gfx_drawlist
*
drawlist
=
&
drawlists
[
last_descno
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment