Merge pull request #10647 from Snuffleupagus/ImageMask-cached
Actually transfer eligible ImageMask data, rather than always copying it
This commit is contained in:
commit
9f6de3bfbb
@ -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] = {
|
||||||
|
@ -534,30 +534,6 @@ var OperatorList = (function OperatorListClosure() {
|
|||||||
var CHUNK_SIZE = 1000;
|
var CHUNK_SIZE = 1000;
|
||||||
var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5; // close to chunk size
|
var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5; // close to chunk size
|
||||||
|
|
||||||
function getTransfers(queue) {
|
|
||||||
var transfers = [];
|
|
||||||
var fnArray = queue.fnArray, argsArray = queue.argsArray;
|
|
||||||
for (var i = 0, ii = queue.length; i < ii; i++) {
|
|
||||||
switch (fnArray[i]) {
|
|
||||||
case OPS.paintInlineImageXObject:
|
|
||||||
case OPS.paintInlineImageXObjectGroup:
|
|
||||||
case OPS.paintImageMaskXObject:
|
|
||||||
var arg = argsArray[i][0]; // first param in imgData
|
|
||||||
|
|
||||||
if (typeof PDFJSDev === 'undefined' ||
|
|
||||||
PDFJSDev.test('!PRODUCTION || TESTING')) {
|
|
||||||
assert(arg.data instanceof Uint8ClampedArray,
|
|
||||||
'OperatorList - getTransfers: Unsupported "arg.data" type.');
|
|
||||||
}
|
|
||||||
if (!arg.cached) {
|
|
||||||
transfers.push(arg.data.buffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return transfers;
|
|
||||||
}
|
|
||||||
|
|
||||||
function OperatorList(intent, messageHandler, pageIndex) {
|
function OperatorList(intent, messageHandler, pageIndex) {
|
||||||
this.messageHandler = messageHandler;
|
this.messageHandler = messageHandler;
|
||||||
this.fnArray = [];
|
this.fnArray = [];
|
||||||
@ -630,10 +606,33 @@ var OperatorList = (function OperatorListClosure() {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
flush(lastChunk) {
|
get _transfers() {
|
||||||
|
const transfers = [];
|
||||||
|
const { fnArray, argsArray, length, } = this;
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
switch (fnArray[i]) {
|
||||||
|
case OPS.paintInlineImageXObject:
|
||||||
|
case OPS.paintInlineImageXObjectGroup:
|
||||||
|
case OPS.paintImageMaskXObject:
|
||||||
|
const arg = argsArray[i][0]; // first param in imgData
|
||||||
|
|
||||||
|
if (typeof PDFJSDev === 'undefined' ||
|
||||||
|
PDFJSDev.test('!PRODUCTION || TESTING')) {
|
||||||
|
assert(arg.data instanceof Uint8ClampedArray,
|
||||||
|
'OperatorList._transfers: Unsupported "arg.data" type.');
|
||||||
|
}
|
||||||
|
if (!arg.cached) {
|
||||||
|
transfers.push(arg.data.buffer);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return transfers;
|
||||||
|
},
|
||||||
|
|
||||||
|
flush(lastChunk = false) {
|
||||||
this.optimizer.flush();
|
this.optimizer.flush();
|
||||||
var transfers = getTransfers(this);
|
const length = this.length;
|
||||||
var length = this.length;
|
|
||||||
this._totalLength += length;
|
this._totalLength += length;
|
||||||
|
|
||||||
this.messageHandler.send('RenderPageChunk', {
|
this.messageHandler.send('RenderPageChunk', {
|
||||||
@ -645,7 +644,8 @@ var OperatorList = (function OperatorListClosure() {
|
|||||||
},
|
},
|
||||||
pageIndex: this.pageIndex,
|
pageIndex: this.pageIndex,
|
||||||
intent: this.intent,
|
intent: this.intent,
|
||||||
}, transfers);
|
}, this._transfers);
|
||||||
|
|
||||||
this.dependencies = Object.create(null);
|
this.dependencies = Object.create(null);
|
||||||
this.fnArray.length = 0;
|
this.fnArray.length = 0;
|
||||||
this.argsArray.length = 0;
|
this.argsArray.length = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user