fix(editor): invalidate turbo renderer on selection update (#10499)
This commit is contained in:
@@ -27,6 +27,8 @@ const font = new FontFace(
|
|||||||
// @ts-expect-error worker env
|
// @ts-expect-error worker env
|
||||||
self.fonts && self.fonts.add(font);
|
self.fonts && self.fonts.add(font);
|
||||||
|
|
||||||
|
const debugSentenceBoarder = false;
|
||||||
|
|
||||||
function getBaseline() {
|
function getBaseline() {
|
||||||
const fontSize = 15;
|
const fontSize = 15;
|
||||||
const lineHeight = 1.2 * fontSize;
|
const lineHeight = 1.2 * fontSize;
|
||||||
@@ -60,8 +62,6 @@ class LayoutPainter {
|
|||||||
private clearBackground() {
|
private clearBackground() {
|
||||||
if (!this.canvas || !this.ctx) return;
|
if (!this.canvas || !this.ctx) return;
|
||||||
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||||
this.ctx.fillStyle = 'white';
|
|
||||||
this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
paint(layout: ViewportLayout, version: number) {
|
paint(layout: ViewportLayout, version: number) {
|
||||||
@@ -94,7 +94,9 @@ class LayoutPainter {
|
|||||||
// Only render if we haven't rendered at this position before
|
// Only render if we haven't rendered at this position before
|
||||||
if (renderedPositions.has(posKey)) return;
|
if (renderedPositions.has(posKey)) return;
|
||||||
|
|
||||||
|
if (debugSentenceBoarder) {
|
||||||
ctx.strokeRect(x, y, textRect.rect.w, textRect.rect.h);
|
ctx.strokeRect(x, y, textRect.rect.w, textRect.rect.h);
|
||||||
|
}
|
||||||
ctx.fillStyle = 'black';
|
ctx.fillStyle = 'black';
|
||||||
ctx.fillText(textRect.text, x, y + baselineY);
|
ctx.fillText(textRect.text, x, y + baselineY);
|
||||||
|
|
||||||
|
|||||||
@@ -78,10 +78,10 @@ export class ViewportTurboRendererExtension extends LifeCycleWatcher {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
this.std.store.slots.blockUpdated.on(() => {
|
this.selection.slots.updated.on(() => this.invalidate())
|
||||||
this.invalidate();
|
);
|
||||||
this.debouncedRefresh();
|
this.disposables.add(
|
||||||
})
|
this.std.store.slots.blockUpdated.on(() => this.invalidate())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,8 +95,16 @@ export class ViewportTurboRendererExtension extends LifeCycleWatcher {
|
|||||||
this.setState('inactive');
|
this.setState('inactive');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get gfx() {
|
||||||
|
return this.std.get(GfxControllerIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
get viewport() {
|
get viewport() {
|
||||||
return this.std.get(GfxControllerIdentifier).viewport;
|
return this.gfx.viewport;
|
||||||
|
}
|
||||||
|
|
||||||
|
get selection() {
|
||||||
|
return this.gfx.selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
get layoutCache() {
|
get layoutCache() {
|
||||||
|
|||||||
Reference in New Issue
Block a user