-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Modularize the character atlas system, add a LRU-cache based dynamic character atlas #1327
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
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6f21385
Add BaseCharAtlas and implement StaticCharAtlas
bgw 8c980bc
Add a dummy NoneCharAtlas implementation
bgw 24feaab
Add a basic dynamic character atlas implementation
bgw c8b500c
Skip drawing whitespace from DynamicCharAtlas
bgw 8b3b753
Add a new LRUMap class, remove uses of Map
bgw ac7db87
Remove use of Promises in {Base,Static}CharAtlas
bgw 9c0ce1d
Fix DynamicCharAtlas with transparency
bgw c6d66d7
Fix subpixel antialising in DynamicCharAtlas
bgw c3eea02
Add a LRUMap test, fix a bug in LRUMap
bgw 1f692ed
Use a single tmpCtx, avoid parsing color values
bgw 5a05db7
Add a per-frame limit on dynamic atlas writes
bgw 4a13813
Rename DRAW_TO_CACHE_LIMIT to FRAME_CACHE_DRAW_LIMIT
bgw ec96c40
Re-add colors.ansi slicing in generateConfig
bgw 4fd630e
Add code to IGlyphIdentifer, use it
bgw d254d69
Fix fontWeight options with DynamicCharAtlas
bgw 453da35
Merge branch 'master' into dynamic-char-atlas
bgw 7f761b5
Merge branch 'master' into dynamic-char-atlas
bgw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /** | ||
| * Copyright (c) 2017 The xterm.js authors. All rights reserved. | ||
| * @license MIT | ||
| */ | ||
|
|
||
| import { IGlyphIdentifier } from './Types'; | ||
|
|
||
| export default abstract class BaseCharAtlas { | ||
| private _didWarmUp: boolean = false; | ||
|
|
||
| /** | ||
| * Perform any work needed to warm the cache before it can be used. May be called multiple times. | ||
| * Implement _doWarmUp instead if you only want to get called once. | ||
| */ | ||
| public warmUp(): void { | ||
| if (!this._didWarmUp) { | ||
| this._doWarmUp(); | ||
| this._didWarmUp = true; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Perform any work needed to warm the cache before it can be used. Used by the default | ||
| * implementation of warmUp(), and will only be called once. | ||
| */ | ||
| protected _doWarmUp(): void { } | ||
|
|
||
| /** | ||
| * Called when we start drawing a new frame. | ||
| * | ||
| * TODO: We rely on this getting called by TextRenderLayer. This should really be called by | ||
| * Renderer instead, but we need to make Renderer the source-of-truth for the char atlas, instead | ||
| * of BaseRenderLayer. | ||
| */ | ||
| public beginFrame(): void { } | ||
|
|
||
| /** | ||
| * May be called before warmUp finishes, however it is okay for the implementation to | ||
| * do nothing and return false in that case. | ||
| * | ||
| * @param ctx Where to draw the character onto. | ||
| * @param glyph Information about what to draw | ||
| * @param x The position on the context to start drawing at | ||
| * @param y The position on the context to start drawing at | ||
| * @returns The success state. True if we drew the character. | ||
| */ | ||
| public abstract draw( | ||
| ctx: CanvasRenderingContext2D, | ||
| glyph: IGlyphIdentifier, | ||
| x: number, | ||
| y: number | ||
| ): boolean; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What do you think about pulling the dynamic cache into an addon for now and monkeypatching some factory method or something to inject while it's still being evaluated?
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.
Seems reasonable. We'll still probably need/want to add the BaseCharAtlas stuff though, so we have a sane way to hook into the atlas/drawing system.
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.
👍
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've spent a little bit of time trying to pull DynamicCharAtlas off into a separate addon, but it's a bit painful given the number of shared types and utility functions, I don't feel like it provides much benefit since we'd still need to leave a large amount of the changed code in place to decouple the renderer and atlas, and it would make it more difficult for us to make DynamicCharAtlas the primary atlas later on, since we'd need to re-integrate it.
How important is this to you?