Skip to content

Commit 8184a06

Browse files
wip: Use PDF ops instead of canvas ops
1 parent 8a2bafa commit 8184a06

File tree

4 files changed

+354
-448
lines changed

4 files changed

+354
-448
lines changed

src/display/api.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import {
6161
NodeWasmFactory,
6262
} from "display-node_utils";
6363
import { CanvasGraphics } from "./canvas.js";
64-
import { CanvasRecorder } from "./canvas_recorder.js";
64+
import { CanvasDependencyTracker } from "./canvas_dependency_tracker.js";
6565
import { DOMCanvasFactory } from "./canvas_factory.js";
6666
import { DOMCMapReaderFactory } from "display-cmap_reader_factory";
6767
import { DOMFilterFactory } from "./filter_factory.js";
@@ -1462,19 +1462,16 @@ class PDFPageProxy {
14621462
this._pumpOperatorList(intentArgs);
14631463
}
14641464

1465-
const recordingContext =
1465+
const shouldRecordOperations =
14661466
this._pdfBug &&
14671467
globalThis.StepperManager?.enabled &&
1468-
!this._recordedGroups
1469-
? new CanvasRecorder(canvasContext)
1470-
: null;
1468+
!this._recordedGroups;
14711469

14721470
const complete = error => {
14731471
intentState.renderTasks.delete(internalRenderTask);
14741472

1475-
if (recordingContext) {
1476-
this._recordedGroups =
1477-
CanvasRecorder.getFinishedGroups(recordingContext);
1473+
if (shouldRecordOperations) {
1474+
this._recordedGroups = internalRenderTask.gfx.dependencyTracker.take();
14781475
internalRenderTask.stepper.setOperatorGroups(this._recordedGroups);
14791476
}
14801477

@@ -1510,7 +1507,10 @@ class PDFPageProxy {
15101507
callback: complete,
15111508
// Only include the required properties, and *not* the entire object.
15121509
params: {
1513-
canvasContext: recordingContext ?? canvasContext,
1510+
canvasContext: canvasContext,
1511+
dependencyTracker: shouldRecordOperations
1512+
? new CanvasDependencyTracker(canvasContext)
1513+
: null,
15141514
viewport,
15151515
transform,
15161516
background,
@@ -3146,6 +3146,7 @@ class InternalRenderTask {
31463146
this._scheduleNextBound = this._scheduleNext.bind(this);
31473147
this._nextBound = this._next.bind(this);
31483148
this._canvas = params.canvasContext.canvas;
3149+
this._dependencyTracker = params.dependencyTracker;
31493150
}
31503151

31513152
get completed() {
@@ -3175,7 +3176,13 @@ class InternalRenderTask {
31753176
this.stepper.init(this.operatorList);
31763177
this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
31773178
}
3178-
const { canvasContext, viewport, transform, background } = this.params;
3179+
const {
3180+
canvasContext,
3181+
viewport,
3182+
transform,
3183+
background,
3184+
dependencyTracker,
3185+
} = this.params;
31793186

31803187
this.gfx = new CanvasGraphics(
31813188
canvasContext,
@@ -3185,7 +3192,8 @@ class InternalRenderTask {
31853192
this.filterFactory,
31863193
{ optionalContentConfig },
31873194
this.annotationCanvasMap,
3188-
this.pageColors
3195+
this.pageColors,
3196+
dependencyTracker
31893197
);
31903198
this.gfx.beginDrawing({
31913199
transform,

0 commit comments

Comments
 (0)