diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 0c776882f301a..fb4ba386247a7 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -109,11 +109,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { } }; - WorkerNativeImageStreamDecoder.isSupported = - function WorkerNativeImageStreamDecoder_isSupported(image) { - return image instanceof Jbig2Stream || image instanceof JpxStream; - }; - // Trying to minimize Date.now() usage and check every 100 time var TIME_SLOT_DURATION_MS = 20; var CHECK_TIME_EVERY = 100; @@ -324,10 +319,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { return; } - var workerNativeImageStreamDecoder = null; - if (WorkerNativeImageStreamDecoder.isSupported(image)) { - workerNativeImageStreamDecoder = new WorkerNativeImageStreamDecoder(self.handler); - } + var workerNativeImageStreamDecoder = new WorkerNativeImageStreamDecoder(self.handler); PDFImage.buildImage(self.handler, self.xref, resources, image, inline, workerNativeImageStreamDecoder). diff --git a/src/core/image.js b/src/core/image.js index 837cd5b26a6cb..bcf929257a9f2 100644 --- a/src/core/image.js +++ b/src/core/image.js @@ -156,7 +156,11 @@ var PDFImage = (function PDFImageClosure() { PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeImageStreamDecoder) { - var imagePromise = handleImageData(handler, xref, res, image, nativeImageStreamDecoder); + var isSupportedNativeImage = function(i) { + return i instanceof Jbig2Stream || i instanceof JpxStream; + }; + + var imagePromise = handleImageData(handler, xref, res, image, isSupportedNativeImage(image) && nativeImageStreamDecoder); var smaskPromise; var maskPromise; @@ -164,13 +168,13 @@ var PDFImage = (function PDFImageClosure() { var mask = image.dict.get('Mask'); if (smask) { - smaskPromise = handleImageData(handler, xref, res, smask, nativeImageStreamDecoder); + smaskPromise = handleImageData(handler, xref, res, smask, isSupportedNativeImage(smask) && nativeImageStreamDecoder); maskPromise = Promise.resolve(null); } else { smaskPromise = Promise.resolve(null); if (mask) { if (isStream(mask)) { - maskPromise = handleImageData(handler, xref, res, mask, nativeImageStreamDecoder); + maskPromise = handleImageData(handler, xref, res, mask, isSupportedNativeImage(mask) && nativeImageStreamDecoder); } else if (isArray(mask)) { maskPromise = Promise.resolve(mask); } else {