Compute the length of the final image-bitmap/data on the worker-thread

Currently this is done in the API, but moving it into the worker-thread will simplify upcoming changes.
This commit is contained in:
Jonas Jenwald 2023-12-14 21:32:08 +01:00
parent b09f238436
commit e547b198a3
2 changed files with 16 additions and 16 deletions

View file

@ -2781,18 +2781,8 @@ class WorkerTransport {
pageProxy.objs.resolve(id, imageData);
// Heuristic that will allow us not to store large data.
if (imageData) {
let length;
if (imageData.bitmap) {
const { width, height } = imageData;
length = width * height * 4;
} else {
length = imageData.data?.length || 0;
}
if (length > MAX_IMAGE_SIZE_TO_CACHE) {
pageProxy._maybeCleanupAfterRender = true;
}
if (imageData?.dataLen > MAX_IMAGE_SIZE_TO_CACHE) {
pageProxy._maybeCleanupAfterRender = true;
}
break;
case "Pattern":