Skip to content

Commit c13ca9b

Browse files
committed
Detect filters in annotations
1 parent 1f77366 commit c13ca9b

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

src/core/document.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,21 +552,46 @@ class Page {
552552
});
553553
}
554554

555+
// Wait for annotations to check their resources for canvas filters
556+
// before sending StartRenderPage (fixes issue17069).
557+
const annotationsPromise = this._parsedAnnotations;
558+
555559
const pageListPromise = Promise.all([
556560
contentStreamPromise,
557561
resourcesPromise,
558-
]).then(async ([contentStream]) => {
562+
annotationsPromise,
563+
]).then(async ([contentStream, , parsedAnnotations]) => {
559564
const resources = await this.#getMergedResources(
560565
contentStream.dict,
561566
RESOURCES_KEYS_OPERATOR_LIST
562567
);
568+
569+
// Check for canvas filters in page resources and annotation resources.
570+
let hasCanvasFilters = partialEvaluator.hasCanvasFilters(resources);
571+
if (!hasCanvasFilters) {
572+
// Check annotation appearance resources for canvas filters.
573+
for (const annotation of parsedAnnotations) {
574+
const appearance = annotation.appearance;
575+
if (appearance) {
576+
const annotResources = appearance.dict?.get("Resources");
577+
if (
578+
annotResources &&
579+
partialEvaluator.hasCanvasFilters(annotResources)
580+
) {
581+
hasCanvasFilters = true;
582+
break;
583+
}
584+
}
585+
}
586+
}
587+
563588
const opList = new OperatorList(intent, sink);
564589
handler.send("StartRenderPage", {
565590
transparency: partialEvaluator.hasBlendModes(
566591
resources,
567592
this.nonBlendModesSet
568593
),
569-
hasCanvasFilters: partialEvaluator.hasCanvasFilters(resources),
594+
hasCanvasFilters,
570595
pageIndex,
571596
cacheKey,
572597
});
@@ -585,7 +610,7 @@ class Page {
585610
// eslint-disable-next-line prefer-const
586611
let [pageOpList, annotations, newAnnotations] = await Promise.all([
587612
pageListPromise,
588-
this._parsedAnnotations,
613+
annotationsPromise,
589614
newAnnotationsPromise,
590615
]);
591616

src/display/renderer_worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class RendererMessageHandler {
7777
this.#renderTaskStates.delete(renderTaskId);
7878
}
7979

80-
static #cleanupPage(pageIndex) {
80+
static #cleanupPage(pageIndex, keepCanvas = false) {
8181
this.#objsMap.delete(pageIndex);
8282
for (const [renderTaskId, renderTaskState] of this.#renderTaskStates) {
8383
if (renderTaskState.pageIndex === pageIndex) {

0 commit comments

Comments
 (0)