mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge pull request #16075 from calixteman/svg_filter_hcm
[api-minor] Use a SVG filter when rendering pages in HCM
This commit is contained in:
commit
3903391f3c
5 changed files with 181 additions and 85 deletions
|
@ -1002,8 +1002,14 @@ class PDFPageView {
|
|||
// is complete when `!this.renderingQueue`, to prevent black flickering.
|
||||
canvas.hidden = true;
|
||||
let isCanvasHidden = true;
|
||||
const showCanvas = function () {
|
||||
if (isCanvasHidden) {
|
||||
const hasHCM = !!(
|
||||
this.pageColors?.background && this.pageColors?.foreground
|
||||
);
|
||||
const showCanvas = function (isLastShow) {
|
||||
// In HCM, a final filter is applied on the canvas which means that
|
||||
// before it's applied we've normal colors. Consequently, to avoid to have
|
||||
// a final flash we just display it once all the drawing is done.
|
||||
if (isCanvasHidden && (!hasHCM || isLastShow)) {
|
||||
canvas.hidden = false;
|
||||
isCanvasHidden = false;
|
||||
}
|
||||
|
@ -1064,7 +1070,7 @@ class PDFPageView {
|
|||
};
|
||||
const renderTask = this.pdfPage.render(renderContext);
|
||||
renderTask.onContinue = function (cont) {
|
||||
showCanvas();
|
||||
showCanvas(false);
|
||||
if (result.onRenderContinue) {
|
||||
result.onRenderContinue(cont);
|
||||
} else {
|
||||
|
@ -1074,7 +1080,7 @@ class PDFPageView {
|
|||
|
||||
renderTask.promise.then(
|
||||
function () {
|
||||
showCanvas();
|
||||
showCanvas(true);
|
||||
renderCapability.resolve();
|
||||
},
|
||||
function (error) {
|
||||
|
@ -1082,7 +1088,7 @@ class PDFPageView {
|
|||
// a black canvas if rendering was cancelled before the `onContinue`-
|
||||
// callback had been invoked at least once.
|
||||
if (!(error instanceof RenderingCancelledException)) {
|
||||
showCanvas();
|
||||
showCanvas(true);
|
||||
}
|
||||
renderCapability.reject(error);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue