mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-03 21:07:24 +02:00
Define the global cache-data once in buildPaintImageXObject
Currently we duplicate the same identical code three times, which seems both unnecessary and error prone.
This commit is contained in:
parent
e8b4ed2fde
commit
e0e59eaf01
@ -742,7 +742,8 @@ class PartialEvaluator {
|
|||||||
// If there is no imageMask, create the PDFImage and a lot
|
// If there is no imageMask, create the PDFImage and a lot
|
||||||
// of image processing can be done here.
|
// of image processing can be done here.
|
||||||
let objId = `img_${this.idFactory.createObjId()}`,
|
let objId = `img_${this.idFactory.createObjId()}`,
|
||||||
cacheGlobally = false;
|
cacheGlobally = false,
|
||||||
|
globalCacheData = null;
|
||||||
|
|
||||||
if (this.parsingType3Font) {
|
if (this.parsingType3Font) {
|
||||||
objId = `${this.idFactory.getDocId()}_type3_${objId}`;
|
objId = `${this.idFactory.getDocId()}_type3_${objId}`;
|
||||||
@ -767,15 +768,17 @@ class PartialEvaluator {
|
|||||||
operatorList.addImageOps(fn, args, optionalContent, hasMask);
|
operatorList.addImageOps(fn, args, optionalContent, hasMask);
|
||||||
|
|
||||||
if (cacheGlobally) {
|
if (cacheGlobally) {
|
||||||
if (this.globalImageCache.hasDecodeFailed(imageRef)) {
|
globalCacheData = {
|
||||||
this.globalImageCache.setData(imageRef, {
|
|
||||||
objId,
|
objId,
|
||||||
fn,
|
fn,
|
||||||
args,
|
args,
|
||||||
optionalContent,
|
optionalContent,
|
||||||
hasMask,
|
hasMask,
|
||||||
byteSize: 0, // Data is `null`, since decoding failed previously.
|
byteSize: 0, // Temporary entry, to avoid `setData` returning early.
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (this.globalImageCache.hasDecodeFailed(imageRef)) {
|
||||||
|
this.globalImageCache.setData(imageRef, globalCacheData);
|
||||||
|
|
||||||
this._sendImgData(objId, /* imgData = */ null, cacheGlobally);
|
this._sendImgData(objId, /* imgData = */ null, cacheGlobally);
|
||||||
return;
|
return;
|
||||||
@ -792,14 +795,7 @@ class PartialEvaluator {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (localLength) {
|
if (localLength) {
|
||||||
this.globalImageCache.setData(imageRef, {
|
this.globalImageCache.setData(imageRef, globalCacheData);
|
||||||
objId,
|
|
||||||
fn,
|
|
||||||
args,
|
|
||||||
optionalContent,
|
|
||||||
hasMask,
|
|
||||||
byteSize: 0, // Temporary entry, to avoid `setData` returning early.
|
|
||||||
});
|
|
||||||
this.globalImageCache.addByteSize(imageRef, localLength);
|
this.globalImageCache.addByteSize(imageRef, localLength);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -848,14 +844,8 @@ class PartialEvaluator {
|
|||||||
this._regionalImageCache.set(/* name = */ null, imageRef, cacheData);
|
this._regionalImageCache.set(/* name = */ null, imageRef, cacheData);
|
||||||
|
|
||||||
if (cacheGlobally) {
|
if (cacheGlobally) {
|
||||||
this.globalImageCache.setData(imageRef, {
|
assert(globalCacheData, "The global cache-data must be available.");
|
||||||
objId,
|
this.globalImageCache.setData(imageRef, globalCacheData);
|
||||||
fn,
|
|
||||||
args,
|
|
||||||
optionalContent,
|
|
||||||
hasMask,
|
|
||||||
byteSize: 0, // Temporary entry, note `addByteSize` above.
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user