Apply HCM filters on annotations which have their own canvas (bug 1830850)
This commit is contained in:
parent
797f8d3dca
commit
c07149a44f
@ -3326,7 +3326,8 @@ class InternalRenderTask {
|
|||||||
this.canvasFactory,
|
this.canvasFactory,
|
||||||
this.filterFactory,
|
this.filterFactory,
|
||||||
{ optionalContentConfig },
|
{ optionalContentConfig },
|
||||||
this.annotationCanvasMap
|
this.annotationCanvasMap,
|
||||||
|
this.pageColors
|
||||||
);
|
);
|
||||||
this.gfx.beginDrawing({
|
this.gfx.beginDrawing({
|
||||||
transform,
|
transform,
|
||||||
@ -3342,7 +3343,7 @@ class InternalRenderTask {
|
|||||||
cancel(error = null, extraDelay = 0) {
|
cancel(error = null, extraDelay = 0) {
|
||||||
this.running = false;
|
this.running = false;
|
||||||
this.cancelled = true;
|
this.cancelled = true;
|
||||||
this.gfx?.endDrawing(this.pageColors);
|
this.gfx?.endDrawing();
|
||||||
|
|
||||||
if (this._canvas) {
|
if (this._canvas) {
|
||||||
InternalRenderTask.#canvasInUse.delete(this._canvas);
|
InternalRenderTask.#canvasInUse.delete(this._canvas);
|
||||||
|
@ -947,7 +947,8 @@ class CanvasGraphics {
|
|||||||
canvasFactory,
|
canvasFactory,
|
||||||
filterFactory,
|
filterFactory,
|
||||||
{ optionalContentConfig, markedContentStack = null },
|
{ optionalContentConfig, markedContentStack = null },
|
||||||
annotationCanvasMap
|
annotationCanvasMap,
|
||||||
|
pageColors
|
||||||
) {
|
) {
|
||||||
this.ctx = canvasCtx;
|
this.ctx = canvasCtx;
|
||||||
this.current = new CanvasExtraState(
|
this.current = new CanvasExtraState(
|
||||||
@ -983,6 +984,7 @@ class CanvasGraphics {
|
|||||||
this.viewportScale = 1;
|
this.viewportScale = 1;
|
||||||
this.outputScaleX = 1;
|
this.outputScaleX = 1;
|
||||||
this.outputScaleY = 1;
|
this.outputScaleY = 1;
|
||||||
|
this.pageColors = pageColors;
|
||||||
|
|
||||||
this._cachedScaleForStroking = null;
|
this._cachedScaleForStroking = null;
|
||||||
this._cachedGetSinglePixelWidth = null;
|
this._cachedGetSinglePixelWidth = null;
|
||||||
@ -1135,7 +1137,7 @@ class CanvasGraphics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endDrawing(pageColors = null) {
|
endDrawing() {
|
||||||
this.#restoreInitialState();
|
this.#restoreInitialState();
|
||||||
|
|
||||||
this.cachedCanvases.clear();
|
this.cachedCanvases.clear();
|
||||||
@ -1153,11 +1155,14 @@ class CanvasGraphics {
|
|||||||
cache.clear();
|
cache.clear();
|
||||||
}
|
}
|
||||||
this._cachedBitmapsMap.clear();
|
this._cachedBitmapsMap.clear();
|
||||||
|
this.#drawFilter();
|
||||||
|
}
|
||||||
|
|
||||||
if (pageColors) {
|
#drawFilter() {
|
||||||
|
if (this.pageColors) {
|
||||||
const hcmFilterId = this.filterFactory.addHCMFilter(
|
const hcmFilterId = this.filterFactory.addHCMFilter(
|
||||||
pageColors.foreground,
|
this.pageColors.foreground,
|
||||||
pageColors.background
|
this.pageColors.background
|
||||||
);
|
);
|
||||||
if (hcmFilterId !== "none") {
|
if (hcmFilterId !== "none") {
|
||||||
const savedFilter = this.ctx.filter;
|
const savedFilter = this.ctx.filter;
|
||||||
@ -2712,6 +2717,7 @@ class CanvasGraphics {
|
|||||||
this.annotationCanvasMap.set(id, canvas);
|
this.annotationCanvasMap.set(id, canvas);
|
||||||
this.annotationCanvas.savedCtx = this.ctx;
|
this.annotationCanvas.savedCtx = this.ctx;
|
||||||
this.ctx = context;
|
this.ctx = context;
|
||||||
|
this.ctx.save();
|
||||||
this.ctx.setTransform(scaleX, 0, 0, -scaleY, 0, height * scaleY);
|
this.ctx.setTransform(scaleX, 0, 0, -scaleY, 0, height * scaleY);
|
||||||
|
|
||||||
resetCtxToDefault(this.ctx);
|
resetCtxToDefault(this.ctx);
|
||||||
@ -2735,6 +2741,9 @@ class CanvasGraphics {
|
|||||||
|
|
||||||
endAnnotation() {
|
endAnnotation() {
|
||||||
if (this.annotationCanvas) {
|
if (this.annotationCanvas) {
|
||||||
|
this.ctx.restore();
|
||||||
|
this.#drawFilter();
|
||||||
|
|
||||||
this.ctx = this.annotationCanvas.savedCtx;
|
this.ctx = this.annotationCanvas.savedCtx;
|
||||||
delete this.annotationCanvas.savedCtx;
|
delete this.annotationCanvas.savedCtx;
|
||||||
delete this.annotationCanvas;
|
delete this.annotationCanvas;
|
||||||
|
@ -7530,5 +7530,17 @@
|
|||||||
"md5": "1aa34fbb2154f9a647c7fa9e90db0eff",
|
"md5": "1aa34fbb2154f9a647c7fa9e90db0eff",
|
||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "text"
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "annotation-fileattachment-forced-colors-eq",
|
||||||
|
"file": "pdfs/annotation-fileattachment.pdf",
|
||||||
|
"md5": "d20ecee4b53c81b2dd44c8715a1b4a83",
|
||||||
|
"rounds": 1,
|
||||||
|
"pageColors": {
|
||||||
|
"background": "black",
|
||||||
|
"foreground": "#00FF00"
|
||||||
|
},
|
||||||
|
"annotations": true,
|
||||||
|
"type": "eq"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user