Merge pull request #11974 from Snuffleupagus/sendImgData
A couple of small image caching/sending improvements
This commit is contained in:
commit
c97200ff59
@ -439,6 +439,30 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_sendImgData(objId, imgData, cacheGlobally = false) {
|
||||||
|
const transfers = imgData ? [imgData.data.buffer] : null;
|
||||||
|
|
||||||
|
if (this.parsingType3Font) {
|
||||||
|
return this.handler.sendWithPromise(
|
||||||
|
"commonobj",
|
||||||
|
[objId, "FontType3Res", imgData],
|
||||||
|
transfers
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (cacheGlobally) {
|
||||||
|
return this.handler.send(
|
||||||
|
"commonobj",
|
||||||
|
[objId, "Image", imgData],
|
||||||
|
transfers
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return this.handler.send(
|
||||||
|
"obj",
|
||||||
|
[objId, this.pageIndex, "Image", imgData],
|
||||||
|
transfers
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
async buildPaintImageXObject({
|
async buildPaintImageXObject({
|
||||||
resources,
|
resources,
|
||||||
image,
|
image,
|
||||||
@ -552,42 +576,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
.then(imageObj => {
|
.then(imageObj => {
|
||||||
imgData = imageObj.createImageData(/* forceRGBA = */ false);
|
imgData = imageObj.createImageData(/* forceRGBA = */ false);
|
||||||
|
|
||||||
if (this.parsingType3Font) {
|
return this._sendImgData(objId, imgData, cacheGlobally);
|
||||||
return this.handler.sendWithPromise(
|
|
||||||
"commonobj",
|
|
||||||
[objId, "FontType3Res", imgData],
|
|
||||||
[imgData.data.buffer]
|
|
||||||
);
|
|
||||||
} else if (cacheGlobally) {
|
|
||||||
this.handler.send(
|
|
||||||
"commonobj",
|
|
||||||
[objId, "Image", imgData],
|
|
||||||
[imgData.data.buffer]
|
|
||||||
);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
this.handler.send(
|
|
||||||
"obj",
|
|
||||||
[objId, this.pageIndex, "Image", imgData],
|
|
||||||
[imgData.data.buffer]
|
|
||||||
);
|
|
||||||
return undefined;
|
|
||||||
})
|
})
|
||||||
.catch(reason => {
|
.catch(reason => {
|
||||||
warn("Unable to decode image: " + reason);
|
warn("Unable to decode image: " + reason);
|
||||||
|
|
||||||
if (this.parsingType3Font) {
|
return this._sendImgData(objId, /* imgData = */ null, cacheGlobally);
|
||||||
return this.handler.sendWithPromise("commonobj", [
|
|
||||||
objId,
|
|
||||||
"FontType3Res",
|
|
||||||
null,
|
|
||||||
]);
|
|
||||||
} else if (cacheGlobally) {
|
|
||||||
this.handler.send("commonobj", [objId, "Image", null]);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
this.handler.send("obj", [objId, this.pageIndex, "Image", null]);
|
|
||||||
return undefined;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.parsingType3Font) {
|
if (this.parsingType3Font) {
|
||||||
|
@ -107,11 +107,10 @@ class GlobalImageCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getData(ref, pageIndex) {
|
getData(ref, pageIndex) {
|
||||||
if (!this._refCache.has(ref)) {
|
const pageIndexSet = this._refCache.get(ref);
|
||||||
|
if (!pageIndexSet) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const pageIndexSet = this._refCache.get(ref);
|
|
||||||
|
|
||||||
if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) {
|
if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user