-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store round corners in 16x16 patches instead of 8x8 #82
Conversation
I was getting some OOM on my slider-using example because we made too many unneccesary alpha maps. This cuts them down. Also improves speed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
src/style.toit
Outdated
- byte-opacity: a 64 entry byte array of 8x8 opacity values, or null if the patch is fully transparent. | ||
- bit-opacity: an 8 entry byte array of 8x8 opacity values, or null if the patch is fully transparent. | ||
- byte-opacity: a 256 entry byte array of 16x16 opacity values, or null if the patch is fully transparent. | ||
- bit-opacity: an 32 entry byte array of 16x16 opacity values, or null if the patch is fully transparent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- bit-opacity: an 32 entry byte array of 16x16 opacity values, or null if the patch is fully transparent. | |
- bit-opacity: a 32 entry byte array of 16x16 opacity values, or null if the patch is fully transparent. |
src/style.toit
Outdated
- x: the x coordinate of the top left corner of the patch. | ||
- y: the y coordinate of the top left corner of the patch. | ||
- orientation: the orientation to draw the patch, one of $ORIENTATION-0, $ORIENTATION-90, $ORIENTATION-180, $ORIENTATION-270. | ||
*/ | ||
draw-corners_ left/int top/int right/int bottom/int corner-radius/int [block]: | ||
for j := 0; j < corner-radius; j += 8: | ||
for i := 0; i < corner-radius; i += 8: | ||
for j := 0; j < corner-radius; j += 16: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use constants.
Would make it easier to tweak and give these constants meaning.
src/style.toit
Outdated
@@ -423,7 +423,7 @@ class RoundedCornerOpacity_: | |||
radius/int | |||
static cache_ := Map.weak | |||
|
|||
static OPAQUE-BYTES-8x8_/ByteArray ::= ByteArray 64: 0xff | |||
static OPAQUE-BYTES-16x16_/ByteArray ::= ByteArray 256: 0xff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure I asked this before, but just didn't see the response: why is this not a literal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find that. I think may be thinking of.
https://github.com/toitware/toit-pixel-display/pull/55/files/0d382646d2b146089bd6405b64958666b2af96db#r1417165258
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the end I decided not to make this change, because it harmonizes badly with the request to use a constant for the patch size. There's no way to make a literal that is sized based on a different constant.
This is a moderate performance improvement.
See the 16x16 column below on the example with 4 round buttons on the M5 display, based on tests/icons-visualized.toit.