Merge pull request #16079 from mozilla/Snuffleupagus-PDFObjects-bitmap
Move the `ImageBitmap` clean-up into the `PDFObjects` class
This commit is contained in:
commit
3f33fbf8cf
@ -1282,8 +1282,6 @@ class PDFPageProxy {
|
||||
this.commonObjs = transport.commonObjs;
|
||||
this.objs = new PDFObjects();
|
||||
|
||||
this._bitmaps = new Set();
|
||||
|
||||
this.cleanupAfterRender = false;
|
||||
this.pendingCleanup = false;
|
||||
this._intentStates = new Map();
|
||||
@ -1679,10 +1677,6 @@ class PDFPageProxy {
|
||||
}
|
||||
}
|
||||
this.objs.clear();
|
||||
for (const bitmap of this._bitmaps) {
|
||||
bitmap.close();
|
||||
}
|
||||
this._bitmaps.clear();
|
||||
this.pendingCleanup = false;
|
||||
return Promise.all(waitOn);
|
||||
}
|
||||
@ -1718,10 +1712,6 @@ class PDFPageProxy {
|
||||
if (resetStats && this._stats) {
|
||||
this._stats = new StatTimer();
|
||||
}
|
||||
for (const bitmap of this._bitmaps) {
|
||||
bitmap.close();
|
||||
}
|
||||
this._bitmaps.clear();
|
||||
this.pendingCleanup = false;
|
||||
return true;
|
||||
}
|
||||
@ -2774,9 +2764,8 @@ class WorkerTransport {
|
||||
if (imageData) {
|
||||
let length;
|
||||
if (imageData.bitmap) {
|
||||
const { bitmap, width, height } = imageData;
|
||||
const { width, height } = imageData;
|
||||
length = width * height * 4;
|
||||
pageProxy._bitmaps.add(bitmap);
|
||||
} else {
|
||||
length = imageData.data?.length || 0;
|
||||
}
|
||||
@ -3150,6 +3139,10 @@ class PDFObjects {
|
||||
}
|
||||
|
||||
clear() {
|
||||
for (const objId in this.#objs) {
|
||||
const { data } = this.#objs[objId];
|
||||
data?.bitmap?.close(); // Release any `ImageBitmap` data.
|
||||
}
|
||||
this.#objs = Object.create(null);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user