Skip to content
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

Add logic to track rendering area of various PDF ops #19043

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import {
NodeStandardFontDataFactory,
} from "display-node_utils";
import { CanvasGraphics } from "./canvas.js";
import { CanvasRecorder } from "./canvas_recorder.js";
import { DOMCanvasFactory } from "./canvas_factory.js";
import { DOMCMapReaderFactory } from "display-cmap_reader_factory";
import { DOMFilterFactory } from "./filter_factory.js";
Expand Down Expand Up @@ -1517,9 +1518,22 @@ class PDFPageProxy {
this._pumpOperatorList(intentArgs);
}

const recordingContext =
this._pdfBug &&
globalThis.StepperManager?.enabled &&
!this._recordedGroups
? new CanvasRecorder(canvasContext)
: null;

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

if (recordingContext) {
this._recordedGroups =
CanvasRecorder.getFinishedGroups(recordingContext);
internalRenderTask.stepper.setOperatorGroups(this._recordedGroups);
}

// Attempt to reduce memory usage during *printing*, by always running
// cleanup immediately once rendering has finished.
if (this._maybeCleanupAfterRender || intentPrint) {
Expand Down Expand Up @@ -1552,7 +1566,7 @@ class PDFPageProxy {
callback: complete,
// Only include the required properties, and *not* the entire object.
params: {
canvasContext,
canvasContext: recordingContext ?? canvasContext,
viewport,
transform,
background,
Expand Down
Loading