Adding experimental async LaTeX renderer (speeds up rendering ridiculously, but causes instability)
This commit is contained in:
parent
f734e40ad9
commit
cf73b35a9a
6 changed files with 50 additions and 12 deletions
|
@ -84,13 +84,21 @@ export class DialogInterface extends Interface {
|
|||
}
|
||||
|
||||
export class LatexInterface extends Interface {
|
||||
supportsAsyncRender = BOOLEAN
|
||||
/**
|
||||
* @param {string} markup - LaTeX markup to render
|
||||
* @param {number} fontSize - Font size (in pt) to render
|
||||
* @param {string} color - Color of the text to render
|
||||
* @returns {string} - Comma separated data of the image (source, width, height)
|
||||
*/
|
||||
render = FUNCTION
|
||||
renderSync = FUNCTION
|
||||
/**
|
||||
* @param {string} markup - LaTeX markup to render
|
||||
* @param {number} fontSize - Font size (in pt) to render
|
||||
* @param {string} color - Color of the text to render
|
||||
* @returns {Promise<string>} - Comma separated data of the image (source, width, height)
|
||||
*/
|
||||
renderAsync = FUNCTION
|
||||
/**
|
||||
* @param {string} markup - LaTeX markup to render
|
||||
* @param {number} fontSize - Font size (in pt) to render
|
||||
|
|
|
@ -112,7 +112,12 @@ class LatexAPI extends Module {
|
|||
*/
|
||||
async requestAsyncRender(markup, fontSize, color) {
|
||||
if(!this.initialized) throw new Error("Attempting requestAsyncRender before initialize!")
|
||||
let args = this.#latex.render(markup, fontSize, color).split(",")
|
||||
let render
|
||||
if(this.#latex.supportsAsyncRender)
|
||||
render = await this.#latex.renderAsync(markup, fontSize, color)
|
||||
else
|
||||
render = this.#latex.renderSync(markup, fontSize, color)
|
||||
const args = render.split(",")
|
||||
return new LatexRenderResult(...args)
|
||||
}
|
||||
|
||||
|
|
|
@ -46,8 +46,15 @@ class EnableLatex extends BoolSetting {
|
|||
}
|
||||
}
|
||||
|
||||
const ENABLE_LATEX_ASYNC = new BoolSetting(
|
||||
qsTranslate("general", "Enable asynchronous LaTeX renderer (experimental)"),
|
||||
"enable_latex_async",
|
||||
"new"
|
||||
)
|
||||
|
||||
export default [
|
||||
CHECK_FOR_UPDATES,
|
||||
RESET_REDO_STACK,
|
||||
new EnableLatex()
|
||||
new EnableLatex(),
|
||||
ENABLE_LATEX_ASYNC
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue