Commit graph

285 commits

Author SHA1 Message Date
nworbnhoj
64f6ddeade breakout mod Dither adaptor iterator 2022-07-28 05:51:07 +10:00
nworbnhoj
dadaae2884 mark color_types palette as unsupported in Bitmap::from_png 2022-07-28 05:25:05 +10:00
nworbnhoj
118f0c0346 extend color_types & bit_depths in GreyScale adaptor iterator 2022-07-28 05:21:20 +10:00
nworbnhoj
7cd5ee82ce Implement decode_png adaptor iterator
This incomplete PNG decoder presents as an Iterator reading u8 bytes directly from a Reader.

Aproaching a png decoder as an Iterator requires significantly less Heap than
the traditional batch aproach.

On Precursor, this enables PNG bytes to be intercepted at the network interface
and processed into the much smaller gam::Bitmap format without ever having to
store the original PNG file.
2022-07-27 09:18:19 +10:00
nworbnhoj
e7d5c11cbc
Merge branch 'main' into iter 2022-06-29 10:54:06 +10:00
nworbnhoj
247dfd2fe7 simplify gam bitmap img struct 2022-06-29 07:33:37 +10:00
nworbnhoj
29925a5caa implement Dither adaptor iterator 2022-06-28 07:31:18 +10:00
Sean Cross
748d4ce87d Merge remote-tracking branch 'origin/main' into libstd-fs 2022-06-27 09:14:04 +08:00
bunnie
e2b550f34d
Merge pull request #193 from nworbnhoj/main
reduce memory footprint of Dither::dither()
2022-06-27 04:06:34 +08:00
Sean Cross
5639bb81ce gam: define opcode numbers for opcodes
Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-26 16:45:18 +08:00
bunnie
e2f335ec3a make missed input forwarding non-fatal 2022-06-23 02:26:02 +08:00
bunnie
0624dee629 fix default entry population on multiple fields 2022-06-23 01:27:24 +08:00
bunnie
44b15c7262 modify text entry behavior to recover default
if the field is empty and you're not in password mode,
pressing left or right will populate the autocomplete field
2022-06-22 21:41:07 +08:00
nworbnhoj
549178e148 implement Shrink adaptor iterator 2022-06-22 21:30:20 +10:00
bunnie
7e65f3db66 add a breadcrumb 2022-06-22 18:16:28 +08:00
bunnie
5e450235e3 improve debug output for raise/lower; add a nonblocking relinquish 2022-06-22 18:14:00 +08:00
bunnie
e33c7b9ecc add raise/lower debug info 2022-06-22 18:12:04 +08:00
bunnie
f041dfb9b4 fix warning message on nonblocking redraw 2022-06-22 18:11:23 +08:00
bunnie
b777714435 modify textentry behavior: default text changes
at the moment, default text will always come back if you
remove the text so there is no text in the field (for example,
you start typing, and then you decide you want to start over,
the suggested text re-appears).

this change makes it so that once you start typing, the suggested
text does not return. Furthermore, it counts the initial backspace
as a key that's hit, so you can clear the suggested text by just
hitting backspace.
2022-06-22 04:42:05 +08:00
nworbnhoj
0f971fcc33 implement 3xU8 RGB to U8 Greyscale adapter iterator 2022-06-20 08:03:03 +10:00
bunnie
5f4678ca6a fix concurrency issue in predictor/redraw loop
So there's a bit of a nasty bug that arises from the GAM
both handling drawing primitives and context swaps.

In particular, because the GAM handles both of these in a
single thread, context swaps can't block, because the redraws
triggered by the context swap would be blocked, causing a deadlock.

When the API token for the predictor was introduced, this added
a blocking operation inside the context swap. This would cause
a deadlock under certain conditions.

This patch refactors the API token so that it's not a return
result of swapping the predictors. Instead, the predictors
return the API token as a non-blocking message to the GAM. This
API token is correlated with the *GAM* token (not the app token).
Present me thanks past me for adding the GAM token, which was
as of yet unused, but now, there is a very sensible role for it--
exactly what it was made for, e.g. handling GAM-local API calls
without disclosing the application token.

Anyways, hopefully this patch puts the race condition to
rest, while allowing us to have per-context prediction histories.
2022-06-20 03:05:16 +08:00
bunnie
78ea80f809 remove main() thread-wrapping for non-ditherpunk configs
saves a bit of memory
2022-06-19 21:39:29 +08:00
bunnie
9acab60018 strip out some debug statements 2022-06-19 01:56:58 +08:00
bunnie
b7453b627e add API tokens to prediction API
The prediction API now takes an API token. This is a 128-bit
number that gets passed to the prediction engine, and it's meant
to be unique for every context that requires a predictor.

It's up to the prediction engine to do anything with the token.
For the "null" engines (such as the icontray for `vault` and
`tts`) the token is just ignored. But for example, in `shellchat`,
the API token is used to store a history record in a HashMap on
a per-token basis. This means that every app that uses the
`shellchat` history function gets their own history that can only
be read out by that app.

The actual token itself is mostly passed through the API. The
token storage is in the Context layer (each Context has a record
for a token, that starts as `None`), and is passed down to
the predictor every time the context swaps, and the predictor
receives the token and passes it back if the token was `Some`,
or allocates a new random token if it was `None`.

Note that everything is a Context, including, for example, menus and
modal dialog boxes, but not all contexts have predictors. Only
Contexts that ask for a predictor have them. This mechanism
works smoothly in this model (as opposed to other hacks and work-arounds
previously tried getting to this solution).
2022-06-19 01:01:25 +08:00
nworbnhoj
5c48439a66 reduce memory footprint of Dither::dither() 2022-06-18 21:02:21 +10:00
nworbnhoj
2dbdb10704 remove dependency on fast-image-resize crate 2022-06-18 12:07:58 +10:00
nworbnhoj
e9224cf4ae Merge branch 'main' of github.com:nworbnhoj/xous-core into main 2022-06-18 08:47:40 +10:00
nworbnhoj
409f696fde Implement gam::PixelType
enables gam::Img to import different image formats: U8 & U8x3 for now
2022-06-18 08:43:32 +10:00
nworbnhoj
9b8c4e063f
Merge branch 'betrusted-io:main' into main 2022-06-18 07:10:33 +10:00
nworbnhoj
f7e216bb25 convert RGB image immediately to greyscale on import
code simplification/reduction, and memory/processing saving
2022-06-18 07:07:15 +10:00
bunnie
1e266b3389 adjust image modal size to match the target size for image centering 2022-06-17 22:01:07 +08:00
bunnie
d829839c28
Merge pull request #190 from nworbnhoj/main
fix gam::Tile render RHS
2022-06-17 21:40:28 +08:00
nworbnhoj
d33d7958f2 Merge branch 'main' of github.com:nworbnhoj/xous-core into main 2022-06-17 23:08:37 +10:00
nworbnhoj
148e0fdd99 remove unnecessary Img clone 2022-06-17 23:06:39 +10:00
bunnie
6e0d025dea add "menu mode" option to the IMEF
in "menu mode" the predictive area functions as four menu
option keys instead of dynamic prediction updates.

this patch is mostly working but we need to figure out how to
force a redraw of the predction area when the app is raised,
because we get a stale image from the previous app on context
switch.
2022-06-17 12:40:44 +08:00
bunnie
cf89ebe5f5 add wrapper around main functions that need bigger stacks
This allows for `ditherpunk` config to have a much larger
stack size on select processes only.

The cost comes at a 4k fixed overhead for the sacrificial
wrapper thread, so we lose about 20k of runtime RAM, even
when ditherpunk is *not* activated (because we're
always wrapping the threads).

There is no impact on scheduling or CPU utilization, as the
wrapper thread blocks and is never scheduled once the real
main starts. However, it does subtract one thread from the
total available thread pool.
2022-06-16 03:40:19 +08:00
bunnie
d39c319c05 recode GAM interface to send one tile at a time
Don't add Tiles to ObjectList because it greatly inflates
the amount of RAM required to sling tiles around
2022-06-15 01:32:12 +08:00
bunnie
1bd82b9ea4 try to debug why images aren't showing up 2022-06-14 19:06:33 +08:00
bunnie
fc8e5df2b1 Merge remote-tracking branch 'origin/dither2' into dp2-merge 2022-06-14 16:45:38 +08:00
nworbnhoj
0bf71b84c1 implement gam Bitmap Dither
- remove depencency on dither crate
- Burkes diffusion scheme
2022-06-14 04:27:04 +10:00
bunnie
21c8c09050 create a API to insert an item at an offset 2022-06-10 21:29:33 +08:00
bunnie
64f008b4fa add debugging facilities to gam 2022-06-07 16:28:26 +08:00
bunnie
741a6ab45e fix dynamic resize redraw bug
for some reason I was setting the state of a canvas to not drawable
when the clip rectangle was being reset, causing dynamic dialog boxes
to become static if the content inside changes size.

I think this is an artifact of a previous generation of this code,
so commenting that out, but left a breadcrumb is case I'm wrong.
2022-06-07 16:27:16 +08:00
bunnie
ebd4e7a1ba improve dynamic notifications / kbhit reporting 2022-06-06 03:46:57 +08:00
nworbnhoj
4b12915df0 performance improvement for gam bitmap from Img 2022-06-04 20:43:34 +10:00
nworbnhoj
7f90e6e999 change dithering algorithm to BURKES 2022-06-04 17:01:43 +10:00
nworbnhoj
767461fa16 remove image crate dependency from gam Bitmap 2022-06-04 16:34:00 +10:00
nworbnhoj
66b0665d08 remove unnecessary image processing step 2022-06-04 09:04:24 +10:00
nworbnhoj
beb2778ce6 implement gam bitmap.rotate90() 2022-06-02 14:23:09 +10:00
bunnie
6f1bbb49d1 cleanup whitespace issues 2022-06-01 22:33:04 +08:00