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,
|
||||
inverseDecode: (!!decode && decode[0] > 0),
|
||||
});
|
||||
imgData.cached = true;
|
||||
imgData.cached = !!cacheKey;
|
||||
args = [imgData];
|
||||
|
||||
operatorList.addOp(OPS.paintImageMaskXObject, args);
|
||||
if (cacheKey) {
|
||||
imageCache[cacheKey] = {
|
||||
|
@ -534,30 +534,6 @@ var OperatorList = (function OperatorListClosure() {
|
||||
var CHUNK_SIZE = 1000;
|
||||
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) {
|
||||
this.messageHandler = messageHandler;
|
||||
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();
|
||||
var transfers = getTransfers(this);
|
||||
var length = this.length;
|
||||
const length = this.length;
|
||||
this._totalLength += length;
|
||||
|
||||
this.messageHandler.send('RenderPageChunk', {
|
||||
@ -645,7 +644,8 @@ var OperatorList = (function OperatorListClosure() {
|
||||
},
|
||||
pageIndex: this.pageIndex,
|
||||
intent: this.intent,
|
||||
}, transfers);
|
||||
}, this._transfers);
|
||||
|
||||
this.dependencies = Object.create(null);
|
||||
this.fnArray.length = 0;
|
||||
this.argsArray.length = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user