Actually transfer eligible ImageMask data, rather than always copying it
By transfering `ArrayBuffer`s you can avoid having two copies of the same data, i.e. one copy on each of the worker/main-thread, for data that's used only *once* on the worker-thread. Note how the code in [`PDFImage.createMask`](80135378ca/src/core/image.js (L284-L285)
) goes to great lengths to actually enable tranfering of the image data. However in [`PartialEvaluator.buildPaintImageXObject`](80135378ca/src/core/evaluator.js (L336)
) the `cached` property is always set to `true`, which disqualifies the image data from being transfered; see [`getTransfers`](80135378ca/src/core/operator_list.js (L552-L554)
). For most ImageMask data this patch won't matter, since images found in the `/Resources -> /XObject` dictionary will always be indexed by name. However for *inline* images which contains ImageMask data, where only "small" images are cached (in both `parser.js` and `evaluator.js`), the current code will result in some unnecessary memory usage.
This commit is contained in:
parent
80135378ca
commit
7273795eb6
@ -333,8 +333,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
imageIsFromDecodeStream: image instanceof DecodeStream,
|
imageIsFromDecodeStream: image instanceof DecodeStream,
|
||||||
inverseDecode: (!!decode && decode[0] > 0),
|
inverseDecode: (!!decode && decode[0] > 0),
|
||||||
});
|
});
|
||||||
imgData.cached = true;
|
imgData.cached = !!cacheKey;
|
||||||
args = [imgData];
|
args = [imgData];
|
||||||
|
|
||||||
operatorList.addOp(OPS.paintImageMaskXObject, args);
|
operatorList.addOp(OPS.paintImageMaskXObject, args);
|
||||||
if (cacheKey) {
|
if (cacheKey) {
|
||||||
imageCache[cacheKey] = {
|
imageCache[cacheKey] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user