Skip to content

Commit

Permalink
Test native decoding of masks and soft masks separately
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrant committed Jun 22, 2017
1 parent cdb403f commit d363c14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 1 addition & 9 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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).
Expand Down
10 changes: 7 additions & 3 deletions src/core/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,25 @@ 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;

var smask = image.dict.get('SMask');
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 {
Expand Down

0 comments on commit d363c14

Please sign in to comment.