Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a helper function for handling locally cached image data (PR 18269 follow-up) #18273

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 9 additions & 31 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,12 @@ function normalizeBlendMode(value, parsingArray = false) {
return "source-over";
}

function incrementCachedImageMaskCount(data) {
function addLocallyCachedImageOps(opList, data) {
if (data.objId) {
opList.addDependency(data.objId);
}
opList.addImageOps(data.fn, data.args, data.optionalContent);

if (data.fn === OPS.paintImageMaskXObject && data.args[0]?.count > 0) {
data.args[0].count++;
}
Expand Down Expand Up @@ -1785,16 +1790,7 @@ class PartialEvaluator {
if (isValidName) {
const localImage = localImageCache.getByName(name);
if (localImage) {
if (localImage.objId) {
operatorList.addDependency(localImage.objId);
}
operatorList.addImageOps(
localImage.fn,
localImage.args,
localImage.optionalContent
);

incrementCachedImageMaskCount(localImage);
addLocallyCachedImageOps(operatorList, localImage);
args = null;
continue;
}
Expand All @@ -1812,16 +1808,7 @@ class PartialEvaluator {
localImageCache.getByRef(xobj) ||
self._regionalImageCache.getByRef(xobj);
if (localImage) {
if (localImage.objId) {
operatorList.addDependency(localImage.objId);
}
operatorList.addImageOps(
localImage.fn,
localImage.args,
localImage.optionalContent
);

incrementCachedImageMaskCount(localImage);
addLocallyCachedImageOps(operatorList, localImage);
resolveXObject();
return;
}
Expand Down Expand Up @@ -1936,16 +1923,7 @@ class PartialEvaluator {
if (cacheKey) {
const localImage = localImageCache.getByName(cacheKey);
if (localImage) {
if (localImage.objId) {
operatorList.addDependency(localImage.objId);
}
operatorList.addImageOps(
localImage.fn,
localImage.args,
localImage.optionalContent
);

incrementCachedImageMaskCount(localImage);
addLocallyCachedImageOps(operatorList, localImage);
args = null;
continue;
}
Expand Down