Skip to content

Commit 23cfb34

Browse files
committed
Make dependencyTracker work with the renderer
1 parent b928461 commit 23cfb34

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/display/api.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3335,9 +3335,16 @@ class InternalRenderTask {
33353335
this.graphicsReadyCallback ||= this._continueBound;
33363336
return;
33373337
}
3338-
this.gfx.dependencyTracker?.growOperationsCount(
3339-
this.operatorList.fnArray.length
3340-
);
3338+
if (!this._renderInWorker) {
3339+
this.gfx.dependencyTracker?.growOperationsCount(
3340+
this.operatorList.fnArray.length
3341+
);
3342+
} else {
3343+
this.rendererHandler.send("growOperationsCount", {
3344+
taskID: this.taskID,
3345+
newOperatorListLength: this.operatorList.fnArray.length,
3346+
});
3347+
}
33413348
this.stepper?.updateOperatorList(this.operatorList);
33423349

33433350
if (this.running) {

src/display/renderer_worker.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class RendererMessageHandler {
7979
transparency,
8080
background,
8181
optionalContentConfig,
82+
dependencyTracker,
8283
}) => {
8384
assert(!this.#tasks.has(taskID), "Task already initialized");
8485
const ctx = canvas.getContext("2d", {
@@ -94,7 +95,8 @@ class RendererMessageHandler {
9495
this.#filterFactory,
9596
{ optionalContentConfig },
9697
map,
97-
colors
98+
colors,
99+
dependencyTracker
98100
);
99101
gfx.beginDrawing({ transform, viewport, transparency, background });
100102
this.#tasks.set(taskID, { canvas, gfx });
@@ -148,6 +150,18 @@ class RendererMessageHandler {
148150
mainHandler.destroy();
149151
mainHandler = null;
150152
});
153+
154+
mainHandler.on(
155+
"growOperationsCount",
156+
({ taskID, newOperatorListLength }) => {
157+
if (terminated) {
158+
throw new Error("Renderer worker has been terminated.");
159+
}
160+
const task = this.#tasks.get(taskID);
161+
assert(task !== undefined, "Task not initialized");
162+
task.gfx.dependencyTracker?.growOperationsCount(newOperatorListLength);
163+
}
164+
);
151165
}
152166
}
153167

0 commit comments

Comments
 (0)