mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
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:
parent
b09f238436
commit
e547b198a3
2 changed files with 16 additions and 16 deletions
|
@ -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":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue