Don't uselessly change the filter when drawing

When profiling the pdf in https://bugzilla.mozilla.org/show_bug.cgi?id=1508765,
I noticed that half a second was spent to set the filter to "none".
This commit is contained in:
Calixte Denizet 2023-07-21 12:52:16 +02:00
parent 1a69b6ad64
commit 9a4750fee5

View File

@ -790,8 +790,11 @@ function resetCtxToDefault(ctx) {
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) || (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
!isNodeJS !isNodeJS
) { ) {
const { filter } = ctx;
if (filter !== "none" && filter !== "") {
ctx.filter = "none"; ctx.filter = "none";
} }
}
} }
function composeSMaskBackdrop(bytes, r0, g0, b0) { function composeSMaskBackdrop(bytes, r0, g0, b0) {
@ -2961,8 +2964,11 @@ class CanvasGraphics {
// It must be applied to the image before rescaling else some artifacts // It must be applied to the image before rescaling else some artifacts
// could appear. // could appear.
// The final restore will reset it to its value. // The final restore will reset it to its value.
const { filter } = ctx;
if (filter !== "none" && filter !== "") {
ctx.filter = "none"; ctx.filter = "none";
} }
}
// scale the image to the unit square // scale the image to the unit square
ctx.scale(1 / width, -1 / height); ctx.scale(1 / width, -1 / height);