Skip to content

Implement canvas-based TextBubbleSkin #451

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

Merged
merged 7 commits into from
May 24, 2019

Conversation

adroitwhiz
Copy link
Contributor

@adroitwhiz adroitwhiz commented May 1, 2019

Resolves

Resolves scratchfoundation/scratch-gui#2721 (I think)

Proposed Changes

This PR replaces the SVG text bubble generator with a canvas-based TextBubbleSkin. This skin is rendered in screen-space and its texture updates synchronously (to the best of my knowledge).

Reason for Changes

This removes all the SVG rendering quirks (textures only re-rendering at power-of-two scale factors, weird jaggies, etc.) from text bubbles.

It also improves performance; see Test Bubbles. It's important to note that the old implementation will still be faster in full-screen mode, but only due to a bug in the SVG renderer which renders the text bubbles at 1x scale for the first frame they are shown.
However, the new implementation is significantly faster at the same scale (~2x according to my tests, but more benchmarking would be a good idea).

Test Coverage

I'm not quite sure how to test this! Any guidance is appreciated.

@adroitwhiz adroitwhiz changed the title Canvas text bubble Implement canvas-based TextBubbleSkin May 1, 2019
@paulkaplan
Copy link
Contributor

Wow this looks great! I am also seeing about a 2x speedup! I tested other language/character sets, line breaks, and it seems to also fix some unusual "jumping" that happens when quickly refreshing the text bubble.

@paulkaplan
Copy link
Contributor

@cwillisf not sure if you want to take a peek at this

@paulkaplan
Copy link
Contributor

Incidentally, this seems to fix garbled text ordering with multi-line say bubbles: scratchfoundation/scratch-vm#1887

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Speech bubble can show cut off
3 participants